简体   繁体   English

无法在付款机上进行API调用-找到302作为响应-Rails

[英]cannot make API call on paymill - 302 found as a response - rails

I used the examples on the paymill page to get the token with no problem. 我使用了“付款程序”页面上的示例来毫无问题地获取令牌。 I'm passing the token using an ajax call. 我正在使用ajax调用传递令牌。 But I cannot make the API to make the final call. 但是我无法使API进行最终调用。 I cannot really understand how to use the code from the paymill-ruby or paymill-rails code at github, so I went trough the code and found the API call -which is what I'm missing-, but cannot make it work. 我真的无法理解如何使用github上的paymill-ruby或paymill-rails代码中的代码,因此我仔细研究了代码并找到了API调用(这是我所缺少的),但无法使其正常工作。 All I want to do is a simple payment. 我要做的就是简单的付款。 No subscription, no user. 没有订阅,没有用户。 Just a credit card payment. 只需信用卡付款。 Here is the code from my controller: 这是我的控制器中的代码:

token = params[:token]

params = {'amount' => '#{@@amount}', 'currency' => 'EUR', 'token' => '#{token}', 'description' => 'description'}

https = Net::HTTP.new('api.paymill.de', 80)
https.use_ssl = false
https.start do |connection|
  url = "/v2/transactions"
  https_request = Net::HTTP::Post.new(url)
  https_request.basic_auth(Paymill.api_key,"")
  https_request.set_form_data(params)
  @response = https.request(https_request)
end

puts @response.body
puts @response.header

render :action => "confirm"

The response is 响应是

<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
#<Net::HTTPFound:0x00000004a98400>

And I cannot figure out what's wrong... a few weeks ago I didn't know what ajax was... can anybody give a hand? 而且我不知道出了什么问题...几周前我不知道ajax是什么...有人可以伸出援手吗?

I'm not a rails expert but ... 我不是Rails专家,但是...

... you are connecting to our API at port 80 without using SSL. ...您正在使用端口80连接到我们的API,而无需使用SSL。 We only allow SSL requests to the api so you'll have to connect using port 443 and having SSL enabled. 我们仅允许对api的SSL请求,因此您必须使用端口443进行连接并启用SSL。

Hope that solves your issues. 希望能解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM