# Total refund

Use the **issueRefund** method to issue a total refund for an order processed by 2Checkout.

## Requirements

* The payment for the refundable order needs to be collected.
* You cannot issue a refund for an amount higher than the total order amount.

### Request sample

```php
<?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 = [];
    $amount = '241.49';
    $comment = "This is a comment";
    $reason = "Fraud";

    $refundedOrder = $client->issueRefund($sessionID, $orderReference, $amount, $items, $comment, $reason);
    var_dump($refundOrder);
} catch (SoapFault $e) {
    echo "Authentication: " . $e->getMessage() . PHP_EOL;
    exit;
}
```

## Response parameters

| Response | Type/Description                                                                                          |
| -------- | --------------------------------------------------------------------------------------------------------- |
| Boolean  | <p><strong>TRUE</strong> if the refund was processed successfully<br><strong>FALSE</strong> otherwise</p> |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.2checkout.com/soap-api-reference/soap-api-6.0/api-requests/refund-an-order/total-refund.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
