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

Errormessage

Started by victorius, September 17, 2008, 09:00:49 pm

Previous topic - Next topic

victorius

Dear Forum,

I work with Konakart version 2.2.4.
After selecting payment option:  I choose cash on delivery,  I get the following error message from Konakart.
====>
De details van het probleem zijn :

Exception Name = com.konakart.app.KKException
Exception Message = Cannot find order for Id = 21
Exception Stack Trace =
at com.konakart.bl.EmailMgr.sendOrderConfirmationEmail(Unknown Source)
at com.konakart.app.KKEng.sendOrderConfirmationEmail(Unknown Source)
at com.konakart.al.OrderMgr.sendOrderConfirmationEmail(Unknown Source)
at com.konakart.al.OrderMgr.saveOrder(Unknown Source)
at com.konakart.actions.CheckoutConfirmationSubmitAction.execute(CheckoutConfirmationSubmitAction.java:164)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
at java.lang.Thread.run(Thread.java:595)


<==

Can anyone tell me what causes this error message?

Thanks,

Victorius

ryan

The exception message is pretty clear:

Exception Message = Cannot find order for Id = 21

Have you checked in your database whether it exists ? It may not find the order if you haven't set up Order Statuses in your default language.

victorius

Thanks for your reply, I agree to that, but if I choose to pay by creditcard it works fine.

Is there anything related to the cash on delivery option which I overlook?

Thanks

ryan

Does the order exist in the DB when paying by COD ?

victorius

No, the order is not in the DB

ryan

