betacie/mangopay-sdk

This package is abandoned and no longer maintained. No replacement package was suggested.

MangoPay PHP SDK

v0.3.0 2014-03-25 10:03 UTC

This package is not auto-updated.

Last update: 2016-06-19 08:35:50 UTC


README

PHP SDK to use MangoPay API. mangopay-sdk integrate Guzzle for all the cURL requests. We only creates a plugin names LeetchiPlugin which will sign all your requests to the MangoPay API.

Installation

The recommended way to install mangopay-sdk is through Composer

composer require "betacie/mangopay-sdk": "dev-master"
composer update betacie/mangopay-sdk

Configuration

To request the API, you need to instantiate a Guzzle Client and add him the dedicated plugin.

<?php

use Betacie\MangoPay\LeetchiPlugin;
use Guzzle\Http\Client;

$client = new Client('https://api.leetchi.com/v1/partner/{partnerId}/', array(
    'partnerId'                 => 'your_partner_id',
    'ssl.certificate_authority' => false,
    'request.options'           => array(
        'headers' => array('Content-Type' => 'application/json'),
    )
));

$plugin = new LeetchiPlugin('private_key_path', 'private_key_passphrase');
$client->addSubscriber($plugin);

Now you can use the API.

Usage

Now all you need, is to create a message. For exemple if you need to create an user you only have to write the following code.

<?php

use Betacie\MangoPay\Message\UserRequest;

//You already have created your client with the plugin.

$message = new UserRequest($client);
$response = $message->create(array(
    'Email' => 'j.doe@email.tld',
    'FirstName' => 'John',
    'LastName' => 'Doe',
    'IP' => '127.0.0.1',
    ...
));

$data = $response->json();

All message methods return a GuzzleResponse.