POST
Cancel subscription contract
Use this endpoint to cancel an existing subscription contract by
contractId and choose when the cancellation takes effect.Request
merchantNoMerchant number assigned by Onerway. See Setup for how to obtain it.
Example:
replace_with_merchant_nocontractIdSubscription contract number to cancel. It normally comes from the initial subscription response, webhook, or Query subscription details.
Example:
sub_contract_demo_202606210001expireModeCancellation 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:
1Allowed 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
2and3require an existing contract expiration time. Mode2uses 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.
expireDateCondition: Required when
Date when cancellation takes effect, in expireMode=3, cancel on a specified date.yyyy-MM-dd format.Example:
2099-12-15Constraints
- 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.
signRequest signature string. See Request signing for how to generate it.
curl -X POST 'https://sandbox-acq.onerway.com/v1/txn/sub/cancel' \
-H 'Content-Type: application/json' \
--data-raw '{
"merchantNo": "replace_with_merchant_no",
"contractId": "example_subscription_contract",
"expireMode": "1",
"sign": "replace_with_signature"
}'Response
respCode20000 means the cancellation request was processed successfully. Other values are error codes. See Response codes.respMsgHuman-readable message for the response code.
dataFixed 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.{
"respCode": "20000",
"respMsg": "Success",
"data": "3"
}No error responses are documented for this endpoint.