RapidCents Developer Documentation
Checkout Sessions Integration Guide
v1.0 · REST API

Checkout Sessions

Embeddable checkout · Hosted payment pages · One-time & subscription payments · Saved cards & Google Pay

Summary

Checkout Sessions let merchants create secure, pre-configured payment sessions that customers complete through a RapidCents-hosted payment page (hosted mode) or an embedded iframe on the merchant’s website (embedded mode). In both modes, the customer enters their card details directly on the RapidCents-hosted form — your server and your frontend never handle or see card data.

🔒

Zero PCI scope for you. Card data is entered directly on the RapidCents-hosted checkout form. Whether you use hosted mode (full-page redirect) or embedded mode (iframe on your page), your servers never receive, process, or store card numbers, CVVs, or any sensitive payment data. RapidCents handles all card entry, tokenization, 3D Secure, and payment processing.

Checkout Sessions support card entry on RapidCents form, saved cards (card on file), and Google Pay. 3D Secure is automatically applied when enabled on the business. Sessions expire after 24 hours and enforce a maximum of 3 payment attempts.

Checkout Session Lifecycle

  1. Create — Merchant creates a checkout session via the API with amount, customer, URLs, and configuration. A unique session_token and checkout_url are returned.
  2. Present — For hosted mode, the customer is redirected to the checkout URL. For embedded mode, the checkout form loads in an iframe on the merchant’s page.
  3. Pay — Customer enters payment details directly on the RapidCents-hosted form (card, saved card, or Google Pay) and submits. 3D Secure step-up is triggered if enabled. The merchant’s server never receives card data.
  4. Complete — On approval, the session status changes to COMPLETED and payment status to PAID. The customer is redirected to the success_url with the session_token appended.
  5. Verify — Merchant retrieves the session details via the API to confirm payment status and get transaction details.

Session Statuses

Session Status

PENDING

Session created, awaiting payment

COMPLETED

Payment flow finished (check payment_status for result)

EXPIRED

Session expired (24 hours elapsed)

CANCELLED

Session was cancelled by the merchant

FAILED

Maximum payment attempts exceeded

Payment Status

UNPAID

No successful payment yet

PAID

Payment approved successfully

FAILED

All payment attempts failed

UI Modes

ModeDescriptionCard Data EntryUse Case
hostedCustomer is redirected to a full-page RapidCents checkout pageCustomer enters card on RapidCents pageSimple integration — no frontend work needed
embeddedCheckout form loads in an iframe on your pageCustomer enters card in RapidCents iframeSeamless branded experience within your site

In both modes, the merchant never collects card data. The customer enters their card details directly on the RapidCents-hosted form. In hosted mode, this is a full-page checkout on dashboard.rapidcents.com. In embedded mode, this is a secure iframe loaded from dashboard.rapidcents.com within your page. Your JavaScript, your page DOM, and your server never have access to card numbers, CVVs, or expiry dates.

Processing Flow

Hosted Mode

Merchant ServerPOST /checkout/create
RapidCentsReturns checkout_url
CustomerRedirected to checkout
CustomerEnters card on RapidCents
RapidCentsProcesses payment
MerchantRedirect to success_url

Embedded Mode

Merchant PagePOST /checkout/create
RapidCentsReturns checkout_url
IframeLoads checkout form
CustomerEnters card in iframe
RapidCentsProcesses payment
postMessagerc:checkout_result

Authentication

All merchant-facing Checkout Session endpoints require OAuth 2.0 Bearer token authentication. Customer-facing (public) endpoints use the session token in the URL as an implicit access token.

ScopeAuth RequiredDetails
Merchant API (create, list, details)YesBearer token + business ID in URL
Customer (Public) (view, pay)NoSession token in URL acts as access token

Required Headers

Authorization: Bearer {access_token}
Content-Type: application/json
Accept: application/json

Obtaining an Access Token

RapidCents uses OAuth 2.0 with the Password Grant and Refresh Token flows. You will receive the following credentials during merchant onboarding:

