Overviewβ
Cancel Payment is used to cancel a payment that has not yet been completed. When a payment is in a cancellable status, merchants can call this API to actively terminate the payment process. Once the cancellation is successful, the payment will no longer be processed.
Note
- The Cancel Payment feature must be enabled by Oceanpayment Technical Support before it can be used.
- Cancel Payment is only applicable to payments that have not yet been completed. For payments that have already been successfully completed, please use the Refund feature instead.
Use Casesβ
- Customer Cancels an Order: The customer cancels the order during the payment process, such as by returning to the merchant's website and choosing to cancel the order.
- Order Has Expired: The payment remains incomplete after the order's payment validity period has expired. The merchant can call the Cancel Payment API to terminate the payment.
- Multiple Payment Attempts for the Same Order: The same merchant order may have multiple payment records due to repeated clicks, payment retries, or other reasons. Once one payment attempt is successfully completed, the merchant can cancel any remaining incomplete payment attempts based on its business logic.
- Merchant Terminates the Payment: The merchant may proactively cancel an incomplete payment when the order can no longer be paid due to reasons such as insufficient inventory, product unavailability, an abnormal order status, or other business requirements.
Payment Statusβ
Cancel Payment is generally applicable to payments that have not yet been completed.
| Payment Status | Cancel Payment Support |
|---|---|
| Successful | β |
| Pending (Non-Pre-Authorization) | β |
| Failed | β |
Flow Chartβ
Cancel Paymentβ
Merchants can specify the payment order to be cancelled using the order_number and payment_id parameters.
curl -X POST '/gateway/service/auth'
-H 'Content-Type: application/x-www-form-urlencoded'
-d 'account=995149'
-d 'terminal=99514901'
-d 'signValue=6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b'
-d 'order_number=123456789'
-d 'payment_id=240528151145313026060'
-d 'payment_authType=4'
- Resquest
| Parameter | Type | Length | Required | Description |
|---|---|---|---|---|
order_number | string | 1-50 | Required | Merchantβs order ID |
payment_id | string | 1-50 | Required | Oceanpayment payment ID |
payment_authType | int | 1 | Required | Cancel payment
|
Responseβ
<?xml version="1.0" encoding="utf-8"?>
<respon>
<account>995149</account>
<terminal>99514901</terminal>
<signValue>A75EBFFC5CF11EBBF752373115FD1CC1FF4472ACB338EF1E6F303594C656C3D0</signValue>
<order_number/>
<payment_id>240528151145313026060</payment_id>
<payment_status>1</payment_status>
<payment_details>80103:Order closed successfully</payment_details>
</respon>
Operation Resultβ
| Parameter | Description |
|---|---|
payment_status | Operation result
|
payment_details | Result details
|
- View the complete list of authorization operation response parameters β
Cancel Payment Processing Rulesβ
- Preliminary Validation:
payment_authType = 4and the Cancel Payment feature is enabled. - Production Transaction Exists for the
payment_id:
| Transaction Type | Current Payment Status | Processing Logic | payment_status (Operation Result) | payment_details |
|---|---|---|---|---|
| Non-Pre-Authorization | Pending | Close the order directly | 1 | 80103:Order closed successfully |
| Non-Pre-Authorization | Failed | No cancellation action is performed | 0 | 40014:Cannot cancel the unsuccessful order |
| Non-Pre-Authorization | Successful | No cancellation action is performed | 0 | 40014:Cannot cancel the unsuccessful order |
| Pre-Authorization | Pending | No cancellation action is performed | 0 | 40014:Cannot cancel the unsuccessful order |
| Blocked Transaction | Failed | Close the order directly | 1 | 50009:Order closed successfully |