Download the PHP package b2binpay/api-php without Composer
On this page you can find all versions of the php package b2binpay/api-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package api-php
B2BinPay API client for PHP
Accepting Bitcoin, Bitcoin Cash , Ethereum, DASH, Litecoin , Monero, NEO, NEM, Ripple , Cardano, Dogecoin, Zcash , Stellar, EOS, TRON , Binance Coin and any ERC20 and stablecoin, NEO tokens in one place!
Requirements
- B2BinPay account
- PHP >= 7.1 (If you need 7.0, please, use version 1.1.0)
- PHP extensions enabled: cURL, JSON
Composer Installation
The easiest way to install the B2BinPay API client is to require it with Composer through command-line:
or by editing composer.json
:
Local installation
Support currencies
Currency | Name | Blockchain, links |
---|---|---|
ADA | Cardano | Cardano |
BCH | Bitcoin Cash | Bitcoin Cash |
BNB | Binance Coin | Binance Chain, BEP2 |
BTC | Bitcoin | Bitcoin |
BUSD-ETH | Binance USD | Ethereum, Stablecoin |
DAI-ETH | Dai | Ethereum, Stablecoin |
DASH | Dash | Dash |
DOGE | Dogecoin | Dogecoin |
EOS | EOS | EOS |
ETH | Ethereum | Ethereum |
GUSD-ETH | Gemini Dollar | Ethereum, Stablecoin |
LTC | Litecoin | Litecoin |
NEO | Neo | Neo |
PAX-ETH | Paxos Standard | Ethereum, Stablecoin |
TRX | TRON | TRON |
TUSD-ETH | TrueUSD | Ethereum, Stablecoin |
USDC-ETH | USD Coin | Ethereum, Stablecoin |
USDT-ETH | Tether | Ethereum, Stablecoin |
USDT-OMNI | Tether | OMNI, Stablecoin |
XEM | NEM | NEM |
XLM | Stellar | Stellar |
XMR | Monero | Monero |
XRP | Ripple | Ripple |
ZEC | Zcash | Zcash |
Getting started
See examples with comments in examples/README.md
Create Provider instance
Use the API key and secret to access your B2BinPay account:
Test Mode
In order to use testing sandbox, pass true
as a third parameter for B2Binpay\Provider
:
Warning: Sandbox and main gateway have their own pairs of key and secret!
Create a bill
The payment currency is considered to match the currency of your wallet.
Create a new bill:
Params | Description |
---|---|
WALLET_ID | (int) Each wallet is responsible for creating bill only in the currency assigned to it |
AMOUNT | (string) Amount in the value of the currency being created |
CURRENCY | (string) See list of supported currencies in the table above |
LIFETIME | (int) Number in seconds that will set bill to expire from the current creation date |
TRACKING_ID | (string) Optional. Track for bill tracking. This value will be returned on callback |
CALLBACK_URL | (string) Optional. URL to which the callback will be sent |
SUCCESS_URL | (string) _ |
Optional_. URL to which the user can be sent after successful payment, is used only on the payment page | |
ERROR_URL | (string) _ |
Optional_. URL to which the user can be sent after unsuccessful payment, is used only on the payment page |
Convert currency
You can get actual rates and convert supported currencies respecting your wallet's parameters.
Get rates for _BASECURRENCY:
Params | Description |
---|---|
BASE_CURRENCY | (string) Optional. Currency to which the rates will be calculated. Default: USD |
RATE_TYPE | (string) Optional. Receiving the type of rates, for deposit and withdrawal. Default: deposit |
Convert currency using actual rates:
Params | Description |
---|---|
AMOUNT | (string) The amount in the currency to be converted |
BASE_CURRENCY | (string) The currency in which the amount is indicated |
CURRENCY | (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 again |
Now you can provide $amount
variable as a second parameter for createBill()
method to set an accurate amount of
cryptocurrency.
Add markup
You can add some markup to the existing amount.
Set 10% markup for the current amount:
Params | Description |
---|---|
$amount | (string) Amount to add markup |
CURRENCY | (string) Currency in which markup is added |
10 | (int) Percentage on which to add markup |
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:
Warning: If specified, your Callback URL should return the message "OK" with status 200. Until that payment will not be considered complete!
Callback verification
You can verify Callback request headers by comparing it with the $provider->verifySign()
method output:
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
Bill callback request will contain the following data:
Withdraw callback request will contain the following data:
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:
Params | Description |
---|---|
VIRTUAL_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 rate |
AMOUNT | (string) Amount to be withdrawn |
CURRENCY | (string) See list of supported currencies in the table above |
ADDRESS | (string) Blockchain address to which you want to withdraw |
UNIQUE_ID | (int) Any unique positive number. This number should not be repeated from withdrawal to withdrawal |
TRACKING_ID | (string) Optional. Track for withdraw tracking. This value will be returned on callback |
CALLBACK_URL | (string) Optional. URL to which the callback will be sent |
MESSAGE | (string) Optional. Used for Ripple blockchain, NEM, Stellar, EOS and Binance Chain |
WITH_FEE | (boolean) _ |
Optional_. Include the commission in the withdrawal amount. Not all blockchains support this method |
System statuses lists
List of bills statuses
Status | Description |
---|---|
-2 | Failed |
-1 | Expired |
1 | Created |
2 | Paid |
List of transactions statuses
Status | Description |
---|---|
-4 | Waiting for return |
-3 | Returned |
-2 | Failed |
-1 | Expired |
0 | Pending |
1 | Sent |
2 | Approved |
List of withdraws statuses
Status | Description |
---|---|
-2 | Failed |
0 | Waiting |
1 | Pending |
2 | Sent |
List of transfers statuses
Status | Description |
---|---|
-1 | Failed |
0 | Pending |
1 | Sent |
List of transfers types
Status | Description |
---|---|
0 | Deposit from blockchain |
1 | Bank transfer |
2 | Auto withdraw |
3 | Withdraw blockchain fee |
4 | Token payout fee |
5 | Finance deposit |
6 | Bank transfer commission |
7 | Commissions |
License
B2BinPay\API-PHP is licensed under the MIT License.
All versions of api-php with dependencies
guzzlehttp/guzzle Version ^6.3
vlucas/phpdotenv Version ^2.5
php Version ^7.1
ext-json Version *