How to connect to external API before/during checkout and get the response for validation

I need help on how to implement sending a request to an external API/web service and getting the response data to use in validation before/during checkout. It is about getting a member’s status from an external webservice/API before checking out. If a particular response or value is returned, for example Account’s VIP Flag is false on the time of checkout, checkout should be disabled, or an error message should be displayed.

I am very new to Shopify and searched that in order for me to do this, I need to create a custom app. I already created custom apps (1 for cart-checkout-validation, and 1 for checkout-ui). But I can’t seem to work it. Maybe my idea was incorrect? Do you have sample code the same problem I have? Or is there a detailed guide on how to do this?

Hi @aih_kimg

There is no API that can implement this logic.

Hi kyle_liu,

Thank you for your reply.

What I am trying to do is send an API call from Shopify to our company’s webservice (for example an AWS API) then get the response to use as a validation back in Shopify. I have no exact idea on how to do that.

@aih_kimg shopify Try to sidestep the network request by using metafields as much as possible.
Shopify is not a server, it wont do arbitrary backend networking.

Client side networking( customers browser )

If this is before checkout using the online sales channel theme you’d need to just use javascript client-side to fetch external apis and all the complexities such as security issues that comes with :bomb:.
Or us an app proxy, again javascript client-side to fetch, so it’s on the same domain.

Checkout networking( shopify-functions enterprices/plus plans only )

To make network requests from checkout as store needs to be on an Enterprise of Plus plan to access the networking features of shopify-functions and has to be granted network access capability by shopify.

1 Like

Following up on Paul’s answer here, they are correct that the best option would be to store those values as metafields and then you can use UI extension and functions to validate during checkout.

The benefit of this is a more performant checkout process. You can then use the admin API to keep these metafields in sync.