Wednesday, May 18, 2011

What you Know about EDPOrder ?

Noting ?? no probs..
here is the answer.. .
  • An EDPOrder can be seen as a portion of the complete order container. The orders subsystem part is the one that handles order items, taxes, etc. The EDPOrder is the portion that handles the payments part only.
  • EDPOrder will provide the status of the task working on a payment action in backgroud
  • Copying from another blog
  • At the time of adding item to shopping cart ORDERS,ORDERITEMS and EDPORDER will get populate
  • Based on the customer payment selection in the order there is a payment instruction record will create in EDPPAYINST
  • In the code, EDP Order data is retrieved using the EDPServices as shown below.
  •  ---Rest is copyed from chetan;s blog.. here ..
    EDPOrderData edpOrderData = EDPServices.getServices().getOmfAccessor().getOMF().getEDPOrder(new Long(getOrderId()), Integer.valueOf(storeId));
    Long edpOrderId = edpOrderData.getOrderKey();

    We get the EDP order payment instructions through the following

    SortedSet pis = EDPServices.getServices().getOmfAccessor().getOMF().getPis(edpOrderId);

    Using the payment instruction returned, you can get the details like amount, payment method, etc.

    Orders data can be accessed using the websphere commerce OrderAccessBean and order details using OrderItemAccessBean

    There is a PPCPAYINST table which stores the value object Payment Instruction in WCS which contains information for payment plugins to process the final payments. Payments for a specific payment method can only be charged upto a maximum specified by the AMOUNT column in PPCPAYINST table. PPCEXTDATA contains non-standard data specific to a payment method. For example, paymentexpress might have some non-standard protocol data which is stored in here

  • Payment Tables 
  • POLICY
  • ORDPAYMTHD
  • ordpayinfo
  • paysummary
  • POLICYTYPE
  • EDPPAYINST
  • EDPORDER

  • Payment flow
  • Customer select payment method(VISA) from store front
  • OrderProcess invokes PrimePayment task command
  • select * from policy table where where policyname='visa'
  • update the EDPOrder table
  • PrimePayment task command calls the Payment rules engine
  • Payment rules engine determines the Action that needs to be performed
  • The Action (wrapped into event) is passed to the Payment plug-in-controller
  • The payment plug-in controller determines the plug-in to be used
  • The Action is invoked agaist the plug-in
  • The plug-in interacts with payment service provider 

  • All configures are there in 
  • xml/config/payment(s)/paymentmapping.xml,*.xml

Tuesday, May 17, 2011

WebSphere Commerce Order Flow process

WCS Order management flow
Place an order.
  • A customer(use store front) or an administrator(Use accelerator/MC) who has the authority to act on behalf of the customer places an order with the store.
  • While adding items to shopping cart order status will be Pending state
Check out:
  • After the shopper completes the order checkout sequence, the order moves from a Pending state (P) to M state (pending payment approval). Here the order can also go into the state of M or C (for some payment method) or L (no inventory and no back order) or B (some backordered orderitems).
  •  When the order checkout sequence is complete the order moves to one of the following states:
    •  A:Payment authorization requires review
    •  B:Backordered
    •  C:Payment authorization complete
Order Approval
  • B2B required Order Approval , B2C not required
  • Approve payment for the order, if required. Payment methods such as COD (Cash on Delivery) and Bill Me do not need approval.
Order Process
  • If the order contains products that are to be backordered, then it moves to state B (backordered).
  • Orders can be backordered with the command ProcessBackorders, or by a scheduler.
  • For reauthorization, the order goes back to state M or a state such as A, I, B, or C. After a backorder is approved, it should be allocated and not reordered, or else it may go back for approval again.
  • Order process includes following task -using accelerator
    • Finding Order
    • Change the quantity of the product in the order
    • Changing the purchase order number for an order in a B2B direct store
    • Add/Remove a product to an order
    • Selecting another shipping address/Shipping method/billing address for an order
    • Changing the total price of an order
    • Editing an order level adjustment
    • Changing the payment options/payment processing for an order
    • Add comments
    • View -Order summary/payment status/Order invoice
    • Cancel the orders
    • Apply Order Blocks
Order Release:
  • Release the order to fulfillment. The Scheduler Job ReleaseToFulfillment releases the orders to fulfillment.
  • When all order items for the order are released, the order moves to state R (Released).
Order Fullfillment:
  • Create a pick batch for all orders released to the specified fulfillment center using Websphere commerce Accelerator
  • View and print pick tickets.
  • View and print packaging slips.
  • Pick and pack products specified in the pick ticket and packing slip.
  • Create package.
  • Ship goods. Ship the order to the customer. (No action from wcs)
Order Completion:
  • Confirm shipment has been sent. When all order items are shipped, the order moves to S (Shipped) status.
  • Finalize the order.
    • The BalancePayment scheduled job initiates payment deposit. The order state moves to D (Deposited).
    • The OrderClose checks whether the shipped order is totally deposited. If YES, the order status is changed to 'D';
    • OrderPaymentSynchronize:Checks whether the order is totally authorized. If YES, the order status is changed to 'C'
