use of com.google.android.gms.identity.intents.model.CountrySpecification in project braintree_android by braintree.
the class AndroidPayActivity method launchAndroidPay.
public void launchAndroidPay(View v) {
setProgressBarIndeterminateVisibility(true);
ArrayList<CountrySpecification> allowedCountries = new ArrayList<>();
for (String country : Settings.getAndroidPayAllowedCountriesForShipping(this)) {
allowedCountries.add(new CountrySpecification(country));
}
AndroidPay.requestAndroidPay(mBraintreeFragment, mCart, Settings.isAndroidPayShippingAddressRequired(this), Settings.isAndroidPayPhoneNumberRequired(this), allowedCountries);
}
use of com.google.android.gms.identity.intents.model.CountrySpecification in project braintree_android by braintree.
the class AndroidPayTest method requestAndroidPay_sendsAnalyticsEvent.
@Test
public void requestAndroidPay_sendsAnalyticsEvent() throws InterruptedException, InvalidArgumentException {
BraintreeFragment fragment = getSetupFragment();
doNothing().when(fragment).startActivityForResult(any(Intent.class), anyInt());
AndroidPay.requestAndroidPay(fragment, Cart.newBuilder().build(), false, false, new ArrayList<CountrySpecification>());
InOrder order = inOrder(fragment);
order.verify(fragment).sendAnalyticsEvent("android-pay.selected");
order.verify(fragment).sendAnalyticsEvent("android-pay.started");
}
use of com.google.android.gms.identity.intents.model.CountrySpecification in project braintree_android by braintree.
the class AndroidPayTest method requestAndroidPay_startsActivity.
@Test
public void requestAndroidPay_startsActivity() {
BraintreeFragment fragment = getSetupFragment();
doNothing().when(fragment).startActivityForResult(any(Intent.class), anyInt());
Cart cart = Cart.newBuilder().build();
ArrayList<CountrySpecification> allowedCountries = new ArrayList<>();
AndroidPay.requestAndroidPay(fragment, cart, true, true, allowedCountries);
ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
verify(fragment).startActivityForResult(captor.capture(), eq(BraintreeRequestCodes.ANDROID_PAY));
Intent intent = captor.getValue();
assertEquals(AndroidPayActivity.class.getName(), intent.getComponent().getClassName());
assertEquals(AUTHORIZE, intent.getIntExtra(EXTRA_REQUEST_TYPE, -1));
assertEquals(WalletConstants.ENVIRONMENT_TEST, intent.getIntExtra(EXTRA_ENVIRONMENT, -1));
assertEquals("", intent.getStringExtra(EXTRA_MERCHANT_NAME));
assertEquals(cart, intent.getParcelableExtra(EXTRA_CART));
assertTrue(intent.getBooleanExtra(EXTRA_SHIPPING_ADDRESS_REQUIRED, false));
assertTrue(intent.getBooleanExtra(EXTRA_PHONE_NUMBER_REQUIRED, false));
assertEquals(allowedCountries, intent.getParcelableArrayListExtra(EXTRA_ALLOWED_COUNTRIES));
assertNotNull(intent.getParcelableExtra(EXTRA_TOKENIZATION_PARAMETERS));
assertNotNull(intent.getIntegerArrayListExtra(EXTRA_ALLOWED_CARD_NETWORKS));
}
use of com.google.android.gms.identity.intents.model.CountrySpecification in project braintree_android by braintree.
the class AndroidPayTest method requestAndroidPay_postsExceptionWhenCartIsNull.
@Test
public void requestAndroidPay_postsExceptionWhenCartIsNull() throws InterruptedException, InvalidArgumentException {
BraintreeFragment fragment = getSetupFragment();
AndroidPay.requestAndroidPay(fragment, null, false, false, new ArrayList<CountrySpecification>());
InOrder order = inOrder(fragment);
order.verify(fragment).sendAnalyticsEvent("android-pay.selected");
order.verify(fragment).sendAnalyticsEvent("android-pay.failed");
}