Hello this is my first forum post, so let me know if I can do anything differently in the future!
I have a sock subscription website which sells socks every month. In order to customize the Wix PaidPlans landing page, I have to code the page using the WixPay API.
Everything works fine, even the payment goes through. The only problem is that the
wixPay.startPayment function does not prompt/return a shipping address. So I don’t know where to ship the goods. The frustrating part is that if you use the regular Wix Store, the checkout page requires both the billing and shipping addresses. As far as I can tell, there is no way to modify the lightbox that appears in order to collect more information.
Please let me know if there is indeed a way to import shipping info from the customers using WixPay.
A picture of the WixPay payment collection lightbox:
Here is the code I am using. Again, it works, but I just need to add the extra shipping address.
Page Code:
$w.onReady(function () {
const currentPlanObject = $w("#dynamicDataset").getCurrentItem();
const planId = currentPlanObject._id;
const planPrice = currentPlanObject.price;
$w('#button1').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) {
wixPaidPlans.purchasePlan(myId).then(orderObject => {
wixWindow.openLightbox("Contact", orderObject)
.then((goForIt) => {
if (goForIt) {
wixPay.startPayment(orderObject.wixPayOrderId);
}
});
})
}
Backend code:
import wixData from 'wix-data';
export function wixPaidPlans_onPlanPurchased(event) {
// Insert a title reflecting the type of transaction, and
// the event's order object (json) into
// the collection's data field.
if (event.order.price.amount === 0) {
let orderData = {
"title": "Free plan purchased",
"data": event.order
};
wixData.insert("planEvents", orderData);
} else {
let orderData = {
"title": "Regular plan purchased",
"data": event.order
};
wixData.insert("planEvents", orderData);
}
}
Link to how it would look. This is a product page, not a subscription page, but the problem is the same:
https://reexlmain.wixsite.com/nysc/stores/products