Hi,
I was trying to create a dynamic payment plan page with a custom purchase process (following this tutorial ) When I tried to use the orderPlan function, I receive the following error in console:
wixcode-paid-plans.js:610 Uncaught (in promise) Error: Purchase preconditions not met
at new t (wixcode-paid-plans.js:610)
at eval (wixcode-paid-plans.js:518)
My page code:
import wixPay from 'wix-pay';
import wixPaidPlans from 'wix-paid-plans';
import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
$w.onReady(function () {
const currentPlanObject = $w("#dynamicDataset").getCurrentItem();
const planId = currentPlanObject._id;
$w('#MoreButton').onClick((event) => {
let user = wixUsers.currentUser;
let isLoggedIn = user.loggedIn;
if (!isLoggedIn) {
wixUsers.promptLogin().then(() => {
processPlan(planId);
})
} else {
processPlan(planId);
}
});
});
function processPlan(myId, myPrice) {
wixPaidPlans.orderPlan(myId).then(orderObject => {
wixLocation.to("/blank-5");
})
}
The error happens when I press the MoreButton.