Skip to content

Commit

Permalink
feat: Support flow_data parameter in createPortalLink function
Browse files Browse the repository at this point in the history
  • Loading branch information
chetbox authored Sep 4, 2023
1 parent 1070319 commit 2e63228
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion firestore-stripe-payments/functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,13 @@ export const createPortalLink = functions.https.onCall(
);
}
try {
const { returnUrl: return_url, locale = 'auto', configuration } = data;
const {
returnUrl: return_url,
locale = 'auto',
configuration,
flow_data,
} = data;

// Get stripe customer id
const customer = (
await admin
Expand All @@ -355,6 +361,12 @@ export const createPortalLink = functions.https.onCall(
if (configuration) {
params.configuration = configuration;
}
if (flow_data) {
// Ignore type-checking because `flow_data` was added to
// `Stripe.BillingPortal.SessionCreateParams` in
// [email protected] (API version 2022-12-06)
(params as any).flow_data = flow_data;
}
const session = await stripe.billingPortal.sessions.create(params);
logs.createdBillingPortalLink(uid);
return session;
Expand Down

0 comments on commit 2e63228

Please sign in to comment.