23786784ef
Summary: Adds the Balanced PHP API to externals/. Ref T2787. Test Plan: Used in next diff. Reviewers: btrahan, chad Reviewed By: chad CC: aran, aurelijus Maniphest Tasks: T2787 Differential Revision: https://secure.phabricator.com/D5764 |
||
---|---|---|
.. | ||
example | ||
src/Balanced | ||
tests | ||
.gitignore | ||
.travis.yml | ||
bootstrap.php | ||
build-phar | ||
composer.json | ||
LICENSE | ||
README.md |
Balanced
Online Marketplace Payments
The design of this library was heavily influenced by Httpful.
Requirements
Issues
Please use appropriately tagged github issues to request features or report bugs.
Installation
You can install using composer, a phar package or from source. Note that Balanced is PSR-0 compliant:
Composer
If you don't have Composer install it:
$ curl -s https://getcomposer.org/installer | php
Add this to your composer.json
:
{
"require": {
"balanced/balanced": "*"
}
}
Refresh your dependencies:
$ php composer.phar update
Then make sure to require
the autoloader and initialize all:
<?php
require(__DIR__ . '/vendor/autoload.php');
\Httpful\Bootstrap::init();
\RESTful\Bootstrap::init();
\Balanced\Bootstrap::init();
...
Phar
Download an Httpful phar file, which are all here:
$ curl -s -L -o httpful.phar https://github.com/downloads/nategood/httpful/httpful.phar
Download a RESTful phar file, which are all here:
$ curl -s -L -o restful.phar https://github.com/bninja/restful/downloads/restful.phar
Download a Balanced phar file, which are all here:
$ curl -s -L -o balanced.phar https://github.com/balanced/balanced-php/downloads/balanced-{VERSION}.phar
And then include
all:
<?php
include(__DIR__ . '/httpful.phar');
include(__DIR__ . '/restful.phar');
include(__DIR__ . '/balanced.phar');
...
Source
Download Httpful source:
$ curl -s -L -o httpful.zip https://github.com/nategood/httpful/zipball/master;
$ unzip httpful.zip; mv nategood-httpful* httpful; rm httpful.zip
Download RESTful source:
$ curl -s -L -o restful.zip https://github.com/bninja/restful/zipball/master;
$ unzip restful.zip; mv bninja-restful* restful; rm restful.zips
Download the Balanced source:
$ curl -s -L -o balanced.zip https://github.com/balanced/balanced-php/zipball/master
$ unzip balanced.zip; mv balanced-balanced-php-* balanced; rm balanced.zip
And then require
all bootstrap files:
<?php
require(__DIR__ . "/httpful/bootstrap.php")
require(__DIR__ . "/restful/bootstrap.php")
require(__DIR__ . "/balanced/bootstrap.php")
...
Quickstart
curl -s http://getcomposer.org/installer | php
echo '{
"require": {
"balanced/balanced": "*"
}
}' > composer.json
php composer.phar install
curl https://raw.github.com/balanced/balanced-php/master/example/example.php > example.php
php example.php
curl https://raw.github.com/balanced/balanced-php/master/example/buyer-example.php > buyer-example.php
php -S 127.0.0.1:9321 buyer-example.php
# now open a browser and go to http://127.0.0.1:9321/ to view how to tokenize cards and add to a buyer
Usage
See https://www.balancedpayments.com/docs/overview?language=php for tutorials and documentation.
Testing
$ phpunit --bootstrap vendor/autoload.php tests/
Or if you'd like to skip network calls:
$ phpunit --exclude-group suite --bootstrap vendor/autoload.php tests/
Publishing
- Ensure that all tests pass
- Increment minor
VERSION
insrc/Balanced/Settings
andcomposer.json
(git commit -am 'v{VERSION} release'
) - Tag it (
git tag -a v{VERSION} -m 'v{VERSION} release'
) - Push the tag (
git push --tag
) - Packagist will see the new tag and take it from there
- Build (
build-phar
) and upload a phar file
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Write your code and tests
- Ensure all tests still pass (
phpunit --bootstrap vendor/autoload.php tests/
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new pull request