CredentialDescription
Client IDOAuth application identifier
Client SecretOAuth application secret
Access TokenBearer token for API authentication (expires in 24 hours)
Refresh TokenUsed to obtain new access tokens (long-lived)
Business UUIDYour business identifier used in all API paths

Checkout session creation requires an OAuth client with a valid HTTPS redirect URL. The request Origin header, success_url, and cancel_url must match the registered OAuth redirect URL origin.

IP Whitelisting

🛡

Required: Before you can process any transactions, you must provide your server’s static IP address(es) to RapidCents for whitelisting. API requests from non-whitelisted IPs will be rejected.

RapidCents enforces IP-based access control on all payment processing endpoints. Only requests originating from your whitelisted server IPs are permitted to create checkout sessions and process payments.

How to Whitelist

  1. Identify your server IPs — Determine the static/elastic IP address(es) of the server(s) that will make API calls to RapidCents. If you use a load balancer or NAT gateway, provide the outbound IP.
  2. Submit to RapidCents — Provide your IP address(es) to the RapidCents integration team during onboarding or via your account manager.
  3. Confirmation — RapidCents will whitelist your IPs and confirm. You can then begin making API calls.
  4. Update when IPs change — If your server infrastructure changes and your outbound IP changes, contact RapidCents to update the whitelist before migrating.

You may whitelist multiple IPs (e.g., for redundancy, staging, and production). Each environment (staging and production) has its own whitelist. Contact RapidCents support to manage your whitelisted IPs.

EnvironmentBase URLWhitelist
Staginghttps://uatstage00-api.rapidcents.comSeparate whitelist — add your dev/staging server IPs
Productionhttps://api.rapidcents.comSeparate whitelist — add your production server IPs

OAuth Token Flow

Refresh Access Token

POST /api/oauth/token

Access tokens expire after 24 hours. Use the refresh token to obtain a new access token without re-authenticating.

Request
POST /api/oauth/token
Content-Type: application/json

{
  "grant_type": "refresh_token",
  "refresh_token": "{your_refresh_token}",
  "client_id": "{your_client_id}",
  "client_secret": "{your_client_secret}",
  "redirect_uri": "",
  "scope": ""
}
Response — 200 OK
{
  "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOi...",
  "refresh_token": "def50200a3c2f7...",
  "token_type": "Bearer",
  "expires_in": 86400
}

Store both the new access_token and refresh_token from the response. The previous refresh token is invalidated after use. Refresh proactively before expiry to avoid failed API calls.

Create Checkout Session

POST /api/{business_id}/checkout/create

Request Body

FieldTypeRequiredDescription
amount_totalnumberYesTotal payment amount (min: 0.01)
amount_subtotalnumberNoSubtotal before tax and discount
amount_taxnumberNoTax amount
amount_discountnumberNoDiscount amount
currencystringNoUSD or CAD. Defaults to merchant’s currency.
customer_idstringConditionalCustomer UUID. Required if customer_email not provided.
customer_emailstringConditionalCustomer email. Required if customer_id not provided.
customer_namestringNoCustomer display name
success_urlstringYesHTTPS URL for successful payment redirect
cancel_urlstringYesHTTPS URL for cancellation redirect
ui_modestringNohosted (default) or embedded
modestringNopayment (default) or subscription
descriptionstringNoPayment description (max 255 chars)
client_reference_idstringNoYour internal reference ID
metadataobjectNoCustom key-value pairs
surchargebooleanNoEnable surcharge (must be configured on business)
line_itemsarrayConditionalRequired when mode is subscription
discountsarrayNoDiscount details
billing_address_collectionstringNoauto or required
shipping_address_collectionstringNoauto or required
consent_collectionobjectNoConsent requirements
subscriptionobjectConditionalRequired when mode is subscription

When amount_subtotal is provided: amount_total = amount_subtotal + amount_tax − amount_discount. Maximum 10 line items per session.

Request — One-Time Payment
POST /api/{business_id}/checkout/create
Content-Type: application/json
Authorization: Bearer {access_token}

