Flutter

Our API is RESTful and responds in JSON. Gerencianet uses OAuth to provide authorized access to the API. Our NodeJS SDK is already prepared to perform this authentication automatically.

Below, check out the procedures for installing the Gerencianet SDK in Dart:


Installation:

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


Tested with

  • Dart 2.12.3

Basic use

Initialize the plugin preferably in initState in your widget.

Set your credentials, certificate and whether you want to use sandbox or not:

...
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 of how to create 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);
}

All examples available in our SDK you find here.

Also see our Flutter app examples here.

Then run the command:

flutter pub get

Converting the .p12 certificate


To use Pix API endpoints as our SDK in Flutter/Dart it is necessary that the certificate generated in your Gerencianet account be converted to .pem , this conversion can be done using the following OpenSSL commands:

openssl pkcs12 -in path.p12 -out newfile.crt.pem -clcerts -nokeys //certificate
openssl pkcs12 -in path.p12 -out newfile.key.pem -nocerts -nodes //private key