* @return
*/
public FormSubmission processAddCardRequest() {
//Get the form data
CardEditForm cf = getCardFromRequest();
CreditCard card = null;
//Validate and add address
if (cf.isValid()) try {
Visitor v = (Visitor) req.getSession().getAttribute(SESSION_ATTRIBUTE_VISITOR);
AddressHandler ah = new AddressHandler(req);
ah.processAddAddressRequest();
card = new CreditCard(cf.getCardNumber(), cf.getExpMonth(), cf.getExpYear(), cf.getSecurityCode(), cf.getNameOnCard(), false, v.getCustomer(), ah.getAddr());
card.setCardType(cf.getCardType());
service.store(card);
} catch (Exception e) {
l.log(Level.WARNING, "Failed to store card", e);
cf.setResultMessage("Could not store card");
}
String context = req.getParameter(Parameters.CONTEXT.getId());
l.info("context="+context);
if (context != null && context.equals(Contexts.ORDER_PAYMENT.getId())) {
OrderHandler oh = new OrderHandler(req);
cf.setResultView(oh.getOrderPaymentView());
return cf;
}
else {
cf.setResultView(getCreditCardView(card));
}
return cf;
}