> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slm.m1amdocs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Refunding Transactions in Tokens

The Subscribe API allows you to refund transactions that granted or decremented tokens. Refunding token transactions returns the tokens to the token balance in the customer’s account.

If a refund is for a `Product` that granted tokens, be sure to define the action to take for the tokens. When creating the `Refund` object, specify the `tokenAction` attribute, which is an enumeration of the following three values:

* **None:** Makes no changes to the token balance. All previous token balances will stand as if the transaction had not been refunded.
* \*\*CancelZeroBalance:\*\*Subscribe will cancel all previous token transactions. If the cancellation causes the token balance to drop below zero, Subscribe will reset it to zero.
* \*\*CancelNegativeBalance:\*\*Subscribe will cancel all previous token transactions. If the cancellation causes the token balance to drop below zero, the negative balance will remain, and subsequent token-based transactions will fail until the balance rises above zero.

Refund a Transaction that granted Tokens to an Account:

**Note:** Use of the forward slash character (/) in merchant identifiers is not allowed. See [Merchant Identifiers](Merchant_Identifiers#) for more information.

```

 //Create a new refund object
 $refund = new Refund();
  
 $txn = new Transaction(); 
  
 // specify a known transaction by its merchant ID. This transaction
 // should be in the 'Captured' state so it can be refunded
 $txn->setMerchantTransactionId('WID-CUS-9302871'); 
  
 // associate the account and refund objects
 $refund->setTransaction($txn);
  
 // set the amount of the refund
 $refund->setAmount(10.00);
 $refund->setTimestamp('2009-02-11T22:34:32.265Z');
 $refund->setReferenceString('myRefundId101');
 $refund->setTokenAction('CancelNegativeBalance');
  
 $tempSoapRef = new Refund();
  
 // refund the transaction
 $response = $tempSoapRef ->perform(array($refund));
```

**Parent topic:**[Working with Tokens](../topics/ProgGuide_Tokens)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.