Payment

Ashley Barrett edited this page Dec 12, 2016 · 8 revisions
    func paymentOperation() {
        guard let ref = Reference(consumerRef: "payment-reference") else { return }
        try! self.judoKitSession.invokePayment(judoid, amount: Amount(decimalNumber: 0.01, currency: .GBP), 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)
                    return
                }
                
                let alertController = UIAlertController(title: "Fail", message: "This is a fail message", preferredStyle: .alert)
                alertController.addAction(UIAlertAction(title: "OK", style: .cancel, handler: nil))
                self.dismiss(animated: true, completion:nil)
                _ = [self.present(alertController, animated: true, completion: nil)]
                return // BAIL
            }
            
            if let resp = response, let first = resp.items.first {
                let alertController = UIAlertController(title: first.result.rawValue, message: first.message, preferredStyle: .alert)
                alertController.addAction(UIAlertAction(title: "OK", style: .cancel, handler: nil))
                _ = [self.present(alertController, animated: true, completion: nil)]
                self.dismiss(animated: true, completion:nil)
            }
        })
    }

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.