Search in sources :

Example 1 with CountrySpecification

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);
}
Also used : ArrayList(java.util.ArrayList) CountrySpecification(com.google.android.gms.identity.intents.model.CountrySpecification)

Example 2 with CountrySpecification

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");
}
Also used : InOrder(org.mockito.InOrder) Intent(android.content.Intent) CountrySpecification(com.google.android.gms.identity.intents.model.CountrySpecification) Test(org.junit.Test)

Example 3 with CountrySpecification

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));
}
Also used : ArrayList(java.util.ArrayList) Intent(android.content.Intent) CountrySpecification(com.google.android.gms.identity.intents.model.CountrySpecification) Cart(com.google.android.gms.wallet.Cart) Test(org.junit.Test)

Example 4 with CountrySpecification

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");
}
Also used : InOrder(org.mockito.InOrder) CountrySpecification(com.google.android.gms.identity.intents.model.CountrySpecification) Test(org.junit.Test)

Aggregations

CountrySpecification (com.google.android.gms.identity.intents.model.CountrySpecification)4 Test (org.junit.Test)3 Intent (android.content.Intent)2 ArrayList (java.util.ArrayList)2 InOrder (org.mockito.InOrder)2 Cart (com.google.android.gms.wallet.Cart)1