Skip to main content

subscribe

Create a new subscription and get a payment session for it. 🔐 This method requires authorization.

Description​

Subscribes the authenticated user to a paid plan and resolves to an ICreatedSubscription: the payment session whose paymentUrl completes the first payment and activates the subscription.

For a custom payment account the API creates a pending subscription without a payment session, and the method resolves to a full ICreatedSubscription with paymentUrl: null (an admin activates the subscription outside the platform).

.subscribe(

);

Parameters schema​

Schema

body(required): ISubscribe
Subscription parameters.
example:

{ marker: "premium" }

body.marker(required): string
Marker of the subscription.
example: "premium"

Examples​

Minimal example​

const response = await Subscriptions.subscribe({ marker: 'premium' });

Example response​

No example response is shown because calling this method creates a real subscription and payment session. The call resolves to an ICreatedSubscription object; see the response schema below.

Response schema​

Schema: ICreatedSubscription

id: number
Payment session ID.
example: 1

amount: number
Amount to be paid.
example: 100

paymentUrl: string | null
Payment page URL, or null when the session has no checkout link yet (e.g. a freshly created session with status: "waiting").
example: "https://checkout.stripe.com/c/pay/..."

status: string
Payment session status.
example: "waiting"