custCreditCard = (CustomerCreditCard) iterator.next();
break;
}
if (custCreditCard == null) {
paymentMessage = "Unable to locate customer credit card to refund";
throw new AuthorizationException("Unable to locate customer credit card to refund");
}
gwr.setCardExpiryMonth(custCreditCard.getCustCreditCardExpiryMonth());
gwr.setCardExpiryYear(custCreditCard.getCustCreditCardExpiryYear());
gwr.setCardHoldersName(custCreditCard.getCustCreditCardNum());
gwr.setCardNumber(AESEncoder.getInstance().decode(custCreditCard.getCustCreditCardNum()));
gwr.setCustomerInvoiceRef(orderHeader.getOrderNum());
PaymentTran payment = orderHeader.getPaymentTran();
if (payment == null) {
for (InvoiceHeader invoiceHeader : orderHeader.getInvoiceHeaders()) {
payment = invoiceHeader.getPaymentTran();
}
}
gwr.setTrxnNumber(payment.getPaymentReference1());
gwr.setCVN(custCreditCard.getCustCreditCardVerNum());
gwr.setTotalAmount((int)(creditHeader.getCreditTotal() * 100));
//gwr.setTotalAmount(1000);
GatewayResponse response = connector.sendRequest(gwr);
if (!response.getTrxnStatus()) {
logger.error("request = Not able to process credit card authorization for " + orderHeader.getCustAddress().getCustFirstName() + " " + orderHeader.getCustAddress().getCustLastName());
logger.error("response = " + response.getTrxnError());
paymentMessage = response.getTrxnError();
throw new AuthorizationException(response.getTrxnError());
}
authCode = response.getAuthCode();
paymentReference1 = response.getTrxnNumber();
paymentReference2 = response.getTrxnReference();
}