From f86b5865fdd059b8c60b4b13519044797543ae17 Mon Sep 17 00:00:00 2001 From: mlnchk Date: Thu, 23 May 2024 15:37:33 +0400 Subject: [PATCH] Added trial period support --- src/backend.ts | 3 +++ src/react.tsx | 1 + 2 files changed, 4 insertions(+) diff --git a/src/backend.ts b/src/backend.ts index d71bf30..f6b0be9 100644 --- a/src/backend.ts +++ b/src/backend.ts @@ -132,6 +132,9 @@ async function redirectToCheckout({ customerId, body }) { cancel_url: body.cancelUrl, line_items: [{ price: body.price, quantity: 1 }], mode: "subscription", + subscription_data: { + ...body.trialPeriodDays && { trial_period_days: body.trialPeriodDays }, + } }); } return { error: "Error" }; diff --git a/src/react.tsx b/src/react.tsx index a9babac..fd85892 100644 --- a/src/react.tsx +++ b/src/react.tsx @@ -41,6 +41,7 @@ export interface redirectToCheckoutArgs { price: string; successUrl?: string; cancelUrl?: string; + trialPeriodDays?: number } export interface redirectToCustomerPortalArgs {