Hey Everyone, hope you can help…
I’ve created a repeater linked to a dataset following this tutorial ( https://support.wix.com/en/article/corvid-tutorial-using-the-paid-plans-api-to-customize-ordering-and-payment#step-2-set-up-the-collection-repeater-page ) and it’s been great to learn and dissect. I’ve had variants working well and ‘think’ I understand everything except two lines of code.
If I call directly the _id of my paid plan directly as “3e96ecca-11a5-4c42-9cc3-8ab8af9bbcd6” the button works well and the standard Paid Plans payment lightbox appears as expected… BUT when I try to call it dynamically through my dataset (with a field referencing the Paid Plan database) as per the code below, the button is now dead.
I’m sure it’s a simple fix, and I apologise if my language of communicating the issue is sloppy.
Any help much appreciated,
Darren
import wixPay from 'wix-pay';
import wixPaidPlans from 'wix-paid-plans';
$w.onReady(function () {
const currentPlanObject = $w("#dataset1").getCurrentItem();
const planId = currentPlanObject._id;
/* ^^ THESE TWO LINES DON'T WORK */
/* const planId = "3e96ecca-11a5-4c42-9cc3-8ab8af9bbcd6";
^^ THIS LINE WORKS WELL WHEN REPLACING THE FAULTY ONES ABOVE */
$w('#buyNow').onClick((event) => {
wixPaidPlans.purchasePlan(planId)
.then((myPurchase) => {
let myOrderId = myPurchase.orderId;
let myWixPayOrderId = myPurchase.wixPayOrderId;
let myWixPayStatus = myPurchase.wixPayStatus;
});
});
});