cielo_flutter

Creator: coderz1093

Last updated:

0 purchases

cielo_flutter Image
cielo_flutter Images

Languages

Categories

Add to Cart

Description:

cielo flutter

Cielo SDK for Flutter #


An unofficial Flutter SDK for Cielo/Braspag.
Disclaimer #
This SDK is created for personal use and the functionality is limited to the needs of my projects.
You are more than welcome to contribute the code you need as soon as it follows the same code style.
Fortunately, this is a very simple SDK, so it should be easy to understand and extend.
Getting Started #
Installation #
flutter pub add cielo_flutter
copied to clipboard
Configuration #
import 'package:cielo_flutter/cielo_flutter.dart';

// Init core
const options = CieloOptions(
environment: CieloEnvironment.sandbox,
provider: CieloProvider.braspag,
language: CieloLanguage.pt,
);
Cielo.init(options);

// Initialize Silent Order Post
const sop = CieloSOPOptions(enableTokenize: true);
Cielo.initSOP(sop);
copied to clipboard
Usage #
Silent Order Post #
Learn More:

In Cielo
In Braspag

import 'package:cielo_flutter/cielo_flutter.dart';

String accessToken = "<SOP access token generated by your backend>";
CieloCard card = CieloCard(
cardNumber: '0000000000000001',
holder: 'John Doe',
expirationDate: '12/2021',
securityCode: '123',
);
await Cielo.sop.sendCard(card, accessToken: accessToken);
copied to clipboard
Errors #
try {
Cielo.sop.sendCard(brokenCard, accessToken: accessToken);
} on CieloCardValidationException catch (e) {
// Handle card validation errors.
print(e.field); // Name of the field that caused the error.
print(e.code); // The code of the error for dev use.
print(e.message); // User-friendly message, localized according to core options.
} on CieloException catch (e) {
// Handle SDK errors.
// Currently, only thrown for invalid accessToken in SOP.
print(e.code); // The code of the error for dev use.
print(e.message); // The error message for dev use.
} on CieloAPIException catch (e) {
// Handle API errors returned by the provider.
print(e.code); // The code of the error for dev use.
print(e.message); // The error message for dev use.
}
copied to clipboard
Other #
// To reset SDK from all configurations.
Cielo.dispose();
copied to clipboard
License #
Licensed under the MIT license, see LICENSE.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.