【发布时间】:2015-01-20 13:37:57
【问题描述】:
我的 Rails 应用程序中有 paypal,我想对其进行测试,请求看起来不错,但由于某种原因,在提交 url 时附加了 localhost:3000 并给了我这个错误。我在 secrets.yml 文件中调用地址
[2015-01-20 14:33:31] 错误 URI::InvalidURIError: 方案 http 不接受 注册表部分:localhost:3000api.sandbox.paypal.com(或错误的主机名?) C:/Ruby193/lib/ruby/1.9.1/uri/generic.rb:1202:in
rescue in merge' C:/Ruby193/lib/ruby/1.9.1/uri/generic.rb:1199:inmerge' C:/Ruby193/lib/ruby/1.9.1/webrick/httpresponse.rb:220:insetup_header' C:/Ruby193/lib/ruby/1.9.1/webrick/httpresponse.rb:150:insend_response' C:/Ruby193/lib/ruby/1.9.1/webrick/httpserver.rb:110:inrun' C:/Ruby193/lib/ruby/1.9.1/webrick/server.rb:191:inblock in start_thread '
代码如下所示
def paypal_url(return_path)
values = {
business: "username-facilitator@yahoo.com",
cmd: "_xclick",
upload: 1,
return: "#{Rails.application.secrets.app_host}#{return_path}",
invoice: id,
amount: course.price,
item_name: course.name,
item_number: course.id,
quantity: '1',
notify_url: "#{Rails.application.secrets.app_host}/hook"
}
"#{Rails.application.secrets.paypal_host}/cgi-bin/webscr?" + values.to_query
end
【问题讨论】:
标签: ruby-on-rails paypal