hi,
i’m trying to update specific row in a collection after wix pay event from backend/event.js
insert new row seceded if i use insert instead update but update row not working
can someone help me please?
my code:
import  wixData  from  ‘wix-data’;
export function  wixPay_onPaymentUpdate(event) {
let  paymentId = event.payment.id;
let  newTransactionStatus = event.status;
let  transactionId = event.transactionId;
let  firstName = event.userInfo.firstName;
let  lastName = event.userInfo.lastName;
let  phone = event.userInfo.phone;
let  email = event.userInfo.email
let  toUpdate = {
“paymentId”: paymentId,
// “amount”: paymentAmount,
// “currency”: paymentCurrency,
“transactionStatus”: newTransactionStatus,
“transactionId”: transactionId,
// “quantity”: quantity,
“name”: firstName,
“familyName”: lastName,
//“country”: country,
“phone”: phone,
“email”: email,
};
wixData.update(“paydb”, toUpdate)
             
            
              
              
              
            
            
           
          
            
            
              Have a look at Nayeli (Code Queen) tutorial as it is very similar to what you are doing, plus all you really need to do is to change the insert to update in your own code.
https://support.totallycodable.com/en/article/setting-up-wix-pay-api-using-wix-code
             
            
              
              
              
            
            
           
          
            
            
              Iv’d changed to update. But didnt got no data at all.
             
            
              
              
              
            
            
           
          
            
            
              @galilevinshtein
Just try something like this then.
import wixData from 'wix-data';
export function wixPay_onPaymentUpdate(event) {
let paymentId = event.payment.id;
let newTransactionStatus = event.status;
let transactionId = event.transactionId;
let firstName = event.userInfo.firstName;
let lastName = event.userInfo.lastName;
let phone = event.userInfo.phone;
let email = event.userInfo.email;
let toUpdate = {
"paymentId": paymentId,
"transactionStatus": newTransactionStatus,
"transactionId": transactionId,
"name": firstName,
"familyName": lastName,
"phone": phone,
"email": email
};
wixData.update("paydb", toUpdate)
.then( (results) => {
let item = results;
} )
.catch( (err) => {
let errorMsg = err;
} );
             
            
              
              
              
            
            
           
          
            
            
              @givemeawhisky  still not updating. 
             
            
              
              
              
            
            
           
          
            
            
              @galilevinshtein  What’s happening? Any change being made? Are you getting an error message?
You might consider using  save()  instead of update() as save() will do either an insert() or an update(). See the  API  for details.
             
            
              
              
              
            
            
           
          
            
            
              @yisrael-wix  Toda Israel, i’ll check it.
Israel, i have sum bugs with the wix pay returned email.
1.the store name in the subject is wrong, look like it using the name of my site before he was publish - i get website-4
2.the item name is the costumer name,
3.and the email he sending from its my old email and not the current one
can you help with this?