@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == MercadoPago.PAYMENT_METHODS_REQUEST_CODE) { if (resultCode == RESULT_OK) { // Set payment method PaymentMethod paymentMethod = JsonUtil.getInstance() .fromJson(data.getStringExtra("paymentMethod"), PaymentMethod.class); // Call new card activity ExamplesUtils.startCardActivity( this, ExamplesUtils.DUMMY_MERCHANT_PUBLIC_KEY, paymentMethod); } else { if ((data != null) && (data.getStringExtra("apiException") != null)) { Toast.makeText( getApplicationContext(), data.getStringExtra("apiException"), Toast.LENGTH_LONG) .show(); } } } else if (requestCode == ExamplesUtils.CARD_REQUEST_CODE) { if (resultCode == RESULT_OK) { // Create payment ExamplesUtils.createPayment( this, data.getStringExtra("token"), 1, null, JsonUtil.getInstance() .fromJson(data.getStringExtra("paymentMethod"), PaymentMethod.class), null); } else { if (data != null) { if (data.getStringExtra("apiException") != null) { Toast.makeText( getApplicationContext(), data.getStringExtra("apiException"), Toast.LENGTH_LONG) .show(); } else if (data.getBooleanExtra("backButtonPressed", false)) { new MercadoPago.StartActivityBuilder() .setActivity(this) .setPublicKey(ExamplesUtils.DUMMY_MERCHANT_PUBLIC_KEY) .setSupportedPaymentTypes(mSupportedPaymentTypes) .startPaymentMethodsActivity(); } } } } else if (requestCode == MercadoPago.CONGRATS_REQUEST_CODE) { LayoutUtil.showRegularLayout(this); } }
@Override protected void onListItemClick(ListView list, View view, int position, long id) { super.onListItemClick(list, view, position, id); Intent intent = new Intent(IssuersActivity.this, CardDataActivity.class); intent.putExtras(getIntent()); intent.putExtra("issuer", JsonUtil.getInstance().toJson(this.mIssuers.get(position))); startActivity(intent); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_issuers); mActivity = this; Toolbar mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar); mActionBarToolbar.setTitle(R.string.title_activity_issuers); mMerchantPublicKey = getIntent().getStringExtra("merchantPublicKey"); mSelectedPaymentMethod = JsonUtil.getInstance() .fromJson(getIntent().getStringExtra("paymentMethod"), PaymentMethod.class); mMercadoPago = new MercadoPago.Builder().setContext(this).setPublicKey(mMerchantPublicKey).build(); LayoutUtil.showProgressLayout(this); getIssuersAsync(mSelectedPaymentMethod, this.mMerchantPublicKey); }