Menu

Refunds

This guide explains how to make either a full or partial refund with Worldpay.


Refunds can be made either on the Worldpay website or via the API.

Once a refund has been requested, the order will immediately change state to SENT_FOR_REFUND. When the refund has been verified the state will transition to REFUNDED or PARTIALLY_REFUNDED. In case of an error in refunding, for example if your account has insufficient funds, the order will revert to its original state, and we will also send an email to notify you of this. Other order updates e.g. settlement can occur while a refund is being processed; these updates will not affect the refund. Only one refund/partial refund can be in progress for an order at any one time.

Making a full or partial refund on the Worldpay website

To make a either a full or partial refund from the Worldpay website just click on the order you want to refund in theOrders List. You will find the refund and partial refund buttons at the top right-hand side of the order details page.

Making a full refund via the API

The code samples below show how to make a full refund via the API:

Copied!
curl https://api.worldpay.com/v1/orders/[your order code]/refund
    -H "Authorization:your-test-service-key"
    -H "Content-type: application/json"
    -X POST
$worldpay = new Worldpay('your-test-service-key');

try {
    $worldpay->refundOrder('your-order-code');
} catch (WorldpayException $e) {
    echo 'Error code: ' . $e->getCustomCode() . '
    HTTP status code:' . $e->getHttpStatusCode() . '
    Error description: ' . $e->getDescription()  . ' 
    Error message: ' . $e->getMessage();
} catch (Exception $e) {
    echo 'Error message: '. $e->getMessage();
}
worldpay = Worldpay.new('your-test-service-key')

begin

    response = worldpay.refundOrder('your-order-code')

    if (response['code']=="200")
        print "Order refunded"
    else
        print "There was a problem"
    end

rescue Exception => e
    print e.to_s
end
WorldpayRestClient restClient = new WorldpayRestClient("https://api.worldpay.com/v1", "your-test-service-key");

try
{
    restClient.GetOrderService().Refund('your-order-code');
    Console.WriteLine("Order refunded");
}
catch (WorldpayException e)
{
    Console.WriteLine("Error code:" + e.apiError.customCode);
    Console.WriteLine("Error description: " + e.apiError.description);
    Console.WriteLine("Error message: " + e.apiError.message);
}
WorldpayRestClient restClient = new WorldpayRestClient("your-test-service-key");

try {
    restClient.getOrderService().refund('your-order-code');
    System.out.println("Order refunded");
} catch (WorldpayException e) {
    System.out.println("Error code: " + e.getApiError().getCustomCode());
    System.out.println("Error description: " + e.getApiError().getDescription());
    System.out.println("Error message: " + e.getApiError().getMessage());
}

Partial refund via the API

You can also make a partial refund by including a refundAmount in the request. This refundAmount can be equal to or less than the current order value. After a successful partial refund the paymentStatus will be PARTIALLY_REFUNDED. You can make further partial refunds until the value of the order reaches zero - at this point the paymentStatus will be REFUNDED.

The code samples below show how to make a partial refund via the API:

Copied!
curl https://api.worldpay.com/v1/orders/[your order code]/refund
    -H "Authorization:your-test-service-key"
    -H "Content-type: application/json"
    -X POST
    -d '{ "refundAmount" : 100 }'
$worldpay = new Worldpay('your-test-service-key');

try {
    $worldpay->refundOrder('your-order-code', 100);
} catch (WorldpayException $e) {
    echo 'Error code: ' . $e->getCustomCode() . '
    HTTP status code:' . $e->getHttpStatusCode() . '
    Error description: ' . $e->getDescription()  . ' 
    Error message: ' . $e->getMessage();
}
worldpay = Worldpay.new('your-test-service-key')

begin

    response = worldpay.refundOrder('your-order-code', 100)

    if (response['code']=="200")
        print "Order partially refunded"
    else
        print "There was a problem"
    end

rescue Exception => e
    print e.to_s
end
WorldpayRestClient restClient = new WorldpayRestClient("your-test-service-key");

try {
    restClient.getOrderService().refund('your-order-code', 100);
    System.out.println("Order partially refunded");
} catch (WorldpayException e) {
    System.out.println("Error code: " + e.getApiError().getCustomCode());
    System.out.println("Error description: " + e.getApiError().getDescription());
    System.out.println("Error message: " + e.getApiError().getMessage());
}

More fields may be included in the response, depending on the information provided when the order was originally created. You can find an overview of all API fields in ourAPI Reference.