# Error Handling

When you encounter an error while calling the PayKKa API，there are two possible cases:

1. Non-`200` HTTP Code is returned


> This is a standard PayKKa response. We recommend checking the request based on the returned `ret_code` and `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 is returned，but the response body contains additional business error details


> For example，in a transaction request，although the request itself was successful，a business error is returned with the parameters `error_code` and `error_description`.
We recommend handling business errors appropriately to ensure a smooth experience for your customers.
Note: The business parameters may vary for different APIs.


```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": "GW206194332333335",
        "status": "FAILURE",
        "amount": 322,
        "currency": "HKD"
    }
}
```

## Response Format

| Parameter Name  | Description | Type  | Required  |
|  --- | --- | --- | --- |
| `ret_code` | Response error code | String | ✅ |
| `ret_msg` | Response error message | String | ✅ |
| `data` | Response business data，may be empty if the business fails | Object | ❌ |


## Error Enums (ret_code)

| Code | Description |
|  --- | --- |
| `000000` | Request successful |
| `999999` | System exception |
| `010000` | Invalid request，parameter error |


Transaction error codes see [Transaction Error Codes](/payments/docs/developer-resources/transaction-error-code) for more details.