-
Notifications
You must be signed in to change notification settings - Fork 10
Void
Hamon Ben Riazy edited this page Apr 25, 2016
·
2 revisions
After making a pre-Authorization transaction, in some cases you want to void a given preAuth if they are not needed anymore. For this you can use the following code snippet and add your own parameters that are necessary to submit the void.
do {
let preAuth = try judo.preAuth(myJudoID, amount: oneGBPAmount, reference: validReference).card(validVisaCard)
try preAuth.completion({ (response, error) -> () in
if let error = error {
// handle payment failing error
return
}
guard let receiptId = response?.first?.receiptID,
let amount = response?.first?.amount else {
// payment was successful
return
}
do {
let voidTransaction = try self.judo.voidTransaction(receiptId, amount: amount).completion({ (response, error) -> () in
if let error = error {
// handle error
}
})
} catch {
// handle exception thrown (eg. judoId not luhn valid)
}
})
} catch {
// handle exception thrown (eg. judoId not luhn valid)
}
be aware that a void will only work for the full amount that has been pre-authorized or any amount lower than that. There is no need to void a higher amount.