jpaypp / gbas-php
gbas php Library
Requires
- php: >=5.6.0
- ext-bcmath: *
- ext-curl: *
- ext-json: *
- ext-mbstring: *
This package is auto-updated.
Last update: 2025-03-18 21:06:05 UTC
README
You can sign up for a GBasJPay account at https://www.gba.one.
Requirements
PHP 5.6.0 and later.
Composer
You can install the bindings via Composer. Run the following command:
composer require jpaypp/gbas-php
To use the bindings, use Composer's autoload:
require_once('vendor/autoload.php');
Manual Installation
If you do not wish to use Composer, you can download the latest release. Then, to use the bindings, include the init.php
file.
require_once('/path/to/jpay-php/init.php');
Dependencies
The bindings require the following extensions in order to work properly:
If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available.
Getting Started
Simple usage looks like:
\GBasJPay\GBasJPay::setDebug(true); //调试模式 true /false \GBasJPay\GBasJPay::setApiMode('sandbox'); //环境 live 线上,sandbox 沙盒 \GBasJPay\GBasJPay::setClientId('10000000'); // 设置 CLIENT ID \GBasJPay\GBasJPay::setApiKey('BQokikJOvBiI2HlWgH4olfQ2'); // 设置 API Key try { $ch = \GBasJPay\Charge::create([ 'channel' => '901', // 支付使用的第三方支付渠道取值 'out_order_no' => time(), //外部订单号 ,为空时由系统生成 'product' =>[ //商品信息 'subject' => '测试商品', //商品名称 'body' => '测试商品', //商品描述 'amount' => '1', // 订单总金额 'quantity' => '1' //商品数量 ], 'extra' =>[ //扩展信息 'mode' => 'mweb', //微信渠道901 ,支付模式,jsapi 微信公众号、native 扫码支付、mweb H5 支付 ,link 返回支付链接跳转 'format' => 'json', //返回方式 from 表单直接提交/ json 返回 ], 'metadata' => '自定义数据', 'client_ip' => '1.1.1.1', //客户端发起支付请求的IP 'description' => '测试数据', //订单备注说明 'notify'=> 'http://localhost/notify.html', //异步通知地址 'return'=>'http://localhost/callback.html', //同步地址 ]); echo $ch; // 输出 返回的支付凭据 Charge } catch (\GBasJPay\Error\Base $e) { // 捕获报错信息 if ($e->getHttpStatus() != null) { header('Status: ' . $e->getHttpStatus()); echo $e->getHttpBody(); } else { echo $e->getMessage(); } }
Documentation
Please see https://www.gba.one/api for up-to-date documentation.
Development
Get [Composer][composer]. For example, on Mac OS:
brew install composer
Install dependencies:
composer install
Install dependencies as mentioned above (which will resolve PHPUnit), then you can run the test suite:
./vendor/bin/phpunit
Or to run an individual test file:
./vendor/bin/phpunit tests/UtilTest.php
The method should be called once, before any request is sent to the API. The second and third parameters are optional.