forked from Ryce/JudoKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Collection
Hamon Ben Riazy edited this page Apr 25, 2016
·
3 revisions
After making a pre-Authorization transaction, in most cases you want to collect the amount of a given preAuth. For this you can use the following code snippet and add your own parameters that are necessary to submit the collection.
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 collection = try self.judo.collection(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 collection will only work for either the full amount that has been pre-authorized or any amount lower than that. If you want to collect more than the originally pre-authorized amount you need to do a payment or a new preAuth.