Hi all, trying to make repeater for paid plans, and all looks good so far, only thing is working incorrectly is - when wixPay lightbox appear and for example you are trying to close it, behind there is one more (or even more) lightboxes with the same request - to pay. Looking at console.log (i got 4 items so far in paid plans) my const planId retrieving 4 lines, which i think making wixPay to request to pay for all 4 each time sequentely. Some people might think that they didn’t paid so can pay twice accidently. Please help
Here is code:
$w.onReady( function () {
$w( “#repeater23” ).onItemReady(($item, itemData, index) => {
$w( “#bb” ).onMouseIn((event, $w) => {
$w( “#bb” ).label = [$w( “#dataset6” ).getCurrentItem().price + “Eur” ].toLocaleString() } )
$w( “#bb” ).onMouseOut((event, $w) => { $w( “#bb” ).label = “Buy now” } )
$w( “#bb” ).onClick((event, $w) => {
const currentPlanObject = $w( “#dataset6” ).getCurrentItem()
const planId = currentPlanObject._id;
const planPrice = currentPlanObject.price;
console.log(planId)
wixPaidPlans.purchasePlan(planId)
.then((myPurchase) => {
let myOrderId = myPurchase.orderId;
let myWixPayOrderId = myPurchase.wixPayOrderId;
let myWixPayStatus = myPurchase.wixPayStatus;
})
})
})
})