Skip to content

Instantly share code, notes, and snippets.

@matiasgualino
Created April 26, 2016 01:04
Show Gist options
  • Save matiasgualino/0f07680f858cb9152314e053ca87fe25 to your computer and use it in GitHub Desktop.
Save matiasgualino/0f07680f858cb9152314e053ca87fe25 to your computer and use it in GitHub Desktop.
public void startCardFlowActivity(View view) {
// Llamar al activity propuesta por MP
new MercadoPago.StartActivityBuilder()
.setActivity(this)
.setPublicKey(TU_PUBLIC_KEY)
.setAmount(MONTO)
.startCardFlowActivity();
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode == MercadoPago.CARD_FLOW_REQUEST_CODE) {
if (resultCode == RESULT_OK && data != null) {
// Obtené los datos cargados por tu usuario
PaymentMethod selectedPaymentMethod =
(PaymentMethod) data.getSerializableExtra("paymentMethod");
Issuer selectedIssuer =
(Issuer) data.getSerializableExtra("issuer");
Token createdToken =
(Token) data.getSerializableExtra("token");
// Aquí estan las cuotas!
PayerCost selectedPayerCost =
(PayerCost) data.getSerializableExtra("payerCost");
// Ahora podes continuar con tu flujo.
} 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