Developers Guides Recurring Payments

Recurring Payments

Implement subscription billing and recurring charges using tokenization, recurring payment configuration, and Merchant Initiated Transactions.

Online API Recurring Subscriptions Tokenization MIT

Overview

Recurring payments let you charge customers on a schedule without requiring them to re-enter card details each time. This guide covers the full lifecycle: tokenizing a card during the initial payment, configuring subscription parameters, charging with stored tokens, and managing the subscription over time.

This builds on the concepts introduced in the Server-to-Server API guide. If you are new to Merchant Initiated Transactions (MIT) and tokenization, start there first.

How It Works

  1. Initial payment — The customer pays through a PaymentPage or SelfHostedPage terminal. Tokenization stores their card for future use.
  2. Subscription configuration — You define frequency, amount type, and payment count using the recurring object.
  3. Recurring charges — Your backend creates orders against a MerchantInitiated terminal and pays using the stored token.
  4. Lifecycle management — You handle renewals, cancellations, amount changes, and failed payment retries.

Prerequisites

  • A PaymentPage or SelfHostedPage terminal for the initial customer-present payment
  • A MerchantInitiated terminal for subsequent server-to-server charges
  • API credentials (API key, API secret, merchant ID)

Step 1: Create the Initial Tokenized Order

The first order collects card details and sets up the recurring agreement. Use enforceTokenization together with the recurring configuration and set subscription to true:

POST /merchants/:merchantId/orders
{
  "terminal$id": "YOUR_PAYMENT_PAGE_TERMINAL_ID",
  "orderLines": [
    {
      "id": "SUB-001",
      "name": "Pro Plan - Monthly",
      "quantity": 1,
      "amount": {
        "regular": 9900,
        "total": 9900,
        "currency": "752"
      }
    }
  ],
  "controlFunctions": {
    "initiatePaymentsOptions": {
      "paymentMethod": "CARD",
      "amount": 9900
    },
    "online": {
      "enforceTokenization": true,
      "subscription": true,
      "recurring": {
        "subscriptionAmountType": "fixed",
        "frequency": "monthly",
        "numberOfPayments": 12,
        "uniqueReference": "cust-42-pro-monthly",
        "validation": "validated"
      }
    }
  }
}

The customer completes this payment on the payment page. Once the payment succeeds, the card is tokenized.

Step 2: Retrieve and Store the Token

After the initial payment completes, fetch the token:

GET /merchants/:merchantId/orders/:orderId/tokens

Store the returned tokenId securely on your backend, associated with the customer record. This token is used for all future recurring charges.

Warning: Never expose token IDs in client-side code or logs.

Recurring Configuration Reference

The controlFunctions.online.recurring object controls how the subscription behaves:

FieldRequiredTypeDescription
subscriptionAmountTypeYesstring"fixed" for same amount each cycle, "variable" for amounts that change
maxAmountNonumberMaximum charge amount in smallest currency unit. Only used with "variable" amount type
frequencyYesstringBilling cycle. See frequency options below
numberOfPaymentsNonumberTotal number of payments for the subscription. Omit for indefinite
uniqueReferenceNostringYour unique identifier for this recurring agreement
validationYesstring"validated" if the initial payment is authenticated (3DS), "notValidated" otherwise

Frequency Options

ValueCycle
dailyEvery day
twiceWeeklyTwice per week
weeklyEvery week
tenDaysEvery 10 days
fortNightlyEvery 2 weeks
monthlyEvery month
everyTwoMonthsEvery 2 months
trimesterEvery 4 months
quarterlyEvery 3 months
twiceYearlyEvery 6 months
annuallyEvery year
unscheduledNo fixed schedule (usage-based or on-demand)

Step 3: Charge with the Stored Token

When a billing cycle is due, create an order on the MerchantInitiated terminal and pay with the token:

Create the recurring order

POST /merchants/:merchantId/orders
{
  "terminal$id": "YOUR_MIT_TERMINAL_ID",
  "referenceId": "sub-cust42-2026-02",
  "orderLines": [
    {
      "id": "SUB-002",
      "name": "Pro Plan - February 2026",
      "quantity": 1,
      "amount": {
        "regular": 9900,
        "total": 9900,
        "currency": "752"
      }
    }
  ]
}

Initiate payment with the token

POST /merchants/:merchantId/payments
{
  "orderId": "ORDER_ID_FROM_ABOVE",
  "paymentMethod": "CTOKEN",
  "tokenId": "STORED_TOKEN_ID"
}

Verify the result

GET /merchants/:merchantId/orders/:orderId/status

A successful charge returns orderStatus: "PAYMENT_COMPLETED".

Variable-Amount Subscriptions

For metered billing or usage-based pricing, set subscriptionAmountType to "variable" and specify a maxAmount:

"recurring": {
  "subscriptionAmountType": "variable",
  "maxAmount": 50000,
  "frequency": "monthly",
  "uniqueReference": "cust-42-usage",
  "validation": "validated"
}

Each recurring charge can then use a different amount (up to maxAmount) based on the customer’s usage for that period.

Handling Failed Payments

When a recurring charge fails, the order status will show PAYMENT_FAILED or PAYMENT_CANCELLED. Common reasons include expired cards, insufficient funds, or issuer declines.

