9pay / wallet
用于连接到钱包9pay的库
1.0.0
2018-11-29 08:49 UTC
Requires
- php: >=5.3.0
- guzzlehttp/guzzle: ~6.0
This package is auto-updated.
Last update: 2024-09-29 05:02:15 UTC
README
9pay钱包是一个通过9pay钱包连接到支付系统的库,适用于商家
要求
- PHP >= 5.3
入门
安装
使用Composer进行安装。只需添加Packagist依赖即可
"require": { // ... "9pay/wallet": ">=1.0.0" }
或者,如果您想直接从GitHub获取,可以将以下内容添加到您的composer.json中
"require": { // ... "9pay/wallet": "dev-master" }
如果您没有composer.json文件,请使用以下内容
composer require 9pay/wallet
用法
配置
支持库使用两种类型的配置文件或数组。
- 文件配置
$path = '/app/config';
您需要创建一个配置文件,文件名与您要使用的环境名称相同。以下是一些带有应用程序配置选项的文件示例
sand.php
return array( 'url' => 'https://example.com', 'api_key' => 'api_key', 'version' => '2.1' );
production.php
return array( 'url' => 'https://example.com', 'api_key' => 'api_key', 'version' => '2.1' );
- 数组配置
您可以直接使用数组配置。例如
$config = array( 'url' => 'https://example.com', 'api_key' => 'api_key', 'version' => '2.1' );
方法
- create: 在9pay钱包中创建一个支付
- query: 获取9pay钱包中支付的信息
示例代码
use Ninepay\Api\Wallet; $config = array( 'url' => 'https://example.com', 'api_key' => 'api_key', 'version' => '2.1' ); $wallet = new Wallet($config); $attr = array( 'payment_no' => '123456', 'amount' => '10000', 'description' => 'This is test order', 'return_url' => 'https://example.com' ); $res = $wallet->create($attr);
如果您使用数组配置,则不需要设置环境。如果您使用文件配置,则可以通过以下方式设置要使用的环境
$wallet = new Wallet($path, 'sand');
如果您没有设置环境,则库将默认使用sand