Got a question that has probably been asked a dozen times, but hoping someone might be able to help me out.
I need to try and integrate a payment gateway into a storefront we are building. The gateway is hosted off-site, and has an old-school way of integration, in that I need to POST some hidden fields to it. I then need to parse a response and update an order accordingly.
I think I am probably about 90% of the way through, the bit I am struggling with is updating the status of an order if it is successful or not. Here’s my pseudo-logic so far:
- A customer selects card payment from the payment methods
- Using a
v-if, I generate a form with the hidden fields. On clicking the button, I call the
placeOrder()method which creates the order in Magento 2 with a status of pending. When this is fulfilled I then submit the form with the hidden fields in
- The user enters their payment details on the 3rd party form, and on success goes to a custom ExpressJS route so that I can grab the POST data from it. With this data is the
cart_idthat has been generated for the order.
- I then redirect to my site with specific info about the payment (success, messages etc.) as query parameters.
It’s at this point where I am stuck. What I need to do ideally is update the status of the order based on if it was successful or not. If I try to construct an order and call
this.$bus.$emit("checkout-do-placeOrder"), it just generates another order instead of updating one, even if I pass the same cart_id in.
Is this something that should be handled server side? I.e. should I call a custom API endpoint to update the status? Am I even in the right area with my workflow? I tried tracing the logic from the PayPal plugin by Develo but couldn’t figure out at what state the order status is updated.
If anyone is able to give me any pointers I would appreciate it. If it helps, I’m using VSF@1.10.5. I’ll be happy to provide any more code if it helps