> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ozura.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Recurring Mode

> Set up subscription and membership payments with automated billing schedules

Recurring mode lets you create a checkout session that, on successful payment, automatically enrolls the customer in a billing plan. The customer enters their card details once; OzuraPay handles every subsequent charge on the plan's schedule.

> [!NOTE]
>
> **How it works under the hood:** When the customer pays, Checkout enrolls them in a recurring plan through OzuraPay API instead of making a one-time sale. The first charge happens right then, at signup; OzuraPay API runs every later charge on the plan's schedule. Card details never reach your server.

## Enable Recurring Mode

Set `checkoutMode` to `"recurring"` and include a `recurringConfig` object:

```json theme={null}
{
  "merchantId": "your_merchant_id",
  "merchantName": "My App",
  "amount": "29.99",
  "currency": "USD",
  "checkoutMode": "recurring",
  "recurringConfig": {
    "planName": "Monthly Pro",
    "interval": "monthly"
  },
  "successUrl": "https://yoursite.com/welcome",
  "cancelUrl": "https://yoursite.com/pricing",
  "errorUrl": "https://yoursite.com/error"
}
```

> [!WARNING]
>
> `recurringConfig` is **required** when `checkoutMode` is `"recurring"`. Omitting it returns a `400` validation error.

## `recurringConfig` Fields

### Required

| Field | Type | Constraints | Description |
| :- | :- | :- | :- |
| `planName` | string | Max 50 chars | Label for this subscription plan, shown to the customer in the checkout UI |
| `interval` | string | `"daily"`, `"weekly"`, `"monthly"`, `"yearly"` | Billing frequency keyword. Combine with `intervalCount` for non-standard periods (e.g. every 3 months) |

### Optional

All fields below are optional. When omitted, they are not stored on the session and not sent to OzuraPay API — any defaults listed are applied by the **OzuraPay API**, not by Checkout.

> [!NOTE]
>
> **Type note:** `intervalCount`, `initialCycles`, `maxCycles`, and `maxAttempts` must be JSON **numbers** (not strings). `initialAmount` and `setupFee` must be JSON **strings** with at most 2 decimal places (like `"9.99"`). This matches how OzuraPay API expects them.