{
  "amount_total": 150.00,
  "amount_subtotal": 130.00,
  "amount_tax": 20.00,
  "currency": "CAD",
  "customer_email": "[email protected]",
  "customer_name": "John Doe",
  "success_url": "https://yoursite.com/success",
  "cancel_url": "https://yoursite.com/cancel",
  "ui_mode": "hosted",
  "description": "Order #1234",
  "line_items": [
    { "name": "Widget Pro", "quantity": 2, "unit_amount": 50.00, "total": 100.00 },
    { "name": "Premium Support", "quantity": 1, "unit_amount": 30.00, "total": 30.00 }
  ],
  "billing_address_collection": "required",
  "metadata": { "order_id": "1234" }
}
Response — 200 OK
{
  "ok": true,
  "message": "Checkout session created successfully",
  "status": "PENDING",
  "checkout_session": {
    "id": "session-uuid",
    "token": "a1b2c3d4e5f6...64chars",
    "checkout_url": "https://dashboard.rapidcents.com/customer/checkout/a1b2c3...",
    "session_status": "PENDING",
    "payment_status": "UNPAID",
    "amount_total": 150.00,
    "currency": "CAD",
    "expires_at": "2026-06-09T12:00:00.000000Z",
    "ui_mode": "hosted",
    "success_url": "https://yoursite.com/success",
    "cancel_url": "https://yoursite.com/cancel"
  },
  "transaction": null
}

Line Items

FieldTypeRequiredDescription
namestringYesItem name (max 255 chars)
quantityintegerYesQuantity (min: 1)
unit_amountnumberYesUnit price (min: 0.01)
totalnumberYesLine total (quantity × unit_amount)
imagestringNoProduct image URL

Subscription Mode

Request — Subscription Checkout
{
  "amount_total": 49.99,
  "customer_email": "[email protected]",
  "success_url": "https://yoursite.com/success",
  "cancel_url": "https://yoursite.com/cancel",
  "mode": "subscription",
  "line_items": [
    { "name": "Pro Plan", "quantity": 1, "unit_amount": 49.99, "total": 49.99 }
  ],
  "subscription": {
    "interval": "Monthly",
    "start_date": "2026-07-01",
    "name": "Pro Plan Monthly"
  }
}

Subscription Intervals

IntervalFrequency
WeeklyEvery week
Bi-WeeklyEvery 2 weeks
MonthlyEvery month
QuarterlyEvery 3 months
Twice a yearEvery 6 months
AnnualEvery year

Get Checkout Session Details

GET /api/{business_id}/checkout/{session_token}/details

Retrieve full session details including transaction information after payment. Use this endpoint on your success_url page to verify the payment.

Response — 200 OK (Paid Session)
{
  "ok": true,
  "status": "COMPLETED",
  "checkout_session": {
    "session_status": "COMPLETED",
    "payment_status": "PAID",
    "amount_total": 150.00
  },
  "transaction": {
    "code": "AA",
    "message": "Approved Transaction (Auths / Reversals)",
    "receiptID": "receipt-uuid",
    "transactionID": "transaction-uuid",
    "details": {
      "association": "Visa",
      "amount": 150.00,
      "issuer_reference": "ref-123456",
      "source": "checkout_session"
    }
  }
}

List Checkout Sessions

GET /api/{business_id}/checkout-sessions

Returns a paginated list of checkout sessions with optional filters.

ParameterTypeDescription
fromDatedateFilter from this date
toDatedateFilter up to this date
customerstringSearch by customer name or email
statusstringFilter by session status
perPageintegerResults per page (default: 10)

Internal Checkout Endpoints: The following public endpoints are used internally by the RapidCents checkout form (hosted page or embedded iframe). You do not need to call these from your server or frontend — they are documented here for reference only. Card data is submitted directly from the RapidCents-hosted form to the RapidCents API, never through your systems.

Get Session Data (Internal)

GET /api/checkout/{session_token}/data

Used by the RapidCents checkout form to load session details, business info, saved cards, and 3DS configuration. No authentication required (session token in URL acts as implicit access).

Create Customer for Session (Internal)

POST /api/checkout/{session_token}/customer

FieldTypeRequiredDescription
namestringYesCustomer full name (max 255)
emailstringYesCustomer email
phonestringNoPhone number (10-15 digits)

