smartdog23/gerencianet-sdk-php
Composer 安装命令:
composer require smartdog23/gerencianet-sdk-php
包简介
GN API SDK PHP
README 文档
README
Sdk for Gerencianet Pagamentos' API. For more informations about parameters and values, please refer to Gerencianet documentation.
Installation
Require this package with composer:
$ composer require gerencianet/gerencianet-sdk-php
Or include it in your composer.json file:
...
"require": {
"gerencianet/gerencianet-sdk-php": "3.*"
},
...
Install the dependencies
$ composer install
Requirements
- PHP >= 5.6
- Extension ext-simplexml
Tested with
php 5.6 and 7.X
Getting started
Require the module and namespaces:
require __DIR__ . '/vendor/autoload.php'; use Gerencianet\Gerencianet;
Although the web services responses are in json format, the sdk will convert any server response to array. The code must be within a try-catch and exceptions can be handled as follow:
try { /* code */ } catch(GerencianetException $e) { /* Gerencianet's api errors will come here */ } catch(Exception $ex) { /* Other errors will come here */ }
To begin, you must configure the parameters in the config.json file. Instantiate the information client_id, client_secret for your application and sandbox equal to true, if your environment is Homologation, or false, if it is Production. If you use Pix charges, inform in the attribute pix_cert the directory and name of your certificate in .pem format.
For development environment
Instantiate the module passing using your client_id, client_secret and sandbox equals true:
$options = [ 'client_id' => 'client_id', 'client_secret' => 'client_secret', 'pix_cert' => '../certs/developmentCertificate.pem', 'sandbox' => true, 'debug' => false, 'timeout' => 30 ]; $api = new Gerencianet($options);
For production environment
To change the environment to production, just set the third sandbox to false:
$options = [ 'client_id' => 'client_id', 'client_secret' => 'client_secret', 'pix_cert' => '../certs/productionCertificate.pem', 'sandbox' => false, 'debug' => false, 'timeout' => 30 ]; $api = new Gerencianet($options);
To generate your certificate open a ticket at https://gerencianet.com.br/fale-conosco informing your account number, application name and environment (Homologation/Production). Our team will return with the .p12 certificate for you to consume the endpoints.
For use in PHP, the certificate must be converted to .pem. Below you will find example using the OpenSSL command for conversion.
Command OpenSSL
// Gerar certificado e chave em único arquivo
openssl pkcs12 -in certificado.p12 -out certificado.pem -nodes
Running examples
You can run using any web server, like Apache or nginx, or simple start a php server as follow:
php -S localhost:9000
Then open any example in your browser.
⚠️ Some examples require you to change some parameters to work, like examples/charge/oneStepBillet.php or examples/pix/charge/create.php where you must change the id parameter.
Version Guidance
| Version | Status | Packagist | Repo | PHP Version |
|---|---|---|---|---|
| 1.x | Maintained | gerencianet/gerencianet-sdk-php |
v1 | >= 5.4 |
| 2.x | Maintained | gerencianet/gerencianet-sdk-php |
v2 | >= 5.5 |
| 3.x | Maintained | gerencianet/gerencianet-sdk-php |
v3 | >= 5.6 |
Additional Documentation
The full documentation with all available endpoints is in https://dev.gerencianet.com.br/.
License
smartdog23/gerencianet-sdk-php 适用场景与选型建议
smartdog23/gerencianet-sdk-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 02 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 smartdog23/gerencianet-sdk-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 smartdog23/gerencianet-sdk-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-02-19