Hello everyone,
I’m working with wix bookings, trying to set up a custom flow where a user selects a service, and fills in a custom form of input fields that I’m using as booking info.
This part is working and a booking is generated.
The problem is the payment part, I need to skip the user info page on wix pay page.
I tried building the payment on wix pay, and wix pay backend but since bookings checkout already triggers the payment window I was doubling the payment and had to remove it.
RESUME - what do I need? to use input info that is used as bookingInfo to be filled on the payment form so the user only fills it in once.
This is happening on a lightbox and here is the code:
import wixWindow from 'wix-window';
import { session } from 'wix-storage';
import wixBookings from 'wix-bookings';
$w.onReady(function () {
let slotIndex = session.getItem("slotIndex");
let availableSlots
let itemId = session.getItem("serviceId");
let sessionId = session.getItem("sessionId");
wixBookings.getServiceAvailability(itemId)
.then((availability) => {
availableSlots = availability.slots;
})
$w('#bookButton').onClick(() => {
let formFieldValues = [{
"_id": "00000000-0000-0000-0000-000000000001",
"value": $w("#firstName").value + " " + $w("#lastName").value,
}, {
"_id": "00000000-0000-0000-0000-000000000002",
"value": $w("#email").value,
}, {
"_id": "00000000-0000-0000-0000-000000000003",
"value": $w("#telefone").value,
}, {
"_id": "131fc6db-2bb1-4e2b-bf90-081f12f4928b",
"value": sessionId
}];
let bookingInfo = {
"slot": availableSlots[slotIndex],
"formFields": formFieldValues
};
wixBookings.checkoutBooking(bookingInfo)
.then((results) => {
$w("#confirmationText").text = `Booking ID: ${results.bookingId} Status: ${results.status}`;
});
})
})
export function button2_click(event) {
wixWindow.lightbox.close({
})
}
Thank you in advance.