# notifyPayment

The **notifyPayment** API is used by Alipay+ to notify the payment result to the Acquiring Service Provider (ACQP) after payment processing reaches a final state of success or failure. 

**Note:** In the following sections, Mobile Payment Provider (MPP) is also known as Payment Service Provider. For example, the _pspId_ parameter specifies the ID that identifies an MPP. 

Structure

A message consists of a header and body. The following sections are focused on the body structure. For the header structure, see:

-   [Request header](api_overview#3mLq0)
-   [Response header](api_overview#YdmVS)

**Note:** 

Set the data type of each field (except array) as String. This means that you must use double quotation marks (" ") to enclose the field value. Examples:

-   If the data type of a field is Integer and its value is 20, set it as "20".
-   If the data type of a field is Boolean and its value is `true`, set it as "true".

## Request parameters

#### paymentResult (Result, REQUIRED)

The result of the payment. The value of the _paymentResult.resultStatus_ parameter represents the payment status, where `S` represents success and `F` represents failure. The value of the _paymentResult.resultStatus_ parameter cannot be `U` when this API is called to send the payment result. See the _Payment result codes_ table below for details.

##### resultCode (String, REQUIRED)

The result code that indicates the detailed processing result.

More information:

- Maximum length: 64 characters

##### resultStatus (String, REQUIRED)

The result status that indicates the processing result. Valid values are:

-   `S`: Successful
-   `F`: Failed

##### resultMessage (String)

The result message that describes the result code in detail.

More information:

- Maximum length: 256 characters

#### paymentRequestId (String, REQUIRED)

The unique ID that is assigned by the ACQP to identify a payment order.

More information:

- Maximum length: 64 characters

#### paymentId (String)

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

**Note**: This parameter is specified by Alipay+ if the value of the _paymentResult.resultStatus_ parameter is `S`, which means that the payment succeeds; otherwise, this parameter may or may not be specified.

More information:

- Maximum length: 64 characters

#### acquirerId (String, REQUIRED)

The unique ID that is assigned by Alipay+ to identify an ACQP.

More information:

- Maximum length: 64 characters

#### pspId (String)

The unique ID that is assigned by Alipay+ to identify an MPP. 

**Note**: Specified by Alipay+ if the value of the _paymentResult.resultStatus_ parameter is `S`, which means that the payment succeeds.

More information:

- Maximum length: 64 characters

#### customerId (String)

The unique ID that is assigned by Alipay+ to identify an MPP user.

**Note**: Specified by Alipay+ if the value of the _paymentResult.resultStatus_ parameter is `S` and the MPP provides a unique ID that identifies the user.

More information:

- Maximum length: 64 characters

#### walletBrandName (String)

The brand name of the MPP that is displayed to the customer.

**Note**: Specified by Alipay+ if the value of the _paymentResult.resultStatus_ parameter is `S`, which means that the payment succeeds.

More information:

- Maximum length: 128 characters

#### paymentAmount (Amount, REQUIRED)

The amount that the ACQP requests to receive from Alipay+. The currency of the amount is the same as the one that the ACQP uses to create the payment order.

**Note**: Specified if the value of the _paymentResult.resultStatus_ parameter is `S`, which means that the payment succeeds.

##### currency (String, REQUIRED)

The currency code of the amount. The value of this parameter must be an alphabetic code that follows the [ISO 4217](https://www.iso.org/iso-4217-currency-codes.html) standard, for example, "EUR" for Euros.

More information:

- Maximum length: 3 characters

##### value (Integer, REQUIRED)

The value of the amount as a natural number. By default, the value of this parameter is in the smallest currency unit. For example, if the currency is USD and the amount is $1.00, set the value of this parameter to 100; or if the currency is JPY and the amount is ￥1, set the value of this parameter to 1.

More information:

- Value range: 1 - unlimited

#### paymentTime (Datetime)

The date and time when the payment order reaches a final state.

**Note**: Specified by Alipay+ if the value of the _paymentResult.resultStatus_ parameter is `S`, which means that the payment succeeds.

More information:

- The value follows the [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) standard format. For example, "2019-11-27T12:01:01+08:00".

#### settlementAmount (Amount)

The gross amount that Alipay+ settles to the ACQP. If the settlement currency (specified on the _settlementAmount.currency_ parameter) is the same as the payment currency (specified on the _paymentAmount.currency_ parameter), the settlement amount is the same as the payment amount (specified on the _paymentAmount.value_ parameter); otherwise, the settlement amount is calculated based on the _paymentAmount_ and _settlementQuote_ parameters.

**Note**: Specified by Alipay+ if the value of the _paymentResult.resultStatus_ parameter is `S`, which means that the payment succeeds.

##### currency (String, REQUIRED)

The currency code of the amount. The value of this parameter must be an alphabetic code that follows the [ISO 4217](https://www.iso.org/iso-4217-currency-codes.html) standard, for example, "EUR" for Euros.

More information:

- Maximum length: 3 characters

##### value (Integer, REQUIRED)

The value of the amount as a natural number. By default, the value of this parameter is in the smallest currency unit. For example, if the currency is USD and the amount is $1.00, set the value of this parameter to 100; or if the currency is JPY and the amount is ￥1, set the value of this parameter to 1.

More information:

- Value range: 1 - unlimited

#### settlementQuote (Quote)

The exchange rate between the settlement currency (specified on the _settlementAmount.currency_ parameter) and the payment currency (specified on the _paymentAmount.currency_ parameter).

**Note**: Specified by Alipay+ if the value of the _paymentResult.resultStatus_ parameter is `S` and the settlement currency is different from the payment currency.

##### quoteId (String, REQUIRED)

The unique ID that is assigned by Alipay+ to identify an exchange rate.

More information:

- Maximum length: 64 characters

##### quoteCurrencyPair (String, REQUIRED)

A currency pair, of which the first listed currency (also called base currency) is quoted against the second currency (also called quote currency). The value of this parameter is in the format of `_{ base_currency } / { quote_currency }_`, where `_{ base_currency }_` and `_{ quote_currency }_` are alphabetic codes that follow the [ISO 4217](https://www.iso.org/iso-4217-currency-codes.html) standard. For example, if the base currency is euro and the quote currency is dollar, the value of this parameter is EUR/USD.

More information:

- Maximum length: 8 characters

##### quotePrice (Decimal, REQUIRED)

The quotation of the exchange rate between the currency pair that is specified on the _quoteCurrencyPair_ parameter.

More information:

- Value range: 0 - unlimited

##### quoteStartTime (Datetime)

The time when the quotation (specified on the _quotePrice_ parameter) takes effect.

More information:

- The value follows the [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) standard format. For example, "2019-11-27T12:01:01+08:00".

##### quoteExpiryTime (Datetime)

The time when the quotation (specified on the _quotePrice_ parameter) expires.

More information:

- The value follows the [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) standard format. For example, "2019-11-27T12:01:01+08:00".

##### baseCurrency (String)

The first currency in the currency pair that is specified on the quoteCurrencyPair parameter. The value is an alphabetic code that follows the [ISO 4217](https://www.iso.org/iso-4217-currency-codes.html) standard.

More information:

- Maximum length: 3 characters

##### quoteUnit (String)

The amount in the base currency that is specified on the _baseCurrency_ parameter.

More information:

- Maximum length: 12 characters

#### customsDeclarationAmount (Amount)

The maximum amount that is to be declared by the ACQP to customs. The currency of the amount is the currency used by the MPP's user. For example, if the user uses ALIPAY\_CN to pay, the currency is CNY.

**Note**: Specified by Alipay+ if the value of the _paymentResult.resultStatus_ parameter is `S` and customs declaration is required by the MPP's local authority (for now this only includes the Chinese Mainland).

##### currency (String, REQUIRED)

The currency code of the amount. The value of this parameter must be an alphabetic code that follows the [ISO 4217](https://www.iso.org/iso-4217-currency-codes.html) standard, for example, "EUR" for Euros.

More information:

- Maximum length: 3 characters

##### value (Integer, REQUIRED)

The value of the amount as a natural number. By default, the value of this parameter is in the smallest currency unit. For example, if the currency is USD and the amount is $1.00, set the value of this parameter to 100; or if the currency is JPY and the amount is ￥1, set the value of this parameter to 1.

More information:

- Value range: 1 - unlimited

#### mppPaymentId (String)

The unique ID that is assigned by the MPP to identify a payment order.

This parameter is specified by Alipay+ if the value of the _paymentResult.resultStatus_ parameter is `S`, which means that the payment succeeds.

More information:

- Maximum length: 64 characters

## Response parameters

#### result (Result, REQUIRED)

The result of the business processing, including the result status, result code, and result message. For more information about how to return the result of the **notifyPayment** API, see _How to return the result_.

##### resultCode (String, REQUIRED)

The result code that indicates the detailed processing result.

More information:

- Maximum length: 64 characters

##### resultStatus (String, REQUIRED)

The result status that indicates the processing result. Valid values are:

-   `S`: Successful
-   `F`: Failed
-   `U`: Unknown

##### resultMessage (String)

The result message that describes the result code in detail.

More information:

- Maximum length: 256 characters

## More information

### How to return the result

The MPP needs to return the result (specified on the _result_ parameter) according to the business processing result.

If you received the notification successfully, set the value of _result.resultStatus_ to `S` and return an HTTP status code of `200` to indicate that your server received the call. Otherwise, Alipay+ takes the notification delivery as unsuccessful and retries the notification sending up to 7 times. The intervals between two consecutive times are as follows: 2min, 10min, 10min, 1h, 2h, 6h, and 15h.

## Result/Error codes

| Code | Value | Message | Further action |
| --- | --- | --- | --- |
| SUCCESS | S | Success |  |
| ACCESS_DENIED | F | Access is denied. |  |
| INVALID_CLIENT | F | The client is invalid. |  |
| INVALID_SIGNATURE | F | The signature is invalid. |  |
| KEY_NOT_FOUND | F | The key is not found. |  |
| MEDIA_TYPE_NOT_ACCEPTABLE | F | The server does not implement the media type that is acceptable to the client. |  |
| METHOD_NOT_SUPPORTED | F | The server does not implement the requested HTTPS method. |  |
| NO_INTERFACE_DEF | F | API is not defined. |  |
| PARAM_ILLEGAL | F | Illegal parameters. For example, non-numeric input, invalid date. |  |
| PROCESS_FAIL | F | A general business failure occurred. Do not retry. |  |
| REQUEST_TRAFFIC_EXCEED_LIMIT | U | The request traffic exceeds the limit. |  |
| UNKNOWN_EXCEPTION | U | An API call failed, which is caused by unknown reasons. |  |

## Payment result codes

| Code | Value | Message |
| --- | --- | --- |
| SUCCESS | S | Success |
| BUSINESS_NOT_SUPPORT | F | The payment business is not supported. |
| CURRENCY_NOT_SUPPORT | F | The currency is not supported. |
| EXPIRED_CODE | F | The code is expired. |
| INVALID_CONTRACT | F | The contract is invalid. |
| INVALID_TOKEN | F | The access token is invalid. |
| ORDER_IS_CLOSED | F | The order is closed. |
| PAYMENT_AMOUNT_EXCEED_LIMIT | F | The payment amount exceeds the limit that is specified by Alipay+. |
| PAYMENT_COUNT_EXCEED_LIMIT | F | The number of payments exceeds the limit. |
| PROCESS_FAIL | F | A general business failure occurred. Do not retry. |
| RISK_REJECT | F | The request is rejected because of the risk control. |
| UNAVAILABLE_PAYMENT_METHOD | F | The payment method is unavailable. |
| USER_AMOUNT_EXCEED_LIMIT | F | The payment amount exceeds the payment limit that is specified by the user's digital wallet. |
| USER_BALANCE_NOT_ENOUGH | F | The user balance is not enough for the payment. |
| USER_NOT_EXIST | F | The user does not exist. |
| USER_STATUS_ABNORMAL | F | The user status is abnormal. |

## Request

```json
{
  "acquirerId": "1111088000000000000",
  "pspId": "1022172000000000000",
  "paymentResult": {
    "resultCode": "SUCCESS",
    "resultStatus": "S",
    "resultMessage": "success"
  },
  "paymentRequestId": "pay_1089760038715669_102775745070000",
  "paymentId": "20200101234567890130000",
  "mppPaymentId": "pay_1089760038715670_102775745070001",
  "paymentTime": "2020-01-01T12:01:01+08:30",
  "paymentAmount": {
    "value": "100",
    "currency": "JPY"
  },
  "customerId": "1230000",
  "walletBrandName": "walletName",
  "settlementAmount": {
    "value": "74",
    "currency": "USD"
  },
  "settlementQuote": {
    "quoteCurrencyPair": "USD/JPY",
    "quoteExpiryTime": "2021-06-02T13:15:48+08:00",
    "quoteId": "046793306919858814",
    "quotePrice": "1.35",
    "quoteStartTime": "2021-05-30T13:15:48+08:00"
  }
}
```

## Response

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