Retry strategy:

  1. Check the failureReason on the payment status response.
  2. For soft declines (insufficient funds, temporary issuer issues), retry the same order by calling the Initiate Payment API again with the token.
  3. Space retries over increasing intervals (e.g., 1 day, 3 days, 7 days).
  4. After repeated failures, notify the customer to update their card details. Direct them to a new payment page order with enforceTokenization: true to capture a fresh token.
  5. Replace the old token with the new one in your system.

Managing the Subscription Lifecycle

ActionHow to implement
PauseStop creating new orders on your billing schedule. The token remains valid.
ResumeStart creating orders again using the same stored token.
CancelStop billing. Optionally delete the stored token via your internal records.
Upgrade / downgradeChange the amount on the next order you create. For variable subscriptions this works within maxAmount. For fixed subscriptions, create a new initial order with the updated recurring configuration.
Update payment methodDirect the customer to a new payment page order with tokenization enabled, then replace the stored token.

Reference

Other Guides

in-store

Tap to Pay on iPhone SDK

Accept contactless payments directly on iPhone. Complete integration guide for Surfboard's iOS SoftPOS SDK -- from setup to production.

in-store

Android SoftPOS SDK

Turn Android devices into payment terminals with the Surfboard Android SoftPOS SDK. Complete integration guide from setup to production.

in-store

EMV Terminal Integration

Integrate traditional card-present terminals through Surfboard's unified API. From account setup to live payments in one guide.

online

Payment Page

Redirect customers to a Surfboard-hosted checkout page. The fastest way to accept online payments with minimal integration effort.

in-store

Inter-App Integration

Integrate your POS app with CheckoutX using native app switch. Register terminals, process payments, and scan NFC tags through a bi-directional deep link flow.

online

Self-Hosted Checkout

Embed a payment form directly in your web app with the Surfboard Online SDK. Full UI control with Surfboard handling PCI compliance.

online

Server-to-Server API

Process online payments entirely from your backend with Merchant Initiated Transactions. Full control over recurring payments, subscriptions, and tokenized card flows.

online

Create an Order

Learn how to create orders with line items, tax, customer details, and control functions. The starting point for accepting payments with the Surfboard API.

online

Merchant Onboarding

Set up merchants and stores on the Surfboard platform. Walk through the full onboarding flow from merchant creation to KYB completion and store setup.

online

Payment Lifecycle

Manage the full payment lifecycle from order creation through capture, void, cancel, and refund operations using the Surfboard Payments API.

online

Capture a Payment

Finalize a previously authorized payment by capturing funds. Covers delay capture and pre-authorization flows with step-by-step API examples.

in-store

Terminal & Device Management

Manage payment terminals and devices via the Surfboard API. Register in-store and online terminals, configure settings, and handle device operations.

online

Cancel a Payment

Stop an in-progress payment before it completes. Use cancellation when a customer abandons checkout or a payment needs to be halted mid-process.

online

Webhooks & Notifications

Receive real-time event notifications via webhooks, email, Slack, and SFTP. Subscribe to payment events and settlement reports for merchants and partners.

online

Void a Payment

Reverse a completed payment before settlement. Voiding stops funds from transferring to the merchant's account, avoiding incorrect transactions.

in-store

Receipts

Generate, email, print, and customise receipts for in-store transactions using the Surfboard Receipts API.

online

Refund an Order

Process a full refund by creating a return order with negative quantities. Covers the complete refund flow with API examples and payment method requirements.

online

Partial Refund

Refund specific items or a reduced amount from a completed order. Process partial returns by creating a return order with only the items to be refunded.

in-store

Tips Configuration

Configure tipping on Surfboard payment terminals at the merchant, store, or terminal level using a hierarchical override model.

in-store

NFC Tag Reading

Use the NFC Reading API to create tag-reading sessions on payment terminals, scan NFC/RFID-tagged products, and retrieve scanned tag data.

online

Partial Payments

Split an order across multiple payment methods or transactions. Accept card, cash, and Swish in any combination to settle a single order.

in-store

Multi-Merchant Terminals

Set up shared payment terminals for multiple merchants using the Multi-Merchant Group API. Ideal for food courts, events, and co-located businesses.

online

Store Management

Create, update, verify, and manage in-store and online stores using the Surfboard Payments Store APIs.

online

Gift Cards & Promotions

Issue and manage gift cards, track transactions, and create marketing promotions using the Surfboard Payments APIs.

online

Product Catalog

Create and manage product catalogs, products, variants, inventory levels, and analytics through the Catalog API.

online

Settlements & Reporting

Retrieve settlement reports, view adjustments, manage merchant charges, and register customer profiles for reconciliation and billing.

online

Account & Service Provider Management

Create merchant and partner accounts, manage user roles, register service providers, and configure external notifications via the Surfboard API.

online

Payment Methods

Activate, deactivate, and list payment methods for a merchant. Manage card, Swish, Klarna, AMEX, Vipps, MobilePay, and more via the API or Partner Portal.

online

Client Auth Tokens

Generate client-side authentication tokens for secure API access from browsers and mobile apps without exposing your API key or secret.

online

Partner Branding

Configure white-label branding for terminals and payment pages. Set colors, fonts, logos, and cover images at the partner level via API or Partner Portal.

Ready to get started?

Create a sandbox account and start building your integration today.