Hi,
I made an event landing page that after filling a form they must pay 30 ILS
when the payment Successful I make insert into a 2 wixData the user info.
but sometimes everything working well and sometimes the payment successful but don’t insert it into the databases.
the page https://www.lp.reidman.co.il/psychotherapy-event
the code
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';
import wixPay from 'wix-pay';
import { psycEvent } from 'backend/payments';
import wixData from 'wix-data';
const {
    source: Source,
} = wixLocation.query;
let url = wixLocation.url;
$w.onReady(() => {
});
export function submit_click(event, $w) {
 if ($w('#firstName').valid && $w('#lastName').valid && $w('#email').valid && $w('#phone').valid && $w('#idNumber').valid && $w('#campus').valid) {
        $w('#erorMesg').collapse();
 const paymentUserInfo = {
            firstName: $w('#firstName').value,
            lastName: $w('#lastName').value,
            phone: $w('#phone').value,
            email: $w('#email').value,
            countryCode: 'IL'
        }
 const paymentOptions = {
            userInfo: paymentUserInfo
        }
        psycEvent()
            .then((payment) => {
                wixPay.startPayment(payment.id, paymentOptions)
                    .then((result) => {
 if (result.status === "Successful") {
 let toInsert = {
 "firstName": $w('#firstName').value,
 "lastName": $w('#lastName').value,
 "email": $w('#email').value,
 "phone": $w('#phone').value,
 "idNumber": $w('#idNumber').value,
 "price": "30",
 "campus": $w('#campus').value,
 "formName": "אירוע פסיכותרפיה"
                            };
                            wixData.insert("Payments", toInsert)
                                .then((results) => {
 let item = results; //see item below
                                })
                                .catch((err) => {
 let errorMsg = err;
                                });
 let toInsertEvent = {
 "name": $w('#firstName').value,
 "email": $w('#email').value,
 "phne": $w('#phone').value,
 "campus": $w('#campus').value,
 "source": wixLocation.query["utm_source"],
 "interest": "פסיכותרפיה הוליסטית",
 "date": "04/03/2021",
 "time": "18:00",
 "eventName": "בין בדידות וזוגיות בעת הזאת",
 "url": url
                            };
                            wixData.insert("EventLead", toInsertEvent)
                                .then((results) => {
 let item = results; //see item below
                                })
                                .catch((err) => {
 let errorMsg = err;
                                });
                            wixWindow.trackEvent("Lead");
                            wixLocation.to("/event-thankyou");
                        }
 // else if (result.status === "Pending") {
 //   wixWindow.openLightbox("Pending Box");
 // }
                    });
            });
    } else {
        $w('#firstName, #lastName, #email, #phone, #idNumber, #campus').required = true;
        $w('#erorMesg').expand();
    }
}
payment successful on isracard
lest one on the databases


