借口,但由于SSL证书存在问题,我无法在开发模式下进行调试。
所以我将我的应用程序部署到了Heroku。
我稍后会更改为真实的凭证。
我在MerchantsController中采取了行动:
class MerchantsController < ApplicationController
helper_method :send_money
def send_money(to_email, how_much_in_cents, options = {})
credentials = {
"USER" => 'pro._1342094044_biz_api1.gmail.com',
"PWD" => '1342094095',
"SIGNATURE" => 'AMVxTgrWf6tUTF0Rf0y4QsqTFFAcApSXcqINQj2b2-a5wFhIx3UG87E- ',
}
params = {
"METHOD" => "MassPay",
"CURRENCYCODE" => "USD",
"RECEIVERTYPE" => "EmailAddress",
"L_EMAIL0" => to_email,
"L_AMT0" => ((how_much_in_cents.to_i)/100.to_f).to_s,
"VERSION" => "51.0"
}
endpoint = ENV["RAILS_ENV"] == 'production' ? "https://api-3t.paypal.com" : "https://api-3t.sandbox.paypal.com"
url = URI.parse(endpoint)
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
all_params = credentials.merge(params)
stringified_params = all_params.collect { |tuple| "#{tuple.first}={CGI.escape(tuple.last)}" }.join("&")
response = http.post("/nvp", stringified_params)
end
我添加了路线:
match 'merchants/send_money' => 'merchants#send_money', :via => [ :post ]
现在,我怎么称呼它,因为这是错误的(来自观点):
<%= link_to "Pay", merchants_send_money_path('pro_1342434702_biz@gmail.com',1) %>
Heroku日志:
←[35m2012-07-16T18:02:02+00:00 app[web.1]:←[0m ActionView::Template::Error (undefined method `gsub' for nil:NilClass)
我该如何做到这一点?