Albert Mata edited this page Nov 3, 2016 · 5 revisions
    func preAuthOperation() {
        guard let ref = Reference(consumerRef: self.reference) else { return }
        let amount: Amount = "2 GBP"
        try! self.judoKitSession.invokePreAuth(judoId, amount: amount, reference: ref, completion: { (response, error) -> () in
            self.dismiss(animated: true, completion: nil)
            if let error = error {
                if error.code == .userDidCancel {
                    self.dismiss(animated: true, completion: nil)
                var errorTitle = "Error"
                if let errorCategory = error.category {
                    errorTitle = errorCategory.stringValue()
                self.alertController = UIAlertController(title: errorTitle, message: error.message, preferredStyle: .alert)
                self.alertController!.addAction(UIAlertAction(title: "OK", style: .cancel, handler: nil))
                self.dismiss(animated: true, completion:nil)
                return // BAIL
            if let resp = response, let transactionData = resp.items.first {
                self.cardDetails = transactionData.cardDetails
                self.paymentToken = transactionData.paymentToken()
            let sb = UIStoryboard(name: "Main", bundle: nil)
            let viewController = sb.instantiateViewController(withIdentifier: "detailviewcontroller") as! DetailViewController
            viewController.response = response
            self.navigationController?.pushViewController(viewController, animated: true)

Note: Please make sure that you are using a unique Consumer Reference for each different consumer.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.