Data not saving after successful payment

I’m running into a problem where a custom form isn’t recording to a data collection after a customer processes a successful transaction through the Wix Pay box.

I believe the bug exists when a customer receives a Thank You! message from the pay box and then closes their browser instead of clicking the “Got It” confirmation button or the X in the top corner. If they opt to close their browser window, our page code never receives a success status to save the data to a collection or process our triggered email function.

Here is the page code for my button function; how could I optimize this to handle the edge case where a customer closes their browser after a successful payment?

export function payBoxButton_click(event) {
        let paymentOptions = {
            userInfo: {
                firstName: $w("#firstName").value,
                lastName: $w("#lastName").value,
                country: null,
                phone: $w("#phone").value,
                email: $w("#email").value.toLowerCase()
            }
        }
        createPayment(
                'databaseCollection',
                $w('#start').value,
                $w('#end').value,
                $w('#time').value,
                $w('#date').value
            )
            .then((payment) => {
                wixPay.startPayment(payment.id, paymentOptions)
                    .then((result) => {
                        if (result.status === "Successful") {
                            // send email to the user
                            emailUserOwy(
                                $w('#firstName').value,
                                $w('#lastName').value,
                                $w('#phone').value,
                                $w('#email').value.toLowerCase(),
                                $w('#time').value,
                                $w('#start').value,
                                $w('#end').value,
                                $w('#date').value
                            )
                            // save to db and open success window
                            wixData.insert("dataCollection", $w("#dataset3").getCurrentItem())
                                .then(() => {
                                    wixWindow.openLightbox("Success Lightbox");
                                })
                        } else {
                            console.log('Payment Failed')
                            wixWindow.openLightbox("Failed Lightbox")
                        }
                    })
            })
}

@matt Im having the same exact issue. Did you ever resolve this?

This ended up being a larger issue with the Wix Pay API (which they patched) and less about my code.

However, I did add this bit of code to the paymentOptions object to bypass that confirmation screen.

export function payBoxButton_click(event) {
    let paymentOptions = {
        "showThankYouPage": false, //bypass confirmation screen after successful payment
        userInfo: {
            firstName: $w("#firstName").value,
            lastName: $w("#lastName").value,
            country: null,
            phone: $w("#phone").value,
            email: $w("#email").value
        }
    }
    createPayment()...
}