import { stepPaywallContent } from '@/steps/content/step-32-paywall.content'; import { buildBillingDiscountCatalog, createRuntimeModeBillingPlanCatalog, type BillingConfig, type BillingDiscountList, type BillingPlanCatalog, } from '@funnelsgrove/payments'; import { type GeneratedOfferSet, type ResolvedFunnelRuntimeConfig, } from '@funnelsgrove/runtime'; import { billingTestPlans } from './billing.test.plans'; const STARTER_OFFER_SET_ID = '11111111-1111-4111-8111-111111111111'; const STARTER_OFFER_SET_KEY = 'default-offer'; const starterLivePlans = { primary: { offerSetId: STARTER_OFFER_SET_ID, offerSetKey: STARTER_OFFER_SET_KEY, projectPlanId: '32b31f69-5907-4736-89c7-76d3acb38813', title: stepPaywallContent.locales.en.catalogLabels["1-Week Plan"], providerPlanId: 'price_1T9WL2PPRN41Ty94g2NNOgif', priceLabel: stepPaywallContent.locales.en.catalogLabels["$7.99/week"], perDayAmount: '$1.14', amountCents: 799, checkoutSummaryLabel: stepPaywallContent.locales.en.catalogLabels["$7.99 today"], }, secondary: { offerSetId: STARTER_OFFER_SET_ID, offerSetKey: STARTER_OFFER_SET_KEY, projectPlanId: 'ce0a0022-7bf0-41f2-a707-edc5e6113a07', title: stepPaywallContent.locales.en.catalogLabels["1-Month Plan"], providerPlanId: 'price_1TP0IIPPRN41Ty94npkzVeDR', featuredTag: stepPaywallContent.locales.en.catalogLabels["🔥 Most Popular Choice"], priceLabel: stepPaywallContent.locales.en.catalogLabels["$29.99/month"], perDayAmount: '$1.00', amountCents: 2999, checkoutSummaryLabel: stepPaywallContent.locales.en.catalogLabels["$29.99 today"], isDefault: true, }, tertiary: { offerSetId: STARTER_OFFER_SET_ID, offerSetKey: STARTER_OFFER_SET_KEY, projectPlanId: 'fb623ebc-c2fd-4e6a-8eb6-b8ed92db1b21', title: stepPaywallContent.locales.en.catalogLabels["1-Year Plan"], providerPlanId: 'price_1T06AEPPRN41Ty94zvVt5xrk', priceLabel: stepPaywallContent.locales.en.catalogLabels["$59.99/year"], perDayAmount: '$0.16', amountCents: 5999, checkoutSummaryLabel: stepPaywallContent.locales.en.catalogLabels["$59.99 today"], }, } satisfies BillingPlanCatalog; export const starterPlansByMode = { test: billingTestPlans, live: starterLivePlans, } satisfies Record<'test' | 'live', BillingPlanCatalog>; const starterDiscounts = [ { stage: 'first', couponId: 'fg_30_off_one', discountPercent: 30, durationSeconds: 600, previousDiscountPercent: null, }, { stage: 'second', couponId: 'fg_46_off_once', discountPercent: 46, durationSeconds: 600, previousDiscountPercent: 30, }, ] satisfies BillingDiscountList; export const starterDefaultOfferSet = { id: STARTER_OFFER_SET_ID, key: STARTER_OFFER_SET_KEY, isActive: true, metadata: { discounts: starterDiscounts.map((discount, position) => ({ key: discount.stage, testProviderCouponId: discount.couponId, liveProviderCouponId: discount.couponId, position, metadata: { stage: discount.stage, discountPercent: discount.discountPercent, durationSeconds: discount.durationSeconds, previousDiscountPercent: discount.previousDiscountPercent, }, })), }, items: [ { funnelPlanKey: 'primary', position: 0, isDefault: false }, { funnelPlanKey: 'secondary', position: 1, isDefault: true }, { funnelPlanKey: 'tertiary', position: 2, isDefault: false }, ], } satisfies GeneratedOfferSet; export const starterBillingRuntimeFallback = { revisionId: 'starter-template', sourceDeploymentId: 'starter-template', sourceVersionId: 'starter-template', publishedAt: '1970-01-01T00:00:00.000Z', sessionReplay: { enabled: false, sampleRate: 10 }, offerSets: [starterDefaultOfferSet], experiments: [], } satisfies ResolvedFunnelRuntimeConfig; export const billing = { plans: createRuntimeModeBillingPlanCatalog(starterPlansByMode), discounts: starterDiscounts, } satisfies BillingConfig; export const billingPlans = billing.plans; export const billingDiscounts = buildBillingDiscountCatalog(billing.discounts); export const billingDiscountList = billing.discounts; export const billingDiscountStorageKeys = ['starter-paywall-discount-v1'] as const;