繁体   English   中英

该金额是无效的paypal_adaptive gem rails

[英]The amount is invalid paypal_adaptive gem rails

我在日志控制台中收到此错误:

The amount is invalid

我正在使用http://localhost:3000/在开发环境中工作

我在控制器中:

def pay
 pay_request = PaypalAdaptive::Request.new
     data = {
       "returnUrl" => user_orders_url(current_user),
       "requestEnvelope" => {"errorLanguage" => "en_US"},
       "currencyCode" => "USD",
       "receiverList" =>
               { "receiver" => [
                 {"receiver"=> [{"email"=>"email1", "amount"=>"10.00", "primary" => true}, {"email"=>"email2", "amount"=>"9.00", "primary" => false}]}
               ]},
       "cancelUrl" => user_orders_url(current_user),
       "actionType" => "PAY",
       "ipnNotificationUrl" => ipn_notification_user_orders_url(current_user)
     }
     pay_response = pay_request.pay(data)

     if pay_response.success?
         # Send user to paypal
         redirect_to pay_response.preapproval_paypal_payment_url
     else
         puts pay_response.errors.first['message']
         redirect_to root_url, alert: "Something went wrong. Please contact support."
     end
end

我在做什么不好?

你可以用

"amount"=>10

要么

"amount"=>"10"

错误已修复:

错误出现在"primary" => true"primary" => false

我删除了此代码,现在控制器确实可以正常工作。

非常感谢你!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM