Paypal Embedded Flow不使用returnUrl或cancelUrl [英] Paypal Embedded Flow not using returnUrl or cancelUrl

查看:384
本文介绍了Paypal Embedded Flow不使用returnUrl或cancelUrl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Paypals自适应付款和嵌入式流量功能通过迷你浏览器提供结帐。除了当付款成功完成时,用户永远不会被重定向到在PAY API请求中设置的returnUrl,所以一切似乎都在沙箱环境中正常工作。同样适用于我的cancelUrl。

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.

似乎没有办法让我的页面知道更改,除了设置一些轮询或一些没有用的东西,我的returnUrl和cancelUrl应该在某处使用,对吗?

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"

以下是我设置paypal js的方式:

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.

推荐答案

好吧 - 似乎是我们这边的一个错误 - 只是自己尝试并与我们的集成团队确认。 :-(

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

不幸的是,除了你提到的(检查弹出窗口是否存在)之外,我能想到的另一个短期修复是调用PaymentDetails来自服务器端的API检查付款状态。我已经打开了我们这边的错误但没有ETA。

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.

编辑10 / 18 :对不起,我错了。这是有效的 - 只是我们的开发者指南没有提供所有必需的信息。如果是迷你浏览器流程,你需要提供'callbackFunction'和也将你的dgFlow变量命名为'dgFlowMini'。(后者很重要 - 因为apdg.js期望定义'dgFlowMini'变量)以下是可行的代码:

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'});

我这里有一个工作样本: https://pp-ap-sample.appspot.com/adaptivesample?action=pay (确保选择mini作为体验类型)

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

我们将更新我们的文档并清理apdg.js以删除对JS变量名的依赖。

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

这篇关于Paypal Embedded Flow不使用returnUrl或cancelUrl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