PHP code example of clearhaus / sdk

1. Go to this page and download the library: Download clearhaus/sdk 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/ */

    

clearhaus / sdk example snippets


use Clearhaus\Client;

$client = new Client($apiKey);

use Clearhaus\Client;

$client->enableSignature();

$authorization = $client->authorizations->authorize([
    'amount' => 2050,
    'currency' => 'EUR',
    'ip' => '1.1.1.1',
    'card' => [
        'number' => '4111111111111111',
        'expire_month' => '06',
        'expire_year' => '2018',
        'csc' => '123',
    ],
]);

$authorization = $client->authorizations->authorizeFromCardId($cardId, [
    'amount' => 2050,
    'currency' => 'EUR',
    'ip' => '1.1.1.1',
]);

$client->captures->capture($authorization['id']);

$client->captures->capture($authorization['id'], ['amount' => 1000]);

$client->refunds->refund($authorization['id']);

$client->refunds->refund($authorization['id'], ['amount' => 500]);

$client->voids->void($authorization['id']);

$client->credits->credit($card['id'], [
    'amount' => 2050,
    'currency' => 'EUR',
]);

$card = $client->cards->createCard([
    'card' => [
        'number' => '4111111111111111',
        'expire_month' => '06',
        'expire_year' => '2018',
        'csc' => '123',
    ],
]);

$account = $client->accounts->getAccount();

$authorization = $client->authorizations->authorize([
    'amount' => 2050,
    'currency' => 'EUR',
    'ip' => '1.1.1.1',
    'card' => [
        'number' => '4111111111111111',
        'expire_month' => '06',
        'expire_year' => '2018',
        'csc' => '123',
    ],
    'threed_secure' => [
        'pares' => '<some-pares-value>',
    ],
]);

use Clearhaus\Container\ClientFactory;

$factory = new ClientFactory();
$client = $factory($psrContainer);

use Clearhaus\Client;

return [
    'clearhaus_sdk' => [
        'api_key' => null, // Allow to provide API key that you will find in your account
        'mode' => Client::MODE_TEST, // Allow to define the usage of either test or live accounts
        'use_signature' => true, // Allow to configure the usage of request signature
        'plugins' => [], // HTTPlug plugins that allow to add some processing logic
    ],
];