> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bafanglaicai88.com/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.

# Quick Start

> Create your first payment in under 5 minutes

# Quick Start

This guide will help you create your first payment using the 123hub 123hub API.

## Step 1: Get Your Credentials

<Steps>
  <Step title="Obtain your credentials">
    Credentials are provided by the 123hub team during merchant onboarding. You will receive:

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

    Contact your account manager or reach out to [support@123hub.pro](mailto:support@123hub.pro) to request access.
  </Step>

  <Step title="Understand request signing">
    Every request must include two authentication headers; the replay pair is optional:

    * `X-Data-Application-Id` — your integer application ID
    * `X-Data-Hash` — SHA-512 hash of the raw JSON request body concatenated with your secret key: `sha512(requestBody + secretKey)`
    * `X-Data-Timestamp` — optional current Unix timestamp in seconds
    * `X-Data-Nonce` — optional unique nonce for this request; send it together with the timestamp
  </Step>
</Steps>

<Info>
  Merchant accounts and credentials are created by the 123hub team. Self-registration is not available.
</Info>

## Step 2: Test Connectivity

Verify your credentials work by calling `gateway.ping`:

<CodeGroup>
  ```bash cURL theme={null}
  BODY='{"method":"gateway.ping","params":{}}'
  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_secret_key_here"
  URL = "https://api.bafanglaicai88.com/public/api/multihub/v1"

  payload = {
      "method": "gateway.ping",
      "params": {}
  }

  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_secret_key_here';
  const URL = 'https://api.bafanglaicai88.com/public/api/multihub/v1';

  const payload = {
    method: 'gateway.ping',
    params: {}
  };

  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);
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "success": true,
  "result": {
    "message": "pong"
  },
  "request_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "processing_time": 5
}
```

## Step 3: Create a Deposit

Create a deposit payment (customer pays to you) using the `payment.in` method.

<Info>
  The `service_id` value is assigned per merchant during onboarding. It determines the provider, payment method, and currency for the payment. Use the value provided by your account manager. The examples below use placeholder `service_id` values for illustration.
</Info>

