Onerway
Scenarios

Subscription payments

Choosing between managed and self-managed subscriptions, contract credentials and lifecycle notifications, renewals and plan changes, and the parameter differences across integration methods.

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. When notificationEmail is configured, Onerway emails the customer subscription confirmations and billing notices, and the customer can self-manage the subscription through the subscriptionManageUrl returned 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 the contractId and tokenId returned by the initial subscription; only frequencyType=D is supported, but that does not limit you to daily billing: the subscription.frequencyPoint field states the billing cycle in days (for example, you can submit 30 for a monthly subscription or 365 for an annual subscription). This value is informational only; you determine when to initiate renewal charges. Whether you make the first charge depends on subscription.mode — under the default 2, 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 contractId and tokenId from 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 when status=S. Use these credentials for subscription charges, queries, and cancellation. When subscription.mode=1, they are also needed to initiate the first charge; see Local payment method subscriptions. This tokenId is 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 scenarios field and the subscriptionStatus field of the subscription payment webhook. Effective cancellation is reported separately through the subscription cancellation webhook.
  • Self-managed renewal: your server submits the stored contractId and tokenId in subscription and sets the amount for this cycle in orderAmount, 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 with scenarios=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 contractId and tokenId (requestType=2); when the change takes effect is controlled by subscription.changeMode. A successful update produces a webhook with scenarios=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 in proration (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-side contractId and tokenId. The two notifications carry different transactionId values 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 cycleRetry interval
Daily1 hour
Every 2–3 days12 hours
Longer than 3 days24 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 methodEndpointKey parametersDifferencesIntegration guide
CheckoutCreate checkout paymentsubProductType=SUBSCRIBE, subscription (requestType=0)Initial subscription only; a top-level merchantCustId, if submitted, must match subscription.merchantCustIdCheckout integration
Web SDKCreate SDK transactionsubProductType=SUBSCRIBE, subscription (requestType=0)Initial subscription only; keep the allowed plan mapping on your serverWeb SDK integration
Direct APICreate direct transactionsubProductType=SUBSCRIBE, subscription.requestTypeInitial subscription, renewal, and plan changes all use this endpoint, distinguished by requestType 0 / 1 / 2Direct API integration