Partial refund
Requirements
Request sample
<?php
$host = 'https://api.avangate.com';
$merchantCode = "MERCHANT_CODE"; // your account's merchant code available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
$key = "SECRET_KEY"; // your account's secret key available in the 'System settings' area of the cPanel: https://secure.2checkout.com/cpanel/account_settings.php
$now = gmdate('Y-m-d H:i:s'); //GMT date format)
$algo = "sha256";
$string = strlen($merchantCode) . $merchantCode . strlen($now) . $now;
$hash = hash_hmac($algo, $string, $key);
try {
$client = new SoapClient($host . "/soap/6.0/?wsdl", [\
'location' => $host . "/soap/6.0/",\
"stream_context" => stream_context_create([\
'ssl' => [\
'verify_peer' => false,\
'verify_peer_name' => false\
]\
])\
]);
$sessionID = $client->login($merchantCode, $now, $hash, $algo);
echo("Token: {$sessionID}" . PHP_EOL);
$orderReference = "73152871";
$items = [];
$item = new stdClass();
$item->Quantity = 1;
$item->LineItemReference = "a439c84a4b1e8ad1d7bf38407f5ea7473433ce7b";
$item->Amount = 29.99;
$items[] = $item;
$comment = "This is a comment";
$reason = "Fraud";
$refundedOrder = $client->issueRefund($sessionID, $orderReference, null, $items, $comment, $reason);
var_dump($refundOrder);
} catch (SoapFault $e) {
echo "Authentication: " . $e->getMessage() . PHP_EOL;
exit;
}Response parameters
Type
Description
Last updated
Was this helpful?