PHP code example of machour / clictopay

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

    

machour / clictopay example snippets


use Machour\ClicToPay\Gateway;
use Machour\ClicToPay\Exception;

$ctp = new Gateway('login', 'password');

try {
    $response = $ctp->register([
        'amount' => 10000,
        'orderNumber' => '123456',
        'description' => 'Pack Standard',
        'returnUrl' => 'https://example.com/success',
    ]);
    
    // store $response->orderId and then
    header('Location: ' . $response->formUrl);
    exit;
    
} catch (Exception $e) {
    
}

/**
 * Authorization request
 *
 * @param array $params
 * @return UrlResponse
 * @throws Exception
 */
public function register(array $params): UrlResponse