cmpayments / guzzle-psp-authentication-middleware
Guzzle middleware which adds authentication-header to Guzzle-requests.
Installs: 7 456
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=5.5.0
- guzzlehttp/guzzle: ^6.0 || ^7.0
Requires (Dev)
- jakub-onderka/php-parallel-lint: ^0.9.0
- phpunit/phpunit: ^4.7|>=5.0 <5.4
- squizlabs/php_codesniffer: ^2.3
This package is auto-updated.
Last update: 2024-11-07 18:42:48 UTC
README
This middleware implements the authentication part of a guzzle request to the CM Payments PSP-api.
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
Installation
To install cmpayments/guzzle-psp-authentication-middleware just require it with composer:
# composer require cmpayments/guzzle-psp-authentication-middleware
Usage examples
Below an example in order to request an iDEAL-transaction via a POST-request.
<?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.
<?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
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.