Square Connect Api V2:如何在订单级税下禁用特定订单项税费?
Absolutely! You can create an order with order-level taxes and exclude specific line items from being subject to those taxes using the CreateOrder endpoint. Here's how to do it properly:
Step 1: Define your order-level tax
First, include your order-level tax in the taxes array of your CreateOrder request. Assign it a unique uid (you can generate this yourself or let Square auto-generate it, but specifying it makes referencing easier later):
"taxes": [ { "uid": "order_sales_tax", "name": "State Sales Tax", "percentage": "7.25", "scope": "ORDER" } ]
Step 2: Exclude the tax from specific line items
For any line item that shouldn't be taxed, add an entry to its applied_taxes array that references the order-level tax's uid and sets the scope to EXCLUDE. This overrides the default behavior of applying the order-level tax to all items:
"line_items": [ { "name": "Taxable Product", "quantity": "1", "base_price_money": { "amount": 5000, "currency": "USD" } // No applied_taxes entry here → order-level tax is applied automatically }, { "name": "Tax-Exempt Product", "quantity": "1", "base_price_money": { "amount": 3000, "currency": "USD" }, "applied_taxes": [ { "tax_uid": "order_sales_tax", "scope": "EXCLUDE" } ] } ]
Alternative Approach (if needed)
If for some reason the exclusion method doesn't fit your workflow, you're right that moving taxes to the line-item level works too—just add the tax directly to the line items that need it, and omit it from exempt ones. But the exclusion method above is the cleanest way to maintain order-level tax settings while exempting specific items.
Just make sure you're using the correct field names and scopes as defined in Square's API schema, and test the request with Square's sandbox first to verify the tax calculations are correct!
内容的提问来源于stack exchange,提问作者taekimjr

