Last active
April 29, 2016 08:48
-
-
Save matiasgualino/68717a22fa4d1d0cc3fc119f94582a21 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
import android.content.Intent; | |
import android.widget.Toast; | |
import android.widget.TextView; | |
import com.mercadopago.core.MercadoPago; | |
import com.mercadopago.model.ApiException; | |
import com.mercadopago.model.Payment; | |
// Espera los resultados del checkout | |
@Override | |
protected void onActivityResult(int requestCode, int resultCode, | |
Intent data) { | |
if (requestCode == MercadoPago.CHECKOUT_REQUEST_CODE) { | |
if (resultCode == RESULT_OK && data != null) { | |
// Listo! El pago ya fue procesado por MP. | |
Payment payment = (Payment) data.getSerializableExtra("payment"); | |
TextView results = (TextView) findViewById(R.id.mp_results); | |
if (payment != null) { | |
results.setText("PaymentID: " + payment.getId() + " - PaymentStatus: " + payment.getStatus()); | |
} else { | |
results.setText("El usuario no concretó un 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