2017 © Pedro Peláez
 

library bf-php

BillForward PHP Client Library

image

billforward/bf-php

BillForward PHP Client Library

  • Wednesday, August 31, 2016
  • by billforward-ian
  • Repository
  • 9 Watchers
  • 9 Stars
  • 27,515 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 67 Versions
  • 0 % Grown

The README.md

Usage

Install (via Composer)

Our library can be installed via the Composer package manager., (*1)

Add us to your composer.json:, (*2)

{
    "require": {
        "billforward/bf-php": "1.*"
    }
}

Install the new package:, (*3)

composer.phar install

Now include our code. Either use Composer's autoloader:, (*4)

require_once('vendor/autoload.php');

Or include manually:, (*5)

require_once('/path/to/vendor/billforward/bf-php/lib/BillForward.php');

Install (manually)

Step 1. Put our library into your repository

Inside lib/, lives: * BillForward.php * BFPHPClient/, (*6)

Put these files in your repository., (*7)

Step 2. Include our library from your code

Point to where BillForward.php is in your repository:, (*8)

require_once('path/to/BillForward.php');

This file will autoload the library., (*9)

Invocation

Use credentials to connect to BillForward

Step 1. Getting BillForward credentials

Login to (or Register) your BillForward Sandbox account., (*10)

Grab a Private API token., (*11)

Step 2. Connect to BillForward using BillForwardClient

Having included BillForward.php, you can now make an instance of BillForwardClient., (*12)

It can be used as the default client for all requests:, (*13)

$access_token = 'YOUR ACCESS TOKEN HERE';
$urlRoot = 'https://api-sandbox.billforward.net:443/v1/';
$client = new BillForwardClient($access_token, $urlRoot);
BillForwardClient::setDefaultClient($client);

Step 3. Make API calls using BillForwardClient

Construction of any BillForwardClient automatically registers that client as the 'default client'., (*14)

Requests can now be made. These use the 'default client' implicitly:, (*15)

$accounts = Bf_Account::getAll();

You can also explicitly specify a client. This is useful when connecting using multiple clients -- i.e. when migrating a user's data:, (*16)

// use null queryparams, and specify the client to use for the request
$accounts = Bf_Account::getAll(null, $client);

Examples

See ExampleUsage.php for a full use-case of interacting with the API., (*17)

View the examples in our PHP Client Library Docs., (*18)

We provide also in the test folder some tests that show usage., (*19)

Compatibility

The BillForward PHP Client Library is expected to work on PHP 5.3+. Required PHP extensions include:, (*20)

cURL
json_decode

Building (for devs)

We use a build system. This is Gradle., (*21)

We use a package manager. This is Composer., (*22)

Mostly the build system is used for interacting with / invoking Composer., (*23)

The build system provides these powers: * Ability to run tests * Composer installs phpunit * Composer generates classmap for tests to find our source code * Ability to regenerate project's 'autoload' classmap (for example if you add a class) * Composer generates classmap * Build system redraws Billforward.php autoloader from that classmap, (*24)

How to build

To get the workspace setup, there are three steps:, (*25)

  1. Install and add to PATH: java, curl, php
  2. Install gradle
  3. Run gradle setup

Step 1. Installing Java, curl and PHP.

These are well-documented; follow normal installation process., (*26)

UNIX users will already have curl. Windows users might want to look http://curl.haxx.se/dlwiz/?type=bin&os=Win32&flav=-&ver=*., (*27)

Step 2. Installing gradle.

This step installs our build system, Gradle., (*28)

Brave users can skip to Step 3; gradle will self-install itself if it needs to, (*29)

(Requires Java on PATH)., (*30)

We provide a Gradle self-installer for Windows and UNIX., (*31)

It is in the build directory., (*32)

Invoke with:, (*33)

cd build
./gradlew

Step 3. Run gradle setup

This step runs a 'setup' build, which:, (*34)

  1. Self-installs Composer (if necessary)
  2. Installs Composer packages (if necessary). [Classmap is also generated at this time]
  3. Creates BillForward.php autoloader from that classmap

(Requires CURL on PATH: to self-install Composer)., (*35)

(Requires PHP on PATH: to invoke Composer)., (*36)

We provide a Composer self-installer for Windows and UNIX. Invoke with:, (*37)

cd build
./gradlew setup

Running tests (for devs)

Setup

Tests login using the credentials you define in: test/BFPHPClientTest/new/config.php. A config.example.php is provided to guide you in creating this file., (*38)

Ideally the credentials should refer to an account that exists solely for testing, as tests cause side-effects (entities created upon your organization)., (*39)

Step 1. Register on Sandbox

Login to (or Register) a Sandbox account, that you are happy with using for tests., (*40)

Grab a Private API token., (*41)

Step 2. Create a config.php inside test/BFPHPClientTest/new/

<?php
$credentials = array(
    'urlRoot' => 'https://api-sandbox.billforward.net:443/v1/',
    'access_token' => 'INSERT_ACCESS_TOKEN_HERE'
    );

We use phpunit as our testrunner. If you have run ./gradlew setup, you will find already a phpunit binary in vendor/bin/phpunit., (*42)

Invocation

(Requires phpunit on PATH)., (*43)

To run all tests, cd to the repository root and invoke:, (*44)

phpunit

phpunit will read phpunit.xml to find tests and find which classes to autoload., (*45)

The tests themselves rely on vendor/bin/autoload.php (generated by Composer) to find their dependencies., (*46)

Run individual file

A custom Sublime script can be used, for example (requires phpunit on PATH):, (*47)

{
    "cmd": ["phpunit", "$file"],
    "selector": "source.php"
}

