SDK Gerencianet for Dart

gn-api-sdk-dart

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

Installation

To use this plugin, add gerencianet as a dependency in your pubspec.yaml file.

Getting started

Then initialize the plugin preferably in the initState of your widget.

...
import 'package:gerencianet/gerencianet.dart';

class _PaymentPageState extends State<PaymentPage> {
  var config = {
    'client_id': 'YOUR_CLIENT_ID',
    'client_secret': 'YOU_CLIENT_SECRET',
    'sandbox': false,
    'pix_cert': '',
    'pix_private_key': ''
  };
  Gerencianet gerencianet;

  @override
  void initState() {
    this.gerencianet  = Gerencianet(config);
  }

}
...

Examples

Example for creating a charge.

void createCharge(){
  Gerencianet gn = Gerencianet(config);
  dynamic body = {
      'items': [
        {'name': "Product 1", 'value': 1100, 'amount': 2}
      ],
    };
  return await gn.call('createCharge', body: body);
}

You can check out examples of all of our endpoints in our repository.

Example app

You can also check out our sample Flutter app in our repository.

If you use the Pix option:

To generate your certificate: Access the menu API (1)-> Meus Certificados (2) and choose the environment you want the certificate: Produção or Homologação -> click in Novo Certificado (3). To generate your certificate

Create a new application to use the Pix API: Access the menu API (1)-> Minhas Aplicações -> Nova Aplicação(2) -> Ative API Pix (3) and choose the scopes you want to release in Produção e/ou Homologação (remembering that these can be changed later). -> click in Criar Nova aplicação(4). Create a new application to use the Pix API

Change an existing application to use the Pix API: Access the menu API (1)-> Minhas Aplicações e escolha a sua aplicação (2) -> Editar(Botão laranja) -> Ative API Pix (3) and choose the scopes you want to release in Produção e/ou Homologação. -> click in Atualizar aplicação (4). Change an existing application to use the Pix API

For use in Dart, the certificate must be converted to .pem. Below you will find example using the OpenSSL command for conversion.

Command OpenSSL

// Gerar certificado e chave separadas
openssl pkcs12 -in path.p12 -out newfile.crt.pem -clcerts -nokeys //certificado
openssl pkcs12 -in path.p12 -out newfile.key.pem -nocerts -nodes //chave privada

To register your Pix keys

The registration of Pix keys can be done through the application. If you don't already have our app installed, click on Android or iOS, according to your smartphone's operating system, to download it.

To register your Pix keys through the application:

  1. Access your account through app Gerencianet.
  2. In the side menu, touch Pix to start your registration.
  3. Read the information that appears on the screen and click Registrar Chave. If this is no longer your first contact, tap Minhas Chaves and then the icon (➕).
  4. Select the data you are going to register as a Pix Key and tap avançar - you must choose at least 1 of the 4 available key options (cell, e-mail, CPF e/ou random key).
  5. After registering the desired Pix keys, click on concluir.
  6. Ready! Your keys are already registered with us.

Additional Documentation

The full documentation with all available endpoints is in https://dev.gerencianet.com.br/.

If you don't have a digital account atnetnet, open yours now!

License

MIT

Libraries

gerencianet