Alipay, China's leading third-party online payment solutionAlipay, China's leading third-party online payment solutionDOCS

      Payment Cancellation

      Use this interface to cancel a payment if the payment result is not returned for a long time, or to cancel a payment authorization after the authorization is completed.  

      Request parameters

      paymentIdString(64)Optional
      The unique ID that is assigned by Alipay to identify a payment. A one-to-one correspondence between paymentId and paymentRequestId exists.
      paymentRequestIdString(64)Optional
      The unique ID that is assigned by a merchant to identify a payment request. Special characters are not supported. If both paymentRequestId and paymentId are provided, paymentId takes precedence.

      Response parameters

      resultResultRequired

      The request result, which contains information related to the request result, such as status and error codes.

      resultCodeString(16)Required
      Result code
      resultStatusEnumRequired

      Result status. Possible values are:   

      • S: Indicates that the result status is successful. 
      • F: Indicates that the result status is failed. 
      • U: Indicates that the result status is unknown.
      resultMessageString(64)Optional
      Result message
      paymentIdString(64)Optional
      The unique ID that is assigned by Alipay to identify a payment
      paymentRequestIdString(64)Optional
      The unique ID that is assigned by a merchant to identify a payment request. Special characters are not supported.
      cancelTimeDatetimeOptional

      The actual execution completion time of the payment cancellation process, that is, the date and time when the payment cancellation succeeds. The value follows the ISO 8601 standard. This parameter is returned only when the cancellation succeeds.

      More information 

      To cancel the payment, you must provide one of the following parameters:

      • paymentId: The original payment ID of the payment request to be cancelled, generated by Alipay when the merchant initiates the original payment.
      • paymentRequestId: The original paymentRequestId of the payment request to be cancelled.  

      Result process logic

      For different request results, different actions are to be performed. See the following list for details:

      • If the value of result.resultStatus is S, the cancellation succeeds.

      If the value of result.resultStatus is F, the cancellation fails. See the returned error code and determine further actions.

      • If the value of result.resultStatus is U, the cancellation result is unknown. Use the same request parameters to retry the cancellation request.
      • If no response is returned, use the same request parameters to retry the cancellation request. 

      Result/Error codes

      CodeValueMessage
      SUCCESSSSuccess
      CANCEL_WINDOW_EXCEEDFThe cancellation date exceeds the period during which cancellation is supported. The period is agreed in the contract.
      ORDER_NOT_EXISTFThe order doesn't exist.
      PROCESS_FAILFA general business failure occurred. Don't retry.
      PARAM_ILLEGALFIllegal parameters exist. For example, a non-numeric input, or an invalid date.
      KEY_NOT_FOUNDFThe key is not found.
      ACCESS_DENIEDFAccess denied
      REQUEST_TRAFFIC_EXCEED_LIMITUThe request traffic exceeds the limit.
      API_INVALIDFAPI is invalid or not active.
      CLIENT_INVALIDFThe client is invalid.
      SIGNATURE_INVALIDFThe signature is invalid.
      METHOD_NOT_SUPPORTEDFThe server does not implement the requested HTTP method.
      MEDIA_TYPE_NOT_ACCEPTABLEFThe server does not implement the media type that is acceptable to the client.
      UNKNOWN_EXCEPTIONUAn API calling is failed, which is caused by unknown reasons.
      Request/Response Code

      Request

      Method

      POST

      Endpoint

      v1/payments/cancel

      Header

      Accept: application/json

      URL

      Domain name

      Request Body
      Request parameters
      Response Body
      Body content