Search in sources :

Example 1 with PaymentData

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);
}
Also used : PaymentData(com.google.android.gms.wallet.PaymentData) PaymentMethodToken(com.google.android.gms.wallet.PaymentMethodToken) CardInfo(com.google.android.gms.wallet.CardInfo)

Example 2 with PaymentData

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());
}
Also used : PaymentData(com.google.android.gms.wallet.PaymentData) Parcel(android.os.Parcel) UserAddress(com.google.android.gms.identity.intents.model.UserAddress) Test(org.junit.Test)

Example 3 with PaymentData

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());
}
Also used : PaymentData(com.google.android.gms.wallet.PaymentData) UserAddress(com.google.android.gms.identity.intents.model.UserAddress) Test(org.junit.Test)

Aggregations

PaymentData (com.google.android.gms.wallet.PaymentData)3 UserAddress (com.google.android.gms.identity.intents.model.UserAddress)2 Test (org.junit.Test)2 Parcel (android.os.Parcel)1 CardInfo (com.google.android.gms.wallet.CardInfo)1 PaymentMethodToken (com.google.android.gms.wallet.PaymentMethodToken)1