Wix-ecom-backend updatePaymentStatus

Question:
Hi, I’m trying to use Wix Ecom Backend to update the payment status of an offline order to PAID. Is there an example of how to do this?

Product:
Wix Editor

What are you trying to achieve:
When the user create an order via Wix Stores, I have an order ID with an initial NOT_PAID paymentStatus. And I’d like to change the paymentStatus to PAID

What have you already tried:
I have visited these documents:

However, there’s only field definition without a real-world workable example.

2 Likes

Please any update on this? Here my code

import { orderTransactions } from ‘wix-ecom-backend’;
import { Permissions, webMethod } from ‘wix-web-module’;
import { elevate } from ‘wix-auth’;

export const myElevatedupdatePaymentFunction = webMethod(Permissions.Anyone, async (orderId, payments) =>{

try {
const elevatedupdatePayment = elevate(orderTransactions.addPayments);
const confirmedPayment = await elevatedupdatePayment(orderId, payments);

console.log('Success! Confirmed payment:', confirmedPayment);
return confirmedPayment;
} catch (error) {
console.error(error);
// Handle error
}

});

and my input

{
“orderId”: “761c52c2-c8a1-4570-bd31-22d63f285811”,
“payments”: [{
“amount” : {
“amount” : “90000”
},
“regularPaymentDetails” : {
“offlinePayment” : true,
“status” : “PAID”
}
}]
}

But the returned result’s status is “undefined”

image

PLEASE HELP

I know I’m late here, but better late than never, in case this pops up for someone else.
In my case, I was trying to updatePaymentStatus with a payment ID from an Invoice and an order ID. Unfortunately I couldn’t get that to work, and this was the only thing that I could get to work.

Your line here is wrong:

All you’re missing is setting that status to Approved.

status: orderTransactions.TransactionStatus.APPROVED 

This fixes your issue at the time of writing this, and marks the order as paid for offline orders. (Supposedly the same as marking it as paid by admins through the dashboard) Though, it’s also worth mentioning that this function is in early preview, so hopefully it doesn’t change in the future and causes you issues.

1 Like