> ## 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.

# Refund.perform

The `perform` method enables you to issue one or more refunds for Transactions that were processed through Subscribe. Not all Subscribe Transactions are refundable. If Subscribe cannot process some of the refunds in your input, you are informed through the return code in this call’s `Return` object.

Subscribe can refund a transaction only if it meets all of the following criteria:

* The transaction status is one of the following:
  * `Captured`.
  * `Refunded` (if a partial refund has occurred).
  * `Authorized`. The Transaction is scheduled for capture but is not yet captured with your payment processor. Refunding such a Transaction essentially cancels it.
  * `AuthorizedPending` or `DepositRetryPending` for ECP or Direct Debit-based transactions. Refunding such a Transaction essentially cancels it.
* The Transaction has an associated authorization response code.
* The Transaction was not paid through the Boleto Bancário payment method.
* The Transaction is not an outbound Transaction, conducted to pay a customer through the ECP-based payment method.
* The sum of all the Transaction’s past refunds is less than the original Transaction amount.

Also note that you cannot grant partial refunds if:

* The Transaction used a `Token` payment method that resulted in the granting of tokens to a customer’s Account.
* Your payment processor is GlobalCollect and the authorization code is `800`, which means that the Transaction has been captured but not yet settled.

**Note:** A refund amount is required. If an amount is not provided or provided as 0, the full transaction amount will be refunded.

Subscribe processes refunds submitted through this call asynchronously with your payment processor in batches. Because Subscribe ensures that the refunds submitted are indeed refundable when you call `perform()`, payment processors rarely reject refunds accepted by Subscribe. To monitor refund status, log into the Subscribe Portal and use the Transaction Details page, which displays the most up-to-date status of your refund-.

## Input

*srd*: sparse response description, a SOAP string (which must be a JSON object), in which you specify the elements you want returned.This parameter enables the calling system to constrain a `method` call to return only components you specify. This gives you greater control over returned content, and improves response time within the Vindicia platform by reducing the processing needed for the call.

Some fields are required, either practically or in the WSDL, and will be returned regardless of the *srd*. A null *srd* returns the complete response.

*refunds*: an array of one or more `Refund` objects, each corresponding to a refund that you would like to process through Subscribe. Because this call creates a `Refund` object in Subscribe, leave the VID field blank. If Subscribe accepts the refund for processing, it populates the VID field in the corresponding `Refund` object in the array of returned refunds.

## Output

*return*: an object of type `Return` that indicates the success or failure of the call.

If the return code is `200`, all the `Refund` objects in this array have Vindicia-assigned VIDs, indicating that Subscribe has accepted these objects for processing. A return code of `206` indicates that only some of the `Refund` objects have been accepted by Subscribe and have VIDs. The `Refund` objects without VIDs have been rejected by Subscribe because they do not meet the criteria described above. Reasons for rejection are included in the `note` attribute of the `Refund` objects.

*refunds*: an array of one or more `Refund` objects, which corresponds to your input array.

## Returns

In addition to those listed in [The Return Object](The_Return_Object#), this call returns:

| Return Code | Return String |
| - | - |
| `206` | `Some (or all) refunds failed; check VIDs, notes.` |
| `404` | `Cannot refund transaction:` *error-description.* |

## Example

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

```

// Create a SpecifiedItems refund object
$refund1 = new Refund();
$refund1->setMerchantRefundId('REF101');
$transaction1 = new Transaction();
// merchant ID of a successful transaction that we wish to refund
$transaction1->setMerchantTransactionId('TX101');
$refund1->setTransaction($transaction1);
$refund1->setRefundDistributionStrategy('SpecifiedItems');
$refundItem1 = new RefundItem();
$refundItem1->setTransactionItemIndexNumber(1);
$refundItem1->setAmount(5.99);
$refund1->setRefundItems(array($refundItem1));
$refund1->setNote('Refunding due to customer complaint about outage');

// Create another refund object (No Distribution Strategy)
$refund2 = new Refund();
$refund2->setMerchantRefundId('REF102');
$transaction2 = new Transaction();
// merchant ID of a successful transaction that we wish to refund
$transaction1->setMerchantTransactionId('TX102');
$refund2->setTransaction($transaction2);
$refund2->setRefundDistributionStrategy('None');
$refund2->setAmount(10.99);
$refund2->setNote('Customer charged twice');

// Create a tax-only refund object
$refund3 = new Refund();
$refund3->setMerchantRefundId('REF103');
$transaction3 = new Transaction();
// merchant ID of a successful transaction that we wish to refund
$transaction3->setMerchantTransactionId('TX103');
$refund3->setTransaction($transaction3);
$refund3->setRefundDistributionStrategy('SpecifiedItems');
$refundItem3 = new RefundItem();
$refundItem3->setTransactionItemIndexNumber(1);
$refundItem3->setTaxOnly(true);
$refund3->setRefundItems(array($refundItem3));
$refund3->setNote('Customer asserts they are tax-exempt');

// Create a RemainingBalance refund object
$refund4 = new Refund();
$refund4->setMerchantRefundId('REF104');
$transaction4 = new Transaction();
// merchant ID of a successful transaction that we wish to refund
$transaction4->setMerchantTransactionId('TX104');
$refund4->setTransaction($transaction4);
$refund4->setRefundDistributionStrategy('RemainingBalance');
$refund4->setNote('Customer fled the country');

$soap_refund = new Refund();
$response = $soap_refund->perform(array($refund1, $refund2, $refund3, $refund4));
if($response['returnCode'] == 200) {
print ("All refunds submitted successfully");
}
else if($response['returnCode'] == 206) {
$resultRefunds = $response['data']->refunds;
// process fetched refunds here
if ($resultRefunds != null) {
foreach ($resultRefunds as $resultRef) {
// process a fetched refund here
if($resultRef->getVID() != null) {
print "Refund id "
. $resultRef->getMerchantRefundId()
. " submitted successfully";
}
else {
print "Refund id "
. $resultRef->getMerchantRefundId()
. " was unsuccessful because "
. $resultRef->getNote();
}
}
}
}
```

**Parent topic:**[Refund Methods](../topics/Refund_Methods)


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