Is it possible to create a checkout + add a discount code + mark it as paid using APIs?

Highlighted
New Member
2 0 0

We have an existing web app where we are using the Storefront JS SDK to create a Shopify Checkout when the user adds a product to the cart. The user is then redirected to the Shopify Checkout to pay for the order.

We are now looking into adding an "express checkout" button to our web app, where we collect all required user information and receive a payment using a third party payment provider outside of Shopify. This means we need to programmatically create a checkout and mark it as paid using the API. We have managed to get this working using Draft Order.

The final piece of the puzzle is to allow our "express checkout" users to enter a discount code. It seems the draft order API only supports adding manual discounts, and there's no way to apply an existing Shopify discount code to a draft order.

So, what we need to do with the API is:

  • Create a checkout
  • Add an existing Shopify Product to the checkout
  • Add an existing Shopify discount code to the checkout
  • Both:
    • A: Redirect to the checkout web url so the user can pay there
    • B: Programmatically create an order and mark the order as paid

Using the Storefront JS SDK won't let us programmatically complete the order. Using draft orders won't let us add a discount code and recalculate the totals. Using the checkout api is only available to public apps.

Any way to do what we want with a custom or private app?

0 Likes