How to use DraftOrderCreate API to get calculated Taxes

How to use DraftOrderCreate API to get calculated Taxes

ezup
Visitor
1 0 1

Hi community,

 

We are integrating Shopify in our e-commerce website and using a 3rd party payment gateway.

 

I am trying to do the following:

 

1. Use DraftOrderCreate API to create an order, and get the tax rate from the DraftOrder based on the shipping address provided by the customer during checkout.

 

2. Add the calculated sales tax to the subtotal and send the total amount to the 3rd party payment gateway for authorization and payment process (not via Shopify API)

 

Issues encountered, the draftOrder doesn't contain any tax information in the taxLines field even though a valid shipping address is provided. How can we get the tax rate or calculated taxes from this API?

 

Thanks,

Reply 1 (1)

goldi07
Navigator
360 38 69

Hello @ezup 

You're on the right track with using the DraftOrderCreate API for Shopify, but there's a limitation: DraftOrderCreate does not automatically calculate tax lines unless certain conditions are met.

Here’s a breakdown of why you’re not seeing tax info — and how to get calculated taxes properly for use with a 3rd party payment gateway:

 

 

 

Why DraftOrderCreate isn't returning taxes:
1. Taxes are calculated only when the use_customer_default_address or full tax-relevant data is passed, and even then, only if Shopify can determine the tax jurisdiction.

2. Shopify doesn’t calculate tax lines for draft orders the same way it does for checkout or order APIs.

3. Most importantly: taxes on Draft Orders are not guaranteed to be calculated until the order is completed or the invoice is sent.

 

 

Solution: Use the Checkout API or Order/Tax Services API instead
If your goal is to retrieve tax calculations before processing payment externally, this is the more reliable route:

 

Option 1: Use the Checkout API
The Checkout API (Storefront API) will:

. Accept full line items and shipping address

. Return a checkout object with accurate taxLines, totalTax, and totalPrice

Example mutation:

graphql...

mutation checkoutCreate($input: CheckoutCreateInput!) {
  checkoutCreate(input: $input) {
    checkout {
      id
      totalTaxV2 {
        amount
      }
      totalPriceV2 {
        amount
      }
    }
    checkoutUserErrors {
      field
      message
    }
  }
}

 

You’ll pass in:

. Line items (variant IDs + quantity)

. Shipping address

. Email (required)

 

 

Option 2: Use the Order API with Tax Services (Only for Shopify Plus)
If you're on Shopify Plus, you may be able to use custom tax services or Orders API with tax overrides — but for most stores, Checkout API is the only reliable pre-payment tax calculator.

 

 

Why not to rely on DraftOrder for tax estimates
. DraftOrder was designed for internal/admin use (e.g., invoices or phone orders), not real-time tax quotes.

. Its tax calculation behavior is limited and inconsistent across store setups (e.g., US vs. EU vs. Canada).

 

 

Your Best Workflow (Recommended)
1. Use Storefront checkoutCreate mutation with full shipping address

2. Get the accurate totalTax and totalPrice

3. Pass that totalPrice to your 3rd-party payment gateway

4. After payment, use the Order API to create an order with financial_status: paid and the externally processed payment details

 

Thank you 😊

Was I helpful?

Buy me a coffee


APPS BY US :

Professional Customer Accounts APP


Want to modify or custom changes or bug fix on store . Or Need help with your store? Or -Want Complete Storefront
Email me -Goldi184507@gmail.com - Skype: live:.cid.819bad8ddb52736c -Whatsapp: +919317950519
Checkout Some Free Sections Here