Skip to content

Sample code ​

Complete samples in five languages. Each includes:

  • request encryption and all 12 endpoints;
  • receiving and verifying callbacks (decrypt → check merchant number → deduplicate → verify state and amount with Get order);
  • a command-line demo;
  • self-tests that don't touch the platform (a local mock platform);
  • only the language's standard library (plus cryptography for Python) — no other third-party dependencies.

Keys are always read from environment variables or files; the samples contain no keys.

Downloads ​

LanguageDownloadSHA256
Node.jsibitpay-openapi-nodejs.zip (12.5 KB)b11b827ea2b12bb1eb0bce39898f4e7d2184895d5e249ea8a1a72abdc9b24c59
Pythonibitpay-openapi-python.zip (11.3 KB)19177186fd8f956bd0b7281c3a680a49789aed86a8cc6a5c186e855daa05ab91
PHPibitpay-openapi-php.zip (11.5 KB)81de4476eae49a75053813571ce598f67f1b7888450a603f8cf3914f02bcc025
Javaibitpay-openapi-java.zip (18.3 KB)3e7a09545efa6b45fba0c79091f5797f94703095308035acbd006f0b4ee939a0
C#ibitpay-openapi-csharp.zip (13.5 KB)b88c102b001931f0380a9ed78229f0492fbf11127cf6708cfa11bd331b9b0e3e

Verify the SHA256 after downloading to make sure the file is complete and unmodified:

bash
# macOS / Linux
shasum -a 256 ibitpay-openapi-nodejs.zip
# Windows PowerShell
Get-FileHash ibitpay-openapi-nodejs.zip -Algorithm SHA256

All checksums are also in SHA256SUMS.txt.

Requirements ​

LanguageVersionNotes
Node.js20+No dependencies; npm test
Python3.9+pip install -r requirements.txt; python -m unittest
PHP8.1+openssl and curl extensions; php tests/run.php
Java17+JDK only; uses a tiny bundled JSON helper you can swap for Jackson
C#.NET 8+Framework classes only

Quick start ​

  1. In the merchant console under Developers → API & callbacks, find the API base URL and save the public and private key to two files outside your code directory, readable only by the account that runs the program.

  2. Set environment variables:

    bash
    export IBITPAY_BASE_URL=the-API-base-URL-shown-in-the-merchant-console
    export IBITPAY_MERCHANT_NO=your-merchant-number
    export IBITPAY_PUBLIC_KEY_FILE=/secure/dir/ibitpay_public.pem
    export IBITPAY_PRIVATE_KEY_FILE=/secure/dir/ibitpay_private.pem   # only needed by the callback service
  3. Run the self-tests, then the demo (e.g. node demo.js balance), then wire up the callback service as described in the README.

Each package's README (in Chinese) has language-specific details and a payout example.

Old sample

The DemoMerchant.zip offered by the previous documentation is no longer maintained. Its callback handler credited orders straight from the callback content without verifying them, which allows forged callbacks. Please use the samples above.