     public weak var delegate: AuthorizingPaymentViewControllerDelegate?
     
     let webView: WKWebView = WKWebView(frame: CGRect.zero, configuration: WKWebViewConfiguration())
-    
+    let okButtonTitle = NSLocalizedString("OK", comment: "OK button for JavaScript panel")
+    let confirmButtonTitle = NSLocalizedString("Confirm", comment: "Confirm button for JavaScript panel")
+    let cancelButtonTitle = NSLocalizedString("Cancel", comment: "Cancel button for JavaScript panel")
     
     /// A factory method for creating a authorizing payment view controller comes in UINavigationController stack.
     ///

    
    /// A delegation method called when user cancel the authorizing payment process.
    func authorizingPaymentViewControllerDidCancel(_ viewController: AuthorizingPaymentViewController)
    
    /// A delegation method called when authorizing website page displays a JavaScript alert panel.
    /// - parameter message: The message to be displayed.
    /// - parameter frame: Information about the frame whose JavaScript process initiated this call.
    /// - parameter completionHandler: The completion handler to call after the alert panel has been dismissed.
    @objc optional func authorizingPaymentViewController(_ viewController: AuthorizingPaymentViewController, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Void)
    
    /// A delegation method called when authorizing website page displays a JavaScript confirm panel.
    /// - parameter message: The message to be displayed.
    /// - parameter frame: Information about the frame whose JavaScript process initiated this call.
    /// - parameter completionHandler: The completion handler to call after the confirm panel has been dismissed. Pass true if the user chose OK, and pass false if the user chose Cancel.
    @objc optional func authorizingPaymentViewController(_ viewController: AuthorizingPaymentViewController,
                                                         runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (Bool) -> Void)
    
    /// A delegation method called when authorizing website page displays a JavaScript text input panel.
    /// - parameter prompt: The message to be displayed.
    /// - parameter defaultText: The initial text to display in the text entry field.
    /// - parameter frame: Information about the frame whose JavaScript process initiated this call.
    /// - parameter completionHandler: The completion handler to call after the text input panel has been dismissed. Pass the entered text if the user chose OK, otherwise nil.
    @objc optional func authorizingPaymentViewController(_ viewController: AuthorizingPaymentViewController, runJavaScriptTextInputPanelWithPrompt prompt: String, defaultText: String?, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (String?) -> Void)
    
    @available(*, unavailable,
    renamed: "authorizingPaymentViewController(_:didCompleteAuthorizingPaymentWithRedirectedURL:)")


extension AuthorizingPaymentViewController: WKUIDelegate {
    public func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Void) {

        let alertController = UIAlertController(title: nil, message: message, preferredStyle: .alert)
        let okAction = UIAlertAction(title: okButtonTitle, style: .default) { (action: UIAlertAction) -> Void in
            alertController.dismiss(animated: true, completion: nil)
            completionHandler()
        }
        
        alertController.addAction(okAction)
        
        // NOTE: Must present an UIAlertController on AuthorizingPaymentViewController
        self.present(alertController, animated: true)
    }
    
    public func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (Bool) -> Void) {
                
        let alertController = UIAlertController(title: nil, message: message, preferredStyle: .alert)
        let confirmAction = UIAlertAction(title: confirmButtonTitle, style: .default, handler: { (action) in
            completionHandler(true)
        })
        let cancelAction = UIAlertAction(title: cancelButtonTitle, style: .cancel, handler: { (action) in
            completionHandler(false)
        })
        
        alertController.addAction(confirmAction)
        alertController.addAction(cancelAction)

        // NOTE: Must present an UIAlertController on AuthorizingPaymentViewController
        self.present(alertController, animated: true, completion: nil)
    }
    
    public func webView(_ webView: WKWebView, runJavaScriptTextInputPanelWithPrompt prompt: String, defaultText: String?, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (String?) -> Void) {        
        let alertController = UIAlertController(title: nil, message: prompt, preferredStyle: .alert)
        alertController.addTextField { (textField) in
            textField.text = defaultText
        }
        let okAction = UIAlertAction(title: okButtonTitle, style: .default, handler: { (action) in
            if let text = alertController.textFields?.first?.text {
                completionHandler(text)
            } else {
                completionHandler(defaultText)
            }
        })
        let cancelAction = UIAlertAction(title: cancelButtonTitle, style: .cancel, handler: { (action) in
            completionHandler(nil)
        })
        
        alertController.addAction(okAction)
        alertController.addAction(cancelAction)
        
        // NOTE: Must present an UIAlertController on AuthorizingPaymentViewController
        self.present(alertController, animated: true, completion: nil)
    }
}