Note:
Order Process flow another look
http://www.albeesonline.com/blog/category/websphere/websphere-commerce-websphere/

Some Order Command tips:

OrderItemAddCmdImpl
Call ResolveSKUCmdImpl:
+--Check the product attributes and based on that values locate the items , which is ready for order
  -check catentry is buyable or not
  -Check customer is entitlement to buy this catentry id
  -if all above params correct contine
  -if fails but continue=1 then skip to next order
  -if orderitemId is provided update the
  -if partnum/catentry provided new orderitem id
  -if address_id not specified use default(P,nickname)
  -if quantity is 0 delete
  -if shipmod id not availabnle use default
  -Call GetContractUnitPriceCmd to calcuate the price
-OrderItemUpdateCmdImpl
-OrderCreateCmdImpl
-UpdateShippingAddressCmd
+--call findAddressIdForOrderItem() to find the shipping address for orderitem
+--call ValidateOrderAddressCmd to validate billingaddress and shipping address
+--updateShippingAddress() 
-ValidateTradingPaymentCmd
+--This command checks whether the payment method to be added comply with the BOPIS (Buy Online Pick In Store) rules. 
-DoInventoryActionCmd
+--To do all inventory operations
+--There are 10 usages identified as interfaces between the order commands and this interface command.
+--For every usage, different parameters are required
+--Action and parameters together will help to do further processing
-UpdateShipInfoCmdImpl
+--Update SHIPINFO table(ship carrier act number,ship charge type,ship instructions,ship mod)
-RaiseOrderEventCmdImpl
+--This Order task command is used to raise an order related event
+--raiseOrderCancellationEvent()
+--raiseOrderItemUpdateEvent()
 OrderCalculateCmdImpl

This command is called by OrderItemBaseCmdImpl and OrderItemDeleteCmdImpl to refresh the order price, charges and freebie items after Add, Update and Delete order item.
The default implementation of this command is OrderCalculateCmdImpl. But in out-of-the-box CMDREG table, the implementation of this command is mapped to PromotionEngineOrderCalculateCmdImp

-Unlock the order
-initialize the specified CalculationUsages that are enabled
-if RulesBasedDiscount component is enabled
-call discount service to obtain the list of catalogentry to add to order
-if ATP is disabled and there is insufficient inventory
-remove catalogentry from the list
-add catalogentry identifier to outOfInventoryCatalogEntryId list
-Recalculate specified calculation usages
-call the OrderItemAdd
-update the productTotal attributes of the Order and its OrderItems
-update the SubOrders for the Order
-apply the specified CalculationUsages that are enabled
-summarize the specified CalculationUsages that are enabled
-Finally, call the setResponseProperties() method.
-ResolveOrderCmd
-Promotion engine to determine the catalog entries to add
-Recalculate Order
 OrderPrepareCmdImpl
  -prepare order by
  -determine prices
  -discounts
  -shipping charges
  -shipping adjustment
  -taxes
  -Lock the order(1)
  -ensure all orderitems are buyable
  -update order item address
  -update order item validation
  -update order item prices
  -update order item total
  -update auto added order items
  -check order inventory
 OrderProcessCmdImpl

 OrderPrepareCmdImpl
  -Prepares the orders for Display(OrderDisplayCmd)
  -Prepares the orders for OrderProcess
  -if no orderId then use Current pending order
  -Default error view OrderNoneErrorView
  -if commit=1 start new db transaction for every order
  -status should P WINE (bipins formula :)
  -Call PrepareOrder task command
  --Delete generated orderitems(PREPAREFLAG)
  --check CATENTRY.BUYABLE=1
  --If ATP inventory allocation is enabled/disabled, call the DoInventoryActionCmd
  --Call the ValidateDynamicKitConfiguration task command.
  --Obtain new unit price(GetContractSpecialPrice/GetBaseSpecialPrice)
  --Do not refresh prices for order items whose prepareFlags attributes specify "quotation
  -prepare order by
  -determine prices
  -discounts
  -shipping charges
  -shipping adjustment
  -taxes
  -lock the order
  -ensure all orderitems are buyable
  -update order item address
  -update order item validation
  -update order item prices
  -update order item total
  -update auto added order items
  -check order inventory






Monday, May 16, 2011

How to add servlet in the WCS

It is so easy .. check my findings

Step 1; Open \web.xml
add below section
<servlet>
 <display-name>MyServlet</display-name>
 <servlet-name>MyServlet</servlet-name>
 <servlet-class>com.mycompany.wcs.servlet.MyServlet</servlet-class>
</servlet>
 <servlet-mapping>
 <servlet-name>MyServlet</servlet-name>
 <url-pattern>/MyServlet</url-pattern>
</servlet-mapping>

Save and restart the server..
That is it.. Servlet is ready

Now create MyServlet.java under com.mycompany.wcs.servlet.MyServlet package
Make sure service() method is available in your servlet .. and your  MyServlet extends HttpServlet

Done..  call your servlet from anywhere ..
Enjoy servlet in wcs :)