}
GenericValue creditCard = (GenericValue) context.get("creditCard");
String expiryDate = (String) creditCard.get("expireDate");
String cardSecurityCode = (String) context.get("cardSecurityCode");
Payment payment = new Payment();
payment.setServerURL(serverURL);
payment.setProcessTimeout(Integer.valueOf(processtimeout));
payment.setMerchantId(merchantId);
Txn txn = payment.addTxn(10, orderId);
txn.setTxnSource(8);
txn.setAmount(Integer.toString(amont));
if (UtilValidate.isNotEmpty(currency)) {
txn.setCurrencyCode(currency);
} else {
txn.setCurrencyCode("AUD");
}
txn.setCardNumber((String) creditCard.get("cardNumber"));
txn.setExpiryDate(expiryDate.substring(0, 3) + expiryDate.substring(5));
if (UtilValidate.isNotEmpty(cardSecurityCode)) {
txn.setCVV(cardSecurityCode);
}
// Send payment to SecurePay for processing
boolean processed = payment.process(pwd);
Map<String, Object> result = ServiceUtil.returnSuccess();
if (UtilValidate.isEmpty(processed)) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"AccountingSecurityPayPaymentWasNotSent", locale));
} else {
if (payment.getCount() == 1) {
Txn resp = payment.getTxn(0);
boolean approved = resp.getApproved();
if (approved == false){
result.put("authResult", new Boolean(false));
result.put("authRefNum", "N/A");
result.put("processAmount", BigDecimal.ZERO);