PHPackages                             b2binpay/api-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. b2binpay/api-php

AbandonedArchivedLibrary[Payment Processing](/categories/payments)

b2binpay/api-php
================

PHP client for B2BinPay

1.2.1(5y ago)812.7k6[1 issues](https://github.com/b2binpay/api-php/issues)[1 PRs](https://github.com/b2binpay/api-php/pulls)1MITPHPPHP ^7.1

Since Nov 13Pushed 3y ago1 watchersCompare

[ Source](https://github.com/b2binpay/api-php)[ Packagist](https://packagist.org/packages/b2binpay/api-php)[ RSS](/packages/b2binpay-api-php/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (3)Dependencies (5)Versions (6)Used By (1)

B2BinPay API client for PHP
===========================

[](#b2binpay-api-client-for-php)

Accepting [Bitcoin](https://bitcoin.org/), [Bitcoin Cash](https://www.bitcoincash.org/), [Ethereum](https://www.ethereum.org/), [DASH](https://www.dash.org/), [Litecoin](https://litecoin.org/), [Monero](https://getmonero.org/), [NEO](https://neo.org), [NEM](https://nem.io/), [Ripple](https://ripple.com/), [Cardano](https://www.cardano.org/), [Dogecoin](https://dogecoin.com/), [Zcash](https://z.cash/), [Stellar](https://www.stellar.org/), [EOS](https://eos.io/), [TRON](https://tron.network/), [Binance Coin](https://www.binance.com/) and any ERC20 and stablecoin, NEO tokens in one place!

[![Build Status](https://camo.githubusercontent.com/a25d22664178efa65727758ca992a6a58313f95eba4ab5578e366641b0cb89ae/68747470733a2f2f7472617669732d63692e6f72672f623262696e7061792f6170692d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/b2binpay/api-php) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/8c5d8902132bf6af706b65d4f1e096c6eaf6861009eeb4efeb9526b90e31c15b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f623262696e7061792f6170692d7068702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/b2binpay/api-php/?branch=master) [![Coverage Status](https://camo.githubusercontent.com/2e297516330ce2c7f17beb7bffb11028c26fce26724fd0a15200cd4f6ff83c51/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f623262696e7061792f6170692d7068702f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/b2binpay/api-php?branch=master)

Requirements
------------

[](#requirements)

- [B2BinPay](https://b2binpay.com) account
- PHP &gt;= 7.1 (If you need 7.0, please, use [version 1.1.0](https://github.com/b2binpay/api-php/tree/1.1.0))
- PHP extensions enabled: cURL, JSON

Composer Installation
---------------------

[](#composer-installation)

The easiest way to install the B2BinPay API client is to require it with [Composer](http://getcomposer.org/doc/00-intro.md) through command-line:

```
composer require b2binpay/api-php
```

or by editing `composer.json`:

```
    {
  "require": {
    "b2binpay/api-php": "^1.2"
  }
}
```

Local installation
------------------

[](#local-installation)

```
composer install --no-dev
cp .env.example .env
```

Support currencies
------------------

[](#support-currencies)

CurrencyNameBlockchain, linksADACardano[Cardano](https://www.cardano.org/)BCHBitcoin Cash[Bitcoin Cash](https://www.bitcoincash.org/)BNBBinance CoinBinance Chain, [BEP2](https://explorer.binance.org/asset/BNB)BTCBitcoin[Bitcoin](https://bitcoin.org/)BUSD-ETHBinance USDEthereum, [Stablecoin](https://etherscan.io/token/0x4Fabb145d64652a948d72533023f6E7A623C7C53)DAI-ETHDaiEthereum, [Stablecoin](https://etherscan.io/token/0x6b175474e89094c44da98b954eedeac495271d0f)DASHDash[Dash](https://www.dash.org)DOGEDogecoin[Dogecoin](https://dogecoin.com)EOSEOS[EOS](https://eos.io)ETHEthereum[Ethereum](https://ethereum.org/en/)GUSD-ETHGemini DollarEthereum, [Stablecoin](https://etherscan.io/token/0x056Fd409E1d7A124BD7017459dFEa2F387b6d5Cd)LTCLitecoin[Litecoin](https://litecoin.org)NEONeo[Neo](https://neo.org)PAX-ETHPaxos StandardEthereum, [Stablecoin](https://etherscan.io/address/0x8e870d67f660d95d5be530380d0ec0bd388289e1)TRXTRON[TRON](https://tron.network)TUSD-ETHTrueUSDEthereum, [Stablecoin](https://etherscan.io/token/0x0000000000085d4780B73119b644AE5ecd22b376)USDC-ETHUSD CoinEthereum, [Stablecoin](https://etherscan.io/token/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48)USDT-ETHTetherEthereum, [Stablecoin](https://etherscan.io/address/0xdac17f958d2ee523a2206206994597c13d831ec7)USDT-OMNITetherOMNI, [Stablecoin](https://www.omniexplorer.info/asset/31)XEMNEM[NEM](https://www.nem.io)XLMStellar[Stellar](https://www.stellar.org)XMRMonero[Monero](https://www.getmonero.org)XRPRipple[Ripple](https://ripple.com/xrp/)ZECZcash[Zcash](https://z.cash)Getting started
---------------

[](#getting-started)

See examples with comments in [examples/README.md](examples/README.md)

### Create Provider instance

[](#create-provider-instance)

Use the API key and secret to access your B2BinPay account:

```
$provider = new B2Binpay\Provider(
    'API_KEY',
    'API_SECRET'
);
```

#### Test Mode

[](#test-mode)

In order to use testing sandbox, pass `true` as a third parameter for `B2Binpay\Provider`:

```
$provider = new B2Binpay\Provider(
    'API_KEY',
    'API_SECRET',
    true
);
```

**Warning:** Sandbox and main gateway have their own pairs of key and secret!

### Create a bill

[](#create-a-bill)

*The payment currency is considered to match the currency of your wallet*.

Create a new bill:

```
$bill = $provider->createBill(
        'WALLET_ID',
        'AMOUNT',
        'CURRENCY',
        'LIFETIME',
        'TRACKING_ID',
        'CALLBACK_URL',
        'SUCCESS_URL',
        'ERROR_URL'
  );
```

ParamsDescriptionWALLET\_ID(int) Each wallet is responsible for creating bill only in the currency assigned to itAMOUNT(string) Amount in the value of the currency being createdCURRENCY(string) See list of supported currencies in the table aboveLIFETIME(int) Number in seconds that will set bill to expire from the current creation dateTRACKING\_ID(string) *Optional*. Track for bill tracking. This value will be returned on callbackCALLBACK\_URL(string) *Optional*. URL to which the callback will be sentSUCCESS\_URL(string) \_Optional\_. URL to which the user can be sent after successful payment, is used only on the payment pageERROR\_URL(string) \_Optional\_. URL to which the user can be sent after unsuccessful payment, is used only on the payment page### Convert currency

[](#convert-currency)

You can get actual rates and convert supported currencies respecting your wallet's parameters.

Get rates for *BASE\_CURRENCY*:

```
$rates = $provider->getRates('BASE_CURRENCY', 'RATE_TYPE');
```

ParamsDescriptionBASE\_CURRENCY(string) *Optional*. Currency to which the rates will be calculated. Default: USDRATE\_TYPE(string) *Optional*. Receiving the type of rates, for **deposit** and **withdrawal**. Default: depositConvert currency using actual rates:

```
$amount = $provider->convertCurrency('AMOUNT', 'BASE_CURRENCY', 'CURRENCY', $rates);
```

ParamsDescriptionAMOUNT(string) The amount in the currency to be convertedBASE\_CURRENCY(string) The currency in which the amount is indicatedCURRENCY(string) Currency in which you want to convert the amount$rates(array) \_Optional\_. Current rates. If the parameter is not specified, then the rates will be requested againNow you can provide `$amount` variable as a second parameter for `createBill()` method to set an accurate amount of cryptocurrency.

### Add markup

[](#add-markup)

You can add some markup to the existing amount.

Set *10%* markup for the current amount:

```
$amount = $provider->addMarkup($amount, 'CURRENCY', 10);
```

ParamsDescription$amount(string) Amount to add markupCURRENCY(string) Currency in which markup is added10(int) Percentage on which to add markup### Callback

[](#callback)

Once bill status changed, our server can send a callback to your configured Callback URL. Also, you can specify Tracking ID, which will return with the callback to identify the exact order. To do that provide additional parameters to `createBill()` method:

```
$bill = $provider->createBill(
        'WALLET_ID',
        $amount,
        'CURRENCY',
        'LIFETIME',
        '202009051801',
        'https://my.callback.url/callback.php'
    );
```

**Warning:** If specified, your Callback URL should return the message "OK" with status 200. Until that payment will not be considered complete!

```
header('HTTP/1.1 200 OK');
exit('OK');
```

#### Callback verification

[](#callback-verification)

You can verify Callback request headers by comparing it with the `$provider->verifySign()` method output:

```
$verifySign = $provider->verifySign($_POST['sign']['time'], $_POST['sign']['hash']);
if (!$verifySign) {
    header('HTTP/1.1 401 Unauthorized');
    exit();
}
```

**WARNING:** for each callback `$ _POST ['sign'] ['hash']` a new one is generated - if you received `$ _POST ['sign'] ['hash']` which was already used before, you should throw the same error as for signature verification

#### Callback body

[](#callback-body)

Bill callback request will contain the following data:

```
{
  "data": {
    "id": BILL_ID,
    "url": URL_TO_BILL_PAYMENT_PAGE,
    "address": BLOCKCHAIN_ADDRESS,
    "created": TIME,
    "expired": TIME
    |
    NULL,
    "status": BILL_STATUS,
    "tracking_id": TRACKING_ID,
    "callback_url": URL
    |
    NULL
    "amount": AMOUNT_MULTIPLIED_BY_TEN_IN_POW,
    "actual_amount": ALREADY_PAID_AMOUNT_MULTIPLIED_BY_TEN_IN_POW,
    "pow": POW,
    "message": MESSAGE
    |
    NULL,
    "transactions": [
      {
        "id": TRANSACTION_ID,
        "bill_id": BILL_ID,
        "created": TIME,
        "amount": TRANSACTION_AMOUNT_MULTIPLIED_BY_TEN_IN_POW
        ",
        "pow": POW,
        "status": TRANSACTION_STATUS,
        "transaction": HASH_TRANSACTION_IN_BLOCKCHAIN,
        "type": 0,
        "currency": {
          "iso": ISO_CODE_CURRENCY,
          "alpha": SYMBOL_CURRENCY
        }
      }
    ],
    "currency": {
      "iso": ISO_CODE_CURRENCY,
      "alpha": SYMBOL_CURRENCY
    },
    "sign": {
      "time": TIME,
      "hash": HASH
    }
  }
}
```

Withdraw callback request will contain the following data:

```
{
  "data": {
    "id": WITHDRAW_ID,
    "virtual_wallet_id": VIRTUAL_WALLET_ID,
    "with_fee": INCLUDE_COMMISSION_IN_WITHDRAW,
    "created": TIME,
    "address": BLOCKCHAIN_ADDRESS,
    "amount": AMOUNT_MULTIPLIED_BY_TEN_IN_POW,
    "fee": BLOCKCHAIN_FEE_MULTIPLIED_BY_TEN_IN_POW,
    "pow": POW,
    "status": WITHDRAW_STATUS,
    "transaction": HASH_TRANSACTION_IN_BLOCKCHAIN
    |
    NULL
    "tracking_id": TRACKING_ID
    |
    NULL,
    "unique_id": UNIQUE_WITHDRAW_ID,
    "callback_url": URL
    |
    NULL,
    "message": MESSAGE
    |
    NULL,
    "currency": {
      "iso": ISO_CODE_CURRENCY,
      "alpha": SYMBOL_CURRENCY
    },
    "sign": {
      "time": TIME,
      "hash": HASH
    }
  }
}
```

### Create a withdrawal

[](#create-a-withdrawal)

*From a virtual wallet, you can make withdrawals to any blockchain, for this you need to specify ADDRESS and CURRENCY*.

Create a new withdraw:

```
$bill = $provider->createWithdrawal(
        'VIRTUAL_WALLET_ID',
        'AMOUNT',
        'CURRENCY',
        'ADDRESS',
        'UNIQUE_ID',
        'TRACKING_ID',
        'CALLBACK_URL',
        'MESSAGE',
        'WITH_FEE'
    );
```

ParamsDescriptionVIRTUAL\_WALLET\_ID(int) ID virtual wallet. If the currency of the virtual wallet does not match the currency in which the withdrawal is to be made, the system will automatically convert at the current rateAMOUNT(string) Amount to be withdrawnCURRENCY(string) See list of supported currencies in the table aboveADDRESS(string) Blockchain address to which you want to withdrawUNIQUE\_ID(int) Any unique positive number. This number should not be repeated from withdrawal to withdrawalTRACKING\_ID(string) *Optional*. Track for withdraw tracking. This value will be returned on callbackCALLBACK\_URL(string) *Optional*. URL to which the callback will be sentMESSAGE(string) *Optional*. Used for Ripple blockchain, NEM, Stellar, EOS and Binance ChainWITH\_FEE(boolean) \_Optional\_. Include the commission in the withdrawal amount. Not all blockchains support this methodSystem statuses lists
---------------------

[](#system-statuses-lists)

### List of bills statuses

[](#list-of-bills-statuses)

StatusDescription-2Failed-1Expired1Created2Paid### List of transactions statuses

[](#list-of-transactions-statuses)

StatusDescription-4Waiting for return-3Returned-2Failed-1Expired0Pending1Sent2Approved### List of withdraws statuses

[](#list-of-withdraws-statuses)

StatusDescription-2Failed0Waiting1Pending2Sent### List of transfers statuses

[](#list-of-transfers-statuses)

StatusDescription-1Failed0Pending1Sent### List of transfers types

[](#list-of-transfers-types)

StatusDescription0Deposit from blockchain1Bank transfer2Auto withdraw3Withdraw blockchain fee4Token payout fee5Finance deposit6Bank transfer commission7CommissionsLicense
-------

[](#license)

B2BinPay\\API-PHP is licensed under the [MIT License](https://github.com/b2binpay/api-php/blob/master/LICENSE).

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 59.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~175 days

Total

5

Last Release

2040d ago

PHP version history (2 changes)1.0.0PHP ^7

1.2.0PHP ^7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/21535fa4133cc208045ca6aa4ec96e81487915ea1dcb465d4fff236181a2cfbc?d=identicon)[a1ebedew](/maintainers/a1ebedew)

---

Top Contributors

[![a1ebedew](https://avatars.githubusercontent.com/u/44876151?v=4)](https://github.com/a1ebedew "a1ebedew (26 commits)")[![mikhailstepanenko](https://avatars.githubusercontent.com/u/27731558?v=4)](https://github.com/mikhailstepanenko "mikhailstepanenko (16 commits)")[![b2binpay-ok](https://avatars.githubusercontent.com/u/172614076?v=4)](https://github.com/b2binpay-ok "b2binpay-ok (1 commits)")[![iamvar](https://avatars.githubusercontent.com/u/7314366?v=4)](https://github.com/iamvar "iamvar (1 commits)")

---

Tags

b2binpayb2bxbitcoincryptocurrencyethereumlitecoinmoneropaymentpayment-gatewayripplewallet

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/b2binpay-api-php/health.svg)

```
[![Health](https://phpackages.com/badges/b2binpay-api-php/health.svg)](https://phpackages.com/packages/b2binpay-api-php)
```

###  Alternatives

[imdhemy/google-play-billing

Google Play Billing

491.3M5](/packages/imdhemy-google-play-billing)[bitpay/sdk

Complete version of the PHP library for the new cryptographically secure BitPay API

42337.5k4](/packages/bitpay-sdk)[flutterwavedev/flutterwave-v3

A simple SDK for integrating to Flutterwave Payment

24174.1k6](/packages/flutterwavedev-flutterwave-v3)[buckaroo/sdk

Buckaroo payment SDK

12189.1k9](/packages/buckaroo-sdk)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[contica/facturador-electronico-cr

Un facturador de código libre para integrar facturación electrónica en Costa Rica a un proyecto PHP

2128.8k](/packages/contica-facturador-electronico-cr)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
