Onerway
POST

Cancel subscription contract

Use this endpoint to cancel an existing subscription contract by contractId and choose when the cancellation takes effect.

Request

ApiKey
API key for the merchant account. Send it in the ApiKey request header. See Authentication.
Example:
merchantNo
Merchant number assigned by Onerway. See Setup for how to obtain it.
Example:
contractId
Subscription contract number to cancel. It normally comes from the initial subscription response, webhook, or Query subscription details.
Example:
expireMode
Cancellation timing for Onerway-managed subscriptions (selfExecute=1). When both expireMode and expireDate are omitted, cancellation is scheduled for the end of the current billing cycle. Merchant-managed subscriptions (selfExecute=2) are canceled immediately.
Example:
Allowed values
1
Cancel immediately and send a subscription cancellation notification. Customer emails for Onerway-managed subscriptions depend on the configured email address and email settings.
2
Cancel at the end of the current billing cycle.
3
Cancel on a specified date. Submit expireDate; the cancellation notification is sent when the cancellation takes effect.
Constraints
Rule
For Onerway-managed subscriptions, modes 2 and 3 require an existing contract expiration time. Mode 2 uses the end of the current billing cycle, or the existing expiration time if earlier; the cycle end must not be earlier than the current time.
Rule
Scheduled cancellation does not send a cancellation notification when the request is accepted. The subscription cancellation webhook is sent when cancellation takes effect. Payments already initiated are handled according to their own results.
expireDate
Condition: Required when expireMode=3, cancel on a specified date.
Date when cancellation takes effect, in yyyy-MM-dd format.
Example:
Constraints
Rule
For an Onerway-managed subscription in mode 3, the date must not be later than the next billing date or the existing contract expiration date. Onerway combines this date with the time of day of the billing-cycle start anchor; the resulting time must not be earlier than the current server time.

Request example

curl -X POST 'https://sandbox-payment-api.onerway.com/v1/txn/sub/cancel' \
  -H 'ApiKey: replace_with_api_key' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "merchantNo": "replace_with_merchant_no",
  "contractId": "example_subscription_contract",
  "expireMode": "1"
}'

Response

respCode
20000 means the cancellation request was processed successfully. Other values are error codes. See Response codes.
respMsg
Human-readable message for the response code.
data
Fixed to 3 when the cancellation request is processed successfully. This response does not confirm that a scheduled cancellation has taken effect. Use subscriptionStatus from Query subscription details or the subscription cancellation webhook to determine whether cancellation has taken effect.

Response example

{
  "respCode": "20000",
  "respMsg": "Success",
  "data": "3"
}
No error responses are documented for this endpoint.