SetUniqueRef($uniqueRef); if($autoready) $refund->SetAutoReady($autoready); # Perform the refund and read in the result $response = $refund->ProcessRequestToGateway($secret,$testAccount, $gateway); $expectedResponseHash = md5($terminalId . $response->UniqueRef() . ($multicur == true ? $currency : '') . $amount . $response->DateTime() . $response->ResponseCode() . $response->ResponseText() . $secret); if($response->IsError()) echo 'AN ERROR OCCURED! You refund was not processed. Error details: ' . $response->ErrorString(); elseif($expectedResponseHash == $response->Hash()) { switch($response->ResponseCode()) { case "A" : # -- If using local database, update order as (partially) Refunded. echo 'Refund Processed successfully.'; $responseText = $response->ResponseText(); break; case "R" : case "D" : case "C" : case "S" : default : # -- If using local database, update order as declined/failed -- echo 'REFUND DECLINED!'; } } else { echo 'REFUND FAILED: INVALID RESPONSE HASH. Please contact ' . $adminEmail . ' or call ' . $adminPhone . ' to clarify if you will get refunded for this order.'; $uniqueRef = $response->UniqueRef(); if(isset($uniqueRef)) echo 'Please quote %Gateway Terminal ID: ' . $terminalId . ', and Unique Reference: ' . $uniqueRef . ' when mailing or calling.'; } ?>