Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Post-purchase upsell: invalid token on calculateChangeset

Post-purchase upsell: invalid token on calculateChangeset

mashkovtsev
Shopify Partner
41 1 27

I'm trying to set up a post-purchase upsell.

I submit all required fields to the calculateChangeset function, but the request returns an "Invalid token" message. API_KEY and SECRET are correct. Also, the API key in the Chrome extension is equal to the API key in my extension .env. Are there any additional reasons why requests may be rejected? 

Thank you.

All the best.
Alex, Team Lead at INSO.codes Shopify Studio
https://inso.codes/
Replies 2 (2)

jonaswebdev
Shopify Partner
6 0 0

Hi @mashkovtsev, I'm facing the same issue and don't have any information about this issue on the web, except for your post here... Did you figure out anything?

Mario_
Shopify Partner
8 0 5

I had the same error, in my case it was the malformed "changes" parameter passed to the "calculateChangeset" shopify endopoint.

 

I was using an object, but the endpoint requires an Array of object, so instead of passing something like:

  const changes = {
    type: "add_variant",
    variantID: 123456789,
    quantity: 1,
    discount: {
      value: 15,
      valueType: "percentage",
      title: "15% off",
    }
  };

you should use:

  const changes = [{
    type: "add_variant",
    variantID: 123456789,
    quantity: 1,
    discount: {
      value: 15,
      valueType: "percentage",
      title: "15% off",
    }
  }];

 and finally:

const result = await calculateChangeset({
    changes: changes
});

 

Hope it helps! ^_^