Skip to main content

Checkout

Creating a Session Token

You can create a session token for this web component by using the request template below with the Salable API.

const response = await fetch('https://api.salable.app/sessions', {
method: "POST",
headers: {
"x-api-key": "YOUR_SALABLE_API_TOKEN",
version: "v2",
},
body: JSON.stringify({
scope: 'web-components:checkout',
metadata: {
planUuid: 'YOUR_PLAN_UUID'
}
})
})

const { sessionToken } = await response.json()

See the entire API docs for creating sessions for web components.

Examples

<!doctype html>
<head>
<title>Salable Checkout Web Component Example</title>
<script type="module">
import { defineCustomElements } from 'https://cdn.jsdelivr.net/npm/@salable/web-components@latest/loader/index.es2017.js';
defineCustomElements();
</script>
</head>
<body>
<salable-checkout
session-token="YOUR_SESSION_TOKEN"
plan-uuid="YOUR_PLAN_UUID"
member="EXAMPLE_MEMBER"
grantee-id="EXAMPLE_GRANTEE_ID"
success-url="https://example.com/success"
currency="GBP"
></salable-checkout>
</body>
</html>

Properties

PropertyAttributeDescriptionTypeDefault
currency (required)currencyThe short name of the currency used in the checkout e.g. USDstringundefined
granteeId (required)grantee-idA unique identifier used in licensing that represents the entity to which a license is grantedstringundefined
member (required)memberA unique identifier for a member or userstringundefined
planUuid (required)plan-uuidA unique identifier for a specific planstringundefined
sessionToken (required)session-tokenThe generated token for this session from the Salable APIstringundefined
successUrl (required)success-urlThe URL the user is sent to if they successfully completed a paymentstringundefined
emailemailA user's email address to be used for the checkout. Providing the user's email skips the provide email step during checkoutstringundefined