Process Payment (Internal)

POST /api/checkout/{session_token}/pay

Called by the RapidCents checkout form when the customer submits payment. Card data is sent directly from the RapidCents-hosted form to this endpoint — it never passes through the merchant’s server or frontend.

Payment Methods

New Card

{
  "payment_method_type": "new_card",
  "amount": 150.00,
  "customerId": "customer-uuid",
  "cardData": {
    "cardNumber": "4111111111111111",
    "month": "12",
    "year": 2028,
    "nameOnCard": "John Doe",
    "cvv": "123",
    "saveCard": false,
    "address": { "postalCode": "M5V 2T6", "line1": "123 Main St" }
  }
}

Saved Card

{
  "payment_method_type": "saved_card",
  "amount": 150.00,
  "customerId": "customer-uuid",
  "cardId": "stored-card-uuid"
}

Google Pay

{
  "payment_method_type": "google_pay",
  "amount": 150.00,
  "customerId": "customer-uuid",
  "googlePayToken": "{\"signature\":\"...\",\"protocolVersion\":\"ECv2\",...}"
}
Response — Approved
{
  "ok": true,
  "message": "Payment successful",
  "result": { "code": "AA", "recordID": "txn-uuid", "receiptID": "receipt-uuid" },
  "success_url": "https://yoursite.com/success?session_token=a1b2c3d4..."
}
Response — Declined
{
  "ok": false,
  "message": "Payment failed. Please check your payment details and try again.",
  "attempt_count": 1,
  "max_attempts": 3,
  "cancel_url": "https://yoursite.com/cancel?session_token=a1b2c3d4..."
}

RapidCents Checkout.js Library

For embedded and hosted checkout integrations, RapidCents provides a client-side JavaScript library that handles session creation, iframe management, and payment result callbacks.

Installation

<script src="https://api.rapidcents.com/js/rapidcents-checkout.js"></script>

Initialization

RapidCentsCheckout.init({
  businessId: 'your-business-uuid',
  authToken: 'your-oauth-access-token',
  apiBaseUrl: 'https://api.rapidcents.com/api',
  defaultUiMode: 'embedded',
  containerId: 'rc-checkout',

  // Session verification (recommended)
  verifySessionUrl: '/api/rapidcents/checkout-session',
  autoVerify: true,

  // Callbacks
  onSuccess: function(data) {
    console.log('Payment successful!', data.session_id);
  },
  onCancel: function(data) {
    console.log('Payment cancelled', data.session_id);
  },
  onError: function(error) {
    console.error('Payment error:', error.message);
  }
});

Embedded Mode Example

<!-- HTML -->
<div id="rc-checkout"></div>
<button onclick="startCheckout()">Pay Now</button>

<script src="https://api.rapidcents.com/js/rapidcents-checkout.js"></script>
<script>
  RapidCentsCheckout.init({
    businessId: 'your-business-uuid',
    authToken: 'your-oauth-access-token',
    containerId: 'rc-checkout',
    defaultUiMode: 'embedded',
    onSuccess: function(data) {
      window.location.href = '/order-confirmed?session=' + data.session_id;
    },
    onError: function(error) {
      alert('Payment failed: ' + error.message);
    }
  });

  function startCheckout() {
    RapidCentsCheckout.create({
      amount_total: 99.99,
      customer_email: '[email protected]',
      success_url: 'https://yoursite.com/success',
      cancel_url: 'https://yoursite.com/cancel'
    });
  }
</script>

Library Methods

MethodDescription
RapidCentsCheckout.init(options)Initialize the checkout library with configuration
RapidCentsCheckout.create(data)Create a checkout session and open checkout
RapidCentsCheckout.close()Close the embedded checkout iframe
RapidCentsCheckout.setHeight(px)Manually set the iframe height
RapidCentsCheckout.getState()Get current state (isOpen, sessionId)
RapidCentsCheckout.handleReturnPage()Verify session on success/cancel return page

PostMessage Events (Embedded Mode)

