Search.../

refundTransaction( )

Retrieves payment provider information about a newly created refund.

Description

This function is called by Wix Payments when you create a refund from your site's dashboard. The code implemented in this function sends a request to the payment provider's API to create a refund. The function returns refund information from the payment provider, or error information if refund creation fails. Wix uses the information returned by this function to add the refund to your site.

Note: This function has a second parameter called context. This parameter is for internal Wix use only. You don't need to use it in your code.

Syntax

function refundTransaction(options: RefundOptions): Promise<RefundResponse>

refundTransaction Parameters

NAME
TYPE
DESCRIPTION
options
RefundOptions

Information to use when creating a refund request.

Returns

Fulfilled -

Return Type:

Promise<RefundResponse>
NAME
TYPE
DESCRIPTION
pluginRefundId
string

Payment provider refund ID.

reasonCode
number

Code indicating the outcome of the refund request.

errorCode
string

Error code supplied by the payment provider if the refund request fails.

errorMessage
string

Error message supplied by the payment provider if the refund request fails.

Was this helpful?

Successful refund

Copy Code
1// Place this code in the <my-extension-name>.js file
2// in the 'payment-provider' folder of the
3// Custom Extensions section on your site.
4
5export const refundTransaction = async (options, context) => {
6 //Logic for refunding a transaction with the payment provider.
7 return {
8 "pluginRefundId" : "16423-234234"
9 }
10};
Failed refund

Copy Code
1// Place this code in the <my-extension-name>.js file
2// in the 'payment-provider' folder of the
3// Custom Extensions section on your site.
4
5export const refundTransaction = async (options, context) => {
6 //Logic for refunding a transaction with the payment provider.
7 return {
8 "pluginRefundId" : "16423-234234",
9 "reasonCode" : 3025,
10 "errorCode" : "INSUFFICIENT_FUNDS_FOR_REFUND",
11 "errorMessage" : "Insufficient funds for refund"
12 }
13};