Build a subscriptions integration with Checkout

Create and manage subscriptions to accept recurring payments through Checkout.

What you'll build

This guide explains how to use Onerway Checkout to sell subscriptions. Through the subscription field, you will learn how to set up your subscription plans.

Integration Profile

Integration Type
Onerway Hosted Page
Integration Complexity
UI Customization
Limited
PCI Requirement
Not Required

Customization Options

  • Custom fonts
  • Custom background and border colors
  • Custom Logo

Subscription Models

Onerway offers two subscription models:

Comparison ItemManaged SubscriptionSelf-Managed Subscription
Renewal ChargeExecuted automatically by OnerwayMerchant calls API manually
Failed Charge HandlingAutomatic retryHandled by merchant
Customer Management PortalSubscription management portal providedImplemented by merchant
Billing FlexibilityFixed amount/cycleFully adjustable

How to Choose:

Business ScenarioRecommended Model
Fixed cycle & fixed amount (e.g., membership subscription)Managed Subscription
Usage-based billing with variable amountsSelf-Managed Subscription
Quick launch, no desire to maintain billing logicManaged Subscription

Demo

CheckoutConfig

Configure Checkout Parameters

Merchant logo

Subscribe to bilibili monthly pro

22.85 USD

per Monthly

Pay with card

Country

United States (Auto-detected)

Card information

1234 1234 1234 1234
MM / YY
CVC

Cardholder name

By confirming your subscription, you allow to charge you for future payments in accordance with their terms. You can always cancel your subscription.

This is a demo for illustration purposes only. No real transactions will be processed.


How to build a subscription checkout

First, create a subscription product in your payment platform, defining the product name, price, and billing cycle. Make sure to configure related tax rates and currency options.

For multiple calls with the same merchantTxnId (possibly concurrent), use database transactions or distributed locks to prevent race conditions.

When creating a subscription, set subProductType to SUBSCRIBE in the Checkout API and pass the subscription parameter:

Required ParameterDescription
merchantCustIdUnique customer identifier for associating the subscription with the user
frequencyTypeBilling interval unit: D for days, M for months
frequencyPointThe interval value for billing
cycleCount or expireDateEither the total number of billing cycles or the expiration date (mutually exclusive)

Use Checkout to create a hosted payment page for your subscription. The customer will be redirected to Onerway's secure payment page to complete the transaction.

Customers will complete these steps on the checkout page:

  • View subscription details and amount
  • Select payment methods (credit card, digital wallet, etc.)
  • Enter payment information and complete 3D verification (if required)

Checkout features:

  • Automatically adapts to desktop and mobile
  • Supports multiple languages and currencies
  • Built-in 3D Secure verification
  • Secure encryption of payment information

After the payment is completed, Onerway will redirect the customer back to your returnUrl. You need to verify the payment result and update your system accordingly.

Verify Payment Status

After payment completion, Onerway notifies the result through two methods:

Callback TypeTriggerProcessing Recommendation
Synchronous callbackCustomer returns to returnUrl after paymentDisplay result page; do not rely on this status
Asynchronous notificationOnerway sends webhook to notifyUrlVerify signature, deduplicate, update subscription status

Subscription status is determined by webhook notifications. Synchronous callbacks are for display purposes only; always confirm the final status through webhooks.

Key data to save

DataPurpose
contractIdSubscription contract identifier, used for querying and management
tokenIdPayment token, used to initiate charges
subscriptionManageUrlCustomer self-service management page (hosted subscription)

Handle Webhooks

Set up a webhook endpoint to receive real-time notifications about subscription events:

ScenarioTrigger
SUBSCRIPTION_INITIALFirst-time subscription successful
SUBSCRIPTION_RENEWALRenewal charge successful
SUBSCRIPTION_CHANGEDPlan changed
SUBSCRIPTION_CANCELEDSubscription canceled
SUBSCRIPTION_ENDEDNaturally expired

Hosted Subscription Renewal

Onerway automatically charges before expiration and sends a SUBSCRIPTION_RENEWAL webhook. Failed charges are automatically retried and the status becomes pastdue. Merchants only need to listen to webhooks to update local status.

Self-Managed Subscription Renewal

Merchants need to call the API to initiate charges before expiration, passing contractId + tokenId + merchantCustId, and handle charge results and retry logic themselves.

Customer Self-Service Management

Customers will receive subscription emails from Onerway containing a subscription management URL, enabling them to view subscription details, update payment methods, and cancel subscriptions through self-service.

Subscription Status

StatusDescription
trialingTrial period in progress
activeActive and scheduled for renewal
pastduePast due due to failed payment
canceledCanceled; remains active until the end of the current billing cycle
endedSubscription terminated