braintree / popup-bridge-ios

Enable your web view to open pages in an ASWebAuthenticationSession
MIT License
38 stars 20 forks source link

var url = 'http://localhost:3099/'; #11

Closed LaxmanFareportal closed 6 years ago

LaxmanFareportal commented 6 years ago

General information

Could you please explain what do you mean by step

  1. Use PopupBridge from the web page by writing some JavaScript:

  2. Redirect back to the app inside of the popup:

How to do these steps on iOS app?

Explain

Issue description

crookedneighbor commented 6 years ago

Are you trying to use Popup Bridge with PayPal, or just generally with popups? The instructions you're referencing are for general use.

For reference, the documentation for integrating with PayPal is here. Most of the work to integrate with PayPal is already done in the Braintree and PayPal SDKs.

For general usage, the code snippets below the steps you reference illustrate what to do.

  1. Use PopupBridge from the web page by writing some JavaScript:
var url = 'http://localhost:3099/';

 if (window.popupBridge) {
 // Open the popup in a browser, and give it the deep link back to the app
 popupBridge.open(url + '?popupBridgeReturnUrlPrefix=' + popupBridge.getReturnUrlPrefix());

Where url is the popup you are opening. And you append 'popupBridgeReturnUrlPrefix=' + popupBridge.getReturnUrlPrefix() as a query string to that url so popup bridge knows how to return your user back to your webview.

  1. Redirect back to the app inside of the popup:
    if (location.search.indexOf('popupBridgeReturnUrlPrefix') !== -1) {
    var prefix = location.search.split('popupBridgeReturnUrlPrefix=')[1];
    // Open the deep link back to the app, and send some data
    location.href = prefix + '?color=' + color;

Here it checks if that query parameter exists, and if it does it changes the location of the popup back to the webview.

Does that clear it up for you?

LaxmanFareportal commented 6 years ago

I am trying to use Popup Bridge with PayPal. Have downloaded the Example app and tried to run this code. It shows blank on Simulator.

what is this URL for http://localhost:3099/ ?

We are planning to implement Paypal using webview. Whats the best document to follow? Please advise.

REQ:

We need URL that opens paypal screen and takes the control of payment. Once the payment is done it returns the control back to app. How can this be achieved ?

crookedneighbor commented 6 years ago

All you need to do is follow steps 1-3 and create a webpage opened in a WKWebview that uses PayPal's Checkout.js. Everything else is handled by the Checkout.js SDK.

LaxmanFareportal commented 6 years ago

Have completed 1-3 steps.

Please explain what this URL actually is? I am getting blank page on my app. http://localhost:3099/

Also if we run the popupbridgeexample target. The simulator shows blank and nothing really happens. Could you please fix that issue. May be then we can compare with the example code.

Thanks, Laxman

LaxmanFareportal commented 6 years ago

What should be this URL in my app? http://localhost:3099/

crookedneighbor commented 6 years ago

The Popup Bridge library can be used generically with any popup, not just PayPal. http://localhost:3099 is supposed to represent any popup you are trying to access with Popup Bridge. We will update the README documentation to make that clearer.

Here's a gif of what should happen when you open the demo:

popupdemo

Not sure why it doesn't work for you.

If you're a Braintree merchant and need further assistance with your integration, please contact our support team https://articles.braintreepayments.com/forms/contact

If you're not a Braintree merchant, I recommend reaching out to the support channels through PayPal.

crookedneighbor commented 6 years ago

Correction, http://localhost:3099/ refers to the webpage you are opening in the webview. Not the popup. So in this case, you'd substitue http://localhost:3099/ for your website's checkout page that has checkout.js on it.

crookedneighbor commented 6 years ago

That is, in step 3 it refers to the webview. In step 4, it refers to the page you would be opening in the popup.

I have a PR to clarify these instructions and I worked to clear up that confusion: https://github.com/braintree/popup-bridge-ios/pull/10/commits/80b15511d5ba313144138ee85340375b7d1c56eb