apache / apache/cordova-plugin-inappbrowser

ApplePaySession not working in InAppBrowser

Open
#761 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
1.1k
Forks
2.2k
PR merge metrics
No merged PRs in 30d

Description

# 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

- [x] I searched for existing GitHub issues
- [ ] I updated all Cordova tooling to most recent version
(updated in app browser plugin to latest version)
- [x] I included all the necessary information above

Contributor guide

Open the contributing guide

Research direction

Start with the InAppBrowser executeScript() path and the iOS interaction between ApplePaySession.canMakePayments() and webkit.messageHandlers.cordova_iab.postMessage(). Reproduce the reported ordering on iOS 13, then determine whether the behavior can be fixed or needs documentation explaining the limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, javascript
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.