BitPay Client for PHP
, (*1)
Add BitPay payment processing support to your PHP application using the BitPay API and Guzzle, (*2)
Installation
Require the library in your composer.json file:, (*3)
``` json
{
"require": {
"symm/guzzle-bitpay": "~1.0"
}
}, (*4)
## Usage
### Create a client
``` php
use Symm\BitpayClient\BitpayClient;
$client = BitpayClient::createClient('YOUR_API_KEY_HERE');
Create a Test Environment Client
A client which communicates with the Test Environment, (*5)
use Symm\BitpayClient\BitpayClient;
$client = BitpayClient::createTestClient('YOUR_TEST_API_KEY_HERE');
Create a new invoice
``` php
$invoice = $client->createInvoice(
array(
'price' => 5,
'currency' => 'GBP',
)
);, (*6)
print $invoice->getUrl() . PHP_EOL;, (*7)
### Receive an existing invoice
``` php
$invoice = $client->getInvoice(
array(
'id' => 'YOUR_INVOICE_ID_HERE'
)
);
print $invoice->getStatus() . PHP_EOL;
Verify BitPay Notification
``` php
$invoice = $client->verifyNotification(file_get_contents("php://input"));, (*8)
### Get exchange rates
``` php
$currencyCollection = $client->getRates();
foreach ($currencyCollection as $currency) {
/** @var \Symm\BitpayClient\Model\Currency $currency */
print $currency->getCode() . ': ' . $currency->getRate();
}
Localise Invoice page
``` php
use Symm\BitpayClient\Localisation\Language;, (*9)
print $invoice->getUrl(Language::SPANISH)
```, (*10)
Resources
Guzzle Documentation, (*11)
Official API Documentation, (*12)
Copyright and license
Code copyright Gareth Jones and released under the MIT license., (*13)