Event TypeStatusDescription
rc:checkout_resultsucceededPayment approved
rc:checkout_resultcanceledCustomer cancelled checkout
rc:checkout_resultfailedPayment failed or max attempts reached
rc:checkout_heightAuto-resize iframe to content height

Step-by-Step: Hosted Mode

  1. Create a Checkout Session (Server-Side) — From your server, call POST /api/{business_id}/checkout/create with the payment details, success_url, and cancel_url. No card data is needed at this step.
  2. Redirect the Customer — Use the checkout_url from the response to redirect: window.location.href = response.checkout_session.checkout_url. The customer is taken to a RapidCents-hosted checkout page where they enter their card details directly.
  3. Customer Pays on RapidCents — The customer enters their card number, expiry, CVV, and billing info on the RapidCents-hosted page. Your server and your frontend never handle or see this data. 3D Secure is applied automatically if enabled.
  4. Handle the Return — On your success_url page, the session_token is appended as a query parameter. Extract it from the URL.
  5. Verify Payment (Server-Side) — Call GET /api/{business_id}/checkout/{session_token}/details to confirm session_status is COMPLETED and payment_status is PAID.

Step-by-Step: Embedded Mode

  1. Add the container and script — Add <div id="rc-checkout"></div> and include the Checkout.js script on your page.
  2. Initialize and create checkout — Call RapidCentsCheckout.init() with your businessId, authToken, and callbacks. Then call RapidCentsCheckout.create() when the user clicks “Pay Now”.
  3. Customer Pays in Iframe — A secure iframe from RapidCents loads inside your page. The customer enters their card details directly on the RapidCents form within the iframe. Your page’s JavaScript and DOM cannot access the card data inside the sandboxed iframe.
  4. Handle callbacks — The onSuccess callback receives the session data (session ID, transaction ID, receipt ID). Verify the payment on your server before fulfilling the order.

All Endpoints

Merchant API (Authenticated)

MethodEndpointDescription
POST/{business_id}/checkout/createCreate checkout session
GET/{business_id}/checkout/{token}/detailsGet session details + transaction
GET/{business_id}/checkout-sessionsList checkout sessions

Customer API (Public)

MethodEndpointDescription
GET/checkout/{token}Validate session and get checkout URL
GET/checkout/{token}/dataGet session data for payment form
POST/checkout/{token}/customerCreate/find customer
POST/checkout/{token}/paySubmit payment

Session Expiry & Limits

SettingValueDescription
Session lifetime24 hoursSessions expire 24 hours after creation
Max payment attempts3Session is marked FAILED after 3 failed attempts
URL schemeHTTPS onlyBoth success_url and cancel_url must use HTTPS
Max line items10Maximum 10 line items per session
Origin validationRequiredRequest origin must match OAuth client redirect URL

Error Handling

HTTP CodeScenarioDescription
200Payment approvedok: true with transaction details
200Payment declinedok: false with decline reason and attempt count
400Session invalidSession is expired, paid, cancelled, or failed
404Not foundSession token or customer does not exist
422Validation errorMissing required fields, invalid URLs, or origin mismatch
500Server errorUnexpected processing error

After Payment

When the customer completes a payment, the outcome depends on the checkout mode:

Hosted Mode

The customer is automatically redirected to the URL you specified when creating the session:

OutcomeRedirectQuery Parameter
Payment successfulRedirected to success_url?session_id={session_token}
Payment cancelledRedirected to cancel_url?session_id={session_token}
Payment failed (max attempts)Redirected to cancel_url?session_id={session_token}

On your success_url page, extract the session_id from the query string and verify the payment on your server before fulfilling the order.

Embedded Mode

The RapidCents iframe sends a postMessage to your parent page. Your registered callbacks fire automatically:

OutcomeCallbackData Received
Payment successfulonSuccess(data)session_id, transaction_id, receipt_id, amount
Payment cancelledonCancel(data)session_id
Payment failedonError(error)message, error_code, session_id

Always verify server-side. Whether you receive a redirect or a callback, always call GET /api/{business_id}/checkout/{session_token}/details from your server to confirm the payment status before fulfilling the order. Never rely on client-side data alone.