#What is the correct correct JSON Response for the Tax Calculation SPI Extension?

9 messages · Page 1 of 1 (latest)

static niche
#

The documentation is not clear and seems to be wrong about the JSON return for the Tax Calculation SPI Extension using REST.
https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/tax/tax-calculation-integration-service-plugin/calculate-tax

Need help because although my self hosted API receives the POST with the information, the return does not seem to correctly trigger the checkout value needed. Also the GraphQL data does not include any error.

leaden orchid
#

The documentations seems to be clear. You post does not include what data you are receiving, the response of your API and the actual result on the application so it is very difficult to assess as all you mention is "the return does not seem to correctly trigger the checkout value needed"
but there is no data to support that in your post. So it might be best you share this

static niche
#

I mentioned that I receive the POST request on my self-hosted API at {DEPLOYMENT-URI}/v1/calculate-tax with the JSON from the documentation:

  "lineItems": [
    {
      "id": "item123",
      "item_name": "some",
     ...
    }
  ],
  "addresses": [
   ...
  ],
  "currency": "USD"
}```

The problem is that the documentation show a response JSON that does not match even the own documentation (snake case x camelCase for the properties).

{
"currency": "USD",
"tax_summary": {
"total_amount": "123.00",
"total_tax": "10.15",
"total_taxable_amount": "123.00",
"total_tax_included_in_price": "0.00"
},
...

And even though I tried both responses, the checkout does not seem to receive the correct response and always falls back to backup rate.

The documentation is so NOT CLEAR that on this page:
https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/extensions/tax/tax-calculation-integration-service-plugin/introduction

The JSON configuration has a wrong `deploymentUri` property (string VS object) and a wrong base URI pathname `https://my-tax-calc.com/v1/calculateTax` VS `https://my-tax-calc.com/v1/calculate-tax`.
cloud cragBOT
cloud cragBOT
# cloud crag 👀 Looks like you’re trying to post some code? I can help... probably more eager...

👀 Pssst… here's the quick tip! If you're sharing code, could you drop it in like this?

```js
const myCode = 'here';

export function myFunc() {
return true;
}
```

✨ It formats it all nice and shiny (example below) and makes it waaaay easier for everyone to help you out.
Because messy code? Chaos. Formatted code? Beautiful, helpful chaos. 🛠️

const myCode = 'here';

export function myFunc() {
    return true;
}

Alright. That’s the tip.
StudioBot 🤖✨

static niche
#

There are so many inconsistencies on the documentation, it is amazing someone is able to figure it out.

This is completly wrong: https://dev.wix.com/docs/build-apps/develop-your-app/frameworks/self-hosting/supported-extensions/backend-extensions/add-self-hosted-service-plugin-extensions-with-the-sdk

createClient

Does not support the properties for auth described on the documentation

static niche
#
 wixClient.taxCalculationProvider.provideHandlers({
      calculateTax: async (payload) => {
        const { request, metadata } = payload
        console.log('Wix SDK taxCalculationProvider called', {
          request,
          metadata
        })
        return {
          currency: 'USD',
          taxSummary: {
            totalAmount: totalAmount.toFixed(2),
            totalTax: '9.99',
            totalTaxableAmount: totalTaxableAmount.toFixed(2),
            totalTaxIncludedInPrice: '0.00'
          },
          lineItemTaxDetails: [
            {
              _id: 'sample-item-id',
              itemName: 'Sample Item',
              quantity: 1
            }
          ]
        }
      }
    })

Trying to use the SDK, it does not work either.

leaden orchid
#

It is an area of Wix that I do not touch unfortunately ... I suggest two things ... see if there is an implementation in one of the templates ... if not just raise a support request and see if the can both guide you and if the documentation is wrong indeed fix it