Hi,
I’m trying to create a custom purchase plan on my site. I used Wix tutorial and changed the code to match the items in my site.
The problem is when I click the buyNow button nothing happens no matter what and there are no errors on console or code.
I tried to change some settings but still nothing. how can I get it to work?
Thanks!
Here is my Code:
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);
})
}
}