Giter Club home page Giter Club logo

nuveicashierhelper-ios's Introduction

Nuvei Cashier Helper SDK for iOS

SETUP

Pods integration:
Add the next source(s) in the top of the Podfile:

source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/SafeChargeInternational/Pods.git'

Add the next pods in under the relevant target(s) in the Podfile:

pod 'NuveiCashierHelper', '~> 3.0.1'

Carthage integration:
Add the next pods in under the relevant target(s) in the Cartfile:

github "SafeChargeInternational/NuveiCashierHelper-iOS" ~> 3.0.1
github "SafeChargeInternational/CodeScanner" ~> 1.8.2

USAGE

The SDK works with WKWebView, so add the next line before you load Nuvei cashier page in the web view (e.g. in viewDidLoad of the view controller that displays the web view):

override func viewDidLoad() {
  super.viewDidLoad()

  webView.navigationDelegate = self
  
  // Prepare the cashier URL
  let rawUrl = "<YOUR CASHIER URL WITHOUT '#' TAG IN THE END>"
  // CashierHelper.update will throw an exception if rawUrl already contains '#'
  let finalUrl = try? CashierHelper.update(url: rawUrl, with: [.qr, .card]) ?? cashierUrl
  
  // Setup web view and the rest of the view controller...
  
  webView.load(URLRequest(url: finalUrl))

  // Call this line after the webView is part of the view hierarchy
  CashierHelper.connect(to: webView, viewController: self)
}

Implement the WKNavigationDelegate in your view controller:

extension WebViewController: WKNavigationDelegate {
    func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
        do {
            if let url = navigationAction.request.url?.absoluteString, try NuveiCashierHelper.handleURL(url) {
                // Handled by NuveiCashierHelper, no need to do anything else, cancel the URL loading
                decisionHandler(.cancel)
            } else {
                // Not handled by NuveiCashierHelper, add your logic and/or complete the loading of the URL
                decisionHandler(.allow)
            }
        } catch {
            debugPrint(#function, "error = \(error)")
            decisionHandler(.allow)
        }
    }
}

THIRD PARTY LIBS

LICENSE

See: LICENSE

nuveicashierhelper-ios's People

Contributors

manwithbear avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.