Update data collection when payment status changed

Hi!
We are creating a marketplace using the Wix Pay API. Currently, we can make payments and get money on the selected payment gateway and the Wix control panel. We want to send info to a data collection when a payment is successful, pending or cancelled. We are using this code on the front-end payment button.

 export function pagar_click(event) {
 let PaymentUserInfo {"firstName":user.nombre,"lastName":user.apellido,"email":user.email"id":user.id};

let myData = 123;

    createMyPayment(myData)
    .then( (payment) => 
    {
          wixPay.startPayment(payment.id,{
          "userInfo": PaymentUserInfo
        });
 
    } )
    .then( (result) => {
 
 if (result.status === "Successful") 
 {
    wixWindow.openLightbox("Success Box");
    const Insert = {  
    "usuario_id": PaymentUserInfo.id,  "email": PaymentUserInfo.email
     };  
   
   // add the item to the collection                     
   wixData.insert("Pagosn", Insert)                         
  .catch((err) => {                            
   console.log(err);                         
  }); 
}

else if (result.status === "Pending") 
{
  wixWindow.openLightbox("Pending Box");
}

});
}

With this code we didn’t have the desired results. Also, we tried in the “onPaymentUpdate()” function on the file event.jsw in the backend without results.

How can we update the database when a payment is done? Thank you guys!

Hey! Did you finally get this issue solved?
Having the same doubt and getting no answers in my post.