Search in sources :

Example 11 with PaymentRequest

use of com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentRequest in project connect-sdk-client-android by Ingenico-ePayments.

the class GcSessionPreparePaymentRequestTest method constructValidPaymentRequest.

private PaymentRequest constructValidPaymentRequest(boolean shouldHaveAccountOnFile, boolean tokenize) {
    PaymentProduct paymentProductVisa = GsonHelper.fromResourceJson("paymentProductVisa.json", PaymentProduct.class);
    PaymentRequest paymentRequest = new PaymentRequest();
    paymentRequest.setPaymentProduct(paymentProductVisa);
    if (shouldHaveAccountOnFile) {
        paymentRequest.setAccountOnFile(paymentProductVisa.getAccountOnFileById("0"));
    } else {
        paymentRequest.setValue("cardNumber", "4567350000427977");
    }
    paymentRequest.setValue("expiryDate", "0820");
    paymentRequest.setValue("cvv", "123");
    paymentRequest.setTokenize(tokenize);
    assertTrue(paymentRequest.validate().isEmpty());
    return paymentRequest;
}
Also used : PaymentProduct(com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct) PreparedPaymentRequest(com.globalcollect.gateway.sdk.client.android.sdk.model.PreparedPaymentRequest) CreatePaymentRequest(com.ingenico.connect.gateway.sdk.java.domain.payment.CreatePaymentRequest) PaymentRequest(com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentRequest)

Example 12 with PaymentRequest

use of com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentRequest in project connect-sdk-client-android by Ingenico-ePayments.

the class AndroidPay method handleOnActivityResult.

public void handleOnActivityResult(int resultCode, Intent data, int errorCode) {
    switch(resultCode) {
        case Activity.RESULT_OK:
            if (data != null) {
                MaskedWallet maskedWallet = data.getParcelableExtra(WalletConstants.EXTRA_MASKED_WALLET);
                // create the paymentRequest that can eventually be used to pay with, set
                // Android Pay as the payment product
                PaymentRequest paymentRequest = new PaymentRequest();
                paymentRequest.setPaymentProduct(paymentProduct);
                initializeAndStartConfirmationActivity(maskedWallet, paymentRequest);
            }
            break;
        case Activity.RESULT_CANCELED:
            Log.i(TAG, "Android Pay was cancelled");
            break;
        case WalletConstants.RESULT_ERROR:
        default:
            Log.e(TAG, "Something went wrong whilst retrieving the Masked Wallet; errorCode: " + errorCode);
            handleError(errorCode);
            break;
    }
}
Also used : PaymentRequest(com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentRequest) MaskedWallet(com.google.android.gms.wallet.MaskedWallet)

Example 13 with PaymentRequest

use of com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentRequest in project connect-sdk-client-android by Ingenico-ePayments.

the class ValidationTest method testInvalidEmailAddress.

@Test
public void testInvalidEmailAddress() {
    PaymentRequest paymentRequest = new TestPaymentRequest();
    paymentRequest.setValue("emailAddress", emailAddressInvalid);
    ValidationRuleEmailAddress rule = new ValidationRuleEmailAddress("", ValidationType.EMAILADDRESS);
    assertEquals(false, rule.validate(paymentRequest, "emailAddress"));
}
Also used : PaymentRequest(com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentRequest) ValidationRuleEmailAddress(com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationRuleEmailAddress) Test(org.junit.Test)

Example 14 with PaymentRequest

use of com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentRequest in project connect-sdk-client-android by Ingenico-ePayments.

the class ValidationTest method testValidFixedList.

// Test fixed list validator
@Test
public void testValidFixedList() {
    PaymentRequest paymentRequest = new TestPaymentRequest();
    paymentRequest.setValue("fixedList", validListOption);
    ValidationRuleFixedList rule = new ValidationRuleFixedList(listEntries, "", ValidationType.FIXEDLIST);
    assertEquals(true, rule.validate(paymentRequest, "fixedList"));
}
Also used : PaymentRequest(com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentRequest) ValidationRuleFixedList(com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationRuleFixedList) Test(org.junit.Test)

Example 15 with PaymentRequest

use of com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentRequest in project connect-sdk-client-android by Ingenico-ePayments.

the class ValidationTest method testInvalidLength.

@Test
public void testInvalidLength() {
    PaymentRequest paymentRequest = new TestPaymentRequest();
    paymentRequest.setValue("length", invalidLength);
    ValidationRuleLength rule = new ValidationRuleLength(minLength, maxLength, "", ValidationType.LENGTH);
    assertEquals(false, rule.validate(paymentRequest, "length"));
}
Also used : ValidationRuleLength(com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationRuleLength) PaymentRequest(com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentRequest) Test(org.junit.Test)

Aggregations

PaymentRequest (com.globalcollect.gateway.sdk.client.android.sdk.model.PaymentRequest)21 Test (org.junit.Test)19 PreparedPaymentRequest (com.globalcollect.gateway.sdk.client.android.sdk.model.PreparedPaymentRequest)4 CreatePaymentRequest (com.ingenico.connect.gateway.sdk.java.domain.payment.CreatePaymentRequest)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 ValidationRuleEmailAddress (com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationRuleEmailAddress)2 ValidationRuleExpirationDate (com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationRuleExpirationDate)2 ValidationRuleFixedList (com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationRuleFixedList)2 ValidationRuleLength (com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationRuleLength)2 ValidationRuleLuhn (com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationRuleLuhn)2 ValidationRuleRange (com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationRuleRange)2 ValidationRuleRegex (com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationRuleRegex)2 ValidationRuleTermsAndConditions (com.globalcollect.gateway.sdk.client.android.sdk.model.validation.ValidationRuleTermsAndConditions)2 CommunicationException (com.globalcollect.gateway.sdk.client.android.sdk.exception.CommunicationException)1 PaymentProduct (com.globalcollect.gateway.sdk.client.android.sdk.model.paymentproduct.PaymentProduct)1 MaskedWallet (com.google.android.gms.wallet.MaskedWallet)1