PHP code example of khalesartem / mtls-hmac-client

1. Go to this page and download the library: Download khalesartem/mtls-hmac-client 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/ */

    

khalesartem / mtls-hmac-client example snippets


use Payment\MtlsHmac\Client\GatewayClient;
use Payment\MtlsHmac\Config\GatewayConfig;

$config = new GatewayConfig(
    hmacSecret: 'my-secret',
    certPath: '/path/client-cert.pem',
    keyPath: '/path/client-key.pem',
    keyPassphrase: 'badssl.com', // optional
    verify: true,
    hmacAlgo: 'sha256',
    signatureHeader: 'X-Signature',
);

$client = new GatewayClient($config);
$response = $client->get('https://client.badssl.com/', [
    'transaction_id' => '12345',
    'amount' => '99.99',
    'currency' => 'USD',
]);

echo $response->getStatusCode();
echo (string) $response->getBody();
bash
php example.php