简体   繁体   中英

Paypal Adaptive Payments mobile app hangs on completion or cancel

I have a Ruby On Rails mobile app that uses PayPal Adaptive Payments with a minibrowser. The app works fine when running in Safari on an iPhone: after completing the payment (or canceling out if it), the returnFromPaypal callback function is executed and the user is redirected to a reservation page.

However, when I run the app in full-screen mode (from an icon saved to the home screen, which is the intended mode of operation), the app hangs on a PayPal page when I either cancel the payment or complete it, with the messages "Just a moment - this window will close automatically" and "Returning" respectively.

Below is the .haml view of my payment page (sorry I don't have an HTML version).

Anyone has any idea what is going on? Thank you!

= javascript_include_tag  src="https://www.paypalobjects.com/js/external/apdg.js"
#edit_payment.current
  .scroll
    %ul
      %li
        = form_tag "https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay", :method=>'get', :target=>"PPDGFrame", :class=>"standard" do
          = hidden_field_tag :type, "mini", :name=>"expType"
          = hidden_field_tag :paykey, @pay_key, :name=>"paykey"
          = image_submit_tag "paypal_button.jpg", :id=>"submitBtn", :class=>"submit"
    :javascript
      var returnFromPayPal = function(){
          window.location.href = get_full_url("#{room_reservation_path(@room,@reservation)}");
      };                                                                                                                                  
      var dgFlowMini = new PAYPAL.apps.DGFlowMini({trigger: 'submitBtn',expType: 'mini', callbackFunction: 'returnFromPayPal'});

screenshot complete http://ec2-23-21-163-203.compute-1.amazonaws.com/images/scrn_complete.png screenshot canceled http://ec2-23-21-163-203.compute-1.amazonaws.com/images/scrn_canceled.png

This is "work as designed" as I understand. Just catch redirects like https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/closewindow?execution=e7s1 in your WebView and call payment check method on your server.

In apdg.js you can find the check:

if (ua.match(/iPhone|iPod|Android|Blackberry.*WebKit/i)) {
    win = window.open('', this.name);
    winOpened = true;
}

So your current window is completely replaced. No chance for callback.

Or you can support multiple windows in WebView itself. For example Android:

mWebView.getSettings().setSupportMultipleWindows(true);
mWebView.getSettings().setUserAgentString("web browser");

and @Override

public boolean onCreateWindow(WebView view, boolean dialog, boolean userGesture, Message resultMsg) {

Not sure about multiple windows in iOS WebView.

I was experiencing this same issue until I changed my code to redirect to PayPal in a new window. Then when the user completes the payment or cancels, the page doesn't hang, it automatically closes.

More information regarding the mini browser experience (expType=mini) can be found here:

Adaptive Payments without modal box or popups?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM