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

Easy way to change billing address on order

Started by jeffzzang, March 13, 2009, 09:21:36 pm

Previous topic - Next topic

jeffzzang

I am using the KKEngIf to integrate KonaKart into my existing JSP application. It looks like KKEngIf has a way to update the shipping address  for an order (before it has been saved to the database) by using KKEngIf.changeDeliveryAddress(). When I call this and save the order, the database shows the correct shipping address. However, I can't find a similar method for changing the billing address from the default customer address. Do I have to manually copy all the billing address fields using the Order.setBillingXXX() functions? Thanks!

A small code snippet:

Note: At the time this code is executed, the shipping and billing information has already been collected from the user.


/** Defined at top of the class, included for reference **/
AddressIf selectedBillingAddress;
AddressIf selectedShippingAddress;
CreditCardIf curCreditCardInfo;
String sessionId;
KKEngIf eng;


...class body omitted...

OrderIf curOrder = eng.createOrderWithOptions(this.sessionId, eng.getBasketItemsPerCustomer(this.sessionId, this.customerId, KonaKartConstants.DEFAULT_KK_LANGUAGE_ID),null,KonaKartConstants.DEFAULT_KK_LANGUAGE_ID);

/** Thought this would work **/
curOrder.setBillingAddrId(this.selectedBillingAddress.getId());

curOrder = eng.changeDeliveryAddress(this.sessionId, curOrder, this.selectedShippingAddress);

eng.getOrderTotals(curOrder,KonaKartConstants.DEFAULT_KK_LANGUAGE_ID);

PaymentDetailsIf curPaymentDetails = eng.getPaymentGateway(curOrder, "authorizenet", KonaKartConstants.DEFAULT_KK_LANGUAGE_ID);

curPaymentDetails.setCcExpiryMonth(this.ccExpiryMonth);
curPaymentDetails.setCcExpiryYear(this.ccExpiryYear);
curPaymentDetails.setCcOwner(this.curCreditCardInfo.getCcOwner());
curPaymentDetails.setCcNumber(this.curCreditCardInfo.getCcNumber());

curOrder.setPaymentDetails(curPaymentDetails);

curOrder.setStatus(1);
OrderStatusHistoryIf osHistory = new OrderStatusHistory();
osHistory.setOrderStatusId(1);

OrderStatusHistoryIf[] statusArray = new OrderStatusHistoryIf[] { osHistory};
curOrder.setStatusTrail(statusArray);

eng.saveOrder(this.sessionId,curOrder,KonaKartConstants.DEFAULT_KK_LANGUAGE_ID);

trevor

QuoteDo I have to manually copy all the billing address fields using the Order.setBillingXXX() functions?


Yes you do. There is an engine call for the delivery address because it may have tax implications if the country and zone have changed.