use of com.google.android.gms.wallet.PaymentData in project braintree_android by braintree.
the class GooglePaymentCardNonceUnitTest method getPaymentData.
private PaymentData getPaymentData(String email, UserAddress billingAddress, UserAddress shippingAddress, String response) throws Exception {
Constructor<PaymentMethodToken> paymentMethodTokenConstructor = PaymentMethodToken.class.getDeclaredConstructor(int.class, String.class);
paymentMethodTokenConstructor.setAccessible(true);
PaymentMethodToken paymentMethodToken = paymentMethodTokenConstructor.newInstance(0, response);
Constructor<CardInfo> cardInfoConstructor = CardInfo.class.getDeclaredConstructor(String.class, String.class, String.class, int.class, UserAddress.class);
cardInfoConstructor.setAccessible(true);
CardInfo cardInfo = cardInfoConstructor.newInstance("MasterCard 0276", null, null, 0, billingAddress);
Constructor<PaymentData> paymentDataConstructor = PaymentData.class.getDeclaredConstructor(String.class, CardInfo.class, UserAddress.class, PaymentMethodToken.class);
paymentDataConstructor.setAccessible(true);
return paymentDataConstructor.newInstance(email, cardInfo, shippingAddress, paymentMethodToken);
}
use of com.google.android.gms.wallet.PaymentData in project braintree_android by braintree.
the class GooglePaymentCardNonceUnitTest method parcelsCorrectly.
@Test
public void parcelsCorrectly() throws Exception {
UserAddress billingAddress = getAddressObject();
UserAddress shippingAddress = getAddressObject();
PaymentData paymentData = getPaymentData("android-user@example.com", billingAddress, shippingAddress, stringFromFixture("payment_methods/android_pay_card_response.json"));
GooglePaymentCardNonce googlePaymentCardNonce = GooglePaymentCardNonce.fromPaymentData(paymentData);
Parcel parcel = Parcel.obtain();
googlePaymentCardNonce.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
GooglePaymentCardNonce parceled = GooglePaymentCardNonce.CREATOR.createFromParcel(parcel);
assertEquals("Google Pay", parceled.getTypeLabel());
assertEquals("fake-android-pay-nonce", parceled.getNonce());
assertEquals("MasterCard 0276", parceled.getDescription());
assertEquals("Visa", parceled.getCardType());
assertEquals("11", parceled.getLastTwo());
assertEquals("1234", parceled.getLastFour());
assertEquals("android-user@example.com", parceled.getEmail());
assertNotNull(parceled.getBillingAddress());
assertNotNull(parceled.getShippingAddress());
assertBinDataEqual(googlePaymentCardNonce.getBinData(), parceled.getBinData());
}
use of com.google.android.gms.wallet.PaymentData in project braintree_android by braintree.
the class GooglePaymentCardNonceUnitTest method fromPaymentData_createsGooglePaymentCardNonce.
@Test
public void fromPaymentData_createsGooglePaymentCardNonce() throws Exception {
UserAddress billingAddress = getAddressObject();
UserAddress shippingAddress = getAddressObject();
PaymentData paymentData = getPaymentData("android-user@example.com", billingAddress, shippingAddress, stringFromFixture("payment_methods/android_pay_card_response.json"));
GooglePaymentCardNonce googlePaymentCardNonce = GooglePaymentCardNonce.fromPaymentData(paymentData);
assertEquals("Google Pay", googlePaymentCardNonce.getTypeLabel());
assertEquals("fake-android-pay-nonce", googlePaymentCardNonce.getNonce());
assertEquals("MasterCard 0276", googlePaymentCardNonce.getDescription());
assertEquals("Visa", googlePaymentCardNonce.getCardType());
assertEquals("11", googlePaymentCardNonce.getLastTwo());
assertEquals("1234", googlePaymentCardNonce.getLastFour());
assertEquals("android-user@example.com", googlePaymentCardNonce.getEmail());
assertEquals(billingAddress, googlePaymentCardNonce.getBillingAddress());
assertEquals(shippingAddress, googlePaymentCardNonce.getShippingAddress());
}
Aggregations