PHP code example of gingerpayments / ginger-php
1. Go to this page and download the library: Download gingerpayments/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/ */
gingerpayments / ginger-php example snippets
spl_autoload_register(
function($fqcn) {
if (substr($fqcn, 0, 7) === 'Ginger\\') {
return;
}
$pathToGinger = __DIR__ . '/relative/path/to/ginger';
$class = substr($fqcn, 7);
$path = sprintf('%s/src/%s.php', $pathToGinger, str_replace('\\', '/', $class));
if (is_file($path)) {
use \Ginger\Ginger;
$client = Ginger::createClient('https://api.example.com', 'your-api-key');
$order = $client->createOrder(
[
'merchant_order_id' => 'my-custom-order-id-12345',
'currency' => 'EUR',
'amount' => 2500, // Amount in cents
'description' => 'Purchase order 12345',
'return_url' => 'https://www.example.com',
'transactions' => [
[
'payment_method' => 'credit-card'
]
]
]
);
$paymentUrl = $order['order_url'];
$orderId = $order['id'];
$order = $client->getOrder($orderId);
$order = $client->getOrder($orderId);
$order['description'] = "New Order Description";
$updatedOrder = $client->updateOrder($orderId, $order);
$refundOrder = $client->refundOrder($orderId, ['amount' => 123, 'description' => 'My refund']);
$issuers = $client->getIdealIssuers();
$currencies = $client->getCurrencyList();
$result = $client->send(
'POST', // Request method
'/orders', // API path
$orderData // Data to send with the request; optional
);
use \Ginger\Ginger;
$client = Ginger::createClient(
'https://api.example.com',
'your-api-key',
[
CURLOPT_CAINFO => '/path/to/ca-bundle.pem'
]
);
$myHttpClient = new MyHttpClient();
$client = new Ginger\ApiClient($myHttpClient);
composer