
import wixPay from 'wix-pay'; $w.onReady(function () { const MIN_PRICE = 10; // set your base price here $w('#buyButton').onClick(() => { let enteredAmount = Number($w('#priceInput').value); if (isNaN(enteredAmount) || enteredAmount < MIN_PRICE) { $w('#errorText').text = `Minimum price is $${MIN_PRICE}. Please enter a valid amount.`; $w('#errorText').show(); return; } // Hide error if all good $w('#errorText').hide(); // Start Wix Pay with custom amount wixPay.startPayment({ amount: enteredAmount, currency: "USD", items: [{ name: "Album Purchase", quantity: 1, price: enteredAmount }] }) .then((payment) => { if (payment.status === "Successful") { $w('#successText').text = "Thank you for your purchase!"; $w('#successText').show(); } else { $w('#errorText').text = "Payment failed. Please try again."; $w('#errorText').show(); } }); }); });