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