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

      Payment Result Notification

      Alipay uses this interface to send the payment result to the merchant when the payment processing reaches a final state of success or failure. Merchants promote merchant-side transactions based on the payment result.


      #Sample

      In the following example, an e-wallet user buys an 80 EUR item on a merchant website. Alipay sends the payment result to the merchant. The use of Payment Result Notification interface consists of the following steps:


      1. Alipay sends the payment result notification request to the merchant.

      The following example shows a successful payment result.

      copy
      {
          "notifyType": "PAYMENT_RESULT",
          "result": {
              "resultCode": "SUCCESS",
              "resultStatus": "S",
              "resultMessage": "success"
          },
          "paymentRequestId": "20200101234567890444",
          "paymentId": "20200101234567890132",
          "paymentAmount": {
              "value": "8000",
              "currency": "EUR"
          },
          "actualPaymentAmount": {
              "value": "8000",
              "currency": "EUR"
          },
          "paymentCreateTime": "2020-01-01T12:01:00+08:30",
          "paymentTime": "2020-01-01T12:01:01+08:30"
      }


      The following example shows a failed payment result.

      copy
      {
       "notifyType":"PAYMENT_RESULT",
       "result": {
          "resultCode":"USER_BALANCE_NOT_ENOUGH",
          "resultStatus":"F",
          "resultMessage":"user balance not enough"
       },
       "paymentRequestId":"20200101234567890444", 
       "paymentId":"20200101234567890132"
      }


      2. Merchant processes the payment notification and returns the processing result to Alipay. 

      By returning the following result to Alipay, the merchant indicates that the payment notification is successfully recepted by the merchant.

      copy
      {
       "result": {
          "resultCode":"SUCCESS",
          "resultStatus":"S",
          "resultMessage":"success"
       }


      #Structure

      #Request parameters

      No.

      Field

      Description

      1

      notifyType

      MANDATORY PaymentNotifyType

      Payment notification type. Valid values are:

      • PAYMENT_RESULT: indicates that the nofication is a payment result.
      • OFFLINE_PAYMENT_CODE: indicates that the nofication is an offline payment code.

      2

      result

      MANDATORY Result

      The payment result

      3

      paymentRequestId

      MANDATORY String (64)

      The unique ID that is assigned by a merchant to identify a payment request. Special characters are not supported.

      4

      paymentId

      OPTIONAL String (64)

      The unique ID that is assigned by Alipay to identify a payment. 

      A one-to-one correspondence between paymentId and paymentRequestId exists.

      5

      paymentAmount

      MANDATORY Amount

      The payment amount that the merchant requests to receive in the order currency.

      6

      paymentCreateTime

      OPTIONAL Datetime

      The date and time when the payment is created, which follows the ISO 8601 standard.

      7

      paymentTime

      OPTIONAL Datetime

      The date and time when the payment reaches a final state of success or failure, which follows the ISO 8601 standard.

      8

      pspCustomerInfo

      OPTIONAL PspCustomerInfo

      Information about the customer of payment service provider (PSP).


      #Response parameters

      No.

      Field

      Description

      1

      result

      MANDATORY Result

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


      #More information

      This section provides additional information about certain parameters. See the following parameters for details:

      • result (in the notification request sent by Alipay): 

      Payment result. If the value of result.resultStatus is S, then the payment succeeds. If the value is F, the payment fails. The value of result.resultStatus will not be for the payment result notification.

      • paymentTime: 

      This field is returned only when the value of result.resultStatus is S.

      • paymentActionForm: 

      In the in-store payment scenario, paymentCode is passed in through this field, and merchants can display the code to the customer.


      #Result

      #Result process logic

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

      For the result parameter in the response:

      • If the value of result.resultStatus is S, the payment result notification succeeds. Alipay doesn't take any further actions.
      • If the value of result.resultStatus is F, the payment result notification fails. Alipay monitors such results and might intervene if needed.
      • If the value of result.resultStatus is U, the notification request might have failed due to system or network reasons. Alipay will retry. The retry lasts for 24 hours and the retry interval increases during the retry span, such as 5s, 30s, 1m, 5m, and so on. 


      #Result code

      This section helps you identify and resolve problems. See the following table for details: 

      No.resultCoderesultStatusresultMessage

      1

      SUCCESS

      S

      Success

      2

      UNKNOWN_EXCEPTION

      U

      An API calling is failed, which is caused by unknown reasons.