-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support
flow_data
parameter in createPortalLink
function
- Loading branch information
Showing
1 changed file
with
13 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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; | ||
|