• Welcome to KonaKart Community Forum. Please login or sign up.
 

No Credit Card Processing for zero dollar carts

Started by mtoon, July 02, 2008, 01:17:43 pm

Previous topic - Next topic

mtoon

Hi all-
We recently found that if a cart totalled zero dollars that we were still going through the CC processing step.  I added this code to the CheckoutConfirmationSubmitAction class to handle this case.  I'm just posting this here in case anyone else has the same issue.



            OrderIf checkoutOrder = kkAppEng.getOrderMgr().getCheckoutOrder();
            if (checkoutOrder == null || checkoutOrder.getStatusTrail() == null)
            {
                return mapping.findForward("CheckoutDelivery");
            }

---------------- BEGIN  NEW CODE --------------------
            BigDecimal orderTotal = checkoutOrder.getTotalIncTax();
            if (orderTotal.compareTo(java.math.BigDecimal.ZERO) == 0) {
                // Set the order status
                checkoutOrder.setStatus(com.konakart.bl.OrderMgr.PAYMENT_RECEIVED_STATUS);

                // Save the order
                int orderId = kkAppEng.getOrderMgr().saveOrder(/* sendEmail */true);

                OrderIntegrationMgr oim = new OrderIntegrationMgr();
                oim.manageDigitalDownloads(orderId);
               
                // Update the inventory
                kkAppEng.getOrderMgr().updateInventory(orderId);

                // If we received no exceptions, delete the basket
                kkAppEng.getBasketMgr().emptyBasket();

                return mapping.findForward("CheckoutFinished");
            }

------- END NEW CODE -------------           
            int paymentType = kkAppEng.getOrderMgr().getPaymentType();

julie

Thank you mtoon, for sharing that with us.

Just one point:

When using the Web Services SOAP interface you may not be able to instantiate a local version of the OrderIntegrationMgr() since you could be on a completely different server compared to where the KonaKart engine is running.

An alternative way of achieving the same functionality is to edit the OrderIntegrationMgr so that it calls manageDigitalDownloads() in the save method if the status is OrderMgr.PAYMENT_RECEIVED_STATUS. The save method of the OrderIntegrationMgr will be called automatically when the order is saved.

mtoon

you know, i tried that, but it didn't work.  That was the first thing I tried.  Setting Payment received on the order if the value is zero.  But the method was never called..  Thoughts?

julie

The saveOrder method of the OrderIntegration manager should get called ?

You can edit that method to look something like this:

    public void saveOrder(OrderIf order)
    {
        log.info("The order with id = " + order.getId() + " has just been saved ");

        // When an order has a total of zero it can be saved with a payment received status
        if (order.getStatus() == com.konakart.bl.OrderMgr.PAYMENT_RECEIVED_STATUS)
        {
            manageDigitalDownloads(order.getId());
        }
    }

mtoon

That's a great idea.  I realized we are saving the order with an initial status of payment received and never changing it.  I'll add the code to saveOrder.

Thanks for your help!