Hello coders! I’ve been working on this for days after following the Corvi d Tutorial: Using the Paid Plans API to Customize Ordering and Payment , to the letter. The only steps I took that were not included in the tutorial were those steps that were necessary to follow the suggestions offered by @givemeawhisky in his super helpful comments found in a related post . Those suggestions both involved the Confirm lightbox: I changed the id of my Yes button to #goForIt and I disabled the ‘X’ close the lightbox and enabled the ‘Close Lightbox’ button.
Unfortunately, the #goForIt button is not working as nothing happens when the user clicks “Yes” to confirm that they’re ready to pay. The lightbox pages do not currently contain any code or database connections.
Could you take a look at the code on my dynamic page and help me figure out what’s wrong? Did the tutorial leave out code that should be obvious enough for me to figure out on my own?
import wixWindow from 'wix-window';
import wixPay from 'wix-pay';
import wixPaidPlans from 'wix-paid-plans';
import wixUsers from 'wix-users';
$w.onReady(function () {
const currentPlanObject = $w("#dynamicDataset").getCurrentItem();
const planId = currentPlanObject._id;
const planPrice = currentPlanObject.price;
$w('#buyNow').onClick((event) => {
let user = wixUsers.currentUser;
let isLoggedIn = user.loggedIn;
if (!isLoggedIn) {
wixUsers.promptLogin().then(() => {
processPlan(planId, planPrice);
})
} else {
processPlan(planId, planPrice);
}
});
});
function processPlan(myId, myPrice) {
if (myPrice > 0) {
wixPaidPlans.orderPlan(myId).then(orderObject => {
wixWindow.openLightbox("Confirm", orderObject)
.then((goForIt) => {
if (goForIt) {
wixPay.startPayment(orderObject.wixPayOrderId);
}
});
})
} else {
wixPaidPlans.orderPlan(myId).then(orderObject => {
wixWindow.openLightbox("Congrats", orderObject);
})
}
}