PHP code example of gifddo / client

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

    

gifddo / client example snippets


$merchantId = 'MERCHANTID'; // The ID you received from Gifddo
$privateKey = file_get_contents('privkey.pem'); // Change the path as needed
$testMode = false; // Set to true to use the test environment

$gifddo = new \Gifddo\Client($merchantId, $privateKey, $testMode);

// Redirect the browser automatically
$gifddo->request($params);

// Or, alternatively, only return the request URL:
$url = $gifddo->request($params, true);

> $response = [
>     'url' => $client->getUrl(),
>     'params' => $params,
> ];
> 

// Verify the signature:
if (!$gifddo->verify($_REQUEST, $_REQUEST['VK_MAC'])) {
    // do something to indicate that message signature verification failed
}

// Record the payment status update here
$paymentId = $_REQUEST['VK_STAMP'];
// ...

// Display success or fail message to the user (or redirect the browser)
switch ($_REQUEST['VK_SERVICE']) {
    case \Gifddo\Client::SUCCESSFUL_RESPONSE_CODE:
        if ($_REQUEST['VK_AUTO'] === 'N') {
            echo 'Payment completed';
        }
        break;

    case \Gifddo\Client::UNSUCCESSFUL_RESPONSE_CODE:
        if ($_REQUEST['VK_AUTO'] === 'N') {
            echo 'Payment failed';
        }
        break;
}