Billing portal sessions
A billing portal session signs a customer in to the billing portal, where they manage their subscriptions, payment methods and invoices.
The BillingPortalSession object
- Name
object
- Type
- "billing_portal_session",
- Description
- The object's type.
- Name
id
- Type
- string,
- Description
- Unique identifier for the object.
- Name
live
- Type
- boolean,
- Description
trueif the object is live, orfalseif it's in a sandbox.
- Name
created_at
- Type
- integer,
- Description
- When the object was created, in milliseconds since the Unix epoch.
- Name
customer
- Type
- string,
- Description
- The customer the session signs in.
- Name
expires_at
- Type
- integer,
- Description
- When
urlexpires if unused, as a Unix timestamp in milliseconds.
- Name
flow
- Type
- object or null,
- Description
- The change the portal opens to, if any.
- Properties
- Name
return_url
- Type
- string or null,
- Description
- The page the portal links back to.
- Name
subscription
- Type
- string or null,
- Description
- The subscription the portal opens to.
- Name
url
- Type
- string,
- Description
- The link that signs the customer in to the portal. It works once, until
expires_at.
The BillingPortalSession object
Create a billing portal session
Create a session when a customer signed in to your site asks to manage their billing, then redirect them to its url. The link works once and expires 5 minutes after it’s created.
With subscription, the portal opens to that subscription. With a flow, it opens to confirming a plan change you choose, on an active or trialing subscription with one item.
Required parameters
- Name
customer
- Type
- string,
- Description
- The customer to sign in.
Optional parameters
- Name
subscription
- Type
- string,
- Description
- The subscription the portal opens to. Defaults to
flow.subscription.
- Name
return_url
- Type
- string or null,
- Description
- The page the portal links back to.
- Name
flow
- Type
- object,
- Description
- Opens the portal to a specific change, which the customer confirms.
- Properties
Returns
Returns the billing portal session object.