<Tabs>
  <Tab title="INR (India)">
    <CodeGroup>
      ```bash cURL theme={null}
      BODY='{"method":"payment.in","service_id":14701,"params":{"payment":{"description":"Order #12345","identifiers":{"c_id":"12345"},"amount":{"value":10000,"currency":"INR"},"payer":{"email":"customer@example.com","phone":"9876543210","person":{"first_name":"John","last_name":"Doe"}},"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_secret_key_here"
      URL = "https://api.bafanglaicai88.com/public/api/multihub/v1"

      payload = {
          "method": "payment.in",
          "service_id": 14701,
          "params": {
              "payment": {
                  "description": "Order #12345",
                  "identifiers": {"c_id": "12345"},
                  "amount": {"value": 10000, "currency": "INR"},
                  "payer": {
                      "email": "customer@example.com",
                      "phone": "9876543210",
                      "person": {"first_name": "John", "last_name": "Doe"}
                  },
                  "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_secret_key_here';
      const URL = 'https://api.bafanglaicai88.com/public/api/multihub/v1';

      const payload = {
        method: 'payment.in',
        service_id: 14701,
        params: {
          payment: {
            description: 'Order #12345',
            identifiers: { c_id: '12345' },
            amount: { value: 10000, currency: 'INR' },
            payer: {
              email: 'customer@example.com',
              phone: '9876543210',
              person: { first_name: 'John', last_name: 'Doe' }
            },
            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);
      ```
    </CodeGroup>
  </Tab>

  <Tab title="MXN (Mexico)">
    <CodeGroup>
      ```bash cURL theme={null}
      BODY='{"method":"payment.in","service_id":14801,"params":{"payment":{"description":"Order #12345","identifiers":{"c_id":"12345"},"amount":{"value":5000,"currency":"MXN"},"payer":{"email":"cliente@example.com","phone":"5551234567","person":{"first_name":"Juan","last_name":"Perez"}},"client":{"language":"ES","country":"MX"}}}}'
      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_secret_key_here"
      URL = "https://api.bafanglaicai88.com/public/api/multihub/v1"

      payload = {
          "method": "payment.in",
          "service_id": 14801,
          "params": {
              "payment": {
                  "description": "Order #12345",
                  "identifiers": {"c_id": "12345"},
                  "amount": {"value": 5000, "currency": "MXN"},
                  "payer": {
                      "email": "cliente@example.com",
                      "phone": "5551234567",
                      "person": {"first_name": "Juan", "last_name": "Perez"}
                  },
                  "client": {"language": "ES", "country": "MX"}
              }
          }
      }

      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_secret_key_here';
      const URL = 'https://api.bafanglaicai88.com/public/api/multihub/v1';

      const payload = {
        method: 'payment.in',
        service_id: 14801,
        params: {
          payment: {
            description: 'Order #12345',
            identifiers: { c_id: '12345' },
            amount: { value: 5000, currency: 'MXN' },
            payer: {
              email: 'cliente@example.com',
              phone: '5551234567',
              person: { first_name: 'Juan', last_name: 'Perez' }
            },
            client: { language: 'ES', country: 'MX' }
          }
        }
      };

      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);
      ```
    </CodeGroup>
  </Tab>

  <Tab title="ARS (Argentina)">
    <CodeGroup>
      ```bash cURL theme={null}
      BODY='{"method":"payment.in","service_id":14901,"params":{"payment":{"description":"Order #12345","identifiers":{"c_id":"12345"},"amount":{"value":100000,"currency":"ARS"},"payer":{"email":"cliente@example.com","phone":"1155551234","person":{"first_name":"Juan","last_name":"Perez"}},"client":{"language":"ES","country":"AR"}}}}'
      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_secret_key_here"
      URL = "https://api.bafanglaicai88.com/public/api/multihub/v1"

      payload = {
          "method": "payment.in",
          "service_id": 14901,
          "params": {
              "payment": {
                  "description": "Order #12345",
                  "identifiers": {"c_id": "12345"},
                  "amount": {"value": 100000, "currency": "ARS"},
                  "payer": {
                      "email": "cliente@example.com",
                      "phone": "1155551234",
                      "person": {"first_name": "Juan", "last_name": "Perez"}
                  },
                  "client": {"language": "ES", "country": "AR"}
              }
          }
      }

      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_secret_key_here';
      const URL = 'https://api.bafanglaicai88.com/public/api/multihub/v1';

      const payload = {
        method: 'payment.in',
        service_id: 14901,
        params: {
          payment: {
            description: 'Order #12345',
            identifiers: { c_id: '12345' },
            amount: { value: 100000, currency: 'ARS' },
            payer: {
              email: 'cliente@example.com',
              phone: '1155551234',
              person: { first_name: 'Juan', last_name: 'Perez' }
            },
            client: { language: 'ES', country: 'AR' }
          }
        }
      };

      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);
      ```
    </CodeGroup>
  </Tab>

  <Tab title="TRY (Turkey)">
    <CodeGroup>
      ```bash cURL theme={null}
      BODY='{"method":"payment.in","service_id":15001,"params":{"payment":{"description":"Order #12345","identifiers":{"c_id":"12345"},"amount":{"value":50000,"currency":"TRY"},"payer":{"email":"musteri@example.com","phone":"5321234567","person":{"first_name":"Mehmet","last_name":"Yilmaz"}},"client":{"language":"EN","country":"TR"}}}}'
      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_secret_key_here"
      URL = "https://api.bafanglaicai88.com/public/api/multihub/v1"

      payload = {
          "method": "payment.in",
          "service_id": 15001,
          "params": {
              "payment": {
                  "description": "Order #12345",
                  "identifiers": {"c_id": "12345"},
                  "amount": {"value": 50000, "currency": "TRY"},
                  "payer": {
                      "email": "musteri@example.com",
                      "phone": "5321234567",
                      "person": {"first_name": "Mehmet", "last_name": "Yilmaz"}
                  },
                  "client": {"language": "EN", "country": "TR"}
              }
          }
      }

      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_secret_key_here';
      const URL = 'https://api.bafanglaicai88.com/public/api/multihub/v1';

      const payload = {
        method: 'payment.in',
        service_id: 15001,
        params: {
          payment: {
            description: 'Order #12345',
            identifiers: { c_id: '12345' },
            amount: { value: 50000, currency: 'TRY' },
            payer: {
              email: 'musteri@example.com',
              phone: '5321234567',
              person: { first_name: 'Mehmet', last_name: 'Yilmaz' }
            },
            client: { language: 'EN', country: 'TR' }
          }
        }
      };

      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);
      ```
    </CodeGroup>

    <Note>
      Turkey (TRY) deposit methods: `havale` (bank transfer), `papara` (e-wallet), and `kredikarti` (credit/debit card). Withdrawals use `bank_transfer` with IBAN.
    </Note>
  </Tab>
</Tabs>

### Response