Or just invoke normally from anywhere using the terminal:, (*48)

phpunit AccountTest.php

As with the full run, phpunit will climb the project structure looking for phpunit.xml., (*49)

Making changes (for devs)

After adding, renaming or moving a class (ie, changing the classmap), use the build system to regenerate the autoloader BillForward.php and its classmap., (*50)

Specifically, cd into /build and invoke:, (*51)

./gradlew regenerateClassmap recompileClasspath

The newly-generated BillForward.php should be part of any commit., (*52)

Confirm also that the usual unit test run passes (run phpunit from the project root). Refer to the 'Setup' section for instructions on configuring your test run., (*53)

Release automation

Calculates date and major/minor version of release, generates and names zipped release in root dir, tags commit with version string, pushes tag., (*54)

You will still need to go to GitHub and draft a release of the tagged commit (so you can add release notes and attach the zipped file)., (*55)

New major version:, (*56)

cd build
sh ./releaseHelpers/release incrementMajorVer

Same major version:, (*57)

cd build
sh ./releaseHelpers/release

Untag latest release:, (*58)

cd build
sh ./releaseHelpers/delete

The Versions

31/08 2016

dev-master

9999999-dev https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

31/08 2016

v16.2016.244

16.2016.244.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

31/08 2016

dev-curl-errors

dev-curl-errors https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

28/07 2016

v16.2016.210

16.2016.210.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

28/07 2016

dev-revive

dev-revive https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

01/07 2016

v16.2016.183

16.2016.183.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

01/07 2016

dev-add-charge

dev-add-charge https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

29/06 2016

v15.2016.181

15.2016.181.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

29/06 2016

dev-timer-amendments

dev-timer-amendments https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

03/05 2016

v15.2016.124

15.2016.124.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

22/04 2016

v15.2016.113.2

15.2016.113.2 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

22/04 2016

v15.2016.113.1

15.2016.113.1 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

22/04 2016

v14.2016.113

14.2016.113.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

21/04 2016

v14.2016.112

14.2016.112.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

21/04 2016

dev-semantic-errors

dev-semantic-errors https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

20/04 2016

v14.2016.111

14.2016.111.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

20/04 2016

dev-retire-queryparams

dev-retire-queryparams https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

19/04 2016

dev-batch-charges

dev-batch-charges https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

16/03 2016

dev-batch-values

dev-batch-values https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

12/10 2015

v13.2015.285

13.2015.285.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

12/10 2015

dev-bug/time-control-defaults

dev-bug/time-control-defaults https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

12/10 2015

dev-feature/shams

dev-feature/shams https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

28/08 2015

v13.2015.240

13.2015.240.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

28/08 2015

dev-feature/account-time

dev-feature/account-time https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

29/06 2015

v13.2015.181

13.2015.181.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

23/06 2015

v13.2015.175

13.2015.175.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

22/06 2015

v13.2015.173.1

13.2015.173.1 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

22/06 2015

v13.2015.173

13.2015.173.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

18/06 2015

v13.2015.169

13.2015.169.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

15/06 2015

v13.2015.166

13.2015.166.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

09/06 2015

dev-feature/sync-endpoints

dev-feature/sync-endpoints https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

13/05 2015

v12.2015.133

12.2015.133.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

07/05 2015

v12.2015.127

12.2015.127.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

23/04 2015

v12.2015.113

12.2015.113.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

25/03 2015

v12.2015.84

12.2015.84.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

20/03 2015

v11.2015.79

11.2015.79.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

04/03 2015

v11.2015.63

11.2015.63.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

10/02 2015

v10.2015.41

10.2015.41.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

09/02 2015

v9.2015.40

9.2015.40.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

27/01 2015

dev-refactor/simpleupgrade

dev-refactor/simpleupgrade https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

27/01 2015

v8.2015.27

8.2015.27.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

27/01 2015

dev-feature/coupons

dev-feature/coupons https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

16/01 2015

v7.2015.16.2

7.2015.16.2 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

16/01 2015

v7.2015.16.1

7.2015.16.1 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

16/01 2015

v7.2015.16

7.2015.16.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

07/01 2015

v7.2015.7.1

7.2015.7.1 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

07/01 2015

v7.2015.7

7.2015.7.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

05/01 2015

v6.2015.5.1

6.2015.5.1 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

05/01 2015

v6.2015.5

6.2015.5.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

26/11 2014

v5.2014.329

5.2014.329.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

24/11 2014

v5.2014.327

5.2014.327.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

18/11 2014

v5.2014.321

5.2014.321.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

10/11 2014

v5.2014.314

5.2014.314.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

06/11 2014

v4.2014.309

4.2014.309.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

05/11 2014

v3.2014.308.1

3.2014.308.1 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

05/11 2014

v3.2014.308

3.2014.308.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

04/11 2014

v3.2014.307.1

3.2014.307.1 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

03/11 2014

v2.2014.306

2.2014.306.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

29/10 2014

v1.2014.301.2

1.2014.301.2 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

29/10 2014

v1.2014.301.1

1.2014.301.1 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

28/10 2014

v1.2014.300.1

1.2014.300.1 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

28/10 2014

v1.2014.300

1.2014.300.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

27/10 2014

v1.2014.299.1

1.2014.299.1 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

27/10 2014

v1.2014.299

1.2014.299.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

22/10 2014

v1.2014.296

1.2014.296.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

10/09 2014

v1.2014.251

1.2014.251.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill

10/09 2014

v1.0.0

1.0.0.0 https://github.com/billforward/bf-php

BillForward PHP Client Library

  Sources   Download

MIT

The Development Requires

library client subscription billing forward billforward bill