PHP code example of ihatehandles / gava-php-client
1. Go to this page and download the library: Download ihatehandles/gava-php-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/ */
new Gava\Gava('http://gava.dev', '12345678');
try
{
$checkout = $g->processWebhook();
}
catch(Gava\Exceptions\WebhookException $e)
{
//Handle how you want. Or simply ignore, because Gava will resend another notification later
}
//We get here, the checkout is valid and paid, and you can fetch its details
$order = $checkout->reference;
= new Gava\Gava('http://gava.dev', '12345678');
$checkout = $gava->fetchCheckout('abcdefg');
if (!$checkout->paid) {
//Do stuff
}
new Gava\Gava('http://gava.dev', '12345678');
//Let's assume the user submits the reference number for their transfer in a form
$refNo = $_POST['refNo'];
$checkoutUrl = $g->createCheckout(
$reference = 1,
$amount = 1.00,
$returnUrl = 'http://example.com/thankyou',
$cancelUrl = 'http://example.com.cart',
//We don't need the phone
$phone = null,
//We pass the reference number to Gava
$transactionCode = $refNo,
//And let Gava know this is a ZIPIT payment
$method = 'ZIPIT'
);
//We can drop off processing at this point since Gava will notify your webhook URL. But for fun we can:
$checkoutHash = $g->hashFromURL($checkoutUrl);
$checkout = $g->fetchCheckout($checkoutHash);
if ($checkout->paid) {
echo "Thank you for you payment";
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.