Skip to main content

Hosted Checkout

The Hosted Checkout API lets your application initiate a Stripe-hosted checkout page on behalf of a user, without building any payment UI yourself. Eluvio handles the Stripe session, the webhook, and the NFT mint. You redirect the user and poll for completion.


Overview​


Prerequisites​

  • A tenant admin or content admin token (CSAT) for your tenant
  • The user's wallet address (elv_addr) -- your app must know this before checkout
  • The SKU for the product to purchase (see Discovering Which SKU to Purchase)
  • Your success and cancel URLs -- where Stripe redirects after payment

API Reference​

Create a Checkout Session​

POST /tnt/:tid/checkout/external

Authentication​

Tenant admin or content admin bearer token.

Path Parameters​

ParameterDescription
tidYour tenant ID

Request Body​

FieldRequiredDescription
skuYesProduct SKU to purchase
elv_addrYesUser's wallet address
success_urlYesURL to redirect user after successful payment
cancel_urlYesURL to redirect user if they cancel
emailNoUser's email address (for Stripe receipt)
country_codeNoBuyer country code (e.g. "US")

Response​

FieldDescription
checkout_idSession identifier (elvs_...) -- store this to poll status
checkout_urlStripe-hosted checkout URL -- redirect the user here

Example​

curl -s -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' \
-H 'Authorization: Bearer <admin-token>' \
"https://<authority-url>/tnt/<tid>/checkout/external" \
-d '{
"sku": "<sku>",
"elv_addr": "<user-wallet-address>",
"success_url": "https://your-app.com/success",
"cancel_url": "https://your-app.com/cancel",
"country_code": "US"
}' | jq
{
"checkout_id": "elvs_...",
"checkout_url": "https://checkout.stripe.com/c/pay/cs_live_..."
}

Poll Checkout Status​

GET /tnt/:tid/checkout/external/:checkout_id

Authentication​

Tenant admin or content admin token, or the purchasing user's CSAT token.

Path Parameters​

ParameterDescription
tidYour tenant ID
checkout_idThe checkout_id returned from the create call

Response Fields​

FieldDescription
checkout_idSession identifier
status"pending" | "complete" | "failed"
skuThe SKU purchased
elv_addrThe buyer's wallet address
extraPresent on "complete" -- contains minted token info

Status: pending​

{
"checkout_id": "elvs_...",
"status": "pending",
"sku": "<sku>",
"elv_addr": "<user-wallet-address>"
}

Status: complete​

{
"checkout_id": "elvs_...",
"status": "complete",
"sku": "<sku>",
"elv_addr": "<user-wallet-address>",
"extra": {
"0": {
"token_addr": "<contract-address>",
"token_id": "<token-id>",
"token_id_str": "<token-id>"
},
"status": "complete"
}
}

Discovering Which SKU to Purchase​

The Sections API returns everything needed in a single call. Each gated section or content item includes a primary_purchase_skus array with the SKUs the user can buy, resolved server-side from the property's permission configuration.

curl -s \
-H 'Authorization: Bearer <user-token>' \
"https://<authority-url>/mw/properties/<propertyId>/sections" \
-d '["<sectionId>"]' | jq

Section-gated content​

primary_purchase_skus appears on section.permissions:

{
"permissions": {
"behavior": "show_purchase",
"permission_item_ids": ["<permission_item_id>"],
"primary_purchase_skus": [
{
"permission_item_id": "<permission_item_id>",
"sku": "<sku>",
"title": "<pass name>"
}
]
}
}

Item-gated content​

primary_purchase_skus can appear on each content item. Multiple entries appear when several passes each grant access:

{
"media_id": "<media_id>",
"permission_item_ids": ["<permission_item_id_1>", "<permission_item_id_2>"],
"primary_purchase_skus": [
{
"permission_item_id": "<permission_item_id_1>",
"sku": "<sku_1>",
"title": "<pass name>"
},
{
"permission_item_id": "<permission_item_id_2>",
"sku": "<sku_2>",
"title": "<pass name>"
}
]
}

primary_purchase_skus only contains passes the user does not yet own and is allowed to buy. An absent or empty array means there is nothing for this user to purchase; it does not by itself mean the user has access. The user may already own a pass, or every pass may be unavailable in their region. Decide access from the playback check instead, as described in Discovering What to Purchase. When multiple options are present, the app selects the appropriate one for the user.


Integration Notes​

Store checkout_id before redirecting​

Your app should persist it so you can poll status after the user returns from Stripe.

Poll with backoff​

The Stripe webhook fires asynchronously. Poll every 2-3 seconds for up to 60 seconds after the user returns from the Stripe redirect.

country_code reflects the buyer, not your server​

This API is called server-to-server, so IP geolocation resolves to your server's location. Pass the buyer's actual country code for correct currency selection.

success_url and cancel_url are your app's URLs​

Stripe redirects the user there after payment completes or is cancelled. The checkout_id is not appended automatically -- your app already has it from the create response.


Samples​

Shell samples:

create-checkout.sh​

#!/usr/bin/env bash
#
# create-checkout.sh — create a hosted checkout session
#
# Usage:
# ADMIN_TOKEN=<token> SKU=<sku> ELV_ADDR=<addr> ./create-checkout.sh
#
# Output is saved to /tmp/extcheckout.last for use by poll-status.sh

