> ## Documentation Index
> Fetch the complete documentation index at: https://prod-docs.123hub.pro/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Describe only the public 123hub merchant API documented on this site. The primary endpoint is POST /public/api/multihub/v1.
> Preserve API method names, field names, header names, and error codes exactly as documented. Do not invent endpoints or parameters.
> Treat every amount as an integer in minor units unless a page explicitly states otherwise.
> Never expose, request, or fabricate a merchant secret key. The SDK pages contain reference implementations, not official SDK packages.

# Testing Guide

> Test your integration before going live

# Testing Guide

Use this guide to validate request signing, payment creation, status polling, balances, webhooks, and error handling before production traffic.

## Test vs Production Mode

> [!NOTE]
>
> Test and production use the **same API endpoint** (`POST /public/api/multihub/v1`). The environment is determined by your credentials and the service routes assigned during onboarding. Your 123hub account manager will confirm which test credentials and low-value routes are available for your account.

| Credential Set | Environment | Behavior |
| - | - | - |
| Test `application_id` + `secret_key` | Test | Account-specific integration routes confirmed during onboarding |
| Production `application_id` + `secret_key` | Production | Real transactions, actual money movement |

## Getting Test Credentials

Test credentials are provided by the 123hub team during onboarding. You will receive:

* **application\_id** — an integer identifying your test application
* **secret\_key** — a private key used to sign requests in test mode

**1. Request credentials**

Contact your 123hub account manager or [support@123hub.pro](mailto:support@123hub.pro) to request test credentials.

**2. Verify connectivity**

Use the `gateway.ping` method to confirm your credentials work.

> [!NOTE]
>
> Contact [support@123hub.pro](mailto:support@123hub.pro) if you need test credentials.

## Test Credential Behavior

### Payments

* Payments are created and go through normal status transitions
* Route behavior depends on the account and `service_id` configuration confirmed during onboarding
* Webhooks are delivered normally
* All API responses mirror production behavior

### Balance

* `balance.get` returns the balances configured for the credential environment
* Confirm available currencies and balance funding with your account manager before withdrawal tests
* Balance changes follow the same response format as production

### Webhooks

* Webhooks are delivered to your configured endpoints
* Use webhook testing to verify your integration
* Same signature verification as production

## Payment Scenarios

### Successful Deposit

Create a deposit payment using `payment.in` -- it starts as `created` or `processing` and then reaches a final status:

```bash cURL theme={null}
BODY='{"method":"payment.in","service_id":14701,"params":{"payment":{"description":"Test deposit order","identifiers":{"c_id":"99001"},"amount":{"value":10000,"currency":"INR"},"payer":{"email":"test@example.com","phone":"9876543210","person":{"first_name":"Test","last_name":"Customer"}},"client":{"language":"EN","country":"IN"}}}}'
HASH=$(printf '%s%s' "$BODY" "YOUR_SECRET_KEY" | sha512sum | awk '{print $1}')
TIMESTAMP=$(date +%s)
NONCE=$(uuidgen | tr '[:upper:]' '[:lower:]')

curl -X POST "https://api.bafanglaicai88.com/public/api/multihub/v1" \
  -H "Content-Type: application/json" \
  -H "X-Data-Application-Id: 1" \
  -H "X-Data-Hash: ${HASH}" \
  -H "X-Data-Timestamp: ${TIMESTAMP}" \
  -H "X-Data-Nonce: ${NONCE}" \
  --data-binary "${BODY}"
```

```python Python theme={null}
import requests
import hashlib
import json
import time
import uuid

APPLICATION_ID = 1
SECRET_KEY = "your_test_secret_key"
URL = "https://api.bafanglaicai88.com/public/api/multihub/v1"

payload = {
    "method": "payment.in",
    "service_id": 14701,
    "params": {
        "payment": {
            "description": "Test deposit order",
            "identifiers": {"c_id": "99001"},
            "amount": {"value": 10000, "currency": "INR"},
            "payer": {
                "email": "test@example.com",
                "phone": "9876543210",
                "person": {"first_name": "Test", "last_name": "Customer"}
            },
            "client": {"language": "EN", "country": "IN"}
        }
    }
}

body = json.dumps(payload, separators=(",", ":"))
signature = hashlib.sha512((body + SECRET_KEY).encode()).hexdigest()

headers = {
    "Content-Type": "application/json",
    "X-Data-Application-Id": str(APPLICATION_ID),
    "X-Data-Hash": signature,
    "X-Data-Timestamp": str(int(time.time())),
    "X-Data-Nonce": str(uuid.uuid4())
}

response = requests.post(URL, data=body, headers=headers, timeout=(3.05, 30))
print(response.json())
```

