Websphere commerce have Out of the box functionality of handling refunds on cancellation of an order and also returns. Here i am discussing technical details of handling returns and refunds of partial order, Like if you want to cancel only 2 items out of 50 items you ordered. Let’s say you have external Order management system tide up with websphere commerce, How can we handle returns and refunds.
This external system should communicate with services. Below are the steps one has to follow for accomplising this task.
- Lets determince the structure of the request. Websphere commerce provided order status service to communicate. Structure of order status can be found in Update_WCS_OrderStatus_30.dtd .
- Once we receive request XML that follows Update_WCS_OrderStatus_30 structure. WC will invoke command implementation for OrderStatusCmd.
- Create a custom implementation say XOrderStatusCmdImpl and update CMDREG accordingly, Ensure XOrderStatusCmdImpl extends OrderStatusCmdImpl.
- This setting will ensure order will sufficient for getting the request to the our controller.
- Few key points to remember is, Get refund policy id and refund payment method id
- We can get all the values from the request xml by calling super.getOsProp(). This will give return TypeProperties.
- How can we map between XML and TypeProperties? That can be done by going through sys_template.xml
- Ensure order status is ‘X’. This is status for cancellation of order.
- Execute ReturnItemAddCmd
- Execute ReturnPrepareCmd. You can get Return item id from ReturnItemAddCmd (ex: returnItemAddCmd.getResponseProperties().getString(RMAItemId_0))
- If you want to update RMA items and RMA Item component use RMAItemAccessBean and RMAItemComponentAccessBean. I used RMAItemComponentAccessBean for setting shipment should recieve to ‘N’.
- Create RMA entry by calling RMAAccessBean. RMA should have total amount to credit and member id
- Now execute ReturnProcessCmd. finally do call super.doProcess(typedproperty). This will take care of changing the order status to X
Above steps will only prepare the data ready for processing the returns and refunds. You need to configure already exisitng scheduler job ReturnCreditAndCloseScan
The above steps will allow you to return partial order and refund partially.