<Tabs>
  <Tab title="INR Response">
    ```json theme={null}
    {
      "success": true,
      "result": {
        "payment": {
          "amount": { "value": 10000, "currency": "INR" },
          "description": "Order #12345",
          "identifiers": { "c_id": "12345", "h_id": "1001", "p_id": "txn_abc123" },
          "status": { "status": "created", "final": false, "success": null },
          "timestamps": { "created": "2026-01-15T10:30:00Z" },
          "destination": "in",
          "service_id": 14701
        }
      },
      "request_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "processing_time": 125
    }
    ```
  </Tab>

  <Tab title="MXN Response">
    ```json theme={null}
    {
      "success": true,
      "result": {
        "payment": {
          "amount": { "value": 5000, "currency": "MXN" },
          "description": "Order #12345",
          "identifiers": { "c_id": "12345", "h_id": "1002", "p_id": "txn_def456" },
          "status": { "status": "created", "final": false, "success": null },
          "timestamps": { "created": "2026-01-15T10:31:00Z" },
          "destination": "in",
          "service_id": 14801
        }
      },
      "request_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "processing_time": 130
    }
    ```
  </Tab>

  <Tab title="ARS Response">
    ```json theme={null}
    {
      "success": true,
      "result": {
        "payment": {
          "amount": { "value": 100000, "currency": "ARS" },
          "description": "Order #12345",
          "identifiers": { "c_id": "12345", "h_id": "1003", "p_id": "txn_ghi789" },
          "status": { "status": "created", "final": false, "success": null },
          "timestamps": { "created": "2026-01-15T10:32:00Z" },
          "destination": "in",
          "service_id": 14901
        }
      },
      "request_id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "processing_time": 118
    }
    ```
  </Tab>

  <Tab title="TRY Response">
    ```json theme={null}
    {
      "success": true,
      "result": {
        "payment": {
          "amount": { "value": 50000, "currency": "TRY" },
          "description": "Order #12345",
          "identifiers": { "c_id": "12345", "h_id": "1004", "p_id": "txn_jkl012" },
          "status": { "status": "created", "final": false, "success": null },
          "timestamps": { "created": "2026-01-15T10:33:00Z" },
          "destination": "in",
          "service_id": 15001
        }
      },
      "request_id": "d4e5f6a7-b8c9-0123-defa-234567890124",
      "processing_time": 95
    }
    ```
  </Tab>
</Tabs>

<Info>
  **Other supported currencies:** The same pattern works for Australian Dollar (`AUD`) and Sri Lankan Rupee (`LKR`) using the `bank_transfer` payment method. Use the `service_id` assigned by your account manager for each currency.
</Info>

## Step 4: Check Payment Status

Use `payment.status` with the `h_id` returned from the deposit to check its current status:

