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

Modifying the delivery using the web service

Started by sputnikgota, January 10, 2008, 12:36:06 am

Previous topic - Next topic

sputnikgota

Hi,

We've been working on the Konakart integration with OpenCMS using the web service and having some issues in changing order details.

Our user story:

- create a cart for a customer by calling getTempCustomerId, addToBasket, getBasketItemsPerCustomer, removeFromBask etc.
- check if the customer exists upon checkout by calling doesCustomerExistForEmail
- if the email exists, let the customer log in, otherwise collect the customer info required for CustomerRegistration
- in both ways, call createAndSaveOrder to create an order
- provide billing details page to edit the billing address and save it by editCustomerAddress
- provide delivery details page to edit the delivery address and save it by changeDeliveryAddress
- provide order item summary to verify the order by getOrder
- provide the payment page to edit the payment details
- when the above is completed, process the payment transaction by using our payment module API (external from Konakart)
- change the order status according to the transaction by calling changeOrderStatus(

The issue is

- provide delivery details page to edit the delivery address and save it by changeDeliveryAddress

returns the order object with the correct delivery address specified but this is not saved in the database

My understanding is that once an order is created by createAndSaveOrder, there is no way to modify the order object since there is no editOrder in the service and all what we can change are the delivery address and the order status by calling changeDeliveryAddress and changeOrderStatus.

changeOrderStatus does the job fine but changeDeliveryAddress doesn't.


Could you please let us know if this is a bug or my usage is wrong.


The following is my test case which passes but the data is not saved (konaKartService is our interface to encapsulate KK Web service):

    @Test
    public void testChangeDeliveryAddress() {
        System.out.println("testChangeDeliveryAddress - start");
        try {
            Integer customerId = konaKartService.getTempCustomerId();

            assertNotNull(customerId);
           
            Basket[] baskets = createBasketsByCustomerId(customerId);
           
            String sessionId = konaKartService.login(email, password);
           
            System.out.println("testChangeDeliveryAddress sessionId=" + sessionId);

            assertNotNull(sessionId);
            assertTrue(konaKartService.checkSession(sessionId));
           
            //order
            Order order = konaKartService.createAndSaveOrder(email, password, baskets);

            assertNotNull(order);
            assertNotNull(order.getId());

            Address address = konaKartService.createAddress();
            address.setFirstName("Hirok");
            address.setLastName("Got");
            address.setStreetAddress("112 Hoddel st");
            address.setCity("Abbotsford");
            address.setSuburb("Abbotsford");
            address.setPostcode("3067");
           
            Zone[] zones = konaKartService.getZonesPerCountry();
            address.setState(zones[3].getZoneName());
           
            Order orderRetrieved = konaKartService.changeDeliveryAddress(sessionId, order, address);
           
            assertEquals(order.getId(), orderRetrieved.getId());

            System.out.println("testChangeDeliveryAddress order.getId()=" + order.getId());
           
            assertEquals(orderRetrieved.getDeliveryStreetAddress(), address.getStreetAddress());
           
        }catch (Exception e) {
            System.out.println("testCreateAndSaveOrder4ExistingCustomer exception! konakartService.getKKWSEngIf())=" + konaKartService.getKKWSEngIf());
            e.printStackTrace();
            assertTrue(false);
        }
    }
           



julie

Hi,

That sounds like an interesting project. Please send us a link when it is up and running.

What you need to do is to call createOrder() and only call saveOrder() when all of the details have been confirmed. The method createAndSaveOrder() that you are using was created to simplify the process but you lose some flexibility along the way. An example of how to create and save an order can be found here : http://www.konakart.com/apiexamplesfaq.php#CanYouShowMeAnExample by downloading the zip file.

The createOrder() method, returns a partially populated Order object which hasn't yet been saved in the DB. To change the billing address, you can just edit the order object directly. To change the delivery address, you should make an API call since this modification could affect the tax rates applied on the products.

When all of the details are finally confirmed by the user, you can then save the order and it will be persisted in the DB.

Good luck,

Julie

kate

just a quick note - from 2.2.1.0 you don't have to download those api examples separately - you'll find them included in every download kit (at the top level of the installation directory - called java_api_examples) with an ant build file to make it easy to get them built...

BTW..  sounds like you're doing some interesting things in your project...  please send a link when you can!

Kate

sputnikgota

Thanks for the quick reply and that makes sense.

We'll change the implementation accordingly and will let you know.

We're happy to send you the link when done! it should be around the end of Feb ~ Mar.

Thanks again.

Go