PHP code example of pwparsons / paygate

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

    

pwparsons / paygate example snippets


// Initiate transaction
$http = PayGate::initiate()
               ->withReference('pgtest_123456789')
               ->withAmount(32.99)
               ->withEmail('[email protected]')
               ->withCurrency('USD') // Optional: defaults to ZAR
               ->withCountry('USA') // Optional: defaults to ZAF
               ->withLocale('en-us') // Optional: defaults to 'en'
               ->withReturnUrl('https://website.com/return_url')
               ->withNotifyUrl('https://website.com/notify_url') // Optional
               ->create();

if ($http->fails()) {
    dump($http->getErrorCode());
    dump($http->getErrorMessage());
    dump($http->all());
}

// Redirect to PayGate's payment page
return PayGate::redirect();

$http = PayGate::query()
               ->withPayRequestId('YOUR_PAY_REQUEST_ID_HERE')
               ->withReference('pgtest_123456789')
               ->create();

if ($http->fails()) {
    dump($http->getErrorCode());
    dump($http->getErrorMessage());
    dump($http->all());
}

dd($http->all());

class VerifyCsrfToken extends Middleware
{
    protected $except = [
        'return_url',
        'notify_url',
    ];
}

$object->withReference('pgtest_123456789')
       ->withAmount(32.99)
       ->withEmail('[email protected]')
       ->withReturnUrl('https://my.return.url/page');

echo $object->getPaygateId();       // 10011072130
echo $object->getPayRequestId();    // 23B785AE-C96C-32AF-4879-D2C9363DB6E8
echo $object->getReference();       // pgtest_123456789
bash
php artisan vendor:publish --tag=paygate.config