codegidi/globalpay

该包最新版本(dev-master)没有可用的许可信息。

Globalpay PHP 库 composer

dev-master 2019-01-07 10:10 UTC

This package is auto-updated.

Last update: 2024-09-11 02:26:31 UTC


README

Globalpay PHP 是一个用于PHP的 [Globalpay] API 库。

安装

composer require codegidi/globalpay

使用方法

  • 执行交易步骤如下
    1. 通过调用客户端授权方法获取访问令牌
    1. 使用 access_token 通过调用交易初始化方法发起交易
    1. 使用 Transaction 初始化调用返回的 redirectUri 跳转到 GlobalPay 交易界面
    1. 交易完成后,您将被重定向到包含交易引用作为查询字符串的 redirectUrl
    1. 通过使用检索交易调用验证结果

客户端认证

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'];
}
交易初始化
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'];
}
交易验证
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'];
}