# Notifications

> Learn about how to integrate notification APIs provided by Antom.

Learn about how to integrate notification APIs provided by Antom.

# Features

The supported products and description of these notifications are shown in the following table:

| **Notification** **API** | **One-time Payments** | **Tokenized Payment** | **EasySafePay** | **Scan to Link** | **User-presented Mode Payment** | **Order Code Payment** | **Entry Code Payment** | **Description** |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| [**notifyAuthorization**](https://docs.antom.com/ac/ams/notifyauth.md) | ❌ | ✔️ | ✔️ | ✔️ | ❌ | ❌ | ❌ | Sends the authorization result to you when the authorization succeeds or when the authorization cancellation succeeds. The parameter _authorizationNotifyType_ indicates the type of the authorization notification. - `AUTHCODE_CREATED`: indicates a successful authorization. - `TOKEN_CANCELED`: indicates a canceled authorization. |
| [**notifyPayment**](https://docs.antom.com/ac/ams/paymentrn_online.md) | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | Sends the payment result to you when the payment processing reaches a final state of success or failure. The parameter _result.resultStatus_ indicates the payment result. - `S`: indicates the payment is successful when _notifyType_ is `PAYMENT_RESULT`; indicates the payment is being processed when _notifyType_ is `PAYMENT_PENDING`. - `F`: indicates the payment is failed. |
| [**notifyCapture**](https://docs.antom.com/ac/ams/notify_capture.md) | ✔️ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | Sends the capture result to you when the capture processing reaches a final state of success or failure. The parameter _result.resultStatus_ indicates the capture result. - `S`: indicates a successful capture. - `F`: indicates a failed capture. |
| [**notifyDispute**](https://docs.antom.com/ac/ams/notify_dispute.md) | ✔️ | ✔️ | ✔️ | ✔️ | ❌ | ❌ | ❌ | Sends the dispute information to you. The parameter _disputeNotificationType_ indicates the type of the dispute notification. - `DISPUTE_CREATED`: indicates a created dispute. - `DISPUTE_JUDGED`: indicates a judged dispute. |
| [**notifyRefund**](https://docs.antom.com/ac/ams/notify_refund.md) | ✔️ | ✔️ | ✔️ | ✔️ | ❌ | ❌ | ❌ | Sends the refund result to you when the refund processing reaches a final state of success or failure. The parameter _refundstatus_ indicates the refund result. - `S`: indicates a successful refund. - `F`: indicates a failed refund. |

Table 1. Capabilities of notifications

# Configure receiving address

You can configure the receiving address of each notification via an API or in Antom Dashboard. If you use both ways to specify the address, the URL configured in the API takes precedence.

| **Notification** **API** | **Configure in API** | **Configure in Antom Dashboard** |
| --- | --- | --- |
| [**notifyAuthorization**](https://docs.antom.com/ac/ams/notifyauth.md) | N/A | Go to **Developer** > **Notification URL** of Antom Dashboard to [configure the receiving address](https://docs.antom.com/ac/merchant_service/notification.md). |
| [**notifyPayment**](https://docs.antom.com/ac/ams/paymentrn_online.md) | Specify the _paymentNotifyUrl_ field in the [**pay (Tokenized Payment)**](https://docs.antom.com/ac/ams/payment_agreement.md) API. | Go to **Developer** > **Notification URL** of Antom Dashboard to [configure the receiving address](https://docs.antom.com/ac/merchant_service/notification.md). |
| [**notifyCapture**](https://docs.antom.com/ac/ams/notify_capture.md) | Specify the _paymentNotifyUrl_ field in the [**pay (One-time Payments)**](https://docs.antom.com/ac/ams/payment_cashier.md) API. | Go to **Developer** > **Notification URL** of Antom Dashboard to [configure the receiving address](https://docs.antom.com/ac/merchant_service/notification.md). |
| [**notifyDispute**](https://docs.antom.com/ac/ams/notify_dispute.md) | N/A | Go to **Developer** > **Notification URL** of Antom Dashboard to [configure the receiving address](https://docs.antom.com/ac/merchant_service/notification.md). |
| [**notifyRefund**](https://docs.antom.com/ac/ams/notify_refund.md) | Specify the _refundNotifyUrl_ field in the [**refund**](https://docs.antom.com/ac/ams/refund_online.md) API. | Go to **Developer** > **Notification URL** of Antom Dashboard to [configure the receiving address](https://docs.antom.com/ac/merchant_service/notification.md). |

Table 2. Receiving address configuration

# Process the notification

## 1\. Verify the signature

The result notification from Antom is signed by Antom. It is recommended to verify the signature and check whether the notification is sent by Antom. You can verify the signature by yourself or by using Antom SDK.

To verify the signature by yourself, see [Sign a request and validate the signature](https://docs.antom.com/ac/ams/digital_signature.md#x6Le8). To use Antom SDK, specify the values for the corresponding parameters in the `SignatureTool.verify` method provided in [SDKs](https://global.alipay.com/docs/ac/sdks/server_sdks):

```json
boolean isSuccess = SignatureTool.verify(httpMethod, path, clientId, rspTimeStr, rspBody, signature, alipayPublicKey);
```

The value of _signature_ is from the notification header. The following example shows a notification header:

```json
"Content-Type": "application/json", "Request-Time": "2019-07-12T12:08:56+05:30", "client-id": "T_111222333", "Signature": "algorithm=RSA256,keyVersion=1,signature=jTOHqknjk%2fnDjEn8lfg%2beNODdoh2eHGJV%2blvrKaDwP782WxJ7ro49giqUu23MUM8sFVVNvhg32qHS3sd4O6uf5kAVLqztqNOPJFZcjw141EVi1vrs%2bIB4vU0%2fK%2f8z2GyWUByh2lHOWFsp%2b5QKCclXp%2bjacYqWYUur5IVbuebR1LoD5IiJ7u7J9qYriFxodkxmIAJYJyJs7mks2FWHh2YePLj3K%2f4B65idy7RBKqY1NN1XcvqnbQmlfCH8CIv75bg%2fr9sGmPE5a%2bYgL8N9Q41buGwMSq1IcNsbceMbyPhw5Z5HnJ7tPz12fvdSi0cEicPikDthQ2EQFmtpntXcAc%2fHA%3d%3d"
```

## 2\. Return a receipt acknowledgment message

After verifying the signature and confirming that the notification is from Antom, you need to return a receipt acknowledgment message to Antom to inform Antom of a successful receipt of the notification. **No digital signature is required for the process of returning a receipt acknowledgment message.**

The example below shows the header of the message you send to Antom:

```json
"Content-Type": "application/json", "response-time": "2019-07-12T12:08:56+05:30", "client-id": "T_111222333",
```

The example below shows the body of the message you send to Antom:

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

If no such message is returned to Antom due to operation or network issues, Antom will automatically resend the asynchronous notification within 24 hours for up to seven times or until the correct response is received. The sending intervals are as follows: 0 s, 2 min, 10 min, 10 min, 1 h, 2 h, 6 h, and 15 h.

> **Note**: Record the processed notifications received from Antom for a payment request, and properly handle the idempotency to avoid processing a single request multiple times.

> **Common questions**
>
> **Q: Why I cannot receive the asynchronous notifications sometimes?**
>
> A: It might occur that the buyer completes the payment but you cannot receive the payment result. The possible reasons are:
>
> -   When the payment is complete, the Antom server sends an asynchronous notification to inform the merchant of the corresponding payment result. However, for some wallets, asynchronous notifications will not be sent when the payment fails.
> -   The asynchronous notification does not have a 100% delivery guarantee.
>
> When this happens, you can call the [**inquiryPayment**](https://docs.antom.com/ac/ams/paymentri_online.md) API to get the accurate payment result.