cURL
#!/usr/bin/env bash
# Authenticated merchant view of a checkout session. Branch on data.status;
# never on gateway_response_code. Note: GET timestamps are epoch
# milliseconds, unlike the ISO string returned at create time. An expired
# session with data.decline_reason "expired_while_processing" has an unknown
# outcome (the charge may have gone through): wait for the payment.* webhook
# or poll the transaction status; fulfil only on payment.captured.
# null (or an unrecognised value) means no charge was submitted.
# data.status "authorized" is a hold, not a payment: capture it (Payments
# API, using data.gateway_transaction_id) or let the hold lapse -- it can't
# be voided -- and fulfil only on payment.captured. Treat a status you don't recognise as not paid.
set -euo pipefail
CHECKOUT_BASE="${RADIUMONE_CHECKOUT_BASE:-https://checkout-sandbox.radiumone.io}"
: "${RADIUMONE_SECRET_KEY:?set RADIUMONE_SECRET_KEY to your r1sk_* secret key}"
: "${RADIUMONE_CHECKOUT_ID:?set RADIUMONE_CHECKOUT_ID to the checkout_id to verify}"
curl -sS "$CHECKOUT_BASE/api/v1/checkout/sessions/$RADIUMONE_CHECKOUT_ID" \
-H "X-Api-Key: $RADIUMONE_SECRET_KEY"#!/usr/bin/env python3
"""Authenticated merchant view of a checkout session. Branch on ``status``;
never on ``gateway_response_code``.
"""
import json
import os
import requests
CHECKOUT_BASE = os.environ.get("RADIUMONE_CHECKOUT_BASE", "https://checkout-sandbox.radiumone.io")
def retrieve_checkout_session() -> dict:
checkout_id = os.environ["RADIUMONE_CHECKOUT_ID"]
resp = requests.get(
f"{CHECKOUT_BASE}/api/v1/checkout/sessions/{checkout_id}",
headers={"X-Api-Key": os.environ.get("RADIUMONE_SECRET_KEY", "")},
timeout=30,
)
payload = resp.json()
if not resp.ok:
problem_type = payload.get("type")
raise RuntimeError(f"checkout session fetch failed: {problem_type} ({resp.status_code})")
session = payload["data"]
if session["status"] == "authorized":
# A hold, not a payment: the card is held for the full amount but
# nothing was captured. Capture it (Payments API, using
# gateway_transaction_id) or let the hold lapse -- a hold can't be
# voided. Fulfil only once the payment.captured webhook arrives.
return {**payload, "action": "capture_or_let_hold_lapse"}
if session["status"] not in ("pending", "processing", "completed", "failed", "expired", "cancelled"):
# More statuses may be added: treat one you don't recognise as not paid.
return {**payload, "action": "treat_as_not_paid"}
if session["status"] == "expired" and session.get("decline_reason") == "expired_while_processing":
# Expired mid-payment: the outcome is unknown and the charge may have
# gone through. Hold the order (no retry session yet) and wait for the
# payment.* webhook for this order_reference: fulfil on payment.captured
# (or void before settlement); declined/reversed/failed mean nothing
# was kept. Or poll the transaction status every 60 s --
# only if gateway_transaction_id is set (usually None here: then the
# id comes only from the payment.* webhook).
return {**payload, "action": "await_payment_webhook"}
# decline_reason None (or any value you don't recognise, treated as None):
# no charge was submitted by an expired session. Confirm order_reference
# and amount match your order before fulfilling a completed one.
return payload
if __name__ == "__main__":
print(json.dumps(retrieve_checkout_session(), indent=2))
{
"status": "ok",
"data": {
"checkout_id": "chk_3f9a1c2e5b7d4a608e1f2c3b4d5e6f70",
"merchant_id": "8f1c2e10-4b3a-4c5d-9e6f-7a8b9c0d1e2f",
"amount": 5000,
"currency": "SGD",
"currency_minor_units": 2,
"order_reference": "ORD-1001",
"description": "",
"status": "completed",
"mode": "redirect",
"expires_at": 1789300200000,
"created_at": 1789298400000,
"updated_at": 1789298460000,
"locale": "en",
"metadata": {
"cart_id": "c-981"
},
"gateway_transaction_id": "8f1c2e10-4b3a-4c5d-9e6f-7a8b9c0d1e2f",
"gateway_response_code": "00",
"card_brand": "visa",
"last_four": "4242",
"decline_reason": null
}
}Get a session - Hosted checkout
Retrieve a checkout session’s server-side status — the only reliable way to confirm whether the shopper’s payment succeeded.
GET
/
api
/
v1
/
checkout
/
sessions
/
{id}
cURL
#!/usr/bin/env bash
# Authenticated merchant view of a checkout session. Branch on data.status;
# never on gateway_response_code. Note: GET timestamps are epoch
# milliseconds, unlike the ISO string returned at create time. An expired
# session with data.decline_reason "expired_while_processing" has an unknown
# outcome (the charge may have gone through): wait for the payment.* webhook
# or poll the transaction status; fulfil only on payment.captured.
# null (or an unrecognised value) means no charge was submitted.
# data.status "authorized" is a hold, not a payment: capture it (Payments
# API, using data.gateway_transaction_id) or let the hold lapse -- it can't
# be voided -- and fulfil only on payment.captured. Treat a status you don't recognise as not paid.
set -euo pipefail
CHECKOUT_BASE="${RADIUMONE_CHECKOUT_BASE:-https://checkout-sandbox.radiumone.io}"
: "${RADIUMONE_SECRET_KEY:?set RADIUMONE_SECRET_KEY to your r1sk_* secret key}"
: "${RADIUMONE_CHECKOUT_ID:?set RADIUMONE_CHECKOUT_ID to the checkout_id to verify}"
curl -sS "$CHECKOUT_BASE/api/v1/checkout/sessions/$RADIUMONE_CHECKOUT_ID" \
-H "X-Api-Key: $RADIUMONE_SECRET_KEY"#!/usr/bin/env python3
"""Authenticated merchant view of a checkout session. Branch on ``status``;
never on ``gateway_response_code``.
"""
import json
import os
import requests
CHECKOUT_BASE = os.environ.get("RADIUMONE_CHECKOUT_BASE", "https://checkout-sandbox.radiumone.io")
def retrieve_checkout_session() -> dict:
checkout_id = os.environ["RADIUMONE_CHECKOUT_ID"]
resp = requests.get(
f"{CHECKOUT_BASE}/api/v1/checkout/sessions/{checkout_id}",
headers={"X-Api-Key": os.environ.get("RADIUMONE_SECRET_KEY", "")},
timeout=30,
)
payload = resp.json()
if not resp.ok:
problem_type = payload.get("type")
raise RuntimeError(f"checkout session fetch failed: {problem_type} ({resp.status_code})")
session = payload["data"]
if session["status"] == "authorized":
# A hold, not a payment: the card is held for the full amount but
# nothing was captured. Capture it (Payments API, using
# gateway_transaction_id) or let the hold lapse -- a hold can't be
# voided. Fulfil only once the payment.captured webhook arrives.
return {**payload, "action": "capture_or_let_hold_lapse"}
if session["status"] not in ("pending", "processing", "completed", "failed", "expired", "cancelled"):
# More statuses may be added: treat one you don't recognise as not paid.
return {**payload, "action": "treat_as_not_paid"}
if session["status"] == "expired" and session.get("decline_reason") == "expired_while_processing":
# Expired mid-payment: the outcome is unknown and the charge may have
# gone through. Hold the order (no retry session yet) and wait for the
# payment.* webhook for this order_reference: fulfil on payment.captured
# (or void before settlement); declined/reversed/failed mean nothing
# was kept. Or poll the transaction status every 60 s --
# only if gateway_transaction_id is set (usually None here: then the
# id comes only from the payment.* webhook).
return {**payload, "action": "await_payment_webhook"}
# decline_reason None (or any value you don't recognise, treated as None):
# no charge was submitted by an expired session. Confirm order_reference
# and amount match your order before fulfilling a completed one.
return payload
if __name__ == "__main__":
print(json.dumps(retrieve_checkout_session(), indent=2))
{
"status": "ok",
"data": {
"checkout_id": "chk_3f9a1c2e5b7d4a608e1f2c3b4d5e6f70",
"merchant_id": "8f1c2e10-4b3a-4c5d-9e6f-7a8b9c0d1e2f",
"amount": 5000,
"currency": "SGD",
"currency_minor_units": 2,
"order_reference": "ORD-1001",
"description": "",
"status": "completed",
"mode": "redirect",
"expires_at": 1789300200000,
"created_at": 1789298400000,
"updated_at": 1789298460000,
"locale": "en",
"metadata": {
"cart_id": "c-981"
},
"gateway_transaction_id": "8f1c2e10-4b3a-4c5d-9e6f-7a8b9c0d1e2f",
"gateway_response_code": "00",
"card_brand": "visa",
"last_four": "4242",
"decline_reason": null
}
}