Merge pull request #25911 from overleaf/mf-stripe-payment-page-form-submit-event

[web] Simulate `payment-page-form-submit` event for Stripe subscription

GitOrigin-RevId: 8cfa1a2d91aaea4314a4a40f3256bade50507084
This commit is contained in:
M Fahru
2025-07-07 07:02:05 -07:00
committed by Copybot
parent d4ab715a9b
commit b3c339464e
3 changed files with 54 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
import Stripe from 'stripe'
import { RecurlyPlanCode } from '../subscription/plan'
type MetadataPlanCode = Exclude<
RecurlyPlanCode,
| 'professional_free_trial_7_days'
| 'student_free_trial_7_days'
| 'collaborator_free_trial_7_days'
>
export type ProductMetadata = Stripe.Metadata & {
planCode: MetadataPlanCode
addOnCode?: Extract<RecurlyPlanCode, 'assistant'>
}
@@ -53,6 +53,15 @@ export type InvoicePaidWebhookEvent = {
data: {
object: Stripe.Invoice
}
request: Stripe.Event.Request
}
export type PaymentIntentPaymentFailedWebhookEvent = {
type: 'payment_intent.payment_failed'
data: {
object: Stripe.PaymentIntent
}
request: Stripe.Event.Request
}
export type CustomerSubscriptionWebhookEvent =
@@ -63,3 +72,4 @@ export type CustomerSubscriptionWebhookEvent =
export type WebhookEvent =
| CustomerSubscriptionWebhookEvent
| InvoicePaidWebhookEvent
| PaymentIntentPaymentFailedWebhookEvent
@@ -0,0 +1,30 @@
import { CurrencyCode } from './currency'
import { PaymentProvider } from './dashboard/subscription'
type PaymentPageFormSubmitEventBaseSegmentation = {
currencyCode: CurrencyCode
plan_code?: string
coupon_code: string
isPaypal: boolean
upgradeType: 'standalone'
referrer?: string
}
type PaymentPageFormSubmitEventStripeSegmentation =
PaymentPageFormSubmitEventBaseSegmentation & {
payment_provider: Exclude<PaymentProvider['service'], 'recurly'>
stripe_price_id: string
stripe_price_lookup_key: string
}
type PaymentPageFormSubmitEventRecurlySegmentation =
PaymentPageFormSubmitEventBaseSegmentation & {
payment_provider: Exclude<
PaymentProvider['service'],
'stripe-us' | 'stripe-uk'
>
}
export type PaymentPageFormSubmitEventSegmentation =
| PaymentPageFormSubmitEventStripeSegmentation
| PaymentPageFormSubmitEventRecurlySegmentation