eduardo / gerencianet-sdk-php-atualizado
GN API SDK PHP
1.0.11
2016-12-09 19:25 UTC
Requires
- php: >=5.4.0
- codeclimate/php-test-reporter: v0.3.2
- guzzlehttp/guzzle: 6.2.2
Requires (Dev)
- phpunit/phpunit: ~4.6
This package is not auto-updated.
Last update: 2024-09-18 20:33:32 UTC
README
== 非官方 ==
为Gerencianet Pagamentos API提供的SDK。有关参数和值的更多信息,请参阅Gerencianet文档。
安装
使用 composer 安装此包
$ composer require eduardo/gerencianet-sdk-php-atualizado
或者在您的 composer.json 文件中包含它
...
"require": {
"eduardo/gerencianet-sdk-php-atualizado": "1.*"
},
...
要求
- PHP >= 5.4
测试环境
php 5.4 and 5.5
入门指南
需要模块和命名空间
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 ]; $api = new Gerencianet($options);
生产环境
要将环境更改为生产,只需将第三个sandbox设置为false
$options = [ 'client_id' => 'client_id', 'client_secret' => 'client_secret', 'sandbox' => false ]; $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/找到。