# notifyPayment (NFC Payment)

`POST /aps/api/v1/payments/notifyPayment`

The **notifyPayment** API allows the Mobile Payment Provider (MPP) to notify the payment result to Alipay+ when 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 (PSP). 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](https://docs.alipayplus.com/alipayplus/alipayplus/api_mpp/api_overview.md#3mLq0)
-   [Response header](https://docs.alipayplus.com/alipayplus/alipayplus/api_mpp/api_overview.md#YdmVS) 

**Note:** 

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

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

2\. For optional parameters that are not required in your case, you can take one of the following actions:

-   Exclude the parameters from the request body.
-   Set the parameter values as null (without the double quotation marks). 

Do NOT leave the optional parameters empty by setting their values as ""; otherwise, an error might occur.

## 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 for more 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 Alipay+ to identify a payment order.

More information:

- This field is an API idempotency field.Alipay+ regards the notifications with the same paymentRequestId as repeated and processes them only once. Alipay+ checks the consistency of the following key request parameters:  paymentAmount, paymentResult, paymentId, payToAmount, and customerId. If any values differ from the previous notification, Alipay+ returns the REPEAT_REQ_INCONSISTENT result code.
- Maximum length: 64 characters

#### paymentId (String)

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

Specify this parameter if the value of the _paymentResult.resultStatus_ parameter is `S`, which means that the payment succeeds.

More information:

- Maximum length: 64 characters

#### paymentAmount (Amount, REQUIRED)

The amount that Alipay+ requests to receive from the MPP. The currency of this amount must be the same as that used by Alipay+ to create the payment order. If a promotion exists, this amount does not include the promotion amount.

Specify this parameter 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 as listed in [the Current Currency & Funds list](https://www.currency-iso.org/en/home/tables/table-a1.html). In the list, the Minor unit column defines the number of decimals, which determines the smallest unit of a currency. For example, if the currency is USD and the amount is $1.00 (2 decimals), set the value of this parameter to 100; or if the currency is JPY and the amount is ￥1 (0 decimal), set the value of this parameter to 1.

More information:

- Value range: 1 - unlimited

#### payToAmount (Amount)

The amount that the MPP settles to Alipay+. The currency of the amount is the MPP's currency.

Specify this parameter if the value of the _paymentResult.resultStatus_ parameter is `S` and _payToAmount.currency_ is different from _paymentAmount.currency_. When this parameter is specified, _payToAmount_._value_ is calculated based on _paymentAmount_._value_ and _paymentQuote_._quotePrice_ by using the rounding mode of HALF EVEN.

##### 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 as listed in [the Current Currency & Funds list](https://www.currency-iso.org/en/home/tables/table-a1.html). In the list, the Minor unit column defines the number of decimals, which determines the smallest unit of a currency. For example, if the currency is USD and the amount is $1.00 (2 decimals), set the value of this parameter to 100; or if the currency is JPY and the amount is ￥1 (0 decimal), 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.

Specify this parameter if the value of the _paymentResult.resultStatus_ parameter is `S`, which means that the payment succeeds.

#### customerId (String)

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

Specify this parameter if the value of the _paymentResult.resultStatus_ parameter is `S`, which means that the payment succeeds.

More information:

- Maximum length: 64 characters

#### passThroughInfo (String)

The information that is passed through by the MPP to Alipay+. The value of this parameter is in a set of key-value pairs. 

Specify this parameter if the MPP wants to pass information to the ACQP.

More information:

- Maximum length: 20000 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 handle the result of **notifyPayment** API, see _How to handle 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

#### acquirerId (String)

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

This parameter is returned by Alipay+ if the value of the _result_._resultCode_ parameter is `SUCCESS`, which means that the notification succeeds.

More information:

- Maximum length: 64 characters

#### pspId (String)

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

This parameter is returned by Alipay+ if the value of the _result_._resultCode_ parameter is `SUCCESS`, which means that the notification succeeds.

More information:

- Maximum length: 64 characters

## More information

### How to handle the result

You might receive different results from Alipay+. Follow the instructions below to handle the result. 

| **result.resultStatus** | **result.resultCode** | **Notification status** | **Actions** |
| --- | --- | --- | --- |
| `S` | `SUCCESS` | Successful | N/A |
| `F` | Multiple possible values exist, such as `ACCESS_DENIED`, `KEY_NOT_FOUND`, etc. | Failed | Take action based on the result code (specified in _result.resultCode_ ). For more information, see the _Result codes_ section below. |
| `U` | Multiple possible values exist, such as `UNKNOWN_EXCEPTION`, `REQUEST_TRAFFIC_EXCEED_LIMIT`, etc. | Unknown | Retry the request. |
| No result received |  | Unknown | Retry the request. |

## Result/Error codes

| Code | Value | Message | Further action |
| --- | --- | --- | --- |
| SUCCESS | S | Success | N/A |
| ACCESS_DENIED | F | Access is denied. | Contact connect_support@service.alipay.com to troubleshoot the issue. |
| INVALID_CLIENT | F | The client is invalid. | Contact connect_support@service.alipay.com to troubleshoot the issue. |
| INVALID_SIGNATURE | F | The signature is invalid. | Check whether the public key, signed message, and signature algorithm are as expected. |
| KEY_NOT_FOUND | F | The key is not found. | Contact connect_support@service.alipay.com to troubleshoot the issue. |
| MEDIA_TYPE_NOT_ACCEPTABLE | F | The server does not implement the media type that is acceptable to the client. | Use a media type that is accepted by Alipay+. |
| METHOD_NOT_SUPPORTED | F | The server does not implement the requested HTTPS method. | Ensure the HTTP method is POST. |
| NO_INTERFACE_DEF | F | API is not defined. | Check whether the request URL is correct. Ensure that the endpoint of the called API is correct. |
| PARAM_ILLEGAL | F | Illegal parameters. For example, non-numeric input, invalid date. | Check that all request parameters, including header and body parameters, are valid. For more information, see the Structure section of the specific API reference topic. |
| PROCESS_FAIL | F | A general business failure occurred. Do not retry. | Contact connect_support@service.alipay.com to troubleshoot the issue. |
| REQUEST_TRAFFIC_EXCEED_LIMIT | U | The request traffic exceeds the limit. | Reduce the frequency of API calls. |
| UNKNOWN_EXCEPTION | U | An API call failed, which is caused by unknown reasons. | Try to recall the API. |

## 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. |
| MERCHANT_NOT_REGISTERED | F | The merchant is not registered. |
| 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. |
| REGULATION_RESTRICTION | F | The payment failed due to regulatory restriction. |
| 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_PAYMENT_VERIFICATION_FAILED | F | User fails to pass the payment verification in the methods like OPT, PIN, and so on. |
| USER_STATUS_ABNORMAL | F | The user status is abnormal. |

## Request

```json
{
  "paymentResult": {
    "resultCode": "SUCCESS",
    "resultStatus": "S",
    "resultMessage": "success"
  },
  "paymentRequestId": "20200101234567890132",
  "paymentId": "202001012345678901322222",
  "paymentTime": "2020-01-01T12:01:01+08:30",
  "paymentAmount": {
    "value": "100",
    "currency": "JPY"
  },
  "payToAmount": {
    "value": "1000",
    "currency": "KRW"
  },
  "customerId": "1234567"
}
```

## Response

```json
{
  "result": {
    "resultCode": "SUCCESS",
    "resultStatus": "S",
    "resultMessage": "success"
  },
  "acquirerId": "1022188000000000001",
  "pspId": "1022172000000000001"
}
```