I am trying to implement a customized recurring payment flow in my website. In addition, I want certain users to be able to edit specific pricing plans directly in the PaidPlans/Plans collection. I am however getting a permission error when trying to get or update a plan. I have been trying to tackle this issue for a few days now but have not made much progress. To debug I simply wrote the following on the home page of my site
import { backendGetPlan } from 'backend/plans'
$w.onReady(function () {
backendGetPlan("9a2378ad-7070-4362-8e8a-b74c49fcb185").then((result) => {
console.log(result);
}).catch((error) => {
console.log(error);
});
});
The following is my backend/plans code which has some additional functions for functionalities in other parts of my website. I have left them in incase they are the issue.
import wixPricingPlansBackend from 'wix-pricing-plans-backend';
export function backendCreatePlan(planInfo) {
return wixPricingPlansBackend.createPlan(planInfo);
}
export function backendGetPlan(id) {
return wixPricingPlansBackend.getPlan(id).then((result) => {
console.log(result);
return result;
}).catch((error) => {
console.log("backend error 2");
console.log(error);
});
}
export function backendGetAllPlans() {
return wixPricingPlansBackend.listPublicPlans().then((result) => {
console.log(result);
return result;
}).catch((error) => {
console.log("backend error 1")
console.log(error);
});
}
export function asCurrency(currency, value) {
return new Intl.NumberFormat('en-US', {
style: 'currency',
currency: currency,
minimumFractionDigits: 2
}).format(value);
}
export function backendUpdatePricingPlan(planInfo) {
console.log(planInfo);
return wixPricingPlansBackend.updatePlan(planInfo);
}
I get the following error, in the logs, when I open my front page
"root":{
"insertId":""
"timestamp":"2023-01-14T17:10:20.378Z"
"labels":{
"siteUrl":"n/a"
"revision":"1031"
"namespace":"Velo"
"tenantId":""
"viewMode":"Site"
}
"sourceLocation":{
"file":"backend/plans.jsw"
"line":8
"column":12
}
"operation":{
"id":""
"producer":"backend"
}
"jsonPayload":{
"message":"["message: ''\ndetails:\n applicationError:\n description: Forbidden\n code: FORBIDDEN\n data: {}"]"
}
"receiveTimestamp":"2023-01-14T17:10:20.593Z"
}
This problem wasn’t originally there but appeared without me noticing when or why. The backendGetAllPlans function works seamlessly though.
Any help would be greatly appreciated and I would be happy to provide further information, thank you!