# 异常处理

当您调用PayKKa API时出现错误，可能有如下两种情况，

1. 返回非 `200` HTTP Code


> 这是标准的PayKKa响应，建议您根据对应的`ret_code`，`ret_msg`对请求内容进行检查


```json
{
    "ret_code": "010000",
    "ret_msg": "Invalid request"
}

{
    "ret_code": "1004",
    "ret_msg": "Merchant does not support this payment method"
}
```

1. 返回 `200` HTTP Code，并且响应体中包含更多业务异常详情


> 下面是以交易为例，该请求成功，但是返回了业务异常，并且业务异常以`error_code`，`error_description`为参数返回;
建议您对业务异常做一定处理以便给客户提供流畅的系统体验
注意: 不同处理API的业务参数并不完全一致


```json
{
    "ret_code": "000000",
    "ret_msg": "Success",
    "data": {
        "error_code": "2099",
        "error_description": "Invalid Card",
        "merchant_id": "YOUR_MERCHANT_ID",
        "trans_id": "T4329476032",
        "order_id": "GW_order_id",
        "status": "FAILURE",
        "amount": 322,
        "currency": "HKD"
    }
}
```

## 响应格式

| 参数名  | 含义描述 | 类型  | 必填  |
|  --- | --- | --- | --- |
| `ret_code` | 响应错误码 | String | ✅ |
| `ret_msg` | 响应错误消息 | String | ✅ |
| `data` | 响应业务数据，业务失败可能为空 | Object | ❌ |


## 错误枚举(ret_code)

| 枚举 | 含义 |
|  --- | --- |
| 000000 | 请求成功 |
| 999999 | 系统异常 |
| 010000 | 无效的请求，参数错误 |


交易错误码见[交易错误码](/zh-hans/payments/docs/developer-resources/transaction-error-code)