Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Checkout API - Polling / throttling

Checkout API - Polling / throttling

DiscountNinja
Shopify Partner
104 0 67

Hi,

 

The documentation (https://help.shopify.com/en/api/guides/sell-through-the-checkout-api#polling) states that apps using the Checkout API should handle 202 and 303 messages properly.

 

How can app developers test their implementation of this polling mechanism?

We have tried to simulate this situation by creating multiple checkouts in parallel, but we were not successful in getting 202 or 303 messages, we received only 201 and 429 messages.

 

Can Shopify provide us with one or more of the following?:

- a procedure to reliably provoke the checkout api to respond with 202 / 303 messages

- a clear description of the exact header received in the case of 202 / 303 (the issue https://community.shopify.com/c/Shopify-APIs-SDKs/Polling-Queue-When-Creating-Checkout/m-p/523353#M3... seems to indicate that there is a discrepancy between what is documented and what is actually received in the header, at least in some cases)

- a test endpoint for 202 and a test endpoint for 303 that help to simulate this

 

As it stands we are unable to implement and test what we consider an absolutely critical aspect of the use of the Checkout API. 

 

Looking forward to your assistance on this.

 

Regards,

Bart 

 

Bart Coppens | Limoni Apps | Building apps for Shopify since 2016
Replies 6 (6)

DiscountNinja
Shopify Partner
104 0 67

Does anyone have experience with testing this scenario?

Shopify staff: any suggestions?

Bart Coppens | Limoni Apps | Building apps for Shopify since 2016

Alex
Shopify Staff
1561 81 343

Hey Bart.

 

Let me expand a bit on when you'll see these statuses:

 

  • 201 / 303 - When the checkouts created per-minute exceeds 5, 303s are returned rather than 201s. (Checkout creation)
  • 202 - This will occur on creation when the shop makes use of an asynchronous tax calculation service (more typical on Plus) or, more commonly, the checkout has yet to fetch shipping rates through an external service (such as our own carrier calculated shipping).

You should be able to test a 201/303 situation by surpassing 5 checkout creations in a minute from what I can tell, although you did mention that you were creating some simultaneously, so I wonder how many. A shop ID would give me more insight on that.

 

The 202 is going to be trickier and will likely require you to create a carrier service through which the rates will be requested on checkout creation.

 

I hope that helps a bit.

 

Cheers.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

DiscountNinja
Shopify Partner
104 0 67

Hi Alex,

 

Thanks for the super clear answer. Very helpful indeed!

 

Regarding the 303s: we're not able to get the checkout service to send 303s.

Our test app (I can send it to you, you can run it easily on LinqPad) sends 36 requests to our test store (dev store with following domain: https://discount-ninja-dev-store-33.myshopify.com) creating a complex 15 line item checkout in parallel threads.

It receives a 201 response for all 36 requests within (milli)seconds.

This doesn't seem to be in line with the limitations you outlined in your answer.

Attached is a screenshot of the traffic recorded by Fiddler during the test.fiddler checkout test.png

 

Regarding the 202: any guidance on how to set up such a carrier service?

 

Regards,

Bart

 

Bart Coppens | Limoni Apps | Building apps for Shopify since 2016
Alex
Shopify Staff
1561 81 343

My assessment was definitely incorrect on the checkouts throttle (303s). So for platform protection reasons I actually can't go into specifics of how it works, but what I can say is that if you're using the checkouts API in a way that we would expect, like what we only ever really see, then you won't hit a 303 (we hardly ever see these as it would turn out). The best answer that I can really give in this case is to expect it and react accordingly, unfortunately I don't think we can provide a way for you to set it up in your testing.

 

For the carrier service:

 

You can create one with the carrier_service API - https://help.shopify.com/en/api/reference/shipping-and-fulfillment/carrierservice

 

If you've already understood that and have more specific questions though let me know. The best I can say without making any assumptions is that you'll probably want to be deliberately slow when returning rates to the checkout you're creating.

 

Cheers.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

DiscountNinja
Shopify Partner
104 0 67

Hi Alex,

 

Thanks for your response. So, if I understand correctly, we shouldn't worry about 303s happening in real life too much, correct?

We also use the DraftOrder endpoint for our app, which can respond with "invoice is not ready" when using the returned invoice_url immediately. That behavior happens often in real life. I'll create a separate ticket related to that. I guess we expected the 303 result of the checkout api to be similar.

 

In conclusion: I guess we'll have to write our own test endpoint to mimic the 303 behavior.

Can Shopify provide an exact header that such a test endpoint should return?

 

Regards,

Bart

Bart Coppens | Limoni Apps | Building apps for Shopify since 2016
Alex
Shopify Staff
1561 81 343

Hey Bart.

 

Correct, it's unlikely that you'll be seeing 303s, so don't worry about it occurring often if at all.

 

I can't speak to which headers you'll receive as a response besides most typical ones in addition to the Location header, which which you can poll the checkout until it has been created.

 

Cheers.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog