In case you need to return money to your customers, you can initiate refunds for transactions that were completed successfully. This functionality can be used to issue both full and partial refunds, depending on the scenario.
First, you need to define the amount to refund by instantiating a Money
object, see the following example for a 1£ refund:
let money = Money(amount: 100, currency: .GBP)
Defining a refund works similar to accepting payments. To initiate a refund, you need to create a RefundDefinition
instance, containing a Money
object (you can also use the object you defined in the previous section).
To associate the refund with a specific payment, you need to pass the paymentId
parameter in the RefundDefinition
.
Optionally, you can provide a description
to help you identify these transactions easier.
let paymentId = "<paymentId>" // Replace with the actual paymentId from the previous transaction
let refundDefinition = RefundDefinition(
money: money, // The object defined in the previous step.
description: "Refund for a macchiato",
paymentId: paymentId
)
To start the refund flow call the refund
function on your RefundDefinition
:
RevolutCardReaderKit.shared.refund(
definition: refundDefinition, // The object defined in the previous step.
onResult: { result in
// Handle the result of the refund process
// This could include updating the user interface, logging the refund, or handling errors
}
)
For a full list of available parameters, see: Revolut Reader iOS SDK: Parameters.
Processing refunds do not require interaction with the Revolut Reader.
let money = Money(amount: 100, currency: .GBP)
let paymentId = "<paymentId>" // Replace with the actual ID of the payment from the previous transaction
let refundDefinition = RefundDefinition(
money: money,
description: "Refund for a macchiato",
paymentId: paymentId
)
RevolutCardReaderKit.shared.refund(
definition: refundDefinition,
onResult: { result in
// Handle the result of the refund process
// This could include updating the user interface, logging the refund, or handling errors
}
)