# notifyRefund

> Antom uses this API to send the refund result to the merchant when the refund processing reaches a final state of success or failure. Merchants promote merchant-side transactions based on the refund result.

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

# 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.antom.com/ac/ams/api_fund.md#ML5ur)
-   [Response header](https://docs.antom.com/ac/ams/api_fund.md#WWH90)

> **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

#### notifyType (String, REQUIRED)

The type of the refund status notification. The valid value is:

-   `REFUND_RESULT`: Indicates that the notification is about the refund result.

#### result (Result, REQUIRED)

The details about the refund result, such as refund status, result code, and result message.

##### resultCode (String, REQUIRED)

Result code. Possible values are listed in the Result/Error codes table on this page.

More information:

- Maximum length: 64 characters

##### resultStatus (String, REQUIRED)

Refund status. Valid values are:

-   `S`: Indicates that the refund has been accepted successfully by the channel.
-   `F`: Indicates that the refund failed.

##### resultMessage (String, REQUIRED)

Result message that explains the result code.

More information:

- Maximum length: 256 characters

#### refundStatus (String, REQUIRED)

Indicates the refund result. Valid values are:

-   `SUCCESS`: Indicates that the refund succeeded. 
-   `FAIL`: Indicates that the refund failed.

#### refundRequestId (String, REQUIRED)

The unique ID assigned by a merchant to identify a refund request.

More information:

- Maximum length: 64 characters

#### refundId (String, REQUIRED)

The unique ID that is assigned by Antom to identify a refund. A one-to-one correspondence between _paymentId_ and _paymentRequestId_ exists.

More information:

- Maximum length: 64 characters

#### refundAmount (Amount, REQUIRED)

The refund amount that is initiated by the merchant.

##### currency (String, REQUIRED)

The currency used for the corresponding payment of the refund. The value is a 3-letter currency code that follows the [ISO 4217](https://www.iso.org/iso-4217-currency-codes.html) standard.

More information:

- Maximum length: 3 characters

##### value (Integer, REQUIRED)

The amount to charge as a positive integer in the smallest currency unit. (That is, 100 cents to charge $1.00, or 100 to charge JPY ¥100, a 0-decimal currency).

Notes: For details about the smallest currency unit, see [Smallest unit of the currency](https://global.alipay.com/docs/ac/ref/cc#ONkIe).

More information:

- Value range: 0 - unlimited

#### refundTime (Datetime)

The date and time when the refund reaches a final state of success or failure.

> Note: This field is returned when the refund succeeds (the value of _result.resultStatus_ is `S`).

#### grossSettlementAmount (Amount)

The refund settlement amount, which equals the refund amount multiplied by the value of _settlementQuote_. This field is returned when the currency exchange is predetermined and the exchange rate is locked at the time of the transaction.

##### currency (String, REQUIRED)

The acquiring currency that is specified in the contract. A 3-letter currency code that follows the [ISO 4217](https://www.iso.org/iso-4217-currency-codes.html) standard.

More information:

- Maximum length: 3 characters

##### value (Integer, REQUIRED)

The amount to charge as a positive integer in the smallest currency unit. (That is, 100 cents to charge $1.00, or 100 to charge JPY 100, a zero-decimal currency).

Note: For details about the smallest currency unit, see [Smallest unit of the currency](https://global.alipay.com/docs/ac/ref/cc#ONkIe).

More information:

- Value range: 0 - unlimited

#### settlementQuote (Quote)

The exchange rate between the settlement currency and transaction currency. This field is returned when _grossSettlementAmount_ is returned.

##### guaranteed (Boolean)

Guaranteed exchange rate available for payment.

##### quoteCurrencyPair (String, REQUIRED)

The exchange rate between settlement currency and transaction currency. Two currencies are separated with a slash and use the three-letter [ISO-4217](https://www.iso.org/iso-4217-currency-codes.html) currency code.

More information:

- Maximum length: 16 characters

##### quoteExpiryTime (Datetime)

Expiration time of the exchange rate.

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".

##### quoteId (String)

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

More information:

- Maximum length: 64 characters

##### quotePrice (Decimal, REQUIRED)

The exchange rate used when a currency conversion between settlement currency and transaction currency occurs.

More information:

- Value range: 0 - unlimited

##### quoteStartTime (Datetime)

Effective time of the exchange rate.

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".

#### arn (String)

Acquirer reference number. If the payment method used includes an aquirer reference number, this field will have a value.

More information:

- Value range: [0, +∞)

#### metadata (String)

Your metadata provided during the refund process.

> This parameter is returned when you provided value to the parameter in the [**refund**](https://docs.antom.com/ac/ams/refund_online.md) API.

More information:

- Maximum length: 2048 characters

## Response parameters

#### result (Result, REQUIRED)

A fixed value, which is sent to Antom to acknowledge that the notification is received.

##### resultCode (String, REQUIRED)

The value is fixed as `SUCCESS`.

More information:

- Maximum length: 64 characters

##### resultStatus (String, REQUIRED)

The value is fixed as `S`.

##### resultMessage (String, REQUIRED)

The value is fixed as `success`.

More information:

- Maximum length: 256 characters

## Result process logic

Send the following message with fixed values to Antom after receiving the notification, to acknowledge that the notification from Antom is received:

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

If no such message is returned to Antom due to operation issues or network issues, Antom will intermittently send the notification until the required message is returned by the merchant. Resending of the notification will be performed within 24 hours after the first notification is sent. The notification will be resent up to eight times, with an interval of 0s, 2min, 10min, 10min, 1h, 2h, 6h, and 15h.

> **Note**: In the sandbox environment, if you do not return information in the specified format, Antom will not resend asynchronous notifications to you.

## Result/Error codes

| Code | Value | Message | Further action |
| --- | --- | --- | --- |
| SUCCESS | S | Success | The refund is successful, no further action is needed. |
| ACCESS_DENIED | F | Access is denied. | Contact Antom Technical Support for detailed reasons. |
| CLIENT_INVALID | F | The client ID is invalid. Antom has restrictions on client ID. | Check whether the client ID is correct, or contact Antom Technical Support for detailed reasons. |
| CURRENCY_NOT_SUPPORT | F | The currency is not supported. | Contact Antom Technical Support for detailed reasons. |
| INVALID_API | F | The called API is invalid or not active. | Contact Antom Technical Support to resolve the issue. |
| INVALID_CONTRACT | F | The parameter values in the contract do not match those in the current transaction. | Check whether the parameter values in the contract match those in the current transaction. If the values match, contact Antom Technical Support to troubleshoot the issue. |
| INVALID_MERCHANT_STATUS | F | The merchant status is abnormal because restrictions exist. | Contact Antom Technical Support for detailed reasons. |
| INVALID_SIGNATURE | F | The signature is not validated. The private key used to sign a request does not match the public key of Antom Dashboard. | Check whether the private key used to sign a request matches the public key of Antom Dashboard. The following signature references are useful:The signature field in a request header How to calculate a signature |
| KEY_NOT_FOUND | F | The private key or public key of Antom or the merchant is not found. | Check whether the private key or public key exists. If not, upload the private key in Antom Dashboard. |
| MEDIA_TYPE_NOT_ACCEPTABLE | F | The server does not implement the media type that is acceptable to the client. | Check whether the media type is correct and use a media type that is accepted by Antom. |
| MERCHANT_BALANCE_NOT_ENOUGH | F | The merchant balance is insufficient. | Call the interface again after the merchant has sufficient balance. The refundRequestId field needs to be changed when you try again. |
| MERCHANT_NOT_REGISTERED | F | The merchant is not registered. | Please register the merchant by using the registration interface. Contact Antom Technical Support if failed to call the registration interface. |
| METHOD_NOT_SUPPORTED | F | The server does not implement the requested HTTP method. Only the POST method is supported. | Ensure the HTTP method is POST. |
| MULTIPLE_REFUNDS_NOT_SUPPORTED | F | Multiple refunds are not supported because restrictions exist in the contract. | Check whether multiple refunds exist. Do not call the refund interface anymore. For each refund, only call the interface once. |
| NO_INTERFACE_DEF | F | API is not defined. | Check whether the URL is correct. Please refer to the endpoint in the API documentation. |
| ORDER_IS_CLOSED | F | The transaction is closed and cannot be paid again.  | Use a new paymentRequestId to initiate the refund again. |
| ORDER_NOT_EXIST | F | The order does not exist. | Check whether paymentId is correct. If correct, contact Antom Technical Support for specific reasons. |
| ORDER_STATUS_INVALID | F | The order status is invalid. The transaction is under process or the transaction failed. | Check the order status and take corresponding actions. Wait if the transaction is under process. Do not initiate the refund if the transaction failed. Contact Antom Technical Support for specific reasons. |
| PARAM_ILLEGAL | F | The required parameters are not passed, or illegal parameters exist. For example, a non-numeric input, an invalid date, or the length and type of the parameter are wrong. | Check and verify whether the required request fields (including the header fields and body fields) of the current API are correctly passed and valid. |
| PROCESS_FAIL | F | A general business failure occurred. | Do not retry. Human intervention is usually needed. It is recommended that you contact Antom Technical Support to troubleshoot the issue. |
| REFUND_AMOUNT_EXCEED | F | The total refund amount exceeds the payment amount or the refund amount is less than the minimum refund amount. | Confirm whether the total refund amount exceeds the payment amount or if the refund amount is below the minimum refund amount. Create a new refund using an amount that is less than or equal to the payment amount and greater than or equal to the minimum refund amount, or contact Antom technical support. |
| REFUND_WINDOW_EXCEED | F | The refund date exceeds the refundable period that is agreed in the contract. | Confirm whether the refund date exceeds the refundable period. Check the refundable period in the contract or contact Antom Technical Support for the specific refundable period. |
| REPEAT_REQ_INCONSISTENT | F | The amount or currency is different from the previous request. | Ensure all the fields in the requests are the same or use a new paymentRequestId to initiate the refund again. |
| RISK_REJECT | F | The request is rejected because of the risk control. | Prompt the user that the request is rejected because the risk control failed. |
| SYSTEM_ERROR | F | A system error occurred. | Do not retry, and contact Antom Technical Support for more details. |
| USER_IDENTITY_FROZEN_BY_CHANNEL | F | The user's account has been frozen by the payment method. |  |

## Request

```json
{
  "notifyType": "REFUND_RESULT",
  "arn": "1234567890987654321",
  "refundAmount": {
    "currency": "KRW",
    "value": "151815"
  },
  "refundId": "20240611194010801300188950208960208",
  "refundRequestId": "GN240611526496235533",
  "refundStatus": "SUCCESS",
  "refundTime": "2024-06-11T02:26:06-07:00",
  "result": {
    "resultCode": "SUCCESS",
    "resultMessage": "success.",
    "resultStatus": "S"
  }
}
```

## Response

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