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

查看:30
本文介绍了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?

这是我获取重定向 url 的代码(使用自适应支付 gem):

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.

Edit 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天全站免登陆