Soap API v1.4


Refund a specific transaction.


This method refunds a sale. Both credit card and check sale transactions may be refunded. You may choose to refund the entire amount or just a portion of the original sale.

For credit cards, the refund will show up as a separate transaction on the card holder's statement. To cancel the original sale before the batch it is in has been settled, the voidTransaction method should be used instead.

The transaction to be refunded must be retrieved using the reference number (RefNum) assigned to the transaction by the gateway. The RefNum is assigned by the gateway and returned when a transaction is processed. To find a missing RefNum, use the searchTransactions method.

See also runTransaction, voidTransaction


TransactionResponse refundTransaction ( ueSecurityToken Token, integer RefNum, double Amount )


Type Name Description
ueSecurityToken Token Merchant security token: used to identify merchant and validate transaction.
integer RefNum Transaction Reference number assigned by the gateway.
double Amount Amount to be refunded (set to 0 if refunding entire original amount)

Return Value

TransactionResponse Returns a TransactionResponse object containing the results of the transaction and all relevant data.


For directions on how to set up the WSDL link, create “$token” and “$client”, go to SOAP PHP How-to.

try {
  print_r($client->refundTransaction($token,$refnum, $amount));
catch(SoapFault $e) {    
  echo $e->getMessage();
  echo "\n\nRequest: " . $client->__getLastRequest();
  echo "\n\nResponse: " . $client->__getLastResponse();


This example uses the USAePay Java library. For directions on how to install the library and create the token/client objects, go to either the Java JAX-RPC Howto or the Java JAX-WS Howto.

try {
  //Set RefNum to the Reference Number of transaction you 
  //want to refund.
  BigInteger RefNum = _runTransaction();
  TransactionResponse response;
  response = client.refundTransaction(token, RefNum, 10.10);
} catch (Exception e) {
    System.out.println("Soap Exception: " + e.getMessage());

Visual Basic (.NET)

For directions on how to set up the WSDL link and create the “token” and “client” variables, go to the Visual Basic .Net Soap How-to.

 Dim client As usaepay.usaepayService = New usaepay.usaepayService
        Dim token As usaepay.ueSecurityToken
        token = Me.CreateToken("714SSUxv1uohng2XkMJ7kLpETsu58G66", "1234")
        Dim transaction As usaepay.TransactionRequestObject = New usaepay.TransactionRequestObject
        transaction.Details = New usaepay.TransactionDetail
        transaction.Details.Amount = "11.11"
        transaction.Details.AmountSpecified = "true"
        transaction.Details.Invoice = "123456"
        transaction.AuthCode = "009915"
        transaction.RefNum = "46993455"
        Dim response As usaepay.TransactionResponse = New usaepay.TransactionResponse
        response = client.captureTransaction(token, transaction.RefNum, transaction.Details.Amount)
        If response.ResultCode = "A" Then
            MsgBox("Transaction Approved, Refnum: " & response.RefNum)
            MsgBox("Transaction Error, Reason: " & response.Error)
        End If


For directions on how to set up the WSDL link and create the “token” and “client” variables, go to the C Sharp .Net Soap How-to.

            string refnum;
            double amount;
            refnum = "46973575";
            amount = 10.00;
            usaepay.TransactionResponse response = new usaepay.TransactionResponse();
                response = client.refundTransaction(token, refnum, amount);
                if (response.ResultCode == "A")
                    MessageBox.Show(string.Concat("Transaction Approved, RefNum: ",
                    MessageBox.Show(string.Concat("Transaction Failed: ",
            catch (Exception err)


<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="" 
xmlns:ns1="urn:usaepay" xmlns:xsd="" 
<Token xsi:type="ns1:ueSecurityToken">
<ClientIP xsi:type="xsd:string"></ClientIP>
<PinHash xsi:type="ns1:ueHash">
<HashValue xsi:type="xsd:string">11ac55b0a0b59f8f028dbf85bc32266fa973dd0e</HashValue>
<Seed xsi:type="xsd:string">12678150211876663375</Seed>
<Type xsi:type="xsd:string">sha1</Type>
<SourceKey xsi:type="xsd:string">HB4P7C4K2w2ZCQQQXRqrxDj6agrS2NIT</SourceKey>
<RefNum xsi:type="xsd:integer">1009411</RefNum>
<Amount xsi:type="xsd:double">1.99</Amount>

Change History

Version Change
1.0 Method added in soap v1.0
developer/soap-1.4/methods/refundtransaction.txt · Last modified: 2010/08/30 16:46 by epouchak

Page Tools