{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Refunds","description":"Developer documentation for the WHMCS API — the","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"refunds","__idx":0},"children":["Refunds"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This function will be called any time a transaction is requested to be refunded from within WHMCS."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["It is supported by all payment gateway module types.  If your payment gateway module does not support refunds, simply do not define this function within your module."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Like with a capture attempt, upon completion of the refund, you are expected to return an array containing the transaction details consisting of the status, and if successful a transaction ID and optionally some data to be recorded to the gateway log for debugging purposes."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"variables","__idx":1},"children":["Variables"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following parameters are made available in the parameters passed to the refund function."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"invoice-variables","__idx":2},"children":["Invoice Variables"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$params['invoiceid'] # Invoice ID Number\n$params['transid'] # Transaction ID to be refunded\n$params['amount'] # Amount to be refunded (Format: xxx.xx)\n$params['currency'] # Currency Code (eg. GBD, USD, etc...)\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"client-variables","__idx":3},"children":["Client Variables"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$params['clientdetails']['firstname'] # Client's First Name\n$params['clientdetails']['lastname'] # Client's Last Name\n$params['clientdetails']['email'] # Client's Email Address\n$params['clientdetails']['address1'] # Client's Address\n$params['clientdetails']['address2']\n$params['clientdetails']['city']\n$params['clientdetails']['state']\n$params['clientdetails']['postcode']\n$params['clientdetails']['country']\n$params['clientdetails']['phonenumber']\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"system-variables","__idx":4},"children":["System Variables"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"$params['companyname'] # your Company Name setting in WHMCS\n$params['systemurl'] # the url to the Client Area\n$params['name'] # Module Display Name\n$params['moduleName'] # Module System Name\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"response-format","__idx":5},"children":["Response Format"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Upon completion of the refund attempt, return the results in the following format:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"return array(\n    'status' => 'success',\n    'rawdata' => $responseData,\n    'transid' => $refundTransactionId,\n    'fees' => $feeAmount,\n);\n"},"children":[]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["status"]}," - ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["success"]}," if successful, otherwise ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["declined"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["error"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["rawdata"]}," - data to be recorded in the gateway log for debugging purposes"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["transid"]}," - Unique Transaction ID for the refund transaction"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["fees"]}," - Optional fee amount for the fee value refunded"]}]}]},"headings":[{"value":"Refunds","id":"refunds","depth":1},{"value":"Variables","id":"variables","depth":2},{"value":"Invoice Variables","id":"invoice-variables","depth":3},{"value":"Client Variables","id":"client-variables","depth":3},{"value":"System Variables","id":"system-variables","depth":3},{"value":"Response Format","id":"response-format","depth":2}],"frontmatter":{"title":"Refunds","seo":{"title":"Refunds"}},"lastModified":"2026-08-03T17:00:42.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/payment-gateways/refunds","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}