use of com.google.android.gms.wallet.FullWallet in project braintree_android by braintree.
the class AndroidPayCardNonceUnitTest method fromFullWallet_withCart_createsAndroidPayCardNonce.
@Test
public void fromFullWallet_withCart_createsAndroidPayCardNonce() throws JSONException {
UserAddress billingAddress = mock(UserAddress.class);
UserAddress shippingAddress = mock(UserAddress.class);
Cart cart = Cart.newBuilder().build();
FullWallet wallet = getFullWallet(stringFromFixture("payment_methods/android_pay_card_response.json"), billingAddress, shippingAddress);
AndroidPayCardNonce androidPayCardNonce = AndroidPayCardNonce.fromFullWallet(wallet, cart);
assertEquals("Android Pay", androidPayCardNonce.getTypeLabel());
assertEquals("fake-android-pay-nonce", androidPayCardNonce.getNonce());
assertEquals("MasterCard 0276", androidPayCardNonce.getDescription());
assertEquals("Visa", androidPayCardNonce.getCardType());
assertEquals("11", androidPayCardNonce.getLastTwo());
assertEquals("android-user@example.com", androidPayCardNonce.getEmail());
assertEquals(billingAddress, androidPayCardNonce.getBillingAddress());
assertEquals(shippingAddress, androidPayCardNonce.getShippingAddress());
assertEquals("google-transaction-id", androidPayCardNonce.getGoogleTransactionId());
assertEquals(cart, androidPayCardNonce.getCart());
}
use of com.google.android.gms.wallet.FullWallet in project braintree_android by braintree.
the class AndroidPayCardNonceUnitTest method fromFullWallet_createsAndroidPayCardNonce.
@Test
public void fromFullWallet_createsAndroidPayCardNonce() throws JSONException {
UserAddress billingAddress = mock(UserAddress.class);
UserAddress shippingAddress = mock(UserAddress.class);
FullWallet wallet = getFullWallet(stringFromFixture("payment_methods/android_pay_card_response.json"), billingAddress, shippingAddress);
AndroidPayCardNonce androidPayCardNonce = AndroidPayCardNonce.fromFullWallet(wallet);
assertEquals("Android Pay", androidPayCardNonce.getTypeLabel());
assertEquals("fake-android-pay-nonce", androidPayCardNonce.getNonce());
assertEquals("MasterCard 0276", androidPayCardNonce.getDescription());
assertEquals("Visa", androidPayCardNonce.getCardType());
assertEquals("11", androidPayCardNonce.getLastTwo());
assertEquals("android-user@example.com", androidPayCardNonce.getEmail());
assertEquals(billingAddress, androidPayCardNonce.getBillingAddress());
assertEquals(shippingAddress, androidPayCardNonce.getShippingAddress());
assertEquals("google-transaction-id", androidPayCardNonce.getGoogleTransactionId());
}
use of com.google.android.gms.wallet.FullWallet in project braintree_android by braintree.
the class AndroidPayTest method onActivityResult_sendsAnalyticsEventOnFullWalletResponse.
@Test
public void onActivityResult_sendsAnalyticsEventOnFullWalletResponse() throws Exception {
BraintreeFragment fragment = getSetupFragment();
FullWallet wallet = createFullWallet();
Intent intent = new Intent().putExtra(WalletConstants.EXTRA_FULL_WALLET, wallet);
AndroidPay.onActivityResult(fragment, Activity.RESULT_OK, intent);
verify(fragment).sendAnalyticsEvent("android-pay.authorized");
}
use of com.google.android.gms.wallet.FullWallet in project braintree_android by braintree.
the class AndroidPayCardNonceUnitTest method parcelsCorrectly.
@Test
public void parcelsCorrectly() throws Exception {
UserAddress billingAddress = getAddressObject();
UserAddress shippingAddress = getAddressObject();
Cart cart = Cart.newBuilder().build();
FullWallet wallet = getFullWallet(stringFromFixture("payment_methods/android_pay_card_response.json"), billingAddress, shippingAddress);
AndroidPayCardNonce androidPayCardNonce = AndroidPayCardNonce.fromFullWallet(wallet, cart);
Parcel parcel = Parcel.obtain();
androidPayCardNonce.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
AndroidPayCardNonce parceled = AndroidPayCardNonce.CREATOR.createFromParcel(parcel);
assertEquals("Android Pay", parceled.getTypeLabel());
assertEquals("fake-android-pay-nonce", parceled.getNonce());
assertEquals("MasterCard 0276", parceled.getDescription());
assertEquals("Visa", parceled.getCardType());
assertEquals("11", parceled.getLastTwo());
assertEquals("android-user@example.com", parceled.getEmail());
assertNotNull(parceled.getBillingAddress());
assertNotNull(parceled.getShippingAddress());
assertEquals("google-transaction-id", parceled.getGoogleTransactionId());
assertNotNull(parceled.getCart());
assertBinDataEqual(androidPayCardNonce.getBinData(), parceled.getBinData());
}
use of com.google.android.gms.wallet.FullWallet in project braintree_android by braintree.
the class AndroidPayCardNonceUnitTest method getFullWallet.
private FullWallet getFullWallet(String response, UserAddress billingAddress, UserAddress shippingAddress) {
PaymentMethodToken paymentMethodToken = mock(PaymentMethodToken.class);
when(paymentMethodToken.getToken()).thenReturn(response);
FullWallet wallet = mock(FullWallet.class);
when(wallet.getPaymentMethodToken()).thenReturn(paymentMethodToken);
when(wallet.getPaymentDescriptions()).thenReturn(new String[] { "MasterCard 0276" });
when(wallet.getEmail()).thenReturn("android-user@example.com");
when(wallet.getBuyerBillingAddress()).thenReturn(billingAddress);
when(wallet.getBuyerShippingAddress()).thenReturn(shippingAddress);
when(wallet.getGoogleTransactionId()).thenReturn("google-transaction-id");
return wallet;
}
Aggregations