Launch a Paygate and handle user choices
Supertab
instance using your client ID.
client.your_client
with the live or test client ID associated with site you created
when setting up your experiences. Supertab.js uses this client ID to make sure its running
in the correct place.
createPaygate
Key | Type | Required | Description |
---|---|---|---|
experienceId | string | Yes | ID of the Paygate experience created in the Business Portal |
purchaseMetadata | object | No | Key-value pairs of custom information associated with the purchase. |
createPaygate
returns a PaygateExperienceResult
object containing the initial state of the Paygate
and methods for showing it to users.
Field | Type | Description |
---|---|---|
initialState | ExperienceStateSummary | The state of the paygate immediately after config is loaded, can be used to check if the user is logged in or has a priort entitlement already. |
logIn | () => Promise<ExperienceStateSummary> | Launch an auth flow immediately, if necessary. The returned promise resolves when the login flow is completed. |
show | () => Promise<ExperienceStateSummary> | Display the paygate to the user, the returned promise resolves when the paygate closes. |
destroy | () => void | Clean up and remove all Supertab elements from the DOM. |
async
/ await
or through promise chaining with .then()
.
async
/ await
.
ExperienceStateSummary | Type | Description |
---|---|---|
purchase | Purchase | null | The purchase made by the user. |
paymentResult | boolean | true if the user made a payment to complete their purchase. |
purchase
field.
Purchase | Type | Description |
---|---|---|
id | string | ID of the purchase. You can use this with the Merchant API for backend checks the purchase is valid. |
offeringId | string | ID of the offering which was purchased. |
description | string | Description of the offering which was purchased |
status | string | Possible values: completed , pending .A purchase may be created as pending when the user is required to make payment. If handling entitlements yourself, only grant access when a purchase is completed . The paygate will automatically launch the payment flow when necessary. |
ExperienceStateSummary | Type | Description |
---|---|---|
priorEntitlement | EntitlementStatus[] | null | Array of any prior entitlements the user has purchased. |
EntitlementStatus
contains information on which contentKey
s the user has an entitlement for
and when their entitlement expires.
EntitlementStatus | Type | Description |
---|---|---|
contentKey | string | ID of the content key which the user has an entitlement for. |
expires | string | Date when the user’s entitlement expires. e.g 2025-01-01 00:00:00 |
hasEntitlement | boolean | true if the user has an entitlement for the content key. |
priorEntitlement
field of
the resolves ExperienceStateSummary
object.
logIn
on the paygate itself.
.logIn()
immediately opens a popup it should only be called in response to a user action.