My objective is to create a scheduled task places recurring orders for customers in a Hotcakes website. The scheduled job uses an external database to fetch customer details, including the customer billing address, shipping address, credit card info (number, expiry and cvc). After fetching the customer details, an order should be created in Hotcakes and the customer credit card should be charged. I expect all relevant workflow tasks to take place, i.e. assign order number, set order status to 'placed', apply a transaction and charge the credit card, set order status to paid if successful etc ( just as the website usually works when a user places an order through the Hotcakes frontend). At the moment, this is what actually happens: 1. Using the OrderCreate endpoint, an order record is saved in the Hotcakes database (but doesn't show up in the Hotcakes sales dashboard) 2. Using the OrderTransactionsCreate endpoint, a transaction record is saved in the Hotcakes database. This does not however charge the credit card. The order is still invisible in the Hotcakes sales dashboard. Bottom line: The order is not actually processed in Hotcakes. Only a db row is inserted in the orders table and another db row is inserted in the transactions table. Credit cards are not charged and orders are not confirmed. My questions is, how can I implement the end-to-end ordering process in my scheduled task, i.e.: 1. create order 2. assign order number 3. charge credit card and apply transaction to order 4. if step 3 is successful, set order to complete (it's a non-shipping product) and email the customer 5. if step 3 is not successful (e.g. card declined), set order to unpaid and email the customer
Paras Daryanani
Co-founder & CTO @ Celestial Sites
[email protected]
|