Supertab.checkout client handles the checkout flow for purchases requiring payment.

Methods

start

Starts the checkout process. Whenever the purchase requires payment (i.e. the tab reaches the limit or the purchased offering is of a “pay now” type), use this method to start the checkout flow and allow user to pay for the tab.

The payment is completed in a a popup with Supertab checkout app. Supertab.js uses postMessage for signaling payment status back to the parent window.

Since this method opens a popup, it should be called in response to a user action, e.g. a button click.

Parameters

checkoutUrl
string
required

The URL of the checkout page found in actionRequiredDetails object of the Supertab.api.purchase response.

Returns

Boolean. true if the checkout was completed successfully, false otherwise (e.g. when the user closes the popup or cancels the payment).

Example

Make a purchase and get the checkout URL
const purchaseResponse = await supertabClient.api.purchase({
    offeringId: "test.offering-id"
});

const checkoutUrl = purchaseResponse.actionRequiredDetails.next;
Start the checkout process
<button onClick={
    () => supertabClient.checkout.start(checkoutUrl)
}>Pay</button>