Hello Shopify team!
I’m actively updating my middleware (integrated with Shopify) to support the new version of Shopify’s fulfillment service using the fulfillment orders. Unfortunately, I’m having an issue blocking me from moving forward. I’m going to detail my current process and explain the problem I’m facing to see if you can help me and point me in the right direction.
Step 01 - Orders are placed and transferred from Shopify to the warehouse system
Nowadays, my middleware is synchronizing the new Shopify orders coming from different sales channels with the warehouse system. For that, our middleware is pulling Shopify orders every 15 minutes via REST API and updating them as follows:
- For each order, I’m creating a fulfillment request via Shopify REST API using the API - Sends a fulfillment request
- Right after that, I’m accepting this fulfillment request using the API - Accepts a fulfillment request
- Once I have created and accepted this fulfillment request, then I send it to the warehouse system and update the order in Shopify with a tag.
- So far, the process of synchronizing the order and creating the fulfillment request is complete.
At that moment, I wait for the warehouse process to ship the order and circle back to our system with a shipment confirmation listing all the items shipped and the tracking numbers. This process can take between 1 day and 1 week. It is worth mentioning that I’m not having any problems with this process (step 01).
Step 02 - Order update (fulfillment and payments)
After my system has received the shipment notification from the warehouse system, I update the order in Shopify, following these steps:
- I read what was actually shipped in the shipment notification and create the fulfillment containing the shipped items by using the Shopify GraphQL API - fulfillmentCreateV2. I’m using GraphQL for this task because there are shipments with more than one tracking number.
- After that, I’m working with the “fulfill and kill” mechanism, where we must cancel and refund the customer for the unshipped items (if any) and this is where my problem lies.
- So, let’s say that an order has 5 units of a product “XYZ”, and, for some reason (out of stock, limits, etc), the warehouse shipped only 1 item, then, I must cancel 4 units of that product because one unit has already been fulfilled. For this process, I’m following these steps:
- I’m sending a cancellation request via the Shopify API - Sends a cancellation request
- I’m accepting this cancelation request via the Shopify API right away - Accepts a cancellation request
- After that, I’m calculating and creating refunds for the items not shipped through the Shopify REST API - Calculates a refund & Creates a refund
- After that, when checking the order in the Shopify admin, I see that Shopify didn’t remove all the units informed in the refund API, always keeping one unit of the refunded product inside the previously canceled fulfillment order. This causes the order to remain open, creating some problems for me.- After replicating this problem many times, I’ve noticed that sometimes Shopify behaves correctly and sometimes it doesn’t, which reinforces my theory that something is wrong.
I’m sending an image exemplifying my problem.
Can anyone tell me if I’m doing something wrong or if I should change something?
Thanks!!!
