资源未找到:Paypal验证(电子邮件,名字,姓氏)rails

时间:2016-06-17 09:22:09

标签: html ruby-on-rails ruby paypal controller

我的emailfirstnamelastname都在paypal网站上进行验证:https://paypal-sdk-samples.herokuapp.com/adaptive_accounts/get_verified_status

我提交表单后遇到问题我在控制器中自动调用emailfirstnamelastname,然后再将其设置为输入框以确保我已正确设置所有内容。为了让这个帐户得到验证并具有状态,我还有什么必须做的吗?

提交后我得到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 个答案:

答案 0 :(得分:0)

我认为这是您应该更改调用用户属性的位置

@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" })