Fulfillment Service Question - How to know the shop?

Solved
HunkyBill
Shopify Expert
4509 46 492

Assuming a fulfillment service is assigned as part of an App, and the extra step tp OPT-IN to fulfillments is taken, we now have to handle incoming calls to the endpoint, specifically /fulfillment_order_notification. Two kinds of request are expected. When the merchant clicks Request Fulfillment, Shopify sends to the endpoint { kind: FULFILLMENT_REQUEST }. I see that request! That works! NOTE: We can also expect { kind: CANCELLATION_REQUEST }. Oddly, when I cancel a fulfillment request in the admin, I never get that notification sent to the endpoint.

But neverminding that, how is the App supposed the know the shop for which the FULFILLMENT_REQUEST has just been made? We do not get the shop as a parameter, only the kind. So how is an App supposed to issue the call to now ask for assignedFulfillmentOrders when all we know is a request was made at some shop, but not which one?

Can anyone explain how that is supposed to work? On the other hand, the calls to fetch_stock and fetch_tracking_numbers do provide a shop, making it easier on the App to decide what to respond with. Am I really blind to the obvious here?

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
keiraarts
Shopify Partner
16 3 3

This is an accepted solution.

On my own app --

I'm decoding the headers and reading x-shopify-shop-domain. You'll have to verify the authenticity of the request of the webhook though.

HunkyBill
Shopify Expert
4509 46 492

The fulfillment calls are NOT WEBHOOKS! so there is no HMAC etc.. but that is good advice to look in the header. I forgot to think about that. I will expose my headers now to see if that is indeed the way to go.

Turns out Shopify does embed the HMAC in the header, so by simply leveraging the existing PayloadVerification codes, I was able to extract not only the shop, but the incoming call was also verified as being from Shopify, so that is super. It is awkward that none of this is explained very well, but we'll just let that go for now.

My next problem is why CANCEL is not being sent, when you press the CANCEL button. Seems strange that that just never fires.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
keiraarts
Shopify Partner
16 3 3

Yes you are right - they are not webhooks!

I wasn't getting cancel requests unless I had previously accepted fulfillment request. That might be worth looking into more.

HunkyBill
Shopify Expert
4509 46 492

That does make sense! While I was informed of the request, I never acted on it. Thanks for your valuable input!

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes