Are you using the Booking API or the Stores API?
If you are using the Booking API, you can do this:
import wixBookings from "wix-bookings"
$w.onReady(async () => {
let availability = await wixBookings.getServiceAvailability("87edd4e0-42b1-4802-8766-584f3eeb6436") //Service ID
let slots = availability.slots
let chosenSlot = slots[1] //Chosen slot available to booking
let formFieldValues = [
{
_id: "20657271-c55f-43d6-adfd-39b7acc38e11", // name field ID
value: "John Doe",
},
{
_id: "87edd4e0-42b1-4802-8766-584f3eeb6436", // email field ID
value: "john@doe.com",
},
]
let bookingInfo = {
slot: chosenSlot,
formFields: formFieldValues,
}
let options = {
paymentType: "wixPay_Offline", //Here you can define the payment method
couponCode: "thecouponcode", //Here you put the coupon code
}
let booking = await wixBookings.checkoutBooking(bookingInfo, options)
let bookingId = booking.bookingId
let bookingStatus = booking.status
console.log(bookingId, bookingStatus)
})