2

对不起,但由于 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)

我应该如何做到这一点?

4

0 回答 0