mpcheckout 1.1.0
mpcheckout: ^1.1.0 copied to clipboard
An unofficial package of MercadoPago Mobile Checkout.
mpcheckout #
An unofficial package of MercadoPago Mobile Checkout.
Requirements #
- Android minSdk 19
- iOS 10.0
iOS #
Currently IOS is no longer supported because MercadoPago changed the px-ios SDK repo to private mode and we can no longer use this SDK.
How to use #
First you need to initialize credentials
/// initialize credentials
mp = Mpcheckout.initialize(
clientID: 'clientID',
publicKey: 'publicKey',
accesToken: 'accesToken',
);
runApp(MaterialApp(home: MyApp()));
Then create a preference
final Preference _pref = Preference(
statementDescriptor: 'statementDescriptor',
additionalInfo: 'additionalInfo',
items: [
Items(
title: 'Test',
quantity: 1,
unitPrice: 120,
),
],
paymentMethods: PaymentMethods(
excludedPaymentTypes: [
ExcludedPaymentTypes(id: 'ticket'),
ExcludedPaymentTypes(id: 'atm'),
],
),
payer: Payer(
email: 'test@test.com',
),
shipments: Shipments(
mode: 'not_specified',
freeShipping: false,
cost: 350,
),
);
Finally start the checkout
try {
final result = await mp.startCheckout(_pref);
if (result.status == 'rejected') {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('Rejected'),
backgroundColor: Colors.red,
));
}
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('Success'),
backgroundColor: Colors.red,
));
} on MpException catch (error) {
print(error.message);
}