Radom integrated checkout
Radom integrated checkout is the most customizable and flexible way to integrate crypto payments into your platform. The lifecycle of a radom integrated checkout works as follows:
- Show your user the crypto payment methods you would like to accept
- Upon selection of a payment method, create a payment session with Radom's API
- Show the payment session payment details to your user
- User completes the payment
- You receive a webhook message confirming the payment
Creating an API token
In order to use the Radom integrated 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 payment session
Creating a payment 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.
In the example below, a payment session is created using USDC on Ethereum:
- JSON
- NodeJS
{
"total": 39.99,
"currency": "USD",
"method": {
"network": "Ethereum",
"token": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
}
}
var axios = require("axios").default;
var options = {
method: 'POST',
url: 'https://api.radom.com/checkout_session',
headers: {'Content-Type': 'application/json', 'Authorization': 'RADOM_API_TOKEN'},
data: {
"total": 39.99,
"currency": "USD",
"method": {
"network": "Ethereum",
"token": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
}
}
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
Detailed information about using payment session API can be found in the payment session API Reference.
Using the payment session API response
{
"id": "9280fe2b-888d-4a9c-9a2d-511e6b1d512a",
"method": {
"network": "Ethereum",
"token": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
},
"total": "1",
"currency": "USD",
"sessionStatus": "pending",
"paymentTotal": "1",
"paymentAddress": "0x9d0615b0fd5b3e4049cbfa85b2cb451ac0273a00",
"transactions": [],
"canExtend": true,
"expiresAt": "2023-06-13T21:11:36.781920Z",
"createdAt": "2023-06-13T20:41:36.746231Z"
}
The payment session API response includes four fields important for payment:
- method - The payment method your user should use to make the payment.
- paymentAddress - The address which your user should send funds to.
- paymentTotal - The total amount your user should send to. Note: this amount is not formatted using token or currency decimals, but is the human readable representation of the total, e.g. 1 USDC on Ethereum means 1000000 USDC as USDC has 6 decimals on Ethereum mainnet.
- expiresAt - The time until the sesssion is active. It's important to display this to your user as countdown to avoid sending funds to an expired session, which could result in lost funds.
Receiving webhook notifications
Webhook messages are JSON objects which contain two fields:
- eventType - determines the type of webhook event. For one-time checkouts, the type will be managedPayment. For subscription products, the type will be managedRecurringPayment.
- eventData - contains an object keyed with the eventType that includes information about the event, such as the payment amount, network, and token.
- radomData - information about associated radom payment entities at checkout, e.g. checkout session ID, payment link ID, payment session ID, etc.
For example:
{
"eventType": "managedPayment",
"eventData": {
"managedPayment": {
"paymentMethod": {
"network": "SepoliaTestnet",
"token": "0xa4fCE8264370437e718aE207805b4e6233638b9E"
},
"amount": "3.48250000000",
"transactions": [
{
"network": "SepoliaTestnet",
"transactionHash": "0x12968348c62356d30fd65b60e08e62a95129d66b4c9b40b25358fc63c105309a",
"token": "0xa4fce8264370437e718ae207805b4e6233638b9e",
"amount": "0.5000",
"blockTimestamp": "2023-06-04T01:50:12Z"
},
{
"network": "SepoliaTestnet",
"transactionHash": "0xf1fda84316ee0155bf817289ec00ee12f55944bcf6aa41f447958cfa30dc0be6",
"token": "0xa4fce8264370437e718ae207805b4e6233638b9e",
"amount": "3",
"blockTimestamp": "2023-06-04T01:52:00Z"
}
]
}
},
"radomData": {
"paymentSession": {
"paymentSessionId": "caed490d-f1c7-4da0-b53c-797a784f32bb"
}
}
}
See also
Webhook messages
Supported payment methods
Hosted checkout
Testnet token faucet