---
title: Refund
slug: refund
docTags: 
createdAt: 2025-05-20T11:26:06.062Z
---

## Starting a refund

Refunds work very similarly to [purchases](docId\:Mkssy1oNFV6v3FUYRRT3m), with a few key differences.

1. The `TransactionType` must be specified as `.refund` when calling `toro.startTransaction()`
2. There needs to be an existing purchase to refund.
3. Some details of the original purchase are required in order to initiate the refund.
4. The refund amount cannot be more than the original purchase amount.
5. Gratuities are not applicable.
6. The refund amount cannot be greater than the original purchase amount.

```swift
toro.startTransaction(
    amount: 1000,
    type: .refund,
    currency: .gbp,
    metadata: TransactionMetadata(
        originalTransactionDetails: originalTransactionDetails
    ),
    onCompleted: { receipt in
        // Called when a receipt has been generated for a transaction
        print("Transaction Completed: \(receipt)")
    },
    onCancelled: { cancellationType in
        // Called when the transaction was cancelled by the attendant or customer
        print("Transaction Cancelled: \(cancellationType)")
    },
    onError: { error in
        // Called when an error has occured during a transaction
        print("Transaction Error: \(error)")
    },
    onGratuityConfirmed: { _, _ in
        // Not applicable
    }
)
```

Below is an example `OriginalTransactionDetails` object which needs to be passed through the `TransactionMetadata`.

```swift
OriginalTransactionDetails(
    saleReferenceId: "sale-12345",
    amount: 1000,
    currency: .gbp,
    dateTime: "2025-01-01T00:00:00.000Z",
    transactionReference: "purchase_12345123",
    responseCode: .approved,
    authCode: "123456",
    paymentInterface: .contact,
    terminalSerialNumber: "2110022",
    additionalResponseInformation: "01:XZZ022a3a0a9a99f1B5MXJYICT525HCF"
)
```

