Skip to content

Instantly share code, notes, and snippets.

@matiasgualino
Last active April 26, 2016 00:39
Show Gist options
  • Save matiasgualino/7cf5b99ead0edb02a91b3c71c9e23118 to your computer and use it in GitHub Desktop.
Save matiasgualino/7cf5b99ead0edb02a91b3c71c9e23118 to your computer and use it in GitHub Desktop.
public class InstallmentsActivity extends Activity {
private String mMerchantPublicKey;
private String mPaymentMethodId;
private String mBin;
private BigDecimal mAmount;
private String mIssuerId;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_installments);
mMerchantPublicKey = this.getIntent().getStringExtra("merchantPublicKey");
mPaymentMethodId = this.getIntent().getStringExtra("paymentMethodId");
mBin = this.getIntent().getStringExtra("bin");
mAmount = new BigDecimal(this.getIntent().getStringExtra("amount"));
mIssuerId = this.getIntent().getStringExtra("issuerId");
MercadoPago mercadoPago = new MercadoPago.Builder()
.setContext(this)
.setPublicKey(mMerchantPublicKey)
.build();
getInstallmentsAsync(mercadoPago);
}
private void getInstallmentsAsync(MercadoPago mercadoPago) {
mercadoPago.getInstallments(mBin, mAmount, mPaymentMethodId, mIssuerId, new Callback <List<Installment>>() {
@Override
public void success(List<Installment> installments, Response response) {
// Ya tenés la lista de cuotas!
// Ahora armá tu UI para cada una de ellos!
}
@Override
public void failure(RetrofitError error) {
// UPS! Algo salió mal.
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment