Download the PHP package noname9/api-php without Composer
On this page you can find all versions of the php package noname9/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, B2BX and any ERC20, NEO tokens in one place!
Requirements
- B2BinPay account
- PHP >= 7.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
:
Getting started
See example code with comments in public/index.php
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:
_where LIFETIME
- number of seconds for payment page to live and WALLET_ID
- your B2BinPay wallet id._
Now the bill id is available in the $bill->id
property. You should store this id with your order.
After storing the bill id you can find an url to the payment page in the $bill->url
property.
Finally, you can check bill status by requesting it using the stored id:
The bill status will be stored in $billCheck->status
property.
Convert currency
You can get actual rates and convert supported currencies respecting your wallet's parameters.
Get rates for USD:
Convert currency using actual rates:
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 current amount:
Get your wallet's params
You can retrieve your wallet's params to find out actual currency and current amount:
Now your wallet's currency alpha code is stored in the $wallet->currency->alpha
parameter.
You can use it for createBill()
, addMarkup()
and convertCurrency()
methods.
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 getAuthorization()
method output:
Callback body
Callback request will contain the following data:
List of bill statuses
Status | Description |
---|---|
-2 | Payment error |
-1 | Payment lifetime is exceeded |
1 | Payment pending |
2 | Payment success |
3 | Payment freeze |
4 | Payment closed (funds are withdrawn) |
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 ^4.0
php Version ^7
ext-json Version *