Created
April 18, 2016 12:37
-
-
Save matiasgualino/751ab586f93baff7fe952d7bd813c450 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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