FABRIC_URL="${FABRIC_URL:-https://as.glb.contentfabric.io/as}"
TENANT_ID="${TENANT_ID:?TENANT_ID is required}"
ADMIN_TOKEN="${ADMIN_TOKEN:?ADMIN_TOKEN is required}"
SKU="${SKU:?SKU is required}"
ELV_ADDR="${ELV_ADDR:?ELV_ADDR is required}"
SUCCESS_URL="${SUCCESS_URL:-https://example.com/success}"
CANCEL_URL="${CANCEL_URL:-https://example.com/cancel}"
COUNTRY_CODE="${COUNTRY_CODE:-US}"
EMAIL="${EMAIL:-}"

curl -s -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
"${FABRIC_URL}/tnt/${TENANT_ID}/checkout/external" \
-d "$(jq -n \
--arg sku "${SKU}" \
--arg elv_addr "${ELV_ADDR}" \
--arg success "${SUCCESS_URL}" \
--arg cancel "${CANCEL_URL}" \
--arg country "${COUNTRY_CODE}" \
--arg email "${EMAIL}" \
'{sku:$sku, elv_addr:$elv_addr, success_url:$success, cancel_url:$cancel, country_code:$country, email:$email}')" \
| tee /tmp/extcheckout.last \
| jq

echo ""
echo "Redirect the user to the checkout_url above."
echo "Then run poll-status.sh to check for completion."

get-section-skus.sh​

#!/usr/bin/env bash
#
# get-section-skus.sh -- find purchasable SKUs for a property section
#
# The sections response includes primary_purchase_skus inline on each gated section or content item
#
# Usage:
# USER_TOKEN=<token> PROPERTY_ID=<iq__...> SECTION_ID=<pscm...> ./get-section-skus.sh

FABRIC_URL="${FABRIC_URL:-https://as.glb.contentfabric.io/as}"
USER_TOKEN="${USER_TOKEN:?USER_TOKEN is required}"
PROPERTY_ID="${PROPERTY_ID:?PROPERTY_ID is required}"
SECTION_ID="${SECTION_ID:?SECTION_ID is required}"

echo "Fetching section ${SECTION_ID} for property: ${PROPERTY_ID}"
echo ""

section=$(curl -s -H 'Content-Type: application/json' -H 'Accept: application/json' \
-H "Authorization: Bearer ${USER_TOKEN}" \
"${FABRIC_URL}/mw/properties/${PROPERTY_ID}/sections?content_limit=5" \
-d "[\"${SECTION_ID}\"]")

# Section-level purchase SKUs (behavior = show_purchase)
echo "=== Section-level ==="
echo "${section}" | jq '
.contents[0] | {
behavior: .permissions.behavior,
primary_purchase_skus: .permissions.primary_purchase_skus
}'
echo ""

# Content-item-level purchase SKUs
echo "=== Content items with primary_purchase_skus ==="
echo "${section}" | jq '
.contents[0].content[]? |
select(.primary_purchase_skus != null and (.primary_purchase_skus | length) > 0) |
{
media_id: .media_id,
title: .media.title,
primary_purchase_skus: .primary_purchase_skus
}'

poll-status.sh​

#!/usr/bin/env bash
#
# poll-status.sh — poll a hosted checkout session until complete or failed
#
# Usage (reads checkout_id from /tmp/extcheckout.last if not set):
# TOKEN=<admin-or-user-token> ./poll-status.sh
# TOKEN=<token> CHECKOUT_ID=elvs_xxx ./poll-status.sh

FABRIC_URL="${FABRIC_URL:-https://as.glb.contentfabric.io/as}"
TENANT_ID="${TENANT_ID:?TENANT_ID is required}"
TOKEN="${TOKEN:?TOKEN is required (admin or user token)}"

CHECKOUT_ID="${CHECKOUT_ID:-}"
if [[ -z "${CHECKOUT_ID}" && -f /tmp/extcheckout.last ]]; then
CHECKOUT_ID="$(jq -r '.checkout_id // empty' /tmp/extcheckout.last 2>/dev/null || true)"
fi

POLL_INTERVAL="${POLL_INTERVAL:-2}"
MAX_ATTEMPTS="${MAX_ATTEMPTS:-30}"

if [[ -z "${CHECKOUT_ID}" ]]; then
echo "Error: CHECKOUT_ID not set and could not read checkout_id from /tmp/extcheckout.last." >&2
exit 1
fi

echo "Polling ${CHECKOUT_ID} ..."

attempt=0
while (( attempt < MAX_ATTEMPTS )); do
response=$(curl -s -H 'Content-Type: application/json' -H 'Accept: application/json' \
-H "Authorization: Bearer ${TOKEN}" \
"${FABRIC_URL}/tnt/${TENANT_ID}/checkout/external/${CHECKOUT_ID}")

status=$(echo "${response}" | jq -r .status)
echo "[$(( ++attempt ))/${MAX_ATTEMPTS}] status: ${status}"

if [[ "${status}" == "complete" || "${status}" == "failed" ]]; then
echo ""
echo "${response}" | jq
exit 0
fi

sleep "${POLL_INTERVAL}"
done

echo "Timed out waiting for checkout to complete." >&2
exit 1