Refunding a Payment
To refund a payment you can invoke the refund
function, providing the transactionId
that was returned to you
when you processed the payment.
You may also optionally pass in an amountInCents
to refund, in order to refund a portion of the total payment. If
the amount is more than the amount still refundable, or the card that was used for the payment does not support
partial refunds - then an error message will be shown to the user.
let userInfo : [AnyHashable: Any] = ["user" : "info"]
let parameters : RefundParameters = RefundParamters(
amountInCents: 200,
userInfo: userInfo,
staffMember: YocoStaff(staffNumber: "1234", name: "Joe Bloggs"),
refundCompleteNotifier: { paymentResult in
// Get notified immediately when the transaction is complete.
})
)
Yoco.refund(transactionID: transactionID, parameters: parameters) { (result) in
let alert = UIAlertController(title: "Refund Completed", message: "Transaction refunded with result: \(result.result)", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default) { action in
alert.dismiss(animated: true)
})
self.present(alert, animated: true)
}