mp_flutter 0.1.0 mp_flutter: ^0.1.0 copied to clipboard
MecadoPago integration for Flutter
MercadoPago Flutter #
A Flutter package that mix the best of mercadopago_transparent and mercado_pago packages.
Note: this is a work in progress project.
For detailed docs about MercadoPago, please visit MercadoPago Developers Guides.
v0.1.0 #
Currently includes:
- Document identification types available on MercadoPago.
- New card token generation.
- Card token generation for an already saved card.
Usage #
Initialize the package by generating a new MercadoPago
instance:
import 'package:mp_flutter/mp_flutter.dart';
MercadoCredentials mercadoCredentials = MercadoCredentials(accessToken: 'ACESS_TOKEN');
final mercadoPago = MercadoPago(mercadoCredentials);
Document Types #
To get a list of identification types available on MercadoPago
List<DocumentType>? documentTypes = <DocumentType>[];
await mercadoPago.services.documentTypes()
.then((obj) {
if (obj.isSuccessful) {
documentTypes = (json.decode(obj.data) as List)
.map((dt) => DocumentType.fromJson(dt))
.toList();
}
});
Generate new card token #
To generate a new card token use the
newCard
function.
Note: To get more details about payment types, id, etc, visit: MercadoPago payment methods docs.
CardToken cardToken;
await mercadoPago.services.newCard(
code: '123',
year: '2025',
month: 11,
cardNumber: '4509953566233704',
documentNumber: '12345678',
documentType: 'DNI',
fullName: 'APRO'
).then((obj) {
if (obj.isSuccessful) {
cardToken = CardToken.fromJson(obj.data);
}
});
Token with Card #
Generate a token from a card already saved
CardSavedToken cardSavedToken;
await mercadoPago.services.tokenWithCard(
cardId: '1587964933876',
securityCode: '333'
).then((obj) {
if (obj.isSuccessful) {
cardSavedToken = CardSavedToken.fromJson(obj.data);
}
});
Contributions #
Please, feel free to open an Issue if you found any bugs or submit a PR.
License #
mp_flutter
is licensed under MIT.