How to get the full order details on payment status change?

Hi,
I’m trying to capture store order details when they are paid. I’m trying to do it automatically with events. I want to process orders only when they are finally paid.

What is the best/correct way to do it?

The onNewOrder event has all details I want, but it is called only once, when the order is created, but not when payment is changed, such as when accepting manual payments.

The onCartChanged event is called when I mark orders as paid in the dashboard, but it doesn’t have any order details. I tried to query the orders database, but the query promise is neither fulfilled nor rejected. Check the code below.

// events.js
export async function wixStores_onCartCompleted(event) {
console.log( “wixStores_onCartCompleted event” , event.cartId, event.buyerInfo.id);:wink: // This prints
wixData.query( “Stores/Orders” )
//.eq(“buyerInfo.id”, event.buyerInfo.id)
.contains( “buyerInfo.id” , event.buyerInfo.id)
.find()
.then((orders) => {
console.log( “wixStores_onCartCompleted order” , orders); // Does not print
})
. catch ((err) => {
console.log( “wixStores_onCartCompleted catch” , err); // Does not print
})
. finally (() => {
console.log( “wixStores_onCartCompleted finally” ); // This prints
});
}

On my events console I get the first print and the finally print. Nothing else. If I remove the “eq” or the “contains” lines, the result is the same.

What am I missing?

Thanks

I think I’ve read all posts here around this issue, including https://www.wix.com/corvid/forum/community-discussion/update-data-collection-when-payment-status-changed and several other regarding permissions and events not firing.