Creating a checkout session
To create a checkout session, send aPOST request to /api/v1/checkout-sessions with the serviceId and paymentPlanId of the plan you want to offer. Both fields are required.
If you already have a user record in Retempo (for example, a returning subscriber or a pre-registered agent), pass their userId to link the session to that account. Omit userId to create an anonymous session that gets associated with a user once they complete payment.
service, paymentPlan, and user objects for your convenience. Every checkout session is created with status: "PENDING" — you cannot set any other status at creation time.
Checkout session lifecycle
Every checkout session starts asPENDING and moves through the following states as the subscriber takes action:
1
PENDING
The session has been created and is waiting for the subscriber to complete payment. This is always the initial status — you cannot create a session in any other state.
2
PAID
The subscriber has paid and their subscription has been activated. A subscription record is created and linked to the session. The session is now closed.
3
EXPIRED
The session reached its
expiresAt timestamp without a completed payment. The subscriber must start a new session to subscribe.4
CANCELLED
The session was explicitly cancelled before payment was completed. Like expired sessions, a cancelled session cannot be reactivated.
Fetching session status
To retrieve the current state of a checkout session — including any subscriptions that were created after payment — send aGET request with the session ID:
subscriptions array that Retempo populates once the subscriber pays. Before payment, the array is empty.