PHP code example of inverseschool / omnipay-digipay
1. Go to this page and download the library: Download inverseschool/omnipay-digipay 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/ */
inverseschool / omnipay-digipay example snippets
$this->gateway = new Gateway(
new Client(new \Http\Adapter\Guzzle7\Client()),
);
$amount = 60;
$customerPhone = '09xxxxxxxxx';
/** @var CreateOrderResponse $response */
$response = $this->gateway->purchase([
'amount' => $amount,
'phoneNumber' => $customerPhone,
'transactionId' => rand(1111111, 99999999),
'returnUrl' => 'http://localhost/return',
'products' => [192, 193, 194],
'cartId' => 180
])->send();
if ($response->isSuccessful() && $response->isRedirect()) {
// store the transaction reference to use in completePurchase()
$transactionReference = $response->getTransactionReference();
// Redirect to offsite payment gateway
$response->redirect();
} else {
// Payment failed: display message to customer
echo $response->getMessage();
}