Stripe Connect in Ionic Cordova - cannot be redirected back to the application

Frame: Ionic Cordoba

API: Stripe Connect (allows users to send payments to each other).

The registration process of payments is carried out through its own external window Stripe Connects. When registering for Stripe Connect, it uses the redirect URI (which is set in my Stripe account settings) to return to the screen you came from with the authentication code. This works in the browser (because the Redirect URI is set to localhost or IP), but the actual running application on the phone does not work, because the application does not have a URL. Thus, the browser error message "site is not available / does not exist" is displayed.

I am currently using the open Stripe Connect login screen using:

var link = "https://connect.stripe.com/oauth/authorize?response_type=code&client_id=MYCLIENTID&scope=read_write"; window.open(link, '_blank', 'location=no'); 
  • I asked for Stripe support for reference, but they have no solution for this.

  • I tried to use a custom URL scheme to provide the application URL, but Stripe only allows the URL Http: //, not CoolAppName //:, as the custom URL scheme is configured.

  • Please do not get confused with this: if I run "ionic run -l" in cmd and then use this URL as a Redirect URI, it also redirects the authentication code on the phone. BUT, it erases every information stored in the application, so it "forgets" that the user is logged in. Of course, this solution will only work locally.

Any suggestion is appreciated.

Thanks in advance.

+8
redirect cordova ionic-framework stripe-connect
source share
1 answer

You can use any url you want to listen to the loadstart event and check if this url loads, if the redirect was ok

Install the inAppBrowser plugin first if you havenโ€™t already done so cordova plugin add cordova-plugin-inappbrowser

and use window.cordova.InAppBrowser.open instead of window.open (the API has changed a long time ago)

Your code should look something like this:

 var link = "https://connect.stripe.com/oauth/authorize?response_type=code&client_id=MYCLIENTID&scope=read_write"; var browserRef = window.cordova.InAppBrowser.open(link, '_blank', 'location=no'); browserRef.addEventListener('loadstart', function(event) { if((event.url).indexOf(yourRedirectUri) === 0) { //Loaded the redirect url } }); 

Where yourRedirectUri is the URL you used in the strip

+3
source share

All Articles