I am building post purchase upsell extension and I’m having issue with reqeust to /checkouts/unstable/changesets/apply.json
Below is how I send request to create token
const token = await fetch(`${APP_URL}/api/sign-changeset`, {
method: "POST",
headers: {
Authorization: `Bearer ${inputData.token}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
referenceId: inputData.initialPurchase.referenceId,
changes: [
{
type: "add_variant",
variantID: selectedVariant,
quantity: 1,
discount: {
value: product.discount_amount,
valueType:
product.discount_type === "percent"
? "percentage"
: "amount",
title: title,
},
},
],
}),
})
Once I receive token, then I call applyChangeset(token)
but I get a response with error (code 400) as below:
{
"errors": [
{
"code": "invalid_request",
"message": "App is not installed"
}
],
"status": "unprocessed"
}
The payload of the request looks like this (just jwt with key name “changes”):
{"changes":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIzNGQwNmVhNWNhNGVlNTNiNTgyMzk1MmVhYzQwZTQyYyIsImp0aSI6ImJlZTIzMTZkLTQ3NjctNGE3Ny05NGNlLTg4NWNlZjNmNDkyNSIsImlhdCI6MTc1NDU4NTgwMjk5Mywic3ViIjoiOWE1Mjc0ZDMwNGRhY2E3Y2RhZjBiMThlOTA5ZGQ0ZjkiLCJjaGFuZ2VzIjpbeyJ0eXBlIjoiYWRkX3ZhcmlhbnQiLCJ2YXJpYW50SUQiOiJnaWQ6Ly9zaG9waWZ5L1Byb2R1Y3RWYXJpYW50LzUwNzY1NTE0NTA2NTYwIiwicXVhbnRpdHkiOjEsImRpc2NvdW50Ijp7InZhbHVlIjoxMCwidmFsdWVUeXBlIjoicGVyY2VudGFnZSIsInRpdGxlIjoiMTAlIG9mZiJ9fV19.rrZcjVB2BxyGA-WVW5lmkZHb2Hl7GPOua3tegFUCmfU"}
Please help!