reportei / gerencianet-sdk-php-fork
GN API SDK PHP (Guzzle 7)
2.4.1
2020-06-24 11:12 UTC
Requires
- php: >=5.5.0
- guzzlehttp/guzzle: ^6.0.0
Requires (Dev)
- codeclimate/php-test-reporter: ^0.1.2
- phpunit/phpunit: ~4.6
This package is not auto-updated.
Last update: 2024-09-20 07:57:53 UTC
README
Gerencianet Pagamentos API 的 SDK。有关参数和值的更多信息,请参阅 Gerencianet 文档。
安装
使用 composer 安装此包
$ composer require gerencianet/gerencianet-sdk-php
或者将其包含在你的 composer.json 文件中
...
"require": {
"gerencianet/gerencianet-sdk-php": "2.*"
},
...
要求
- PHP >= 5.5
测试
php 5.5, 5.6, 7.0 and 7.1
入门
需要模块和命名空间
require __DIR__ . '/../sdk/vendor/autoload.php'; use Gerencianet\Gerencianet;
尽管 Web 服务响应为 json 格式,但 SDK 会将任何服务器响应转换为数组。代码必须在 try-catch 块中,异常可以按以下方式处理
try { /* code */ } catch(GerencianetException $e) { /* Gerencianet's api errors will come here */ } catch(Exception $ex) { /* Other errors will come here */ }
开发环境
使用你的 client_id、client_secret 和 sandbox 等于 true 来实例化模块
$options = [ 'client_id' => 'client_id', 'client_secret' => 'client_secret', 'sandbox' => true, 'timeout' => 30 ]; $api = new Gerencianet($options);
生产环境
要将环境更改为生产,只需将第三个 sandbox 设置为 false
$options = [ 'client_id' => 'client_id', 'client_secret' => 'client_secret', 'sandbox' => false 'timeout' => 30 ]; $api = new Gerencianet($options);
运行测试
要运行测试,请安装 PHPUnit 并运行以下命令
$ phpunit -c config.xml
运行示例
将 examples/config.json 文件中的 client_id 和 client_secret 替换为你的应用程序的值。
你可以使用任何 Web 服务器(如 Apache 或 nginx)或简单地按照以下方式启动一个 PHP 服务器
php -S localhost:9000
然后在浏览器中打开任何示例。
⚠️ 一些示例需要你更改一些参数才能工作,例如 examples/charge/detail.php,你必须更改 id 参数。
版本说明
附加文档
完整的文档(包括所有可用端点)可在 https://dev.gerencianet.com.br/ 上找到。