PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 7/1/2019 9:36 AM by  Paras Daryanani
Order Transactions in Hotcakes REST API
 4 Replies
 1 Subscribed to this topic
 1 Subscribed to this forum
Sort:
You are not authorized to post a reply.
Author Messages





New Member






--
5/17/2019 1:21 PM
    I want to use the Hotcakes REST API to create an order, process the payment using credit card information that is supplied to the endpoint, followed by marking the order as complete and sending the user an email receipt.

    So far I've used the OrderCreate and OrderTransactionsCreate endpoints, assuming that these will create the order with the specified line items, followed by applying the payment transaction and carry out all related workflow tasks, i.e. charge for the payment using the credit card specified in the OrderTransactionDTO object, update the order and send out an email receipt.

    It looks like my assumption is incorrect, because the workflow tasks don't seem to execute on their own. How would I go about implementing the above specified logic using the Hotcakes REST API?
    Paras Daryanani Co-founder & CTO @ Celestial Sites [email protected]





    Veteran Member






    --
    5/23/2019 1:35 PM
    There is a great deal of work and logic that goes into the checkout process (above and beyond the workflow). Could you please provide additional details about how and why you're going around the checkout process so we can best understand how to respond with assistance?
    Will Strohl, Upendo Ventures Hotcakes Cloud | Get Support | Code Support Official Cloud & Support provider for Hotcakes





    New Member






    --
    5/23/2019 3:18 PM
    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]





    Veteran Member






    --
    5/27/2019 1:52 PM
    Ah... That makes sense. Do you think you're going to be able to submit that as a pull request? :)

    You're going to need to duplicate much of the logic highlighted in the link below, in order to get this to work as you expect.

    https://github.com/hotcak...oller.cs#L1104-L1173
    Will Strohl, Upendo Ventures Hotcakes Cloud | Get Support | Code Support Official Cloud & Support provider for Hotcakes





    New Member






    --
    7/1/2019 9:36 AM
    Thanks Will, that was indeed very helpful. I've implemented this in the form of a new "CheckoutHandler" that has its own API endpoint + a new CheckoutDTO class that's analogous to a slimmed down version of the CheckoutViewModel class.

    I'm currently cleaning up useless code and doing some testing, after which I'm happy to submit an issue and a pull request on Github.
    Paras Daryanani Co-founder & CTO @ Celestial Sites [email protected]
    You are not authorized to post a reply.


    Loading
    • Sign-up for the Hotcakes Community Newsletter: