# Cancel Subscription
The merchant business system initiates a cancellation of the user subscription relationship via the Cancel Subscription API.
# API Description
API
Request API: /api/subscription/cancel
Request Method: POST
Request Type: application/json or application/x-www-form-urlencoded
# Request Parameters
| Field Name | Variable Name | Required | Type | Example Value | Description |
|---|---|---|---|---|---|
| Merchant No | mchNo | Yes | String(30) | M1621873433953 | Merchant Number |
| App ID | appId | Yes | String(24) | 60cc09bce4b0f1c0b83761c9 | App ID |
| Subscription ID | subscriptionId | Yes | String(32) | SUB_20210618164232 | Subscription ID |
| Request Time | reqTime | Yes | long | 1622016572190 | Request timestamp (13 digits) |
| API Version | version | Yes | String(3) | 1.0 | API version, fixed: 1.0 |
| Sign | sign | Yes | String(32) | C380BEC2BFD727A4B6845133519F3AD6 | Signature value, see signature algorithm |
| Sign Type | signType | Yes | String(32) | MD5 | Signature type, currently only supports MD5 |
# Request Example Data
{
"mchNo": "M1623984572",
"appId": "60cc09bce4b0f1c0b83761c9",
"subscriptionId": "SUB_20210618164232",
"reqTime": "1622016572190",
"version": "1.0",
"signType": "MD5",
"sign": "84F606FA25A6EC4783BECC08D4FDC681"
}
# Response Parameters
| Field Name | Variable Name | Required | Type | Example Value | Description |
|---|---|---|---|---|---|
| Return State | code | Yes | int | 0 | 0-Success, others-Error, see error codes |
| Return Msg | msg | No | String(128) | Signature failed | Specific error reason |
| Sign Info | sign | No | String(32) | CCD9083A6DAD9A2DA9F668C3D4517A84 | Signature for data |
| Return Data | data | No | Object | {} | Returned subscription data |
# Data Format (SubscriptionRS)
| Field Name | Variable Name | Type | Example Value | Description |
|---|---|---|---|---|
| Subscription ID | subscriptionId | String | SUB_20210618001 | Payment system subscription ID |
| Merchant No | mchNo | String | M1621873433953 | Merchant Number |
| App ID | appId | String | 60cc09bce4b0f1c0b83761c9 | App ID |
| Plan ID | planId | String | PLAN_001 | Subscription Plan ID |
| Plan Code | planCode | String | VIP_MONTH | Subscription Plan Code |
| Subscription cycle | cycleIndex | integer | 1 | Subscription cycle |
| Merchant Order No | mchOrderNo | String | sub1624005107281 | Merchant passed order number |
| State | state | Byte | 3 | 0-Init, 1-Pending, 2-Active, 3-Paused, 4-Overdue, 5-Canceled, 6-Completed, 7-Invalid |
| Cancel At Period End | cancelAtPeriodEnd | Boolean | true | Whether to cancel at the end of the period |
| Currency | currency | String | USD | Currency |
| Is Active | isActive | Boolean | false | Whether currently valid based on state and time |
# Response Example Data
{
"code": 0,
"msg": "SUCCESS",
"data": {
"subscriptionId": "SUB_20210618001",
"mchOrderNo": "sub1624005107281",
"state": 3,
"cancelAtPeriodEnd": true,
"isActive": false
},
"sign": "F4DA202C516D1F33A12F1E547C5004FD"
}