测试贝宝 rails URL 错误
Testing paypal with rails URL error
我的 rails 应用程序中有 paypal,我想测试它,请求看起来不错,但由于某种原因,在提交时 url 已附加 localhost:3000 并给我这个错误。我正在调用 secrets.yml 文件中的地址
[2015-01-20 14:33:31] ERROR URI::InvalidURIError: the scheme http does not accept
registry part: localhost:3000api.sandbox.paypal.com (or bad hostname?)
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:in
merge'
C:/Ruby193/lib/ruby/1.9.1/webrick/httpresponse.rb:220:in setup_header'
C:/Ruby193/lib/ruby/1.9.1/webrick/httpresponse.rb:150:in
send_response'
C:/Ruby193/lib/ruby/1.9.1/webrick/httpserver.rb:110:in run'
C:/Ruby193/lib/ruby/1.9.1/webrick/server.rb:191:in
block 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
生成的支付宝URL错误:
localhost:3000api.sandbox.paypal.com
将Rails.application.secrets.paypal_host
修改为https://api.sandbox.paypal.com
我的 rails 应用程序中有 paypal,我想测试它,请求看起来不错,但由于某种原因,在提交时 url 已附加 localhost:3000 并给我这个错误。我正在调用 secrets.yml 文件中的地址
[2015-01-20 14:33:31] ERROR URI::InvalidURIError: the scheme http does not accept registry part: localhost:3000api.sandbox.paypal.com (or bad hostname?) 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:in
merge' C:/Ruby193/lib/ruby/1.9.1/webrick/httpresponse.rb:220:insetup_header' C:/Ruby193/lib/ruby/1.9.1/webrick/httpresponse.rb:150:in
send_response' C:/Ruby193/lib/ruby/1.9.1/webrick/httpserver.rb:110:inrun' C:/Ruby193/lib/ruby/1.9.1/webrick/server.rb:191:in
block 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
生成的支付宝URL错误:
localhost:3000api.sandbox.paypal.com
将Rails.application.secrets.paypal_host
修改为https://api.sandbox.paypal.com