createPayment() fails in Live site, but works in Preview

I have built a custom payment flow using the Wix-Pay API. Everything is working great in the Preview mode, but has a fatal error in the live site.

Specifically, I’ve narrowed it down to the wixPay.createPayment() function.

When I call createPayment I get this error in the console: “An error occurred in one of onReady callbacks”

Here is a copy of my code that is called from the backend:

export async function createMyPayment(propertyId, userInfo, reservationID) {
 // Step 3 - Create payment info object.
 //Retrive product details from the database

 let options = {
 "suppressAuth": true,
 "suppressHooks": true
    };
 let property = await wixData.get('Properties', propertyId);
 let reservation = await wixData.get('Reservations', reservationID, options);
    console.log(reservation.checkIn);
    console.log(reservation.checkOut);

 let nights = date_diff_indays(reservation.checkIn, reservation.checkOut);
 let numRooms = reservation.rooms;
 let rateTotals = await calRate(nights, reservation.rooms, property.dailyRate, property.weeklyRate, property.monthlyRate, property.taxDaily, property.taxWeeklyRate, property.taxMonthlyRate, property.taxRate);

 //Set Payment Info
 let paymentInfo = {
 "items": [{
 //Room Line Item
                name: `${property.title} (${numRooms} Rooms for ${nights} night(s)) | ${reservationID}`,
                price: rateTotals.roomTotal,
                quantity: 1
            },
            { //Tax Line Item
                name: "Tax",
                price: rateTotals.taxTotal,
                quantity: 1
            }
        ],
        amount: rateTotals.grandTotal,
        userInfo //Customer details
    };
    console.log(paymentInfo);
 // Step 4 - Call createPayment() with the payment information and return the paymentId.
 //return ;

 let payment = wixPay.createPayment(paymentInfo);
 return payment;

 // (Next, see step 5 in the client-side.)       
}

Any clue what I’m missing? At first, I thought it was my subscription, so I upgraded to the Business & eCommerce plan, but that didn’t fix it.

@salman-hammed I did this following your wizardry, so if you have any bright ideas on how to fix it I’m all ears :stuck_out_tongue_winking_eye: .