# notifyAuthorization

> Antom uses this API to send the authorization result to the merchant when the authorization succeeds or when the authorization cancellation succeeds.

Antom uses this API to send the authorization result to the merchant when the authorization succeeds or when the authorization cancellation succeeds.

# 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

#### authorizationNotifyType (String, REQUIRED)

Authorization notification type. Valid values are:

-   `AUTHCODE_CREATED` (for Auto Debit only): Indicates that the user agrees to authorize an Auto Debit. After the user agrees to authorize, the wallet-generated authorization code can be obtained from this notification and be used in the [**applyToken**](https://docs.antom.com/ac/ams/accesstokenapp.md) API to obtain the access token.
-   `TOKEN_CREATED` (for Auto Debit and EasySafePay): Indicates that the user initiated authorization for an Auto Debit or EasySafePay payment on the merchant's client successfully. 
-   `TOKEN_CANCELED`: Indicates that the authorization cancellation initiated from the merchant or payment method client succeeded.

More information:

- Maximum length: 32 characters

#### authClientId (String)

The unique ID of the secondary merchant to which the user grants resource access permission. The value is specified by the acquirer and needs to be registered in Antom.

> **Note**: This field is returned when the [**consult**](https://docs.antom.com/ac/ams/authconsult.md) API is initiated by the digital wallet and the value of this field is the same as the value of _referenceMerchantId_ in the [**pay (One-time Payments)**](https://docs.antom.com/ac/ams/payment_cashier.md) API.

More information:

- Maximum length: 64 characters

#### accessToken (String)

The access token that is used to access the corresponding scope of the user resource.

> Note: This field is returned when the value of _authorizationNotifyType_ is `TOKEN_CANCELED` or `TOKEN_CREATED`.

More information:

- Maximum length: 128 characters

#### authState (String)

A string that is generated by the acquirer to represent the consult request. The value of this field is to be used for validating whether being consistent with the value of _authState_ specified in the [**consult**](https://docs.antom.com/ac/ams/authconsult.md) request.

> Note: This field is returned when _authorizationNotifyType_ is `AUTHCODE_CREATED` and `TOKEN_CREATED`.

More information:

- Maximum length: 256 characters

#### authCode (String)

The authorization code, used for getting an access token. This value is obtained by the application from the reconstructed redirection URL returned by the wallet after the user is redirected to the reconstructed redirection URL.

> Note: This field is returned when _authorizationNotifyType_ is `AUTHCODE_CREATED`.

More information:

- Maximum length: 128 characters

#### reason (String)

The reason why the authorization is canceled. This field is sent to the merchant when the user provides the reason for authorization cancellation.

> Note: This field is returned when _authorizationNotifyType_ is `TOKEN_CANCELED`.

More information:

- Maximum length: 256 characters

#### result (Result, REQUIRED)

The authorization result. Antom returns the authorization notification only when the authorization succeeds or the authorization cancellation succeeds. Therefore, only the result of a successful authorization is provided.

##### resultCode (String, REQUIRED)

Result code. The valid value is:

-   `SUCCESS`: Indicates that the authorization or authorization cancellation succeeds.

More information:

- Maximum length: 64 characters

##### resultStatus (String, REQUIRED)

Result status. The valid value is:

-   `S`: Indicates that the authorization or authorization cancellation succeeds.

##### resultMessage (String, REQUIRED)

Result message. The valid value is:

-   `S`: Indicates that the authorization or authorization cancellation succeeds.

More information:

- Maximum length: 256 characters

#### userLoginId (String)

The login ID that the user used to register in the wallet. The login ID can be the user's email address or phone number.

Specify this parameter to remove the need for manual entry of the login ID by users.

More information:

- Maximum length: 64 characters

#### userId (String)

The ID assigned by the payment method provider to identify a user.

More information:

- Maximum length: 64 characters

#### passThroughInfo (PassThroughInfo)

The passthrough information that is transmitted between payment providers and merchants. The value of this parameter is in the set of key-value pairs.

More information:

- Maximum length: 2048 characters

##### accountDisplayName (String)

Bank account's last 4 digits for payment method display.

> **Note**: This parameter is returned when the value of _paymentMethodType_ is `ACH_DIRECT_DEBIT`.

More information:

- Maximum length: 64 characters

##### bankName (String)

Bank name.

> **Note**: This parameter is returned when the value of _paymentMethodType_ is `ACH_DIRECT_DEBIT`.

More information:

- Maximum length: 64 characters

##### paymentProviderIconUrl (String)

The icon URL of the payment provider (i.e., bank logo).

> **Note**: This parameter is returned when the value of _paymentMethodType_ is `ACH_DIRECT_DEBIT`.

More information:

- Maximum length: 128 characters

##### accountToken (String)

A unique token that identifies the user's account for the ACH Direct Debit payment provider. It is passed through to the merchant for idempotency check on the _accessToken_.

> **Note**: This parameter is returned when the value of _paymentMethodType_ is `ACH_DIRECT_DEBIT`.

More information:

- Maximum length: 64 characters

## Response parameters

#### result (Result, REQUIRED)

A fixed value that you need to send to Antom to acknowledge that the notification is received.

##### resultCode (String, REQUIRED)

Result code. The value is fixed as `SUCCESS`.

More information:

- Maximum length: 64 characters

##### resultStatus (String, REQUIRED)

Result status. The value is fixed as `S`.

##### resultMessage (String, REQUIRED)

Result message. 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.

## Request

### AUTHCODE_CREATED

```json
{
  "authorizationNotifyType": "AUTHCODE_CREATED",
  "authState": "489767958497",
  "authCode": "28100113_1631148338197000019ba74",
  "result": {
    "resultCode": "SUCCESS",
    "resultMessage": "success",
    "resultStatus": "S"
  }
}
```

### TOKEN_CANCELED

```json
{
  "authorizationNotifyType": "TOKEN_CANCELED",
  "accessToken": "28100103_20215703001538122119",
  "result": {
    "resultCode": "SUCCESS",
    "resultMessage": "success",
    "resultStatus": "S"
  }
}
```

### TOKEN_CREATED

```json
{
  "accessToken": "2810123456789012345678901234567890",
  "authState": "AUTHSTATE_SAMPLE_1234567890",
  "authorizationNotifyType": "TOKEN_CREATED",
  "userLoginId": "852-52***184",
  "result": {
    "resultCode": "SUCCESS",
    "resultMessage": "success.",
    "resultStatus": "S"
  }
}
```

## Response

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