recoverSubscriptions
Open a Stripe Billing Portal session to fix a failed subscription payment. 🔐 This method requires authorization.
Description
Creates a Stripe Billing Portal session for the authenticated user's subscription that has a failed payment (status past_due, incomplete or unpaid), so the user can update the payment method there. It works only for Stripe subscriptions. For any other status, including a cancelled subscription, the API returns a 400 error ("Subscription is not in a recoverable state"), and for a non-Stripe plan a 400 error ("Recovery is only supported for Stripe subscriptions").
The API returns the portal url, but the SDK (through 1.0.186) discards it and resolves to true, so you can't redirect the user to the portal through the SDK yet.
With the default
errors.isShell: true, a failed request resolves to anIErrorobject, never tofalse. An error object is truthy, so checkresult === truerather thanif (result). Witherrors.isShell: false, the method throws instead (SDK 1.0.172 and later).
.recoverSubscriptions(
);
Parameters schema
Schema
body(required): ICancelSubscription
Subscription parameters.
example:
{ marker: "premium" }
body.marker(required): string
Marker of the subscription.
example: "premium"
Examples
Minimal example
const response = await Subscriptions.recoverSubscriptions({ marker: 'premium' });
Example response
No example response is shown because the call needs a user whose subscription payment has failed. On success it resolves to true; see the response schema below.
Response schema
Details
Schema: boolean
boolean: booleantrue when the API created the Billing Portal session. The SDK (through 1.0.186) discards the portal url that the API returns. example: true