keeguon / phaybox
Phaybox 是一个用 PHP 编写的库,它允许电子商务网站轻松地与 Paybox API 交互。
1.2.1
2013-08-26 09:52 UTC
Requires
- php: >=5.3.2
Requires (Dev)
- phpunit/phpunit: 3.7.*
- symfony/class-loader: *
This package is not auto-updated.
Last update: 2024-09-14 12:41:36 UTC
README
Phaybox 是一个用 PHP 编写的库,它允许电子商务网站轻松地与 Paybox API 交互。
要求
- PHP 5.3.x
安装
使用 composer
要使用 composer 安装 Phaybox,您只需在项目根目录中创建一个 composer.json 文件,并添加以下内容:
{
"require": {
"keeguon/phaybox"
}
}
然后运行
$ wget --quiet https://getcomposer.org.cn/composer.phar
$ php composer.phar install --install-suggest
现在您已经将 Phaybox 安装在 vendor/friendspray/phaybox 中
还有一个方便的自动加载文件,您需要将其包含到您项目的 vendor/.composer/autoload.php 中
使用 git
要使用 git 安装 Phaybox,只需运行以下命令
$ git clone https://github.com/Keeguon/Phaybox.git --recursive
测试
该库已完全通过 PHPUnit 进行单元测试。要运行测试,您需要在您的系统上安装 PHPUnit。
转到基本库文件夹并运行测试套件
$ phpunit
代码风格
- Phaybox 遵循大多数 Symfony2 编码标准
如何使用
<?php
use Phaybox\Client;
$client = new Client('your_client_id', 'your_client_secret', 'your_client_rang', 'your_client_site', array(
'algorithm' => '' // Optional, see hash_algos(), defaults to 'sha512'
, 'callback' => '' // Optional, see PBX_RETOUR in the Paybox documentation, defaults to 'Amt:M;Ref:R;Auth:A;Err:E'
, 'path_prefix' => '' // Optional, the path which prefix the different phases for HTTP transactions, defaults to 'paybox'
, 'request_path' => '' // Optional, the path pointing to the request phase
, 'callback_path' => '' // Optional, the path pointing to the callback phase
));
$transaction = $client->getTransaction(array(
'PBX_TOTAL' => 0000 // required
, 'PBX_DEVISE' => 978 // required
, 'PBX_CMD' => 'test' // required
, 'PBX_PORTEUR' => 'me@mail.com' // required
, // optional params...
));
$formFields = $transaction->getFormattedParams();
使用上述代码片段应提供您表单中所需的字段(您仍然需要根据 Paybox 文档对其中一些进行 URL 编码)。
可选字段将位于 HMAC 签名之前但之后,并且它们应该按照您在表单中输入的顺序排列(参见 Paybox 文档中的 4.3)。
有关更多信息,示例文件夹中有详尽的示例。