PHP code example of duronrulez / ginger-php

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

    

duronrulez / ginger-php example snippets


spl_autoload_register(function($class) {
    $prefix = 'GingerPayments\\Payment\\';

    if (!substr($class, 0, 23) === $prefix) {
        return;
    }

    $class = substr($class, strlen($prefix));
    $location = __DIR__ . 'path/to/gingerpayments/ginger-php/src/' . str_replace('\\', '/', $class) . '.php';

    if (is_file($location)) {
        

use \GingerPayments\Payment\Ginger;

$client = Ginger::createClient('your-api-key');

$order = $client->createOrder(
    2500,                           // The amount in cents
    'EUR',                          // The currency
    'ideal',                        // The payment method
    ['issuer_id' => 'INGBNL2A'],    // Extra details expiration period in ISO 8601 format (optional)
);

$order = $client->createIdealOrder(
    2500,                           // The amount in cents
    'EUR',                          // The currency
    'INGBNL2A',                     // The iDEAL issuer
    'A great order',                // A description (optional)
    'order-234192',                 // Your identifier for the order (optional)
    'http://www.example.com',       // The return URL (optional)
    'PT15M'                         // The expiration period in ISO 8601 format (optional)
);

$order = $client->createCreditCardOrder(
    2500,                           // The amount in cents
    'EUR',                          // The currency
    'A great order',                // A description (optional)
    'order-234192',                 // Your identifier for the order (optional)
    'http://www.example.com',       // The return URL (optional)
    'PT15M'                         // The expiration period in ISO 8601 format (optional)
);

$paymentUrl = $order->firstTransactionPaymentUrl();

$orderId = $order->id();

$order = $client->getOrder($orderId);

foreach ($order->transactions() as $transaction) {
    $transaction->status()->isCompleted(); // Check the status
    $transaction->amount(); // How much paid
}

$issuers = $client->getIdealIssuers();

composer