Sdk for Gerencianet Pagamentos' API. For more informations about parameters and values, please refer to Gerencianet documentation.
Require this package with composer:
$ composer require gerencianet/gerencianet-sdk-php
Or include it in your composer.json file:
...
"require": {
"gerencianet/gerencianet-sdk-php": "2.*"
},
...
- PHP >= 5.5
php 5.5, 5.6, 7.0 and 7.1
Require the module and namespaces:
require __DIR__ . '/../sdk/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 */
}
Instantiate the module passing using your client_id, client_secret and sandbox equals true:
$options = [
'client_id' => 'client_id',
'client_secret' => 'client_secret',
'sandbox' => true,
'timeout' => 30
];
$api = new Gerencianet($options);
To change the environment to production, just set the third sandbox to false:
$options = [
'client_id' => 'client_id',
'client_secret' => 'client_secret',
'sandbox' => false
'timeout' => 30
];
$api = new Gerencianet($options);
To run tests install PHPUnit and run the following command:
$ phpunit -c config.xml
Update examples/config.json file with client_id and client_secret of your application.
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.
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 |
The full documentation with all available endpoints is in https://dev.gerencianet.com.br/.