Skip to content

Instantly share code, notes, and snippets.

@matiasgualino
Created June 3, 2016 17:42
Show Gist options
  • Save matiasgualino/e09e754941e1d8eca1781e34e4776c5c to your computer and use it in GitHub Desktop.
Save matiasgualino/e09e754941e1d8eca1781e34e4776c5c to your computer and use it in GitHub Desktop.
public void submit() {
// Armá un mapa con los datos de la compra y el mail de tu cliente.
Map preferenceMap = new HashMap<>();
preferenceMap.put("item_id", "1");
preferenceMap.put("amount", new BigDecimal(10));
preferenceMap.put("payer_email", "[email protected]");
// Envia la información a tu servidor
MerchantServer.createPreference(this, "http://merchantserver.com/",
"merchantUri/create_preference", preferenceMap, new Callback() {
@Override
public void success(CheckoutPreference checkoutPreference,
Response response) {
// La preferencia se creó correctamente.
// Aquí puedes iniciar el Checkout de MercadoPago.
new MercadoPago.StartActivityBuilder()
.setActivity(activity)
.setPublicKey(publicKey)
.setCheckoutPreferenceId(checkoutPreference.getId())
.startCheckoutActivity();
}
@Override
public void failure(RetrofitError error) {
// Ups, ocurrió un error
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment