Skip to main content

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​

  1. 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.
  2. 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.
  3. 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.
  4. 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 StatusCancel 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'
ParameterTypeLengthRequiredDescription
order_numberstring1-50RequiredMerchant’s order ID
payment_idstring1-50RequiredOceanpayment payment ID
payment_authTypeint1RequiredCancel payment
  • 4

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​

ParameterDescription
payment_statusOperation result
  • 1: Success
  • 0: Failed
payment_detailsResult details
  • Code:Description

Cancel Payment Processing Rules​

  1. Preliminary Validation: payment_authType = 4 and the Cancel Payment feature is enabled.
  2. Production Transaction Exists for the payment_id:
Transaction TypeCurrent Payment StatusProcessing Logicpayment_status (Operation Result)payment_details
Non-Pre-AuthorizationPendingClose the order directly180103:Order closed successfully
Non-Pre-AuthorizationFailedNo cancellation action is performed040014:Cannot cancel the unsuccessful order
Non-Pre-AuthorizationSuccessfulNo cancellation action is performed040014:Cannot cancel the unsuccessful order
Pre-AuthorizationPendingNo cancellation action is performed040014:Cannot cancel the unsuccessful order
Blocked TransactionFailedClose the order directly150009:Order closed successfully