Question

I used the examples on the paymill page to get the token with no problem. I'm passing the token using an ajax call. But I cannot make the API to make the final call. 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. 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?

Was it helpful?

Solution

I'm not a rails expert but ...

... you are connecting to our API at port 80 without using SSL. We only allow SSL requests to the api so you'll have to connect using port 443 and having SSL enabled.

Hope that solves your issues.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top