PHP code example of orbifinancial / pay-gateway

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

    

orbifinancial / pay-gateway example snippets


use Orbi\PayGateway\Orbi;

$orbi = Orbi::create([
    'baseUrl' => getenv('ORBI_PAY_GATEWAY_BASE_URL'),
    'serviceKey' => getenv('ORBI_PAY_SERVICE_KEY'),
    'authMode' => 'access_token',
    'environment' => getenv('ORBI_PAY_ENVIRONMENT') ?: 'Demo',
]);

$intent = $orbi->transfers()->send([
    'reference' => 'ORDER-10001',
    'amount' => 125000,
    'currency' => 'TZS',
    'description' => 'Protected checkout',
    'customer' => ['phone' => '+255700000000'],
    'returnUrl' => getenv('ORBI_PAY_RETURN_URL'),
    'cancelUrl' => getenv('ORBI_PAY_CANCEL_URL'),
    'callbackUrl' => getenv('ORBI_PAY_WEBHOOK_URL'),
], [
    'idempotencyKey' => 'payment-intent:merchant:ORDER-10001',
]);

$metadata = $orbi->oauth()->metadata();
echo $metadata['token_endpoint'];

$state = $orbi->oauth()->introspect($accessToken);
if (!$state['active']) {
    // Request a fresh token before making financial requests.
}

$orbi->oauth()->revoke($accessToken);

use Orbi\PayGateway\Webhooks;

$event = Webhooks::verifyAndParse([
    'rawBody' => file_get_contents('php://input'),
    'signatureHeader' => $_SERVER['HTTP_X_ORBI_PAY_SIGNATURE'] ?? '',
    'timestampHeader' => $_SERVER['HTTP_X_ORBI_PAY_TIMESTAMP'] ?? '',
    'secret' => getenv('ORBI_PAY_WEBHOOK_SECRET'),
]);