﻿# Chargeback Integration

## 1. Configure Webhook URL

You need to log in to the [**Merchant Management Center (MMC)**](https://mmc.payermax.com/#/login) first, then go to **Service Settings** → **Development Configuration** to complete the webhook URL configuration.

## 2. Chargeback Notification

When PayerMax receives a chargeback notification from upstream, it will send a notification to the webhook URL configured by the merchant. Merchants can also proactively query the chargeback status.
  
The case statuses are as follows:

| Status           | Description                                                                                |
| ---------------- | ------------------------------------------------------------------------------------------ |
| DISPUTE_INQUIRY  | Inquiry Pending Response: Awaiting merchant feedback and submission of evidence materials. |
| DISPUTE_RECEIVED | Evidence Materials Received                                                                |
| DISPUTE_END      | Inquiry Completed: The issuing bank reviews the appeal and makes a decision.               |
| CASE_CLOSED      | Case Closed                                                                                |
| CASE_CANCEL      | Case Canceled                                                                              |

[Chargeback Notification/chargeBaclNotifyUrl API](https://docs.payermax.com/api.html?docName=New%20Version&docVer=v1.0&docLang=cn#/paths/chargeBaclNotifyUrl/post) Interface Request Example:

``` json
curl --request POST \
  --url https://pay-gate-uat.payermax.com/chargeBaclNotifyUrl \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'sign: FPFVT3o227JrFRbqu19boZCpVVTF9KznxyRawUmxpfXilHV/0yK46haPhAjNu1hPUMy7Vw/ILXhfzffNm4Fj0apWknlTY9OJxnSoQxS9BTFtc61tn5yV1q69x/kkBl82/qwg+XTJ4fOzy7Mar3VaC1E2PlDA6RkkKBUyNE6RYgsdB+Su7an4+4HVTNAnoe74WyvBgxTLMNg28igBTdqxaO3w/UBY6ObVp7vkqkQGdL1Y+HgmMYaAVwrM3+ALWGId0sJ+YqTY4WJ+0xCRGhaSnybiIjZsQEYyID68WNUfuavDLDsEhaMm/HfQvf5p0R1Ltovp3wwJnEbQcjY458iX5A==' \
  --data '{
  "appId": "6666c8b036a24579974497c2f9a11111",
  "code": "APPLY_SUCCESS",
  "data": {
    "fee": "564.47",
    "channelOrderNo": "TPC25414916781601399492036086",
    "batchId": "",
    "outUserId": "useroutTradeNo1678160134430",
    "tradeCreateTime": "2023-03-07T03:35:33.000Z",
    "caseId": "O20230412074414033194005231",
    "outTradeNo": "outTradeNo1678160134430",
    "currency": "PHP",
    "tradeToken": "T2023081604639602348121",
    "tradeCountry": "PH",
    "expirationDate": "2023-04-12",
    "amount": "20000.00",
    "retrievalDate": "2023-04-12",
    "payFinishTime": "2023-03-07T03:35:48.000Z",
    "caseResult": "WIN",
    "tradeCurrency": "PHP",
    "cardOrg": "",
    "productDesc": "this is subject",
    "targetOrg": "GRABPAY",
    "totalAmount": "20564.47",
    "tradeAmount": "20000.00",
    "paymentMethodType": "WALLET",
    "status": "CASE_CLOSED",
    "reasonCode": "4842",
    "reasonMessage": "Late Presentment",
    "originTradeAmount": "20000.00",
    "originTradeCurrency": "PHP"
  },
  "keyVersion": "1",
  "merchantNo": "020213834542382",
  "msg": "Success.",
  "notifyTime": "2023-10-09T05:52:42.159Z",
  "notifyType": "DISPUTE",
  "version": "1.4"
}'

```

[Dispute Notification/chargeBaclNotifyUrl API](https://docs.payermax.com/api.html?docName=New%20Version&docVer=v1.0&docLang=cn#/paths/chargeBaclNotifyUrl/post) Interface Response Example:

``` json
{
  "code": "SUCCESS",
  "msg": "Success"
}
```

## 3. Dispute Reply

[Dispute Reply/caseReplay API](https://docs.payermax.com/api.html?docName=New%20Version&docVer=v1.0&docLang=cn#/paths/aggregate-pay-api-gateway-caseReplay/post) Interface Request Example:

``` json
curl --request POST \
  --url https://pay-gate-uat.payermax.com/aggregate-pay/api/gateway/caseReplay \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'sign: FPFVT3o227JrFRbqu19boZCpVVTF9KznxyRawUmxpfXilHV/0yK46haPhAjNu1hPUMy7Vw/ILXhfzffNm4Fj0apWknlTY9OJxnSoQxS9BTFtc61tn5yV1q69x/kkBl82/qwg+XTJ4fOzy7Mar3VaC1E2PlDA6RkkKBUyNE6RYgsdB+Su7an4+4HVTNAnoe74WyvBgxTLMNg28igBTdqxaO3w/UBY6ObVp7vkqkQGdL1Y+HgmMYaAVwrM3+ALWGId0sJ+YqTY4WJ+0xCRGhaSnybiIjZsQEYyID68WNUfuavDLDsEhaMm/HfQvf5p0R1Ltovp3wwJnEbQcjY458iX5A==' \
  --data '{
  "version": "1.4",
  "keyVersion": "1",
  "requestTime": "{{requestTime}}",
  "appId": "127d5de5b5124d11b9132c6ec9cc61d3",
  "merchantNo": "010113864671194",
  "spMerchantNo": "",
  "data": {
    "batchId": "",
    "caseId": "O20230608124011368140006803",
    "outUserId": "uft_user_1686228003452",
    "responseContent": "测试文件地址",
    "representmentFile": [
      "https://xxx/img/image/public/imgcopyright_index1.jpg"
    ]
  }
}'
```

[Dispute Reply/caseReplay API](https://docs.payermax.com/api.html?docName=New%20Version&docVer=v1.0&docLang=cn#/paths/aggregate-pay-api-gateway-caseReplay/post) Interface Response Example:

``` json
{
  "data": {
    "successCaseIds": [
      "string"
    ],
    "failCaseIds": [
      "string"
    ]
  },
  "code": "string",
  "msg": "string"
}
```

## 4. Dispute Inquiry

[Dispute Inquiry/caseSearch API](https://docs.payermax.com/api.html?docName=New%20Version&docVer=v1.0&docLang=cn#/paths/aggregate-pay-api-gateway-caseSearch/post) Interface Request Example:

``` json
curl --request POST \
  --url https://pay-gate-uat.payermax.com/aggregate-pay/api/gateway/caseSearch \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'sign: FPFVT3o227JrFRbqu19boZCpVVTF9KznxyRawUmxpfXilHV/0yK46haPhAjNu1hPUMy7Vw/ILXhfzffNm4Fj0apWknlTY9OJxnSoQxS9BTFtc61tn5yV1q69x/kkBl82/qwg+XTJ4fOzy7Mar3VaC1E2PlDA6RkkKBUyNE6RYgsdB+Su7an4+4HVTNAnoe74WyvBgxTLMNg28igBTdqxaO3w/UBY6ObVp7vkqkQGdL1Y+HgmMYaAVwrM3+ALWGId0sJ+YqTY4WJ+0xCRGhaSnybiIjZsQEYyID68WNUfuavDLDsEhaMm/HfQvf5p0R1Ltovp3wwJnEbQcjY458iX5A==' \
  --data '{
  "version": "1.5",
  "keyVersion": "1",
  "requestTime": "2023-04-13T06:31:52.000Z",
  "appId": "54a5e69376734010982c1602c88e00ff",
  "spMerchantNo": "",
  "merchantNo": "SP100860372",
  "data": {
    "caseId": "O20230103065545916437107761"
  }
}'

```

[Dispute Inquiry/caseSearch API](https://docs.payermax.com/api.html?docName=New%20Version&docVer=v1.0&docLang=cn#/paths/aggregate-pay-api-gateway-caseSearch/post) Interface Response Example:

``` json
{
  "msg": "Success.",
  "code": "APPLY_SUCCESS",
  "data": {
    "amount": "5000.00",
    "retrievalDate": "2023-02-13",
    "fee": "5000.00",
    "caseResult": "WIN",
    "batchId": "",
    "outUserId": "10042",
    "tradeCreateTime": "2023-01-03T06:32:52.000Z",
    "totalAmount": "10000.00",
    "caseId": "O20230103065545916437107761",
    "outTradeNo": "dev-RenshTest1672727570986",
    "currency": "IDR",
    "tradeToken": "T2023081604639602348121",
    "status": "DISPUTE_INQUIRY",
    "expirationDate": "2023-02-14",
    "originTradeAmount": "5000.00",
    "originTradeCurrency": "IDR"
  }
}
```
