KonaKart Community Forum

Installation / Configuration => Programming of KonaKart => Topic started by: Ted on October 29, 2009, 02:56:07 pm

Title: Order not saved
Post by: Ted on October 29, 2009, 02:56:07 pm
In my Wicket application I have used a great deal of the shopping cart code of the Struts/JSP application.

Now I've taken some of the code from CheckoutConfirmationSubmitAction.java to save the order en get the payment details at the end of the checkout process:


// Save the order
int orderId = kkAppEng.getOrderMgr().saveOrder(/* sendEmail */false);
log.debug("Order succesfully saved as order id " + orderId);

OrderIf dbOrder = kkAppEng.getEng().getOrder(kkAppEng.getSessionId(), orderId, -1);
log.debug("From db: " + dbOrder);

// Get a fully populated PaymentDetails object and attach it to the order
log.debug("Retrieving payment details with sessionId=" + kkAppEng.getSessionId()
+ ", code=" + checkoutOrder.getPaymentDetails().getCode()
+ ", orderId=" + orderId + ", hostAndPort=" + hostAndPort + ", langId="
+ kkAppEng.getLangId());
PaymentDetailsIf pd = kkAppEng.getEng().getPaymentDetails(kkAppEng.getSessionId(),
checkoutOrder.getPaymentDetails().getCode(), orderId, hostAndPort,
kkAppEng.getLangId());
checkoutOrder.setPaymentDetails(pd);


Note that I have added some debug statements myself. This is because I'm getting an exception the following exception:


DEBUG CheckoutPayment - Order succesfully saved as order id 5
DEBUG CheckoutPayment - From db: null
DEBUG CheckoutPayment - Retrieving payment details with sessionId=196bd4150d08942f9b2b6ee9d72a9465, code=<mycode>, orderId=5, hostAndPort=<myshop.com>:8080, langId=1
ERROR CheckoutPayment - Oops.
com.konakart.app.KKException: Cannot find order for Id = 5
at com.konakart.bl.modules.payment.PaymentMgr.getPaymentDetails(Unknown Source)
at com.konakart.app.KKEng.getPaymentDetails(Unknown Source)
at com.konakart.app.KKEng.getPaymentDetails(Unknown Source)
at <somepackage>.CheckoutPayment.process(CheckoutPayment.java:183)


at com.konakart.bl.modules.payment.PaymentMgr.getPaymentDetails()

Except for the log statements every API call is the same in the correct sequence. May be it has something to do with my current user or something I forgot to do before this point, but I can't debug the fact that the order which is supposed to be saved (I'm getting a id) isn't saved - calling kkAppEng.getEng().getOrder(...) results in null and in the database indeed actually nothing shows up.

Any hints to look for would be appreciated!
Title: Re: Order not saved
Post by: Ted on October 29, 2009, 02:59:47 pm
Hmm, wait! The orders ARE actually in the MySQL database in the 'orders' table. But they're not given back by the API - not even to be seen by konakartadmin app.
Title: Re: Order not saved
Post by: Ted on October 29, 2009, 03:12:32 pm
Ah solved!

http://www.konakart.com/forum/index.php?topic=136.0 pointed my into the direction of missing order statusses in my language.