Refund
2 min
Starting a refund
Refunds work very similarly to purchases, with a few key differences.
- The TransactionType must be specified as .refund when calling toro.startTransaction()
- There needs to be an existing purchase to refund.
- Some details of the original purchase are required in order to initiate the refund.
- The refund amount cannot be more than the original purchase amount.
- Gratuities are not applicable.
- The refund amount cannot be greater than the original purchase amount.
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.
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"
)