Look at CheckoutConfirmationSubmitAction.java. The saving of the order should be done there:

            } else if (paymentType == PaymentDetails.COD)
            {
                /*
                 * Cash On Delivery. The order is saved with a pending status and the inventory is
                 * updated.
                 */

                // Set the order status
                checkoutOrder.setStatus(com.konakart.bl.OrderMgr.PENDING_STATUS);

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

                // Update the inventory
                kkAppEng.getOrderMgr().updateInventory(orderId);

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

                return mapping.findForward("CheckoutFinished");
 

victorius

Dear Ryan,

I looked into the source you mentioned. I can't see any difficulty. What I noticed was that in the source the parm in the save statement is /true and in other statements it's /false. What does this mean? Should I change this?

Thanks,
Victor

ryan

You should look at the Javadoc http://www.konakart.com/javadoc/client/ to see what parameters are used for.

However in this case just look at the comment in the line I highlighted.

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

victorius

We worked further on this message and placed DEBUG statements in the source of 'CheckoutConfirmationSubmitAction.jave'
What we noticed is that the ordernumber is not availlable in the beginning of the program. It seems that the number is made at the moment the order is saved.

While we don't have the other source code I would like to ask you to take a look in there.

Here is the source code with our DEBUG statements in the 'CheckoutConfirmationSubmitAction.java':

===>
//
// (c) 2006 DS Data Systems UK Ltd, All rights reserved.
//
// DS Data Systems and KonaKart and their respective logos, are
// trademarks of DS Data Systems UK Ltd. All rights reserved.
//
// The information in this document is free software; you can redistribute
// it and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//

package com.konakart.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.konakart.al.KKAppEng;
import com.konakart.al.KKAppException;
import com.konakart.app.PaymentDetails;
import com.konakart.appif.CustomerIf;
import com.konakart.appif.OrderIf;
import com.konakart.appif.PaymentDetailsIf;

/**
* Gets called after submitting the checkout confirmation page. Where we go from here depends on the
* payment gateway chosen.
*/
public class CheckoutConfirmationSubmitAction extends BaseAction
{
    /**
     *
     * @param mapping
     *            The ActionMapping used to select this instance
     * @param form
     *            The optional ActionForm bean for this request (if any)
     * @param request
     *            The HTTP request we are processing
     * @param response
     *            The HTTP response we are creating
     *
     */
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
    {
        try
        {
            int custId;

            KKAppEng kkAppEng = this.getKKAppEng(request);

            custId = this.loggedIn(kkAppEng, "CheckoutDelivery");

            // Check to see whether the user is logged in
            if (custId < 0)
            {
                return mapping.findForward(loginForward);
            }

            // Ensure we are using the correct protocol. Redirect if not.
            ActionForward redirForward = checkSSL(request, custId, /* forceSSL */false);
            if (redirForward != null)
            {
                return redirForward;
            }

            // Ensure that the user hasn't submitted the order and then got back to here using the
            // back button. We check to see whether the basket is null
            // Check to see whether there is something in the cart
            CustomerIf cust = kkAppEng.getCustomerMgr().getCurrentCustomer();
            if (cust.getBasketItems() == null || cust.getBasketItems().length == 0)
            {
                return mapping.findForward("ShowCartItems");
            }

            // Get the host name and port number
            String hostAndPort = request.getServerName() + ":" + request.getServerPort();

                      
            // Check that order is there and valid
            OrderIf checkoutOrder = kkAppEng.getOrderMgr().getCheckoutOrder();
            if (checkoutOrder == null || checkoutOrder.getStatusTrail() == null)
            {

              ***** comment: It seems that the getId has value '0', so it is not NULL.  ***********

               {if (log.isDebugEnabled())
              {log.debug("CheckoutConfirmationSubmitAction: Double trouble, order is not valid anymore");}
            }
               {log.debug("CheckoutConfirmationSubmitAction: Checkout code: =" +checkoutOrder.getId());
            }   }
               else
               {if (log.isDebugEnabled())
                   
               {log.debug("CheckoutConfirmationSubmitAction: Checkout code: =" +checkoutOrder.getId());
            }
               
                       
               return mapping.findForward("CheckoutDelivery");
            }

            int paymentType = kkAppEng.getOrderMgr().getPaymentType();
            if (paymentType == PaymentDetails.BROWSER_PAYMENT_GATEWAY)
            {
                /*
                 * This payment gateway is a type where the customer enters the credit card details
                 * on a browser window belonging to the gateway. The result is normally returned
                 * through a callback. Therefore we don't update the inventory here, but leave it
                 * for the callback action which will do it if the payment was approved.
                 */

                // Set the order status
                checkoutOrder.setStatus(com.konakart.bl.OrderMgr.WAITING_PAYMENT_STATUS);

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

                // Get a fully populated PaymentDetails object and attach it to the order
                PaymentDetailsIf pd = kkAppEng.getEng().getPaymentDetails(kkAppEng.getSessionId(),
                        checkoutOrder.getPaymentDetails().getCode(), orderId, hostAndPort,
                        kkAppEng.getLangId());
                checkoutOrder.setPaymentDetails(pd);

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

                return mapping.findForward("CheckoutExternalPayment");
            } else if (paymentType == PaymentDetails.SERVER_PAYMENT_GATEWAY)
            {
                /*
                 * This payment gateway is a type where the customer enters the credit card details
                 * on a browser window belonging to KonaKart. The details are passed to the KonaKart
                 * server which communicates with the Gateway server side. A response is returned
                 * immediately but we still save the order and chsnge the state later. Some notes on
                 * this: -- If we save it after receiving payment notification, something may go
                 * wrong and we would have a payment notification for an unknown order. -- If we
                 * save it after receiving payment notification, we don't have an order id to send
                 * to the gateway. The order id often appears in the email response from the gateway
                 * in order to match the response to the order. -- We save the order with a pending
                 * status but don't send an email immediately. If the payment is approved, we change
                 * the status and then send an email.-- If the payment request is never made, we
                 * keep the order in the database with a pending status.-- If the payment is never
                 * approved, we keep the order in the database with a payment declined status. If
                 * the user made at least one attempt to pay for the order, we should also have an
                 * ipnHistory object with details of the gateway transaction.
                 */
                // Set the order status
                checkoutOrder.setStatus(com.konakart.bl.OrderMgr.WAITING_PAYMENT_STATUS);

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

                // Get a fully populated PaymentDetails object and attach it to the order
                PaymentDetailsIf pd = kkAppEng.getEng().getPaymentDetails(kkAppEng.getSessionId(),
                        checkoutOrder.getPaymentDetails().getCode(), orderId, hostAndPort,
                        kkAppEng.getLangId());
                checkoutOrder.setPaymentDetails(pd);

                return mapping.findForward("CheckoutServerPayment");
            } else if (paymentType == PaymentDetails.COD)
            {
                /*
                 * Cash On Delivery. The order is saved with a pending status and the inventory is
                 * updated.
                 */

                // Set the order status
                checkoutOrder.setStatus(com.konakart.bl.OrderMgr.PENDING_STATUS);

                if (log.isDebugEnabled()) {log.debug("CheckoutConfirmationSubmitAction: CheckoutOrder="+checkoutOrder.getId());}
               
               
                // Save the order
                int orderId = kkAppEng.getOrderMgr().saveOrder(/* sendEmail */true);


                if (log.isDebugEnabled()) {log.debug("CheckoutConfirmationSubmitAction: CheckoutOrder="+checkoutOrder.getId());}
               
 
               
               
                // Update the inventory
                kkAppEng.getOrderMgr().updateInventory(orderId);

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

                return mapping.findForward("CheckoutFinished");
            } else
            {
                throw new KKAppException("This Payment Type is not supported");
            }
        } catch (Exception e)
        {
            return mapping.findForward(super.handleException(request, e));
        }
    }
}

julie

QuoteWhat we noticed is that the ordernumber is not availlable in the beginning of the program. It seems that the number is made at the moment the order is saved.


That's true but what's that got to do with the order not being saved ?

victorius

Well that's our question. For what reason is the order not saved. We tried everything we could think of.
In the documentation of the module we cannot find what parms are responsible. It's strange that the program halts because there is no order#. Is it on us to program a catch all in this case?

julie

QuoteIt's strange that the program halts because there is no order#.


Can you point me to the code that does this ?

victorius

This is the information in the logfile of konakart.log.txt:
==>
22-Sep 06:17:33 DEBUG (CheckoutConfirmationSubmitAction.java:execute:102) CheckoutConfirmationSubmitAction: Checkout code: =0
22-Sep 06:17:35 DEBUG (?:getConfiguration:?) The configuration referenced by the key MODULE_SHIPPING_FLAT_STATUS = Configuration:
id = 52
key = MODULE_SHIPPING_FLAT_STATUS
value = True
<==

This is the cosing where the program is at that stage
===>

else if (paymentType == PaymentDetails.COD)
            {
                /*
                 * Cash On Delivery. The order is saved with a pending status and the inventory is
                 * updated.
                 */

                // Set the order status
                checkoutOrder.setStatus(com.konakart.bl.OrderMgr.PENDING_STATUS);

                if (log.isDebugEnabled()) {log.debug("CheckoutConfirmationSubmitAction: CheckoutOrder="+checkoutOrder.getId());}
               
               
                // Save the order
                int orderId = kkAppEng.getOrderMgr().saveOrder(/* sendEmail */true);

<==

julie

Are you saying that the line of code :

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

is run, but no order is saved and no exception is thrown ?


victorius

Yes, that's what happens. This is what we experienced.
When I choose to pay by creditcard there is no problem. There is probably an error in processing the parms for the COD?