【问题标题】:Can't verify(check) paypal account无法验证(检查)贝宝帐户
【发布时间】:2012-07-14 12:51:43
【问题描述】:

当用户注册时,我需要验证 PayPal 帐户。

我有功能(来源 - http://curry.byteally.com/finding-verification-status-of-a-paypal-account-ruby-on-rails-paypal-adaptive-accounts-getverifiedstatus/

我输入了我的凭据并进行了更改。

我把它放在我的 static_pages_controller 中(现在)。

   def verify_paypal
     ...
//change:
if res.status == 200
 @xml = XmlSimple.xml_in(res.content)
 #check if the status node exists in the xml
if @xml['accountType']!=nil
account_type = @xml['accountType'][0]
if account_type.to_s() == "Business"
    render :text => "Business account!"
elseif account_type.to_s() == "Premier"
    render :text => "Premier Account!"
elseif account_type.to_s() == "Personal"
    render :text => "Personal account!"
else
    render :text => "Account type not null but not a valid PayPal account type."
end
   end

在我的 routes.rb 中添加了一行

  post "static_pages/verify_paypal"

在我看来:

   <%= link_to "verify", static_pages_verify_paypal_path, :method => :post %>

但它不断给我文字:

    "Gee! sorry! something went seriously wrong"

什么意思,我的用户没有在 PayPal 中注册(但它是!)。

EDTED 来自 Heroku 日志:

←[33m2012-07-15T17:22:56+00:00 app[web.1]:←[0m Started POST "/static_pages/verify_paypal" for 46.119.153.97 at 2012-07-15 17:22:56 +0000
←[33m2012-07-15T17:22:56+00:00 app[web.1]:←[0m Processing by StaticPagesController#verify_paypal as HTML
←[33m2012-07-15T17:22:56+00:00 app[web.1]:←[0m   Parameters: {"authenticity_token"=>"xnW29ekJqp7qBNrvIZJjPSh05AMdiHWNQMvLZhevCig="}
←[36m2012-07-15T17:22:57+00:00 heroku[router]:←[0m POST sharp-cloud-3895.herokuapp.com/static_pages/verify_paypal dyno=web.1 queue=0 wait=0ms service=1058ms status=200 bytes=42
←[33m2012-07-15T17:22:57+00:00 app[web.1]:←[0m   Rendered text template (0.0ms)
←[33m2012-07-15T17:22:57+00:00 app[web.1]:←[0m Completed 200 OK in 1046ms (Views: 6.7ms | ActiveRecord: 2.7ms)

此行的第一个问题:

    "emailAddress" => params[:paypal] 

可以改成

    current_user.email

第二个问题 - 问题出在哪里,我做错了什么?

【问题讨论】:

  • 当显示“哎呀!抱歉!出现严重错误”时,我们需要将实际错误记录到您的日志文件中
  • 您引用的博文已有 2 年历史。 Paypal 很可能已经更改了他们的 API,并且该代码不再相关。它也只检查 200 状态代码,没有别的,我猜你会因为 API 更改而得到 404。
  • 你是对的!我需要更改有关帐户类型的 if 语句。谢谢!
  • 我改了,但是没用(

标签: ruby-on-rails paypal verify


【解决方案1】:

API调用结构健全。

但是,当您说您输入了凭据时,您是否确保在正确的环境中使用了正确的凭据? 沙盒中不存在实时凭据和实时帐户,反之亦然。您无法根据复选框检查真实账户的状态,因为它根本不存在于沙盒“宇宙”中。

这将是首先要看的东西。如果您觉得您的环境是正确的,您可以发布res.content 的内容以查看 HTTP 调用返回的内容吗?

【讨论】:

  • 远远超出了这个问题的范围。这解释了如何写入 Heroku 日志 devcenter.heroku.com/articles/logging
  • 抱歉,我没有看到从 PayPal 返回的登录结果命令。我可以给你看我的日志还是应该手动包含?
  • 我以某种方式发送 authencity 令牌。为什么?
【解决方案2】:

【讨论】:

    猜你喜欢
    • 2014-09-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-15
    • 2018-09-14
    • 2013-10-16
    • 2013-12-13
    • 1970-01-01
    • 2017-09-25
    相关资源
    最近更新 更多