use of com.braintreepayments.api.models.IdealBank in project braintree_android by braintree.
the class IdealUnitTest method fetchIssuingBanks_postsCallbackToFragment.
@Test
public void fetchIssuingBanks_postsCallbackToFragment() throws InvalidArgumentException {
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
HttpResponseCallback callback = (HttpResponseCallback) invocation.getArguments()[1];
callback.failure(new IOException());
return null;
}
}).when(mMockApiClient).get(eq("/issuers/ideal"), any(HttpResponseCallback.class));
Ideal.fetchIssuingBanks(mBraintreeFragment, new BraintreeResponseListener<List<IdealBank>>() {
@Override
public void onResponse(List<IdealBank> idealBanks) {
fail("Success listener called");
}
});
verify(mBraintreeFragment).postCallback(any(IOException.class));
}
use of com.braintreepayments.api.models.IdealBank in project braintree_android by braintree.
the class IdealUnitTest method startPayment_startsBrowserWithProperRequestCode.
@Test
public void startPayment_startsBrowserWithProperRequestCode() throws InterruptedException, InvalidArgumentException {
final CountDownLatch latch = new CountDownLatch(1);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
HttpResponseCallback callback = (HttpResponseCallback) invocation.getArguments()[1];
callback.success(stringFromFixture("payment_methods/ideal_issuing_banks.json"));
return null;
}
}).when(mMockApiClient).get(eq("/issuers/ideal"), any(HttpResponseCallback.class));
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
String requestBody = (String) invocation.getArguments()[1];
JSONObject json = new JSONObject(requestBody);
assertEquals("some-route-id", json.getString("route_id"));
String expectedRedirectUrl = Uri.parse("http://assets.example.com/mobile/ideal-redirect/0.0.0/index.html?redirect_url=" + mBraintreeFragment.getReturnUrlScheme() + "://").toString();
assertEquals(expectedRedirectUrl, json.getString("redirect_url"));
HttpResponseCallback callback = (HttpResponseCallback) invocation.getArguments()[2];
callback.success(stringFromFixture("payment_methods/pending_ideal_bank_payment.json"));
return null;
}
}).when(mMockApiClient).post(eq("/ideal-payments"), any(String.class), any(HttpResponseCallback.class));
Ideal.fetchIssuingBanks(mBraintreeFragment, new BraintreeResponseListener<List<IdealBank>>() {
@Override
public void onResponse(List<IdealBank> idealBanks) {
IdealBank bank = idealBanks.get(0);
IdealRequest builder = new IdealRequest().issuerId(bank.getId()).amount("1.00").currency("EUR").orderId("abc-123");
Ideal.startPayment(mBraintreeFragment, builder, null);
verify(mBraintreeFragment).browserSwitch(eq(BraintreeRequestCodes.IDEAL), eq("http://approval.example.com/"));
latch.countDown();
}
});
latch.await();
}
use of com.braintreepayments.api.models.IdealBank in project braintree_android by braintree.
the class IdealTest method fetchIssuingBanks_returnsIssuingBanks.
@Test(timeout = 10000)
public void fetchIssuingBanks_returnsIssuingBanks() throws InterruptedException {
Ideal.fetchIssuingBanks(mBraintreeFragment, new BraintreeResponseListener<List<IdealBank>>() {
@Override
public void onResponse(List<IdealBank> idealBanks) {
assertFalse(idealBanks.isEmpty());
assertFalse(TextUtils.isEmpty(idealBanks.get(0).getId()));
assertFalse(TextUtils.isEmpty(idealBanks.get(0).getName()));
assertFalse(TextUtils.isEmpty(idealBanks.get(0).getImageUri()));
mCountDownLatch.countDown();
}
});
mBraintreeFragment.addListener(new BraintreeErrorListener() {
@Override
public void onError(Exception error) {
fail(error.getMessage());
}
});
mCountDownLatch.await();
}
use of com.braintreepayments.api.models.IdealBank in project braintree_android by braintree.
the class IdealActivity method onItemClick.
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
IdealBank bank = (IdealBank) mIssuingBanksListView.getAdapter().getItem(position);
IdealRequest builder = new IdealRequest().issuerId(bank.getId()).amount("10").orderId(UUID.randomUUID().toString()).currency("EUR");
Ideal.startPayment(mBraintreeFragment, builder, new BraintreeResponseListener<IdealResult>() {
@Override
public void onResponse(IdealResult idealResult) {
String idealId = idealResult.getId();
}
});
}
Aggregations