From aaeacb52b71f87c5716221fa153ae6bdce929ac6 Mon Sep 17 00:00:00 2001 From: Liangjun Song <146005915+adai26@users.noreply.github.com> Date: Wed, 17 Sep 2025 15:03:15 +0800 Subject: [PATCH] Merge pull request #28388 from overleaf/ls-set-and-use-user-id-on-customer-object Set and use userId on customer object GitOrigin-RevId: 44749df8135154348fbf099db3c680d3d3212ff3 --- .../Subscription/PaymentProviderEntities.js | 3 +++ services/web/types/stripe/webhook-event.ts | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/services/web/app/src/Features/Subscription/PaymentProviderEntities.js b/services/web/app/src/Features/Subscription/PaymentProviderEntities.js index 976be899a2..7d1d7a2226 100644 --- a/services/web/app/src/Features/Subscription/PaymentProviderEntities.js +++ b/services/web/app/src/Features/Subscription/PaymentProviderEntities.js @@ -650,11 +650,14 @@ class PaymentProviderAccount { * @param {string} props.code * @param {string} props.email * @param {boolean} [props.hasPastDueInvoice] + * @param {object} [props.metadata] + * @param {string} [props.metadata.userId] */ constructor(props) { this.code = props.code this.email = props.email this.hasPastDueInvoice = props.hasPastDueInvoice ?? false + this.metadata = props.metadata ?? {} } } diff --git a/services/web/types/stripe/webhook-event.ts b/services/web/types/stripe/webhook-event.ts index 7acdd7d81e..c9cb304e21 100644 --- a/services/web/types/stripe/webhook-event.ts +++ b/services/web/types/stripe/webhook-event.ts @@ -7,6 +7,7 @@ export type CustomerSubscriptionUpdatedWebhookEvent = { metadata: { adminUserId?: string } + customer: string } // https://docs.stripe.com/api/events/object?api-version=2025-04-30.basil#event_object-data-previous_attributes previous_attributes: { @@ -35,6 +36,7 @@ export type CustomerSubscriptionCreatedWebhookEvent = { metadata: { adminUserId?: string } + customer: string } } } @@ -46,6 +48,7 @@ export type CustomerSubscriptionsDeletedWebhookEvent = { metadata: { adminUserId?: string } + customer: string } } } @@ -90,6 +93,25 @@ export type InvoiceOverdueWebhookEvent = { request: Stripe.Event.Request } +export type CheckoutSessionCompletedWebhookEvent = { + type: 'checkout.session.completed' + data: { + object: Stripe.Checkout.Session & { + metadata: { + userId?: string + } + } + } + request: Stripe.Event.Request +} + +export type CustomerCreatedWebhookEvent = { + type: 'customer.created' + data: { + object: Stripe.Customer + } +} + export type CustomerSubscriptionWebhookEvent = | CustomerSubscriptionUpdatedWebhookEvent | CustomerSubscriptionCreatedWebhookEvent @@ -101,3 +123,5 @@ export type WebhookEvent = | InvoiceVoidedWebhookEvent | PaymentIntentPaymentFailedWebhookEvent | InvoiceOverdueWebhookEvent + | CheckoutSessionCompletedWebhookEvent + | CustomerCreatedWebhookEvent