Making external API calls prior to or during checkout

Hi,

is there any way to make an external API call when someone enters a gift card code (which is not in the Shopify database), so an external API call gets made, and that external service checks if the gift card code is valid in its database, then if it is, a discount is applied to the amount in the cart?

I am building an app and would like to use a third party gift card API during checkout. Any chance to do this?

Thanks!