How it works
- Your server creates an access token, then a payment session, and passes
session_id,session_secret, andpubkey_jwsto the browser. - The browser mounts a card field and the shopper types their card details directly into it.
- The browser calls
elements.submit(). The card iframe encrypts the card data and tokenizes it with RadiumOne directly — your JavaScript never sees the raw card number. - The browser sends the resulting token to your server.
- Your server charges the token with
POST https://api.radiumone.io/gateway/v1/transactions/purchase(sandbox:https://api-sandbox.radiumone.io/gateway/v1/transactions/purchase). - Your server returns the result; your page shows success or a decline message.
Your server’s API calls. Elements pages write them as the full path on the API host, as the SDK publishes them — for example,
POST /gateway/v1/sessions is https://api.radiumone.io/gateway/v1/sessions (sandbox: https://api-sandbox.radiumone.io/gateway/v1/sessions). The Payments API reference lists the same operations relative to that base URL: POST /v1/sessions, PATCH /v1/sessions/{session_id}, GET /v1/payment-methods, POST /v1/transactions/purchase.Before you begin
Complete Install and load Elements first. You’ll need a sandbox secret key (
r1sk_test_…) on your server and a publishable key (r1pk_test_…) in the browser.Amounts are always integers in the currency’s minor units. For example,
5000 for SGD means SGD 50.00. Only currencies with 2 minor units are accepted today — read each currency’s minor units from the API rather than from your own table. See Currencies and amounts.Steps
1
Create an access token on your server
Exchange your secret key for a short-lived access token (API reference). Cache it server-side and reuse it until it expires.
2
Create a payment session on your server
Create a session (API reference) and return
session_id, session_secret, and pubkey_jws to the browser as-is — never re-serialize pubkey_jws. If this call fails, see Handle expired sessions and card tokens.3
Mount a card field in the browser
- Vanilla JS
- React
4
Tokenize the card on submit
Call your server for a session (steps 1–2), pass its response straight into
elements.submit(), then charge the result — all under one guard so the Pay button stays disabled for the entire attempt, not just the submit() call. This is the pattern every failure guide on this site assumes; see Prevent double submission for why the guard matters.- Vanilla JS
- React
submit() throws an ElementsError for validation failures, tokenization failures, and gateway bind errors. Always show customerMessage (never the raw message, which is developer-facing) and check retryAllowed before offering a retry. Branch on the whole err.code URN, never a prefix, and treat a code you don’t recognize as not retryable unless retryAllowed is true. See Handle tokenization failures and Handle browser network errors for the specific failure paths.5
Charge the token on your server
Send the token from your server — never from the browser — to
POST https://api.radiumone.io/gateway/v1/transactions/purchase (sandbox: https://api-sandbox.radiumone.io/gateway/v1/transactions/purchase). The API reference lists the same call as POST /v1/transactions/purchase under the base URL that already ends in /gateway. If the token has expired, see Handle expired sessions and card tokens.See the full pattern: persist request_id, then retry safely on a timeout
See the full pattern: persist request_id, then retry safely on a timeout
Handle the result
Any 2xx response is a result you must branch onstatus — never on response_code (that’s the verbatim host/acquirer code; useful for support tickets, not for your app logic).
After a timeout or a
5xx, replay with the same key. For every payment operation — purchase, authorize, capture, void, and both refunds — a replay of the identical request with the same request_id or operation_id is a lookup, not a resend, so it’s safe even after a 5xx that says retry_allowed: false (switch-timeout, database-unavailable). RadiumOne returns the outcome it recorded. If a capture, void, or referenced refund was sent but its outcome wasn’t recorded, RadiumOne asks the card network for the stored outcome instead of sending it again, and sends it only if the network never received it — so nothing is applied twice. A replay can return PENDING or REVERSAL_PENDING until the outcome settles. A request RadiumOne refused before it reached the card network (for example with device-settling or device-busy) is run again on the same transaction instead of returning a stored result — no second transaction is created. A capture that timed out after it may have reached the card network is reversed — the capture, never the authorization under it: while that reversal is open (REVERSAL_PENDING), a same-operation_id retry gets 409 tx:invalid-state-transition; once it clears, the hold is back to AUTHORIZED and the retry is sent as a new capture attempt. A capture that timed out before it left RadiumOne is sent as a new attempt on a same-operation_id retry — nothing was sent the first time. A void that timed out is reversed too: while that reversal is open, a retry gets 409 transaction:void-reversal-pending (retry_allowed: true); once it clears, the sale is back to CAPTURED and the retry is sent as a new attempt. While that earlier capture, void, or refund is unresolved, a follow-up with a different key on the same transaction gets 409 urn:radiumone:payment-gateway:tx:followup-outcome-in-doubt: resend the pending request first. See Handle timeouts and unknown outcomes.PENDING means the outcome isn’t known yet — most often after a processor timeout. Don’t assume success or failure. Recover it one of two ways:
- Wait for a webhook (
payment.*,authorization.*,refund.*— see Webhook event types). - Poll
GET /v1/transactions/{id}/status— it returns the transaction as RadiumOne holds it. Poll every 60 seconds while it readsPENDINGorREVERSAL_PENDING, and contact support if it isn’t final 60 minutes after your server sent the original request;INCONSISTENTmeans stop and contact support; anything else is final. See Check a transaction’s status.
id yet — a client-side timeout before the first response arrived — replay the same purchase, authorize, or refund with the same request_id and body. The replay is a lookup, not a resend: it returns the stored transaction and its id, whatever status it’s reached, including PENDING or REVERSAL_PENDING. A capture or void replayed with the same operation_id works the same way, and for a capture, void, or referenced refund whose outcome wasn’t recorded, RadiumOne checks with the card network before sending anything. Never re-submit with a new idempotency key just because the first attempt is slow — that risks a second charge for the same order.
token from elements.submit() is single-use context tied to that session; treat it as opaque and never branch on its shape.
Test your integration
Use a sandbox publishable key and a test card. See Test your integration for sandbox test cards and scenarios.Go-live notes
- Complete Install and load Elements and Content Security Policy before switching to production keys.
- Review the go-live checklist.
- Confirm the payment result from your server (webhook or authenticated
GET) — never from the browser alone.
Next steps
Add 3D Secure
Authenticate the card with RadiumOne 3D Secure before charging it.
Card fields and events
Split fields, validation states, and events in depth.