Skip to content
This repository was archived by the owner on Mar 19, 2022. It is now read-only.

Refunding an order

Alexander Vizhanov edited this page Apr 27, 2017 · 3 revisions
// Create a gateway for the WorldPay Gateway
// (routes to GatewayFactory::create)
$gateway = Omnipay::create('\\lembdev\\WorldPay\\Gateway');

// Initialise the gateway
$gateway->initialize([
    'serviceKey' => 'T_S_2addbca3-d0a5-486c-9f83-3d64b6c73288',
    'clientKey'  => 'T_C_c27428cd-9005-4dd3-8f7e-734c06a79abd',
]);

// Do a purchase transaction on the gateway
$transaction = $gateway->refund([
    'orderCode' => 'ORDER_CODE'
]);

$response = $transaction->send();
if ($response->isSuccessful()) {
    echo "Refund transaction was successful!\n";
} else {
    echo $response->getMessage();
}
Clone this wiki locally