Subscription payments
An initial subscription establishes a contract for recurring charges by billing cycle. The initial subscription can be completed through Checkout, the Web SDK, or the Direct API; self-managed renewals and managed plan changes are initiated by your server through the Direct API.
Concepts and choices
The billing model is determined by subscription.selfExecute and chosen at the initial subscription:
- Managed subscriptions (
selfExecute=1): Onerway automatically collects each cycle according to the subscription plan and sends a webhook for every payment. WhennotificationEmailis configured, Onerway emails the customer subscription confirmations and billing notices, and the customer can self-manage the subscription through thesubscriptionManageUrlreturned in the response. - Self-managed subscriptions (
selfExecute=2): you maintain the billing schedule and collect each cycle through Create direct transaction (subscription.requestType=1) using thecontractIdandtokenIdreturned by the initial subscription; onlyfrequencyType=Dis supported, but that does not limit you to daily billing: thesubscription.frequencyPointfield states the billing cycle in days (for example, you can submit30for a monthly subscription or365for an annual subscription). This value is informational only; you determine when to initiate renewal charges. Whether you make the first charge depends onsubscription.mode— under the default2, Onerway collects it once the customer has authorized.
Both cards and wallets can be used for subscriptions, and both billing models apply to Apple Pay and Google Pay. How a wallet subscription is started and how it differs from a card subscription are covered in Apple Pay and Google Pay. A subset of the methods in Local payment methods can also be used for subscriptions, but only as self-managed subscriptions, and the subscription authorization produces a notification of its own.
The billing cycle, cycle count or end date, and trial period are all defined in the subscription field; see the API Reference for field definitions. For the initial subscription, submit the customer identifier in subscription.merchantCustId. The top-level merchantCustId is optional and must match when also submitted. The identifier has the same requirements as in Saved payment methods.
Lifecycle and notifications
- Contract credentials: for card, Apple Pay, and Google Pay subscriptions, store
contractIdandtokenIdfrom the subscription payment webhook after the initial subscription succeeds. For local payment method subscriptions, store them from the subscription authorization result (txnType=BIND_CARD,scenarios=SUBSCRIPTION_INITIAL) only whenstatus=S. Use these credentials for subscription charges, queries, and cancellation. Whensubscription.mode=1, they are also needed to initiate the first charge; see Local payment method subscriptions. ThistokenIdis a subscription token and must not be mixed with card tokens; see Scenario overview. - Lifecycle events: initial purchase, renewal, card replacement, change, expiration, and contract status are described by the
scenariosfield and thesubscriptionStatusfield of the subscription payment webhook. Effective cancellation is reported separately through the subscription cancellation webhook. - Self-managed renewal: your server submits the stored
contractIdandtokenIdinsubscriptionand sets the amount for this cycle inorderAmount, with no card data, so renewals carry no PCI DSS requirement. The customer identifier is taken from the contract and does not need to be submitted again. You specify the amount for each cycle; it is not constrained by the initial subscription amount. A successful charge produces a webhook withscenarios=SUBSCRIPTION_RENEWAL; reconciling with Onerway is your responsibility. - Managed renewal: Onerway charges the amount of the plan in effect, which is the initial subscription amount until you change the plan. An individual automatic charge cannot be adjusted; to change future amounts, update the plan as described below.
- Managed plan changes: initiated with the stored
contractIdandtokenId(requestType=2); when the change takes effect is controlled bysubscription.changeMode. A successful update produces a webhook withscenarios=SUBSCRIPTION_CHANGED. Once the change takes effect, Onerway continues automatic billing at the new plan amount.changeMode=1, apply immediately: Onerway prorates by the remaining days of the current cycle (prorationMode=1, the default), or you calculate the prorated amount and submit it inproration(prorationMode=0). Upgrades charge the difference immediately; for downgrades, refund any difference owed to the customer through Create or cancel refund.changeMode=2, apply from the next billing cycle: no immediate charge, suitable for price increases that require advance notice.
- Subscriptions that also save the card: when a managed card subscription submits
subscription.bindCard=true, two transactions and two separate notifications are created: the saved payment method result webhook (txnType=BIND_CARD) returns the card token usable for later token payments, and the subscription payment webhook (txnType=SALE) returns the subscription-sidecontractIdandtokenId. The two notifications carry differenttransactionIdvalues and must be handled idempotently on their own. - Query and cancel: see Query subscription details and Cancel subscription contract.
Cancel a subscription
Use Cancel subscription contract to request cancellation. Onerway-managed subscriptions support immediate cancellation, cancellation at the end of the current billing cycle, or cancellation on a specified date. See expireMode and expireDate for scheduling prerequisites and date restrictions. Merchant-managed subscriptions are canceled immediately.
A successful response with data="3" means the cancellation request was processed; it does not mean a scheduled cancellation has taken effect. After an Onerway-managed cancellation is scheduled, the query result has dataStatus=3 while subscriptionStatus retains its previous value. When cancellation takes effect, subscriptionStatus becomes canceled and Onerway sends the subscription cancellation webhook. Associate the subscription by contractId and acknowledge the notification with its transactionId.
Cancellation does not guarantee that payments already initiated are reversed; handle each payment according to its own result. Customer emails for Onerway-managed subscriptions depend on the configured email address and email settings.
Failed payments and retries
For self-managed subscriptions (selfExecute=2), you decide whether, how many times, and how often to retry, and submit each retry as a renewal charge (requestType=1) through the Direct API.
For managed subscriptions (selfExecute=1), Onerway retries automatically: at most 3 attempts per cycle, including the initial charge, so up to 2 retries. The interval depends on the billing cycle:
| Billing cycle | Retry interval |
|---|---|
| Daily | 1 hour |
| Every 2–3 days | 12 hours |
| Longer than 3 days | 24 hours |
While retries are pending, subscriptionStatus is pastdue; if all 3 attempts fail, it becomes paused while the contract stays enabled (dataStatus=1). Both fields are returned by the subscription payment webhook and Query subscription details.
Payment retries are separate from webhook redelivery; see Acknowledge and retries.
Replacing the subscription card
Only managed subscriptions (selfExecute=1) support card replacement, and only by the customer on the subscription management page at subscriptionManageUrl; there is no API for it. The result is reported by the subscription payment webhook with scenarios=SUBSCRIPTION_CARD_REPLACEMENT.
Parameters by integration method
| Integration method | Endpoint | Key parameters | Differences | Integration guide |
|---|---|---|---|---|
| Checkout | Create checkout payment | subProductType=SUBSCRIBE, subscription (requestType=0) | Initial subscription only; a top-level merchantCustId, if submitted, must match subscription.merchantCustId | Checkout integration |
| Web SDK | Create SDK transaction | subProductType=SUBSCRIBE, subscription (requestType=0) | Initial subscription only; keep the allowed plan mapping on your server | Web SDK integration |
| Direct API | Create direct transaction | subProductType=SUBSCRIBE, subscription.requestType | Initial subscription, renewal, and plan changes all use this endpoint, distinguished by requestType 0 / 1 / 2 | Direct API integration |
Saved payment methods
Let customers save a card for repeat purchases — choosing between customer opt-in and server-side tokenization, the tokenization result webhook, listing and deleting saved tokens, and the parameter differences across integration methods.
Pre-authorization and capture
Hold funds first and capture on fulfillment — scope of pre-authorization, the lifecycle and notifications from authorization to capture or void, boundaries and status handling, and the parameter differences across integration methods.