| Field | Type | OzuraPay API default | Description |
| :- | :- | :- | :- |
| `planDescription` | string (max 100 chars) | — | Short description shown below the plan name in the checkout UI |
| `intervalCount` | integer ≥ 1 | `1` | **Billing period multiplier.** Combined with `interval` to define the billing period. `interval: "monthly"` + `intervalCount: 3` = billed every 3 months (quarterly). `interval: "weekly"` + `intervalCount: 2` = every 2 weeks |
| `endDate` | string (`YYYY-MM-DD`) | indefinite | Date after which the processor stops billing automatically. It's read as the start of that day in UTC, so a charge due later on the end date doesn't run. Must be at least one billing period after today, so the plan has a charge after signup; otherwise creating the session or link returns a `400`, and an existing payment link stops starting new sessions once its end date gets that close. Omit for an ongoing plan |
| `maxCycles` | integer ≥ 2 | indefinite | Maximum number of billing cycles before the plan completes automatically, counting the first charge at signup. Omit for an ongoing plan. For a single charge, use a standard `payment` session instead. Can be set alongside `endDate` — whichever limit is hit first stops billing |
| `maxAttempts` | integer ≥ 0 | `3` | How many times OzuraPay API retries a failed charge before marking the attempt failed. Pass `0` to disable retries |
| `setupFee` | **string** (decimal, at most 2 decimal places, e.g. `"9.99"`) | — | One-time fee charged on the first billing cycle only, in addition to the regular `amount`. Does not repeat |
| `initialAmount` | **string** (decimal, at most 2 decimal places, e.g. `"9.99"`) | — | Override the billing `amount` for the first N cycles (introductory / trial pricing). **Must always be provided together with `initialCycles`** — sending one without the other returns a `400` validation error. See [Trial Pricing](#trial-pricing) |
| `initialCycles` | integer ≥ 1 | — | Number of cycles at the `initialAmount` before switching to the standard session `amount`. **Must always be provided together with `initialAmount`** — sending one without the other returns a `400` validation error |
| `merchantRecurringReference` | string (max 50 chars) | — | Your own subscription or customer ID forwarded to OzuraPay API. Use this to correlate the plan back to your records — it is the recommended way to look up a plan ID after enrollment |
| `startDate` | string (`YYYY-MM-DD`) | — | **Deprecated and ignored.** Billing always starts when the customer pays — see [Billing Schedule](#billing-schedule). Still accepted so existing integrations keep working; a value that isn't `YYYY-MM-DD` returns a `400` validation error. Omit it in new integrations |

## Billing Schedule

The plan's schedule always starts when the customer completes payment:

* **First charge:** at signup, when the customer pays. Checkout shows it as **Due today**.
* **Every later charge:** one billing period after the previous one (`interval` × `intervalCount`), at the same time of day. Monthly and yearly plans keep the same day of the month (in UTC); in a shorter month the charge moves to that month's last day (a plan started on January 31 next charges on February 28, or 29 in a leap year).

For example, a customer who signs up for a monthly plan on October 9 is charged on October 9, then November 9, December 9, and so on.

Checkout shows the customer this date before they pay, as **Next charge** in the order summary and in the subscription notice. It's calculated the same way OzuraPay API schedules the charge.

> [!NOTE]
>
> **`startDate` doesn't delay billing.** It was never sent to the payment processor, so it never moved the first charge. To give customers a free first period, use `initialAmount: "0.00"` with `initialCycles: 1`: nothing is charged at signup, and the regular `amount` is charged one billing period later. See [Trial Pricing](#trial-pricing).

## `amount` Field

The `amount` on the session is the **standard recurring charge** — what the customer is billed on each normal billing cycle.

```json theme={null}
{
  "amount": "29.99",
  "checkoutMode": "recurring",
  "recurringConfig": { ... }
}
```

**What gets charged on the first cycle?**

Checkout forwards `amount`, `setupFee`, `initialAmount`, and `initialCycles` as separate fields to OzuraPay API, which combines them and calculates the actual charge. Checkout shows the same first-charge amount to the customer as **Due today** (plus sales tax, see [Sales Tax](#sales-tax)), but the charge itself is always calculated by OzuraPay API. The first cycle is charged at signup.

| Configuration | Effective first cycle charge | Subsequent cycles |
| :- | :- | :- |
| No trial fields | `amount` | `amount` |
| `setupFee` only | `setupFee` + `amount` (OzuraPay API adds them) | `amount` |
| `initialAmount` + `initialCycles` | `initialAmount` (repeated for N cycles) | `amount` |
| All three | `setupFee` + `initialAmount` (OzuraPay API adds them) | `amount` (after `initialCycles` expire) |

> [!NOTE]
>
> There is no field called `intervalAmount`. The field that overrides the billing amount for the first N cycles is `initialAmount`.

> [!WARNING]
>
> `items` arrays are **not** supported for recurring mode. Recurring charges are a fixed scalar amount, not a cart total. Providing `items` returns a `400` error.

## Sales Tax

Unless the session is [`taxExempt`](https://docs.ozura.com/guides/payments/checkout/create-session#tax-exempt-checkout-experience), tax (sales tax in the US; VAT, GST or sales tax in [other covered countries](https://docs.ozura.com/guides/payments/checkout/create-session.md#international-billing-addresses)) is calculated from the customer's billing address and added to every charge: the first charge at signup and each later charge.

In the order summary, once the customer has entered a complete billing address, checkout shows:

* **Tax** and **Due today**: the exact tax on the first charge and the total charged at signup.
* \**Then $X every month** (or the plan's interval): the regular charge including today's tax. If intro pricing continues after signup (`initialCycles` greater than 1), it reads, for example, *Then $10.98 every month for 2 more charges, then \$109.75 every month*, with each amount taxed on its own.

Before the address is complete, the summary reads \*\*$X + tax** instead. A $0 first charge shows **No tax due today**.

Each later charge's tax is recalculated when that charge runs, so it follows any change in tax rates. The subscription notice says so: *Amounts include tax at today's rate; tax is recalculated on each charge.*

See [Sales tax in the order summary](https://docs.ozura.com/guides/payments/checkout/create-session.md#sales-tax-in-the-order-summary) for how the address is checked and what the customer sees if it can't be verified.

## Surcharge

Add a credit card surcharge to the recurring charge using `surchargePercent`.

> [!NOTE]
>
> **Hosted payment sessions:** when the customer enters their card on the processor's secure hosted payment page (the default), Checkout doesn't apply `surchargePercent`: it's accepted but ignored, and no surcharge line is shown in the order summary. Any surcharge is applied by the processor on its hosted page, based on how your processor account is configured.

On sessions where Checkout applies the surcharge, it's shown as a line item in the order summary and forwarded to the payment processor.

```json theme={null}
{
  "amount": "29.99",
  "checkoutMode": "recurring",
  "surchargePercent": "2.00",
  "recurringConfig": {
    "planName": "Monthly Pro",
    "interval": "monthly"
  }
}
```

* Accepts a string (`"2.00"`) or number (`2.0`)
* Maximum `"3.00"` (Florida 3% cap)
* Displayed as a separate line item: `Surcharge (2.00%)`
* Applied to the base `amount` before tax

See [Surcharge](#surcharge-reference) below for the full reference.

## Trial Pricing

Use `setupFee`, `initialAmount`, and `initialCycles` together to offer introductory pricing.

### Setup Fee Only

A one-time fee added to the first billing cycle:

```json theme={null}
{
  "amount": "29.99",
  "recurringConfig": {
    "planName": "Pro Monthly",
    "interval": "monthly",
    "setupFee": "9.99"
  }
}
```

| Cycle | Charged |
| :- | :- |
| Cycle 1 (at signup) | `$9.99 + $29.99 = $39.98` |
| Cycle 2+ | `$29.99` |

### Introductory Rate

Override the amount for the first N cycles:

```json theme={null}
{
  "amount": "29.99",
  "recurringConfig": {
    "planName": "Pro Monthly",
    "interval": "monthly",
    "initialAmount": "9.99",
    "initialCycles": 2
  }
}
```

| Cycle | Charged |
| :- | :- |
| Cycles 1–2 (cycle 1 at signup) | `$9.99` |
| Cycle 3+ | `$29.99` |

### Combined (Setup Fee + Trial)

```json theme={null}
{
  "amount": "49.99",
  "recurringConfig": {
    "planName": "Annual Premium",
    "interval": "yearly",
    "setupFee": "10.00",
    "initialAmount": "19.99",
    "initialCycles": 1
  }
}
```

| Cycle | Charged |
| :- | :- |
| Cycle 1 (at signup) | `$10.00 (setup) + $19.99 (trial) = $29.99` |
| Cycle 2+ | `$49.99` |

Sales tax is added to each of these amounts unless the session is tax-exempt — see [Sales Tax](#sales-tax).

## Interval Examples

Use `interval` alone for standard periods. Add `intervalCount` to create any custom period — the two fields multiply together.

```json theme={null}
{ "interval": "daily" }                             // Every day
{ "interval": "weekly" }                            // Every week
{ "interval": "monthly" }                           // Every month
{ "interval": "yearly" }                            // Every year (annual)
{ "interval": "weekly",  "intervalCount": 2 }       // Every 2 weeks (biweekly)
{ "interval": "monthly", "intervalCount": 3 }       // Every 3 months (quarterly)
{ "interval": "monthly", "intervalCount": 6 }       // Every 6 months (semi-annual)
{ "interval": "daily",   "intervalCount": 30 }      // Every 30 days
```

> [!NOTE]
>
> `intervalCount` is a JSON number (not a string). `"intervalCount": "3"` will return a 400 validation error.

## Capped Plans

Use `endDate` or `maxCycles` to automatically stop billing:

```json theme={null}
{
  "amount": "9.99",
  "checkoutMode": "recurring",
  "recurringConfig": {
    "planName": "12-Month Plan",
    "interval": "monthly",
    "maxCycles": 12,
    "endDate": "2027-06-01"
  }
}
```

Either field alone is sufficient; you can set both for belt-and-suspenders control. `maxCycles` counts the first charge at signup, so `12` means the signup charge plus 11 more.

## Full Example

Monthly subscription with a \$5.00 setup fee, a free first month, a 12-cycle cap, and a 3% surcharge (applied only on sessions where Checkout applies surcharges — see [Surcharge](#surcharge)):

```bash theme={null}
curl -X POST https://checkout.ozura.com/api/sessions/create \
  -H "X-API-KEY: your_vault_key" \
  -H "X-OZURA-API-KEY: your_merchant_key" \
  -H "Content-Type: application/json" \
  -d '{
    "merchantId": "your_merchant_id",
    "merchantName": "My SaaS",
    "amount": "49.99",
    "currency": "USD",
    "checkoutMode": "recurring",
    "surchargePercent": "3.00",
    "successUrl": "https://yoursite.com/welcome",
    "cancelUrl": "https://yoursite.com/pricing",
    "errorUrl": "https://yoursite.com/error",
    "recurringConfig": {
      "planName": "Pro Monthly",
      "planDescription": "Unlimited access to all Pro features",
      "interval": "monthly",
      "initialAmount": "0.00",
      "initialCycles": 1,
      "setupFee": "5.00",
      "maxCycles": 12,
      "maxAttempts": 3,
      "merchantRecurringReference": "cus_abc123"
    }
  }'
```

## What the Customer Sees

The checkout page displays a **Subscription Summary** block above the payment form showing:

* Plan name and description
* The regular amount and billing interval (e.g. `$49.99 / month`)
* **Next charge:** the date of the first charge after signup — see [Billing Schedule](#billing-schedule)
* **Billing ends** and **Total cycles** (if `endDate` or `maxCycles` is set)
* **Intro price** (for example *\$10.00 for the first 3 charges*) and **One-time setup fee** (if `initialAmount` or `setupFee` is set). The first charge is the intro price plus the setup fee.
* **Tax**, **Due today**, and **Then \$X every month** — see [Sales Tax](#sales-tax)
* A surcharge row, only on sessions where Checkout applies `surchargePercent` — see [Surcharge](#surcharge)

Above the payment button, a **Subscription Notice** tells the customer what they're authorizing after the signup charge: the regular amount on the plan's interval, starting on the date it first applies. With intro pricing that continues after signup, it names both, for example *$10.98 every month for the next 2 charges, starting November 9, 2026, then $109.75 every month starting January 9, 2027*. Dates the plan won't reach (because of `endDate` or `maxCycles`) are left out.

The payment form and button are otherwise identical to a standard payment session.

## Success Redirect

After a successful recurring signup, the customer is redirected to your `successUrl` with the standard transaction parameters:

```
https://yoursite.com/welcome?success=true&sessionId=session_xxx&checkoutMode=recurring&transactionId=250107000019C4E1B&transactionType=sale&amount=49.99&currency=USD&ozuraMerchantId=ozu_xxx&surchargeAmount=1.50&cardLastFour=1111&cardBrand=VISA&transDate=2026-06-01T12:00:00.000Z
```

| Parameter | Description |
| :- | :- |
| `checkoutMode` | `"recurring"` |
| `transactionType` | `"sale"` (the initial CIT charge that enrolled the customer) |
| `transactionId` | The initial charge transaction ID from the payment processor |
| `surchargeAmount` | Calculated surcharge amount in the session currency |
| (all other standard params) | Same as a standard payment — see [Handle the Result](https://docs.ozura.com/guides/payments/checkout/handle-result.md#success-url-parameters) |

> [!WARNING]
>
> **`planId` is not included in the success URL redirect.** The OzuraPay API plan ID is part of the raw payment processor response but is not appended to the redirect URL. To retrieve the plan ID for subscription management (pause, cancel, lookup), query the OzuraPay API recurring plan endpoints using your merchant credentials — OzuraPay API associates plans with the `merchantRecurringReference` or by listing plans for your merchant account.

## Combine with Payment Links

Create a shareable recurring subscription link:

```json theme={null}
{
  "merchantId": "your_merchant_id",
  "merchantName": "My SaaS",
  "amount": "29.99",
  "currency": "USD",
  "checkoutMode": "recurring",
  "recurringConfig": {
    "planName": "Monthly Pro",
    "interval": "monthly"
  },
  "successUrl": "https://yoursite.com/welcome",
  "cancelUrl": "https://yoursite.com/pricing",
  "errorUrl": "https://yoursite.com/error"
}
```

Post this to `POST /api/payment-links/create` and share the returned `url`. Each customer who visits the link and pays is enrolled in their own plan, with a schedule that starts when they pay. See [Payment Links](https://docs.ozura.com/guides/payments/checkout/payment-links.md) for full details.

***

## Surcharge Reference

`surchargePercent` is independent of `checkoutMode` — it works on standard `payment` sessions too. On hosted payment sessions (the default) it's accepted but ignored; see [Surcharge](#surcharge).

| Field | Type | Required | Behaviour when omitted | Constraints |
| :- | :- | :-: | :- | :- |
| `surchargePercent` | string or number | No | Treated as `0%` at charge time — no surcharge line item shown, `"0.00"` sent to the payment processor | `0`–`3.00` (Florida maximum). Normalised internally to two decimal places (e.g. `2.5` → `"2.50"`) |

When Checkout applies it, the surcharge is:

* Displayed as a line item in the order summary: `Surcharge (X.XX%)`
* Applied to the base `amount` (before tax)
* Forwarded to the payment processor on every charge (including recurring cycles)
* Applied to debit cards at the processor's discretion — OzuraPay API performs a BIN lookup and excludes debit cards automatically where required

```json theme={null}
{
  "amount": "100.00",
  "surchargePercent": "3.00"
}
```

Order summary: `Subtotal $100.00 + Surcharge (3.00%) $3.00 = Total $103.00`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.