找不到资源:Paypal 验证(电子邮件、名字、姓氏)rails
Posted
技术标签:
【中文标题】找不到资源:Paypal 验证(电子邮件、名字、姓氏)rails【英文标题】:Resource not found: Paypal verification (email, firstname, lastname) rails 【发布时间】:2016-10-19 01:39:33 【问题描述】:我的email
、firstname
、lastname
都在paypal网站上进行验证:https://paypal-sdk-samples.herokuapp.com/adaptive_accounts/get_verified_status
我在提交表单后遇到问题,我会在控制器中自动调用email
、firstname
、lastname
,然后再将它们设置为输入框,以确保一切设置正确。为了验证此帐户并获得状态,我还需要做些什么吗?
提交后我得到Resource not found:
也许原因是因为 LIMIT 1 [["id", nil]],也好像用户被调用了太多次? SELECT "users"
谢谢!!!!
错误日志:
Processing by VerificationsController#create as
Parameters: "utf8"=>"✓", "authenticity_token"=>"0S7n8LHhtb5zdAfmv9/BXdNtkeiBNAcvWx2lC3gvmrndUNz4V/Cq+p3yAuQY8vggYqIGm5DJGUFUpMpWxJyg5Q==", "verification"=>"paypal_email"=>"vampiricbeef@gmail.com", "paypal_firstname"=>"", "paypal_lastname"=>"", "commit"=>"verify", "id"=>"3"
User Load (0.3ms) SELECT "users".* FROM "users" ORDER BY created_at DESC
User Load (0.4ms) SELECT "users".* FROM "users"
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 3]]
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", nil]]
Redirected to http://localhost:3000/users/3/paypal_verification
Completed 302 Found in 20ms (ActiveRecord: 2.1ms)
verificationsController:
def create
@user = User.find(params[:user_id])
# @verification = current_user.verification.create(verification_params)
@verification = current_user.create_verification(verification_params)
require 'paypal-sdk-adaptiveaccounts'
@api = PayPal::SDK::AdaptiveAccounts::API.new( :device_ipaddress => "127.0.0.1" )
# Build request object
@get_verified_status = @api.build_get_verified_status(
:emailAddress => "current_user.verification.paypal_email",
:matchCriteria => "NONE" )
# Make API call & get response
@get_verified_status_response = @api.get_verified_status(@get_verified_status)
# Access Response
if @get_verified_status_response.success?
@get_verified_status_response.accountStatus
@get_verified_status_response.countryCode
@get_verified_status_response.userInfo
else
@get_verified_status_response.error
end
status = params[:accountStatus]
verification = Verification.find(params[:emailAddress])
if status != "VERIFIED" || @get_verified_status_response.error
redirect_to edit_user_registration_path(current_user)
verification.update_attributes paypal_verified: false
verification.destroy
elsif status == "VERIFIED"
redirect_to edit_user_registration_path(current_user)
verification.update_attributes paypal_verified: true
else
redirect_to edit_user_registration_path(current_user)
verification.update_attributes paypal_verified: false
verification.destroy
end
end
private
def verification_params
params.require(:verification).permit(:user_id, :paypal_firstname, :paypal_lastname, :paypal_email, :paypal_verified)
end
【问题讨论】:
【参考方案1】:我认为这是您应该更改调用用户属性的地方
@get_verified_status = @api.build_get_verified_status(
:emailAddress => "@user.paypal_email", # or "current_user.paypal_email"
:matchCriteria => "NAME",
:firstName => "@user.paypal_firstname",
:lastName => "@user.paypal_lastname" )
【讨论】:
问题是用户中的 nil .. 一个数组可能我不明白如何修复.. 但是一旦这个用户 nil 问题消失了,它应该可以工作!!!好伤心!!以上是关于找不到资源:Paypal 验证(电子邮件、名字、姓氏)rails的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Laravel 中验证电子邮件地址是不是是有效的 PayPal 电子邮件地址
PayPal 自适应付款 - 错误 520009 - 帐户受到限制