I’m using the Wix Pay API to create donation transactions.
I want to save the donations to my own database.
With my current implementation, I’ve noticed that some payments aren’t being saved after they’re completed.
createPayment() // Backend call to create a payment
.then((payment) => {
wixPay.startPayment(payment.id, {
"showThankYouPage": false
})
.then((result) => {
let toSave = {
"sponsorFirstName": result.userInfo.firstName,
"sponsorLastName": result.userInfo.lastName,
"sponsorEmail": result.userInfo.email.toLowerCase(),
"sponsorPhone": result.userInfo.phone,
"status": result.status,
"amount": result.payment.amount,
"paymentId": result.payment.id,
}
wixData.save("Race-Donations", toSave)
.then((donation) => {
// Code to show success message
})
});
});
I believe the issue is related to the fact that wixPay.startPayment() never gives a response. Maybe when the user doesn’t return to the page from the Wix Pay dialog.
Any ideas as to how I can ensure that every payment is saved?