<CodeGroup>
  ```bash cURL 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}"
  ```

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

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

  payload = {
      "method": "payment.status",
      "params": {
          "payment": {
              "identifiers": {"h_id": "1001"}
          }
      }
  }

  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_secret_key_here';
  const URL = 'https://api.bafanglaicai88.com/public/api/multihub/v1';

  const payload = {
    method: 'payment.status',
    params: {
      payment: {
        identifiers: { h_id: '1001' }
      }
    }
  };

  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);
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "success": true,
  "result": {
    "payment": {
      "payer": {
        "email": "customer@example.com",
        "phone": "9876543210",
        "person": { "first_name": "John", "last_name": "Doe" }
      },
      "amount": { "value": 10000, "currency": "INR" },
      "description": "Order #12345",
      "identifiers": { "c_id": "12345", "h_id": "1001", "p_id": "txn_abc123" },
      "status": {
        "status": "processing",
        "final": false,
        "success": null,
        "history": [
          { "status": "created", "final": false, "success": null, "created": "2026-01-15T10:30:00Z", "reason": null, "amount": 10000 },
          { "status": "processing", "final": false, "success": null, "created": "2026-01-15T10:30:05Z", "reason": null, "amount": 10000 }
        ]
      },
      "timestamps": {
        "created": "2026-01-15T10:30:00Z",
        "updated": "2026-01-15T10:30:05Z"
      },
      "destination": "in",
      "service_id": 14701
    }
  },
  "request_id": "d4e5f6a7-b8c9-0123-defa-234567890123",
  "processing_time": 42
}
```

## Step 5: Check Balance

Use `balance.get` to retrieve your current account balance:

<CodeGroup>
  ```bash cURL theme={null}
  BODY='{"method":"balance.get","params":{}}'
  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_secret_key_here"
  URL = "https://api.bafanglaicai88.com/public/api/multihub/v1"

  payload = {
      "method": "balance.get",
      "params": {}
  }

  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_secret_key_here';
  const URL = 'https://api.bafanglaicai88.com/public/api/multihub/v1';

  const payload = {
    method: 'balance.get',
    params: {}
  };

  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);
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "success": true,
  "result": {
    "balance": {
      "id": 0,
      "amounts": [
        { "value": 500000, "value_freezing": 10000, "value_blocking": 0, "currency": "INR", "enabled": true },
        { "value": 250000, "value_freezing": 5000, "value_blocking": 0, "currency": "MXN", "enabled": true },
        { "value": 1000000, "value_freezing": 0, "value_blocking": 0, "currency": "ARS", "enabled": true },
        { "value": 75000, "value_freezing": 0, "value_blocking": 0, "currency": "TRY", "enabled": true }
      ],
      "enabled": true
    }
  },
  "request_id": "e5f6a7b8-c9d0-1234-efab-345678901234",
  "processing_time": 18
}
```

## Understanding the Response

All API responses follow the same envelope format:

| Field             | Description                                                                                      |
| ----------------- | ------------------------------------------------------------------------------------------------ |
| `success`         | `true` if the request succeeded, `false` if an error occurred                                    |
| `result`          | The response payload (structure varies by method)                                                |
| `error`           | Present only on failure. Contains `code` (integer), `message` (string), `details`, and `context` |
| `request_id`      | Unique identifier for this request (useful for debugging)                                        |
| `processing_time` | Server processing time in milliseconds                                                           |

### Payment identifiers

| Identifier | Description                                                                                                             |
| ---------- | ----------------------------------------------------------------------------------------------------------------------- |
| `c_id`     | Your client-side string identifier (the value you send)                                                                 |
| `h_id`     | Hub-assigned payment identifier. You can use it for status queries.                                                     |
| `p_id`     | Provider-assigned transaction identifier. It is returned for reconciliation and is not accepted as a status lookup key. |

### Payment statuses

| Status               | `final` | `success` | Description                          |
| -------------------- | :-----: | :-------: | ------------------------------------ |
| `created`            | `false` |   `null`  | Payment created, awaiting processing |
| `processing`         | `false` |   `null`  | Payment is being processed           |
| `success`            |  `true` |   `true`  | Payment completed successfully       |
| `error`              |  `true` |  `false`  | Payment failed                       |
| `canceled`           |  `true` |  `false`  | Payment was cancelled                |
| `declined`           |  `true` |  `false`  | Payment expired or was declined      |
| `refunded`           |  `true` |   `true`  | Payment was refunded                 |
| `partially_refunded` |  `true` |   `true`  | Partial refund processed             |

## What's Next?

<CardGroup cols={2}>
  <Card title="Set up Webhooks" icon="webhook" href="/guides/webhooks">
    Receive real-time notifications when the payment completes
  </Card>

  <Card title="Payment Types" icon="credit-card" href="/guides/payments">
    Learn about deposits, withdrawals, and payment pages
  </Card>

  <Card title="Test Your Integration" icon="flask" href="/guides/testing">
    Validate signing, payments, balances, and webhooks before production traffic
  </Card>

  <Card title="Balance Management" icon="wallet" href="/guides/balance">
    Monitor and manage your merchant balances
  </Card>

  <Card title="Go Live" icon="rocket" href="/guides/testing#going-live">
    Switch to production when you're ready
  </Card>
</CardGroup>

## Common Issues

<AccordionGroup>
  <Accordion title="Error 3000: Authentication Error">
    Verify that `X-Data-Hash` is computed as `sha512(requestBody + secretKey)` where `requestBody` is the exact JSON string sent in the request body. Ensure there is no extra whitespace or encoding difference between what you hash and what you send.
  </Accordion>

  <Accordion title="Error 3003: Application Not Found">
    Check that the `X-Data-Application-Id` header contains your correct integer application ID.
  </Accordion>

  <Accordion title="Error 1005: Invalid Request Format">
    Ensure all required fields are present in your request. The `method` and `params` fields are always required. For `payment.in`, you must include `service_id` and the `params.payment` object with `amount`, `identifiers`, and `payer`. Check the `details` field in the error response for specifics.
  </Accordion>

  <Accordion title="Error 2002: No Route Available">
    The specified `service_id` may not be enabled for your account, or the payment method is temporarily unavailable. Contact your account manager to verify your service configuration.
  </Accordion>
</AccordionGroup>
