Mango PHP Library
This is a PHP library that allows interaction with Mango API, (*1)
Installation
Dependencies
* PHP 5.3+
Install with Composer
If you're using Composer, add this to
your composer.json require:, (*2)
{
"require" : {
"mango/mango-php" : "dev-master"
}
}
And load it using Composer's autoloader, (*3)
require 'vendor/autoload.php';
Install from GitHub
To install the source code:, (*4)
$ git clone git@github.com:mango/mango-php.git
Include mango-php in your code and autoload requests:, (*5)
require_once '/path/to/mango-php/mango.php';
require_once '/path/to/rmccue/requests/Requests.php';
Requests::register_autoloader();
Documentation
Documentation is available at https://developers.getmango.com/en/api/?platform=php, (*6)
Usage
Set your secret API key:
$mango = new Mango\Mango(array(
"api_key" => "YOUR_SECRET_API_KEY"
));
Create a customer
In order to create a Customer, you must call the create() method with the required arguments., (*7)
$customer = $mango->Customers->create(array(
"email" => "test-php@example.org",
"name" => "Test Customer"
));
var_dump($customer);
Get single customer
When you have a customer uid, you can get a full detail using the get() method:, (*8)
$customer = $mango->Customers->get("customer_1uqh884oy1ujh9y9eatm0jo3zxu0rm2s");
var_dump($customer);
You can also work with all the other resources authenticated with a secret API Key:
- Charges
- Refunds
- Customers
- Cards
- Queue
- Installments
- Promotions
- Coupons, (*9)
Tests
Install the module along with the dev dependencies using composer:, (*10)
$ git clone git://github.com/mango/mango-php.git
$ cd mango-php
$ composer install
To run the tests you'll need Mango API keys (mode Sandbox):, (*11)
export MANGO_SECRET_TEST_KEY='your secret test API key'
export MANGO_PUBLIC_TEST_KEY='your public test API Key'
Run the tests
$ phpunit test
Run code coverage
To run the code coverage you'll need Xdebug, (*12)
$ phpunit --coverage-html coverage
License
Licensed under the MIT license., (*13)
Copyright (c) 2014 Mango., (*14)