Call startRefund() to process a referenced refund against a previous transaction.
Function signature
finixClient.startRefund(
transactionID: String,
amount: Currency,
completion: ((RefundResponse?, Error?) -> Void)?
)| Parameter | Type | Required | Description |
|---|---|---|---|
transactionID | String | Yes | The ID of the original transaction to refund. |
amount | Currency | Yes | Amount to refund in cents. Cannot exceed the original transaction amount. |
completion | ((RefundResponse?, Error?) -> Void)? | No | Called with the refund result or an error. |
Completion handler
| Parameter | Trigger |
|---|---|
RefundResponse | Refund accepted. Contains the refund details, including its state. A refund can return .pending before it completes. For more information, see Pending refunds. |
Error | Refund failed. Check error.localizedDescription for details. |
let refundAmount = Currency(amount: 1000, code: .USD) // $10.00
finixClient.startRefund(transactionID: "TRxxxxxx", amount: refundAmount) { response, error in
Task { @MainActor in
// handle response and error
}
}
let refundAmount = Currency(amount: 1000, code: .USD)
finixClient.startRefund(transactionID: "TRxxxxxx", amount: refundAmount) { response, error in
Task { @MainActor in
if let error = error {
print("Refund failed: \(error.localizedDescription)")
return
}
if let response = response {
// refund accepted; state can be .pending before the refund completes
print("Refund ID: \(response.id ?? ""), state: \(response.state)")
}
}
}