protected PaymentResponseDTO commonCreditCardProcessing(PaymentRequestDTO requestDTO, PaymentTransactionType paymentTransactionType) {
PaymentResponseDTO responseDTO = new PaymentResponseDTO(PaymentType.CREDIT_CARD, NullPaymentGatewayType.NULL_GATEWAY);
responseDTO.valid(true)
.paymentTransactionType(paymentTransactionType);
CreditCardDTO creditCardDTO = requestDTO.getCreditCard();
String transactionAmount = requestDTO.getTransactionTotal();
CreditCardValidator visaValidator = new CreditCardValidator(CreditCardValidator.VISA);
CreditCardValidator amexValidator = new CreditCardValidator(CreditCardValidator.AMEX);
CreditCardValidator mcValidator = new CreditCardValidator(CreditCardValidator.MASTERCARD);
CreditCardValidator discoverValidator = new CreditCardValidator(CreditCardValidator.DISCOVER);
if (StringUtils.isNotBlank(transactionAmount) &&
StringUtils.isNotBlank(creditCardDTO.getCreditCardNum()) &&
(StringUtils.isNotBlank(creditCardDTO.getCreditCardExpDate()) ||
(StringUtils.isNotBlank(creditCardDTO.getCreditCardExpMonth()) &&
StringUtils.isNotBlank(creditCardDTO.getCreditCardExpYear())))) {
boolean validCard = false;
if (visaValidator.isValid(creditCardDTO.getCreditCardNum())){
validCard = true;
} else if (amexValidator.isValid(creditCardDTO.getCreditCardNum())) {
validCard = true;
} else if (mcValidator.isValid(creditCardDTO.getCreditCardNum())) {
validCard = true;
} else if (discoverValidator.isValid(creditCardDTO.getCreditCardNum())) {
validCard = true;
}
boolean validDateFormat = false;
boolean validDate = false;
String[] parsedDate = null;
if (StringUtils.isNotBlank(creditCardDTO.getCreditCardExpDate())) {
parsedDate = creditCardDTO.getCreditCardExpDate().split("/");
} else {
parsedDate = new String[2];
parsedDate[0] = creditCardDTO.getCreditCardExpMonth();
parsedDate[1] = creditCardDTO.getCreditCardExpYear();
}
if (parsedDate.length == 2) {
String expMonth = parsedDate[0];
String expYear = parsedDate[1];