marcelo-correa/gerencianet-sdk-php

1.0.0 2020-09-23 11:29 UTC

This package is auto-updated.

Last update: 2024-09-24 00:39:56 UTC


README

Gerencianet Pagamentos' API 的 SDK。有关参数和值的更多信息,请参阅Gerencianet文档。

Build Status Code Climate Test Coverage

安装

使用 composer 安装此包

$ composer require marcelo-correa/gerencianet-sdk-php

或在您的 composer.json 文件中包含它

...
"require": {
  "marcelo-correa/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;

尽管网络服务响应为 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

然后在浏览器中打开任何示例。

:warning: 一些示例需要您更改某些参数才能运行,例如 examples/charge/detail.php,其中您必须更改 id 参数。

版本指南

版本状态Packagist仓库PHP 版本
1.x维护中gerencianet/gerencianet-sdk-phpv1>= 5.4
2.x维护中gerencianet/gerencianet-sdk-phpv2>= 5.5

附加文档

完整文档和所有可用端点在 https://dev.gerencianet.com.br/

许可

MIT