0

MassPaymentsを使いたい。

コントローラに機能があります:

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 = RAILS_ENV == 'production' ? "https://api-3t.paypal.com" : "https://api3t.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

私はこの関数を1人のユーザーに対してのみ呼び出しています(最初は):

send_money('pro_1342434702_biz@gmail.com',1000)

しかし、現時点ではエラーが発生します。

uninitialized constant MerchantsController::RAILS_ENV

だから私はこの行を変更しようとしました:

endpoint = RAILS_ENV == 'production' ? "https://api-3t.paypal.com" : "https://api-3t.sandbox.paypal.com"

しかし、私の試みはすべて失敗しました。実験中に発生したエラー-環境エラーまたはSSL証明書エラー。

私が去るときだけ:

endpoint = "https://api-3t.sandbox.paypal.com"

エラーが発生します:

SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

誰かが助けることができますか?

4

1 に答える 1

1

あなたの投稿には2つの質問があると思います。まず、本番モードかどうかをテストするには、次のようにします。

endpoint = ENV["RAILS_ENV"] == 'production' ? "https://api-3t.paypal.com" : "https://api-3t.sandbox.paypal.com"

もう 1 つの質問は、SSL の問題です。ここで解決策を見つけることができます: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

于 2012-07-16T16:39:06.187 に答える