Skip to main content

Pre-built crypto checkout

Explore a full, working code sample of an integration with Radom Hosted Checkout. The client and server-side code redirects to a prebuilt payment page hosted on Radom.

Before you get started, make sure to confirm the list of cryptocurrencies and blockchains you want to support for payment in your seller profile settings. These defaults are used when creating a Checkout Session but may also be overriden by specifying a custom list in the API call.

Creating an API token

In order to use the Radom Hosted Checkout go to the Developer API tokens page in the Radom Dashboard and generate an API token. Make sure to store this somewhere securely as it can only be viewed once after creation, lost API tokens cannot be recovered and a new one will need to be generated.

Creating a checkout session

Creating a checkout session should be done on a secure back-end server, and is usually done when triggered by a request from your customer facing front-end application sending an order request to the back-end server when the customer is ready to checkout.

The code snippets below provide example requests to the Create Checkout Session API across languages:

{
"acceptedChains": [
4002,
5,
1313161555
],
"acceptedTokens": [
{
"chainId": 4002,
"tokenAddress": "0x2e9B1F01068B96D7c85913f70Cf29464FA98b567"
},
{
"chainId": 5,
"tokenAddress": "0x16246c650be7C4EE01fDE5DAEd829D4C65c09450"
},
{
"chainId": 1313161555,
"tokenAddress": "0xACdC5B8b4cD24D99737116afA55F98D05D853c55"
}
],
"cancelUrl": "https://ethereum.org/cancelled_or_failed_payment",
"currency": "USD",
"lineItems": [
{
"itemData": {
"chargingIntervalSeconds": 2592000,
"description": "string",
"isMetered": false,
"name": "Node subscription",
"price": 100
}
},
{
"itemData": {
"chargingIntervalSeconds": 2592000,
"description": "string",
"isMetered": false,
"name": "500 on-demand credits",
"price": 100
}
}
],
"metadata": [],
"sellerAddress": "0x1661371eEEEB14a5cdDbeE636Ba0053Ab0E1B15f",
"successUrl": "https://ethereum.org/successful_payment"
}

Detailed information about this API can be found in our API Reference.

Using the Create Checkout Session API response

Once a call is made to the Create Checkout Session API the response payload will contain two fields, the checkoutSessionId and the checkoutSessionUrl.

The checkoutSessionId should be stored in order to match the customer with webhook messages from the Radom Payment Notification API. This allows you to ship the product or service to the customer programmatically at the point in which a successful payment has been received.

The checkoutSessionUrl is the URL used to redirect the customer to the Hosted Checkout payment page.

{
"checkoutSessionId": "41aa743a-fbb3-42c4-be67-b4083da689b7",
"checkoutSessionUrl": "https://pay.dashboard.radom.network/checkout/41aa743a-fbb3-42c4-be67-b4083da689b7"
}

Adding Products to the Checkout Session

Products provide a useful layer for those wishing to use Radom to track inventory or to provide discount codes specific to a particular offering. Products can be created through the Product API or through the Products Page on the Radom Dashboard.

Once created, products can be attached within the list of line items passed in when creating a Checkout Session.

Below is an example of a Create Checkout Session API request body with a product attached:

{
"acceptedChains": [
4002,
5,
1313161555
],
"acceptedTokens": [
{
"chainId": 4002,
"tokenAddress": "0x2e9B1F01068B96D7c85913f70Cf29464FA98b567"
},
{
"chainId": 5,
"tokenAddress": "0x16246c650be7C4EE01fDE5DAEd829D4C65c09450"
},
{
"chainId": 1313161555,
"tokenAddress": "0xACdC5B8b4cD24D99737116afA55F98D05D853c55"
}
],
"cancelUrl": "https://ethereum.org/cancelled_or_failed_payment",
"currency": "USD",
"lineItems": [
{
"productId": "4d69afb1-9f8f-4bd1-b77c-74d718b02545"
},
{
"productId": "e51fad69-06a0-4a60-b151-036a17791fad"
}
],
"metadata": [],
"sellerAddress": "0x1661371eEEEB14a5cdDbeE636Ba0053Ab0E1B15f",
"successUrl": "https://ethereum.org/successful_payment"
}

It is also possible to mix both products and line items in the same Checkout Session, this can be helpful for tracking inventory on a commonly purchased product but adding in line items that are specific to a customer Checkout Session.

"lineItems": [
{
"itemData": {
"chargingIntervalSeconds": 2592000,
"description": "string",
"isMetered": false,
"name": "Node subscription",
"price": 100
}
},
{
"itemData": {
"chargingIntervalSeconds": 2592000,
"description": "string",
"isMetered": false,
"name": "500 on-demand credits",
"price": 100
}
},
{
"productId": "4d69afb1-9f8f-4bd1-b77c-74d718b02545"
},
{
"productId": "e51fad69-06a0-4a60-b151-036a17791fad"
}
],

See also

Payment Notifications Supported tokens
Support chains
Testnet token faucet