apache / cordova-plugin-inappbrowser

Apache Cordova InAppBrowser Plugin
https://cordova.apache.org/
Apache License 2.0
1.12k stars 2.15k forks source link

ApplePaySession not working in InAppBrowser #761

Open Geschan opened 4 years ago

Geschan commented 4 years ago

Bug Report

Problem

We're using In-App-Browser to open a payment gateway to recieve credit card and Apple Pay payments. To communicate between the app and the payment gateway we use iab.executeScript(); and webkit.messageHandlers.cordova_iab.postMessage()

Our code:

  showBrowser() {
    this.browser = this.iab.create(this.paymentGatewayUrl, '_blank', 'location=no,usewkwebview=yes,hidenavigationbuttons=yes,toolbar=no');
    const iapSubscription = this.browser.on('loadstop').subscribe(() => {
      this.onInAppBrowserLoadstop();
      iapSubscription.unsubscribe();
    });
    this.browser.show();
  }

  sendMessage(type: string, message: string) {
    let code = 'var message = {type: \'' + type + '\', data: \'' + message + '\'};';
    code += 'handleMessage(message)';
    this.browser.executeScript({code: code});
  }

The payment gateway does use window.ApplePaySession to check if Apple Pay is available and initiate payments. But it seems the usage of executeScript() does prevent Apple Pay from working. Before using executeScript the function ApplePaySession.canMakePayments() is set to true, after it's set to false.

The other way arround, when executing ApplePaySession.canMakePayments() first, it seems iab.executeScript(); is not working anymore.

It's probably a security functionality, but we were not able to find any examples or documentation on this.

Environment, Platform, Device

Platform is iOS13 on iPhone

Version information

Ionic:

Ionic CLI : 6.10.1 (C:\Users\morit\AppData\Roaming\npm\node_modules\@ionic\cli) Ionic Framework : ionic-angular 3.9.9 @ionic/app-scripts : 3.2.4

Cordova:

Cordova CLI : 9.0.0 (cordova-lib@9.0.1) Cordova Platforms : android 8.1.0 Cordova Plugins : cordova-plugin-inappbrowser 4.0.0, cordova-plugin-ionic 5.4.6, cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 14 other plugins)

Utility:

cordova-res (update available: 0.15.1) : 0.13.1 native-run : 1.0.0

System:

NodeJS : v12.16.2 (C:\Program Files\nodejs\node.exe) npm : 6.14.7

Checklist

sjregan commented 3 years ago

@Geschan Did you find a way around this? Thanks.