VisaCheckoutPlugin

@interface VisaCheckoutPlugin : NSObject <WKScriptMessageHandler>

VisaCheckoutPlugin is used to configure Visa Checkout for hybrid environments. VisaCheckoutPlugin conforms to the WKScriptMessageHandler protocol and will act as a message handler for your instance of WKWebView.

  • Singleton instance of VisaCheckoutPlugin that is used to configure Visa Checkout for hybrid environments. Use this instance when adding message handlers to your instance of WKWebView.

    Declaration

    Objective-C

    @property (readonly, nonatomic, class) VisaCheckoutPlugin *_Nonnull main;

    Swift

    class var main: VisaCheckoutPlugin { get }
  • Provide an instance of UIViewController that will be used to present Visa Checkout modally. When the Visa Checkout button is clicked by the user, VisaCheckoutPlugin will use this view controller to call present(_:animated:completion:).

    This property is required to launch Visa Checkout. The UIViewController instance must be in your view hierarchy and must not already have a presentingViewController set because any additional calls to present(_:animated:completion:) will be ignored by UIKit.

    Typically, you will set this value to the view controller that contains your webView.

    Declaration

    Objective-C

    @property (readwrite, nonatomic)
        UIViewController *_Nullable presentingViewController;

    Swift

    weak var presentingViewController: UIViewController? { get set }
  • You can use this method as a one line integration for configuring Visa Checkout for hybrid environments. You can call this method passing an instance of WKWebView that will eventually render the Visa Checkout button. Also pass in an instance of UIViewController that is able to be used in a call to present(_:animated:completion:).

    Declaration

    Objective-C

    + (void)configure:(WKUserContentController *_Nonnull)contentController
        viewController:(UIViewController *_Nonnull)viewController;

    Swift

    class func configure(_ contentController: WKUserContentController, viewController: UIViewController)

    Parameters

    contentController

    an instance of the webView’s userContentController, usually accessed in this manner: myWkWebView.configuration.userContentController

    viewController

    an instance of UIViewController that will be used to present Visa Checkout modally. When the Visa Checkout button is clicked by the user, VisaCheckoutPlugin will use this view controller to call present(_:animated:completion:).

  • Only used for UIWebView support (use configure:contentController:viewController if using WKWebView).

    Configure your app with Visa Checkout for hybrid environments using a UIWebView.

    Declaration

    Objective-C

    + (void)configureWithWebView:(UIWebView *_Nonnull)webView
                  viewController:(UIViewController *_Nonnull)viewController;

    Swift

    class func configure(with webView: UIWebView, viewController: UIViewController)

    Parameters

    webView

    the UIWebView that will be loading the page with the Visa Checkout button.

    viewController

    an instance of UIViewController that will be used to present Visa Checkout modally. When the Visa Checkout button is clicked by the user, VisaCheckoutPlugin will use this view controller to call present(_:animated:completion:).

  • Only used for UIWebView support (not needed if WKWebView used).

    Used in webView:shouldStartLoadWithRequest:navigationType: UIWebViewDelegate method to determine if the request should be handled by Visa Checkout.

    Declaration

    Objective-C

    + (BOOL)shouldHandleRequest:(NSURLRequest *_Nonnull)request;

    Swift

    class func shouldHandle(_ request: URLRequest) -> Bool

    Parameters

    request

    the request to check against (forwarded from webView:shouldStartLoadWithRequest:navigationType: UIWebViewDelegate method).

  • Only used for UIWebView support (not needed if WKWebView used).

    If a request from the webView:shouldStartLoadWithRequest:navigationType: UIWebViewDelegate method is found to need to be handled by Visa Checkout (as a result of calling VisaCheckoutPlugin.shouldHandleRequest), forward the request to this method for handling by Visa Checkout.

    Declaration

    Objective-C

    + (void)handleRequest:(NSURLRequest *_Nonnull)request;

    Swift

    class func handle(_ request: URLRequest)

    Parameters

    request

    the request forwarded from the webView:shouldStartLoadWithRequest:navigationType: UIWebViewDelegate method.