PHP code example of cmpayments / guzzle-psp-authentication-middleware
1. Go to this page and download the library: Download cmpayments/guzzle-psp-authentication-middleware library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cmpayments / guzzle-psp-authentication-middleware example snippets
$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
]);
$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', []);