Skip to content

Instantly share code, notes, and snippets.

@matiasgualino
Created April 18, 2016 12:37
Show Gist options
  • Save matiasgualino/751ab586f93baff7fe952d7bd813c450 to your computer and use it in GitHub Desktop.
Save matiasgualino/751ab586f93baff7fe952d7bd813c450 to your computer and use it in GitHub Desktop.
// Button onClick method
public void submit(View view) {
// Start MercadoPago PaymentVault activity
new MercadoPago.StartActivityBuilder()
.setActivity(activity)
.setPublicKey(PUBLIC_KEY)
.setAmount(BigDecimal.valueOf(MONTO))
.setPurchaseTitle(NOMBRE_PRODUCTO)
.startPaymentVaultActivity();
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if(requestCode == MercadoPago.PAYMENT_VAULT_REQUEST_CODE) {
if(resultCode == RESULT_OK) {
Issuer selectedIssuer =
(Issuer) data.getSerializableExtra("issuer");
PayerCost selectedPayerCost =
(PayerCost) data.getSerializableExtra("payerCost");
Token createdToken =
(Token) data.getSerializableExtra("token");
PaymentMethod selectedPaymentMethod =
(PaymentMethod) data.getSerializableExtra("paymentMethod");
// Debes enviar estos datos a tu servidor para finalizar el pago.
} else {
if ((data != null) &&
(data.getSerializableExtra("apiException") != null)) {
ApiException apiException
= (ApiException) data.getSerializableExtra("apiException");
Toast.makeText(getApplicationContext(), apiException.getMessage(),
Toast.LENGTH_LONG).show();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment