onubrooks/glade-pay

一个使用 Glade API 通过银行转账选项进行支付的小型 PHP 库/包。

v1.2 2021-02-21 16:58 UTC

This package is auto-updated.

Last update: 2024-09-22 00:38:19 UTC


README

一个使用 Glade API 通过银行转账选项进行支付的小型 PHP 库/包。

入门指南

要使用此包,您需要在机器上安装 PHP 和 composer。建议使用最新版本。

安装

您可以将此项目克隆到您的项目中,并在项目中包含该类,或者将依赖项添加到您的 composer.json 文件中,如下例所示

{
    "require": {
        "onubrooks/glade-pay": "^1.0.0"
    }
}

或者在您的项目中运行以下命令

composer require onubrooks/glade-pay

用法

实例化 GladePay 类

require_once __DIR__ . '/vendor/autoload.php';

use onubrooks\GladePay\GladePay;

$glade = new GladePay();

使用银行转账支付

$amount = 30000;
$user_data = '
{
    "firstname":"John",
    "lastname":"Wick",
    "email":"wick@gladeuniverse.com",
    "ip":"192.168.10.5",
    "fingerprint": "cccvxbxbxbc"
}
';
$business_name = "Happy Glade Customer";
$user = json_decode($user_data);

//Initiate a bank transfer Transaction, country and currency are optional and defaults to 'NG' and 'NGN'
// user and business_name are also optional
$transaction = $glade->bankTransfer($amount, $user, $business_name);

//After the transaction is completed, verify to confirm final status.
$verification = $glade->verify("GP61548131820210220X");

返回值

所有方法都返回一个数组。

以下是从 bankTransfer 方法返回的数组中的字段,以及示例返回值

{
  "status": 202,
  "txnRef": "GP61548131820210220X",
  "auth_type": "device",
  "accountNumber": "9922554842",
  "accountName": "GladePay Demo",
  "bankName": "Providus Bank",
  "accountExpires": 600,
  "message": "Make a transfer into the following account using your bank app or internet banking platfrom to complete the transaction"
}

对于验证方法,以下是数组中返回的值的示例

{
  "status": 200,
  "txnStatus": "pending",
  "txnRef": "GP9225324020210220G",
  "message": "PENDING",
  "chargedAmount": 0,
  "currency": "NGN",
  "payment_method": "bank_transfer",
  "fullname": "John Wick",
  "email": "wick@gladeuniverse.com",
  "bank_message": "Awaiting Validation"
}

运行测试

您可以使用以下命令在 Windows 命令行中运行测试用例

php vendor/phpunit/phpunit/phpunit --bootstrap vendor/autoload.php tests

对于 bash 用户,请使用以下命令

php vendor/bin/phpunit --bootstrap vendor/autoload.php tests

在此 GitHub 个人资料 中找到作者的其他仓库。