I built an app that is published as a web page (PWA) and also gets compiled as an Android/iOS app. For the web page, when comes the time to pay for an item, I call my Node JS server which uses the paypal-rest-sdk to create a payment (using the ClientID and ClientSecret) and returns a redirect url. I then send the user to this url, the payment is authorised and paypal returns the user to my web page. So far so good.
The problem is that mobile apps don’t play well with getting “redirected”. So I tried to use the inAppBrowser with the “_blank” setting so that it pops the paypal page on top of the app. Works great on Android but iOS 13 doesn’t allow using “_blank” with the inAppBrowser. You can only use “_system” which launches the iOS system browser. Problem is that when the payment is done, it redirects you to the web page instead of returning to the app (makes sense) but my user might not be logged in on the web page so it gives for a weird experience to switch from the app to the web page.
I have read through a lot of forums where they recommend using the Ionic native paypal plugin but all the tutorials show only how to create the payment from the client side. Is there a way to use the redirect url or even just the generated token with the native paypal plugin to allow the user to pay in-app?
It’s kind of confusing because the Ionic documentation refers to the documentation from https://github.com/paypal/PayPal-Cordova-Plugin which in turn says that “PayPal Mobile SDKs are Deprecated” and we should use BrainTree Direct. So which way to go? inAppBrowser with a fix for iOS? Ionic native plugin for PayPal? Braintree?
Does anyone have a clear guideline of how best to do this?
Ionic CLI : 6.1.0
Ionic Framework : @ionic/angular 5.0.1
@angular-devkit/build-angular : 0.803.25
@angular-devkit/schematics : 8.3.25
@angular/cli : 8.3.25
@ionic/angular-toolkit : 2.1.2
Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 7.1.4, ios 5.1.1
Cordova Plugins : cordova-plugin-ionic 5.4.6, cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.3, (and 8 other plugins)
package:
“@ionic-native/ionic-webview”: “^5.19.1”,
“cordova-plugin-inappbrowser”: “^3.2.0”,