We have developed a VTEX module in order to offer Pix as a payment method. However, we don’t know the best way to implement refunding.
Since Pix refunding can be asynchronous, what do we should to do considering that VTEX expects a synchronous response, as described on this link: Payment Provider Protocol
In my side, after receive VTEX request, I will send the request to PSP, and it can delays some minutes in order to answer if refunding was successfully.
Both the refund and the authorization can be asynchronous.
The authorization can be asynchronous using the callback. So, the PSP can return the undefined status and later callback VTEX to inform that the transaction has been paid (and approved).
The refund can happen any time after the settle, so it´s asynchronous too.
In my point of view, authorization can be asynchronous, because we can response the “undefined” status. If VTEX receives an “undefined”, it will wait for my callback, becoming this a asynchronous process.
However, on Refund service, there isn’t the option to response an “undefined” status.
I can response 200 (“Successfully refunded”), 500 (“Refund has failed due to an internal error”) and 501 (“This payment needs to be manually refunded”).
Maybe you can try to return a 501 status code with something different from code: “refund-manually” to force VTEX to retry the operation later. Then return the correct information or return “refund-manually” after 2 or 3 tries.
The VTEX APIs usually retries after sometime, but I am not 100% sure that will happen with the refund. Maybe you can open a ticket with VTEX and ask them.
Another solution is process asynchronously, but respond synchronous…
When VTEX requests a refunding, I can hold it and only responds when PSP has finished all refunding process… but it could last until 1 minute…
Do you know how long is VTEX timeout?