codegidi / globalpay
Globalpay PHP library composer
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Type:project
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: 5.2.*
This package is auto-updated.
Last update: 2024-09-11 02:26:31 UTC
README
Globalpay PHP is a library for using the [Globalpay] API for PHP
Installing
composer require codegidi/globalpay
Usage
- The steps for carrying out a transaction is as follows:
-
- Get an access token by calling the Client Authorisation method
-
- Use the access_token to send initiate your transaction by calling the Transaction initiaion method
-
- Redirect to GlobalPay transaction interface using the redirectUri retured in the Transaction initiation call
-
- After transaction has been done, you will be redirected to the provided redirectUrl provided with the transactionReference as a querystring
-
- Validate the result by using the Retrieve transaction call
Client Authentication
require_once __DIR__ . '/../vendor/autoload.php';
use GlobalPay\Authentication;
$clientAuth = new GlobalPay_Authentication({optional BOOL isLive : #true for for live enviroment and false for staging default value false});
$clientAuthResponse = $clientAuth->Client({client id},{client secret});
if(!isset($clientAuthResponse['error'])){
$access_token = $clientAuthResponse['access_token'];
} else {
echo $clientAuthResponse['error'];
}
Transaction Initialization
require_once __DIR__ . '/../vendor/autoload.php';
use GlobalPay\Transaction;
$transactionInit = new GlobalPay_Transaction({Access_token},{optional BOOL isLive : #true for for live enviroment and false for staging default value false});
$transactionResponse = $transactionInit->initiation({{return url},{merchant reference},merchant id},{description},{total amount in minor},{currency code i.e NGN for naira},{customer email},{customer number},{customer firstname},{customer lastname});
if(!isset($transactionResponse['error'])){
header("location:" . $transactionResponse['redirectUri '])
} else {
echo $transactionResponse['error'];
}
Transaction Verification
require_once __DIR__ . '/../vendor/autoload.php';
use GlobalPay\Transaction;
$transaction = new GlobalPay_Transaction({Access_token},{optional BOOL isLive : #true for for live enviroment and false for staging default value false});
$transactionResponse = $transactionInit->verification({merchant id}, {merchant reference}, {transaction reference});
if(!isset($transactionResponse['error'])){
print_r($transactionResponse);
} else {
echo $transactionResponse['error'];
}