PHP client library for Killbill
In order to use the library, you need to:
- Require the library via composer:
composer require killbill\killbill-client
- Point the library to your Killbill instance via the
Client::$serverUrl
variable (http://127.0.0.1:8080 by default)
The following snippet will create an account:
<?php
use \Killbill\Client\Client;
use \Killbill\Client\Tenant;
use \Killbill\Client\Account;
// Killbill server
Client::$serverUrl = 'http://localhost:8080';
// Set these values for your particular tenant
$tenant = new Tenant();
$tenant->setApiKey('bob');
$tenant->setApiSecret('lazar');
// Unique id for this account
$externalAccountId = uniqid();
// Prepare the account data
$accountData = new Account();
$accountData->setName('Killbill php test');
$accountData->setExternalKey($externalAccountId);
$accountData->setEmail('test-' . $externalAccountId . '@kill-bill.org');
$accountData->setCurrency('USD');
$accountData->setPaymentMethodId(null);
$accountData->setAddress1('12 rue des ecoles');
$accountData->setAddress2('Poitier');
$accountData->setCompany('Renault');
$accountData->setState('Poitou');
$accountData->setCountry('France');
$accountData->setPhone('81 53 26 56');
$accountData->setFirstNameLength(4);
$accountData->setBillCycleDay(12);
$accountData->setTimeZone('UTC');
// Create it
$createdAccount = $accountData->create('pierre', 'PHP_TEST', 'Test for '' . $externalAccountId, $tenant->getTenantHeaders());
If you want to use the client but are not using Composer (yet), follow these steps:
- Install composer locally: Instruction
- Run
composer require killbill/killbill-client
. This will download the library into thevendor/
folder and create acomposer.json
and acomposer.lock
file that define this dependency. - Include the auto-generated
autoload.php
file from thevendor/
folder. - You can now use the client like above described.
- If you don't want to have an additional build step, just check the
vendor/
folder into your repository.
The Killbill PHP client uses phpunit as testing framework. Tests can either be run locally using composer test
or against
a live Killbill instance that is running on 127.0.0.1:8080
using composer test-integration
.
The PHP library requires PHP 5.5 or greater with libcurl compiled (e.g. you need the php-curl package on Ubuntu).
Feel free to ask questions on the killbilling-users Google Group.