```javascript Node.js theme={null}
const crypto = require('crypto');
const axios = require('axios');

const APPLICATION_ID = 1;
const SECRET_KEY = 'your_test_secret_key';
const URL = 'https://api.bafanglaicai88.com/public/api/multihub/v1';

const payload = {
  method: 'payment.in',
  service_id: 14701,
  params: {
    payment: {
      description: 'Test deposit order',
      identifiers: { c_id: '99001' },
      amount: { value: 10000, currency: 'INR' },
      payer: {
        email: 'test@example.com',
        phone: '9876543210',
        person: { first_name: 'Test', last_name: 'Customer' }
      },
      client: { language: 'EN', country: 'IN' }
    }
  }
};

const body = JSON.stringify(payload);
const signature = crypto.createHash('sha512').update(body + SECRET_KEY).digest('hex');
const timestamp = Math.floor(Date.now() / 1000).toString();
const nonce = crypto.randomUUID();

const response = await axios.post(URL, body, {
  headers: {
    'Content-Type': 'application/json',
    'X-Data-Application-Id': String(APPLICATION_ID),
    'X-Data-Hash': signature,
    'X-Data-Timestamp': timestamp,
    'X-Data-Nonce': nonce
  },
  timeout: 30000
});

console.log(response.data);
```

For the request and response of a specific market, use its [country page](https://prod-docs.123hub.pro/countries/overview.md).

### Successful Withdrawal

Create a withdrawal payment using `payment.out` (requires sufficient available balance on the configured route):

```bash cURL theme={null}
BODY='{"method":"payment.out","service_id":14701,"params":{"payment":{"description":"Test payout","identifiers":{"c_id":"99002"},"amount":{"value":5000,"currency":"INR"},"receiver":{"bank":{"account":{"id":"123456789012"},"ifsc":"SBIN0001234"},"email":"payouts@example.com","person":{"first_name":"Juan","last_name":"Perez"}},"client":{"language":"EN","country":"IN"}}}}'
HASH=$(printf '%s%s' "$BODY" "YOUR_SECRET_KEY" | sha512sum | awk '{print $1}')
TIMESTAMP=$(date +%s)
NONCE=$(uuidgen | tr '[:upper:]' '[:lower:]')

curl -X POST "https://api.bafanglaicai88.com/public/api/multihub/v1" \
  -H "Content-Type: application/json" \
  -H "X-Data-Application-Id: 1" \
  -H "X-Data-Hash: ${HASH}" \
  -H "X-Data-Timestamp: ${TIMESTAMP}" \
  -H "X-Data-Nonce: ${NONCE}" \
  --data-binary "${BODY}"
```

```python Python theme={null}
import requests
import hashlib
import json
import time
import uuid

APPLICATION_ID = 1
SECRET_KEY = "your_test_secret_key"
URL = "https://api.bafanglaicai88.com/public/api/multihub/v1"

payload = {
    "method": "payment.out",
    "service_id": 14701,
    "params": {
        "payment": {
            "description": "Test payout",
            "identifiers": {"c_id": "99002"},
            "amount": {"value": 5000, "currency": "INR"},
            "receiver": {
                "bank": {
                    "account": {"id": "123456789012"},
                    "ifsc": "SBIN0001234"
                },
                "email": "payouts@example.com",
                "person": {"first_name": "Juan", "last_name": "Perez"}
            },
            "client": {"language": "EN", "country": "IN"}
        }
    }
}

body = json.dumps(payload, separators=(",", ":"))
signature = hashlib.sha512((body + SECRET_KEY).encode()).hexdigest()

headers = {
    "Content-Type": "application/json",
    "X-Data-Application-Id": str(APPLICATION_ID),
    "X-Data-Hash": signature,
    "X-Data-Timestamp": str(int(time.time())),
    "X-Data-Nonce": str(uuid.uuid4())
}

response = requests.post(URL, data=body, headers=headers, timeout=(3.05, 30))
print(response.json())
```

```javascript Node.js theme={null}
const crypto = require('crypto');
const axios = require('axios');

const APPLICATION_ID = 1;
const SECRET_KEY = 'your_test_secret_key';
const URL = 'https://api.bafanglaicai88.com/public/api/multihub/v1';

const payload = {
  method: 'payment.out',
  service_id: 14701,
  params: {
    payment: {
      description: 'Test payout',
      identifiers: { c_id: '99002' },
      amount: { value: 5000, currency: 'INR' },
      receiver: {
        bank: {
          account: { id: '123456789012' },
          ifsc: 'SBIN0001234'
        },
        email: 'payouts@example.com',
        person: { first_name: 'Juan', last_name: 'Perez' }
      },
      client: { language: 'EN', country: 'IN' }
    }
  }
};

const body = JSON.stringify(payload);
const signature = crypto.createHash('sha512').update(body + SECRET_KEY).digest('hex');
const timestamp = Math.floor(Date.now() / 1000).toString();
const nonce = crypto.randomUUID();

const response = await axios.post(URL, body, {
  headers: {
    'Content-Type': 'application/json',
    'X-Data-Application-Id': String(APPLICATION_ID),
    'X-Data-Hash': signature,
    'X-Data-Timestamp': timestamp,
    'X-Data-Nonce': nonce
  },
  timeout: 30000
});

console.log(response.data);
```

### Check Payment Status

Query the status of a payment using `payment.status`:

```bash theme={null}
BODY='{"method":"payment.status","params":{"payment":{"identifiers":{"h_id":"1001"}}}}'
HASH=$(printf '%s%s' "$BODY" "YOUR_SECRET_KEY" | sha512sum | awk '{print $1}')
TIMESTAMP=$(date +%s)
NONCE=$(uuidgen | tr '[:upper:]' '[:lower:]')

curl -X POST "https://api.bafanglaicai88.com/public/api/multihub/v1" \
  -H "Content-Type: application/json" \
  -H "X-Data-Application-Id: 1" \
  -H "X-Data-Hash: ${HASH}" \
  -H "X-Data-Timestamp: ${TIMESTAMP}" \
  -H "X-Data-Nonce: ${NONCE}" \
  --data-binary "${BODY}"
```

### Error Response Example

Errors are returned with `success: false` and usually HTTP 400 (see [Error Codes](https://prod-docs.123hub.pro/errors/error-codes.md) for the codes that use `403`, `404`, `409`, `429` or `5xx`). Always check the `success` field. Here is an example of an invalid signature error:

```json theme={null}
{
  "success": false,
  "error": {
    "code": 3000,
    "message": "Authentication error",
    "details": null,
    "context": null
  },
  "request_id": "f6a7b8c9-d0e1-2345-abcd-456789012345",
  "processing_time": 3
}
```

## Testing Webhooks

### Local Development

For local development, use a tunneling service like [ngrok](https://ngrok.com) to expose your local server:

```bash theme={null}
# Start ngrok
ngrok http 3000

# Use the ngrok URL for your webhook endpoint
# https://abc123.ngrok.io/webhooks/123hub
```

## Before Going Live

Work through the [Go-live checklist](https://prod-docs.123hub.pro/go-live.md) with your test credentials before you request
production access.

## Error Code Reference

| Code | Description |
| - | - |
| 1000 | Common error (HTTP 500); also returned with HTTP 429 when a rate limit is hit |
| 1002 | Payment method not available for your account (HTTP 404) |
| 1005 | Invalid request format (missing required field) |
| 2002 | No available route for the `service_id` (HTTP 503) |
| 3000 | Authentication error (invalid signature) |
| 3003 | Application not found |
| 6001 | Incorrect transaction amount |
| 6002 | Incorrect currency code |
| 6004 | Insufficient funds |
| 6005 | Monthly limit exceeded |
| 6006 | Daily limit exceeded |
| 6009 | Payment already exists (duplicate `c_id`) |
| 6010 | Payment does not exist |
| 6035 | Exceeded payments |
| 7001 | Provider interaction error |
| 8600 | Invalid bank credentials |
| 8801 | Invalid status transition |
| 9000 | Validation error (unknown fields, wrong types, amount outside route limits) |

## Common Testing Mistakes

> [card] Using Production Credentials in Dev
>
> Always use test `application_id` and `secret_key` in development

> [card] Skipping Signature Verification
>
> Always verify webhook signatures, even in test mode

> [card] Not Testing Errors
>
> Test error scenarios, not just happy paths. Verify your code checks the `success` field in every response.

> [card] Hardcoding Credentials
>
> Use environment variables for `application_id` and `secret_key`

## Need Help?

> [card] [Developer Support](mailto:support@123hub.pro)
>
> Contact our team if you have questions about testing


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.