Ad

Detecting If CarrierService API Is Available

- 1 answer

What is the recommended way of detecting if a store has CarrierService API available? I.e. it's on the right plan or billed annually.

I noticed attempting to retrieve a list of carrier services could work since it's always empty if a shop cannot use the CarrierService API. However, that feels hacky. Apart from that, I can imagine a scenario when this can return empty also for shops with that API available. Is there a better, more reliable way?

Ad

Answer

The only sure way is to try creating a carrier service. This API call will fail with a specific error message in the response body when the shop doesn't have that feature.

Ad
source: stackoverflow.com
Ad