Guzzle Authentication Middleware
![Scrutinizer][badge-quality]
![Total Downloads][badge-downloads]
[
][coverage], (*1)
This middleware implements the authentication part of a guzzle request to the CM Payments PSP-api., (*2)
This library is compatible with PHP 5.5+ and PHP 7.0, but requires the Guzzle, PHP HTTP client version ^6.0 or ^7.0, (*3)
Installation
To install cmpayments/guzzle-psp-authentication-middleware just require it with composer:, (*4)
# composer require cmpayments/guzzle-psp-authentication-middleware
Usage examples
Below an example in order to request an iDEAL-transaction via a POST-request., (*5)
<?php
$key = 'Your-OAuth-Consumer-Key';
$secret = 'Your-OAuth-Consumer-Secret';
$body = [
'amount' => 15.95,
'currency' => 'EUR',
'payments' => [
[
'amount' => 15.95,
'currency' => 'EUR',
'payment_method' => 'iDEAL',
'payment_details' => [
'issuer_id' => 'RABONL2U',
'purchase_id' => 'unqiue' . (new \DateTime())->format('YmdHis'),
'description' => 'Transaction description',
'success_url' => 'http://www.yourdomain.com/ideal/success',
'failed_url' => 'http://www.yourdomain.com/ideal/failed',
'cancelled_url' => 'http://www.yourdomain.com/ideal/cancelled',
'expired_url' => 'http://www.yourdomain.com/ideal/expired'
]
],
],
];
$stack = HandlerStack::create();
$authenticationMiddleware = new AuthenticationMiddleware($key, $secret);
$stack->push($authenticationMiddleware);
$client = new Client(['base_uri' => 'https://api.cmpayments.com/', 'handler' => $stack]);
$response = $client->request('POST', 'charges/v1', [
'json' => $body
]);
Below an example in order to request the iDEAL-issuers list via a GET-request., (*6)
<?php
$key = 'Your-OAuth-Consumer-Key';
$secret = 'Your-OAuth-Consumer-Secret';
$stack = HandlerStack::create();
$authenticationMiddleware = new AuthenticationMiddleware($key, $secret);
$stack->push($authenticationMiddleware);
$client = new Client(['base_uri' => 'https://api.cmpayments.com/', 'handler' => $stack]);
$response = $client->request('GET', 'issuers/v1/ideal', []);
Submitting bugs and feature requests
Bugs and feature request are tracked on GitHub, (*7)
Copyright and license
The cmpayment/guzzle-psp-authentication-middleware library is copyright © CM Payments and licensed for use under the MIT License (MIT). Please see LICENSE for more information., (*8)