From a7be5e2cbe31b1aba9a461c286ef88472636e1c3 Mon Sep 17 00:00:00 2001 From: Perry George Date: Wed, 24 Sep 2025 10:15:39 +0100 Subject: [PATCH 1/2] feat: new cardPreFillBehaviour for plans.getCheckoutLink v3 --- src/plans/v3/plan-v3.test.ts | 14 ++++++++++++++ src/types.ts | 1 + 2 files changed, 15 insertions(+) diff --git a/src/plans/v3/plan-v3.test.ts b/src/plans/v3/plan-v3.test.ts index 8d797b7..4b06bb4 100644 --- a/src/plans/v3/plan-v3.test.ts +++ b/src/plans/v3/plan-v3.test.ts @@ -17,6 +17,7 @@ describe('Plans V3 Tests', () => { const apiKey = testUuids.devApiKeyV3; const salable = initSalable(apiKey, 'v3'); const planUuid = testUuids.paidPlanUuid; + const stripeEnvs = JSON.parse(process.env.stripEnvs || ''); describe('getAll for organisation', () => { const organisation = randomUUID(); @@ -249,6 +250,19 @@ describe('Plans V3 Tests', () => { expect(data).toEqual(PlanCheckoutLinkSchema); }); + + it('getCheckoutLink (w / customerId and cardPreFillBehaviour): should successfully fetch checkout link for plan', async () => { + const data = await salable.plans.getCheckoutLink(planUuid, { + successUrl: 'https://www.salable.app', + cancelUrl: 'https://www.salable.app', + granteeId: 'granteeid@example.com', + owner: 'member-id', + customerId: stripeEnvs.customerId, + cardPreFillBehaviour: 'none' + }); + + expect(data).toEqual(PlanCheckoutLinkSchema); + }); }); async function generateTestData(organisation: string) { diff --git a/src/types.ts b/src/types.ts index 2d6804a..722e4ec 100644 --- a/src/types.ts +++ b/src/types.ts @@ -505,6 +505,7 @@ export type GetPlanCheckoutOptionsV3 = { quantity?: string; changeQuantity?: string; requirePaymentMethod?: boolean; + cardPreFillBehaviour?: 'none' | 'choice' | 'always'; }; export type PlanFeature = { From 6aa3c988967d6ce057efe187a29c146a9e77bdbc Mon Sep 17 00:00:00 2001 From: Perry George Date: Wed, 24 Sep 2025 10:16:31 +0100 Subject: [PATCH 2/2] test: updated checkout link test to include curreny param --- src/plans/v3/plan-v3.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plans/v3/plan-v3.test.ts b/src/plans/v3/plan-v3.test.ts index 4b06bb4..983aaee 100644 --- a/src/plans/v3/plan-v3.test.ts +++ b/src/plans/v3/plan-v3.test.ts @@ -239,7 +239,7 @@ describe('Plans V3 Tests', () => { successUrl: 'https://www.salable.app', cancelUrl: 'https://www.salable.app', granteeId: 'granteeid@example.com', - owner: 'member-id', + owner: 'owner-id', allowPromoCode: true, customerEmail: 'customer@email.com', currency: 'GBP', @@ -256,8 +256,9 @@ describe('Plans V3 Tests', () => { successUrl: 'https://www.salable.app', cancelUrl: 'https://www.salable.app', granteeId: 'granteeid@example.com', - owner: 'member-id', + owner: 'owner-id', customerId: stripeEnvs.customerId, + currency: 'GBP', cardPreFillBehaviour: 'none' });