Skip to content

brunomarciof/gn-api-sdk-php

 
 

Repository files navigation

SDK GERENCIANET FOR PHP

Sdk for Gerencianet Pagamentos' API. For more informations about parameters and values, please refer to Gerencianet documentation.

⚠️ Gerencianet API is under BETA version, meaning that it's not available for all users right now. If you're interested, you can always send an email to suportetecnico@gerencianet.com.br and we'll enable it for your account.

Build Status Code Climate Test Coverage

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": "1.*"
},
...

Getting started

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 */
}

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',
  'sandbox' => true
];

$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',
  'sandbox' => false
];

$api = new Gerencianet($options);

Running tests

To run tests install PHPUnit and run the following command:

$ phpunit -c test/config.xml

Running examples

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.

⚠️ Some examples require you to change some parameters to work, like examples/charge/detail.php where you must change the id parameter.

Additional Documentation

Charges

Carnets

Subscriptions

Marketplace

Notifications

Payments

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%