[英]cannot make API call on paymill - 302 found as a response - rails
我使用了“付款程序”頁面上的示例來毫無問題地獲取令牌。 我正在使用ajax調用傳遞令牌。 但是我無法使API進行最終調用。 我真的無法理解如何使用github上的paymill-ruby或paymill-rails代碼中的代碼,因此我仔細研究了代碼並找到了API調用(這是我所缺少的),但無法使其正常工作。 我要做的就是簡單的付款。 沒有訂閱,沒有用戶。 只需信用卡付款。 這是我的控制器中的代碼:
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"
響應是
<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>
而且我不知道出了什么問題...幾周前我不知道ajax是什么...有人可以伸出援手嗎?
我不是Rails專家,但是...
...您正在使用端口80連接到我們的API,而無需使用SSL。 我們僅允許對api的SSL請求,因此您必須使用端口443進行連接並啟用SSL。
希望能解決您的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.