9

I am using Paypals Adaptive Payments and Embedded flow feature to provide checkout via a minibrowser. Everything seems to be working correctly in the sandbox environment except that when the payment is completed successfully, the user is never redirected to my returnUrl set in the PAY API request. Same goes for my cancelUrl.

After the payment is complete, the user is shown an order overview in the minibrowser and a button labelled "close". If a user clicks this button, the minibrowser is closed.

If a user clicks cancel at any time, the minibrowser is closed.

There doesn't seem to be a way to have my page aware of the change besides setting up some polling or something which doesn't make sense, my returnUrl and cancelUrl should be used somewhere, right?

this is my code to get the redirect url (using adaptive payments gem):

pay_request = PaypalAdaptive::Request.new
data = {
  'requestEnvelope' => {'errorLanguage' => 'en_US'},
  'currencyCode' => 'USD',
  'receiverList' =>
          { 'receiver' => [
            {'email' => '...', 'amount'=> 10.00}
          ]},
  'actionType' => 'PAY',
  'returnUrl' => 'http://www.example.com/paid',
  'cancelUrl' => 'http://www.example.com/cancelled',
  'ipnNotificationUrl' => 'http://www.example.com/ipn'
}

pay_response = pay_request.pay(data)
redirect_to pay_response.approve_paypal_payment_url "mini"

And here is how I am setting up the paypal js:

var dg = new PAYPAL.apps.DGFlowMini({ trigger: "buyit", expType: "mini" });

It all seems pretty straight forward, not sure what I am missing.

Murf
  • 487
  • 5
  • 9
Dan.StackOverflow
  • 1,279
  • 4
  • 18
  • 28
  • I am also having trouble with the return urls, though the paypal IPN does appear to be working, I get a callback on my web page. https://www.paypal.com/us/cgi-bin/webscr?cmd=p/acc/ipn-info-outside – Ron Nov 29 '15 at 14:11

2 Answers2

9

Well - seems to be a bug on our side - just tried it myself and confirmed with our integration teams. :-(

Unfortunately the other short term fix I can think of other than what you've mentioned (checking for the existence of the popup window) is to call the PaymentDetails API from your server side to check the status of the Payment. I've opened the bug on our side but don't have an ETA.

Edit 10/18: Sorry I'm wrong. This is working - it's just that our developer guide is not providing all the required information. In case of the mini-browser flow, you would need to provide a 'callbackFunction' and also name your dgFlow variable as 'dgFlowMini'. (the latter is important - as apdg.js is expecting the 'dgFlowMini' variable to be defined) Here is the code that works:

var returnFromPayPal = function(){
   alert("Returned from PayPal");
   // Here you would need to pass on the payKey to your server side handle to call the PaymentDetails API to make sure Payment has been successful or not
  // based on the payment status- redirect to your success or cancel/failed urls
}
var dgFlowMini = new PAYPAL.apps.DGFlowMini({trigger: 'em_authz_button', expType: 'mini', callbackFunction: 'returnFromPayPal'});

I have a working sample here: https://pp-ap-sample.appspot.com/adaptivesample?action=pay (make sure you select mini as the Experience Type)

We will get our docs updated and also cleanup apdg.js to remove the dependency on the JS variable name.

Praveen
  • 2,039
  • 14
  • 15
  • Yes, i actually created a local copy of apdg.js and modified it to fit my needs. There are a few other issues as well, isOpen doesn't do what you think it does. When a user clicks the paypal button i now have an intervalled ajax request that polls my server which polls paypal. This is the only reliable way to know when the payment has been completed. – Dan.StackOverflow Oct 20 '12 at 15:06
  • @Praveen I am also facing a similar issue. In my case we are implementing it in IOS native application. Mini browser is loaded inside UIWebiew inside my application. While creating payment cancel url as well as returnUrl are specified. But on completion of payment/cancellation, it is not redirecting to return or cancel urls. – arundevma Dec 03 '14 at 07:01
  • Is it also confirmed that in the mini flow, return and cancel urls are not used? The documentation is not clear on this. – Lem Ko Dec 22 '14 at 06:58
  • Hi is it possible to pass parameter to callback function. Like, `var dgFlowMini = new PAYPAL.apps.DGFlowMini({trigger: 'em_authz_button', expType: 'mini', callbackFunction: 'returnFromPayPal($parameter)'});`. – user254153 Apr 24 '15 at 03:55
  • @Praveen Does Embedded Payment Flow work with native Android and iOS webviews? There is mixed information about this all over the place. Would be great to know before spending time converting existing adaptive payments to it. Thanks. – Heinrich Oct 12 '15 at 03:51
  • I have it working with both iPhone and Android mobile and tablets. I am using the minibrowser option specified at https://developer.paypal.com/docs/classic/adaptive-payments/ht_ap-embeddedPayment-curl-etc/#mini-b . I am creating a mobile ready web site using Bootstrap and AngularJS. It does appear that I currently have a problem with the return urls, will be looking more into this, though the paypal IPN is working, I do get a callback on that. – Ron Nov 29 '15 at 14:06
  • mini browser works but in web view it doesnt work. can paypal fix the issue? – moDev Jan 19 '16 at 09:38
2

Looks like the PayPal experience for embedded flows has gotten worse. Now you'll receive an error message after invoking mini or lightbox that says "Payment can't be completed. This feature is currently unavailable."

JohnP
  • 125
  • 1
  • 5