HttpServletRequest request,
HttpServletResponse response) throws Exception {
init(request);
ContentBean contentBean = getContentBean(request);
Site site = contentBean.getSiteDomain().getSite();
ShoppingCart shoppingCart = ShoppingCart.getSessionInstance(request, true);
EntityManager em = null;
em = JpaConnection.getInstance().getCurrentEntityManager();
Customer customer = getCustomer(request);
if (customer.getCustPassword() == null) {
ShoppingCartActionForm form = (ShoppingCartActionForm) actionForm;
ActionMessages errors = validate(form, site.getSiteId());
if (errors.size() != 0) {
saveMessages(request, errors);
form.setCustPassword(null);
form.setCustVerifyPassword(null);
this.initAddressInfo(form, site, shoppingCart, request, errors);
this.initSearchInfo(form, site.getSiteId(), errors);
this.initCartInfo(form, site, shoppingCart, request, errors);
createEmptySecureTemplateInfo(request);
return actionMapping.findForward("error");
}
Customer c = (Customer) em.find(Customer.class, customer.getCustId());
c.setCustPassword(AESEncoder.getInstance().encode(form.getCustPassword()));
c.setCustPublicName(form.getCustPublicName());
}
PayPalEngine paymentEngine = (PayPalEngine) shoppingCart.getPaymentEngine();
String orderNum = null;
createEmptySecureTemplateInfo(request);
OrderEngine orderEngine = new OrderEngine(shoppingCart, null);
try {
OrderHeader orderHeader = orderEngine.getOrderHeader();
InvoiceEngine invoiceEngine = new InvoiceEngine(orderHeader, null);
invoiceEngine.invoiceAll();
invoiceEngine.setCreditCardInfo(orderEngine.getCreditCardInfo());
invoiceEngine.payOrder(shoppingCart.getPaymentEngine(), request);
orderEngine.saveOrder();
orderNum = orderEngine.getOrderHeader().getOrderNum();
invoiceEngine.saveOrder();
}
catch (PaymentException e) {
logger.error(e);
paymentEngine.cancelPayment();
shoppingCart.cancelTransaction();
em.getTransaction().setRollbackOnly();
return actionMapping.findForward("paymentError");
}
try {