Interface: PurchaseNamespace
Defined in: types.ts:721
Methods for initiating and completing purchases.
Access this namespace via allegro.purchase.
Example
window.allegro.push((allegro) => {
allegro.purchase.initiate('term-uuid-here');
});
Methods
exchangeToken()
exchangeToken(
token):Promise<PurchaseTokenExchangeResponse>
Defined in: types.ts:736
Exchange an allegro_purchase_token query param for a JWT + entitlement.
Called automatically on page load when the param is detected.
Parameters
| Parameter | Type |
|---|---|
token | string |
Returns
Promise<PurchaseTokenExchangeResponse>
initiate()
initiate(
termId,returnUrl?):Promise<void>
Defined in: types.ts:729
Initiate a purchase for a term.
Calls the backend to create a hosted checkout session, then redirects the
browser to the provider's checkout page. If returnUrl is omitted, the
current page URL is used.
Parameters
| Parameter | Type |
|---|---|
termId | string |
returnUrl? | string |
Returns
Promise<void>
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
validation | "failed" | "completed" | null | The result of purchase token validation on this page load. - 'completed' — purchase was verified and entitlement created - 'failed' — payment failed or was cancelled - null — no purchase token present on this page load Async timing note: This value may still be null when allegro:ready fires, because token exchange is asynchronous. Do not read validation at ready time. Instead, listen for the allegro:purchase:completed or allegro:purchase:failed events to react to the outcome. | types.ts:750 |