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; crypto deposit orders are credited by the difference from the running total);
  • 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 (13.7 KB)2e43fcd9520ee21abbe34cba10734f06b6d3f73fdfe8b9aad88b637e9193f51f
Pythonibitpay-openapi-python.zip (12.4 KB)af42ea2b8c6ea268d4c303f8c14d56a7ea3fdd48f2db193152c5c3b0720a144b
PHPibitpay-openapi-php.zip (12.5 KB)67f14d698782ee31af3e6bec9602482f8e1cdd4d8d46e488fceea4bd00c77ceb
Javaibitpay-openapi-java.zip (19.5 KB)3b06b6cf99673c8337160b0be8ca5df80d8576f30bf43840be8a965d40b01775
C#ibitpay-openapi-csharp.zip (14.7 KB)1a0387171f71a79873197b440645b2c42c9c7a69af912d0893a0c0b001151c70

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.