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;
}
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;
}
}
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"));
}
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"));
}
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"));
}
Aggregations