Omnikassa is a Rails gem for Rabobank's Omnikassa. We use manual handleiding 4.1 (Dutch).
This gem is not affiliated with the Rabobank.
Install the gem and create an initializer.
# Gemfile
gem 'omnikassa', '~> 0.0.2'
# config/initializers/omnikassa.rb
Omnikassa.configure do |config|
config.merchant_id = '002020000000001'
config.secret_key = '002020000000001_KEY1'
config.environment = :test
end
Above are the official testing credentials from Rabo, so you don't have to use key and secret to run a test.
Create a request in your controller:
# controllers/payment_controller.rb
def payment
@omnikassa_request = Omnikassa::Request.new(
amount: 1234, # transaction amount in cents
reference: '1223123123', # A unique identifier for the transaction
return_url: payment_return_url,
response_url: payment_response_url
)
end
Then create a form that will POST the data you just provided to the Omnikassa:
# views/payments/payment.html.erb
<%= form_tag @omnikassa_request.url do |f| %>
<%= hidden_field_tag 'Data', @omnikassa_request.data_string %>
<%= hidden_field_tag 'InterfaceVersion', @omnikassa_request.interface_version %>
<%= hidden_field_tag 'Seal', @omnikassa_request.seal %>
<%= submit_tag 'Naar betaling' %>
<% end %>
After a user has completed the payment, he is redirected to the URL we specified as return_url
. You can show a message depending on the outcome of the payment.
# controllers/payment_controller.rb
def payment_return
@response = Omnikassa::Response.new(params)
if response.success?
render :success
else
render :error
end
end
Immediately after a payment is completed, Rabobank will send a POST-request to whatever URL we specified in response_url
. Use this to save the payment to the database, send out emails, etc.
# controllers/payment_controller.rb
def payment_response
response = Omnikassa::Response.new(params)
if response.success?
# update database
else
# don't update, send out warning, etc
end
end
# config/initializers/omnikassa.rb
Omnikassa.configure do |config|
config.merchant_id = '002020000000001'
config.secret_key = '002020000000001_KEY1'
config.environment = :test
key_version = 1,
currency_code = 978, # EURO
language = 'nl',
payment_methods: [:ideal, :minitix, :visa, :mastercard, :maestro, :incasso, :acceptgiro, :rembours]
end
Very welcome!
- Fork the project.
- Create a branch -
git checkout -b adding_magic
- Make your changes, and add some tests!
- Check that the tests pass -
bundle exec rake
- Commit your changes -
git commit -am "Added some magic"
- Push the branch to Github -
git push origin adding_magic
- Send us a pull request!
Copyright (C) 2013 by Tijmen Brommet. Published under the MIT license. See LICENSE.md for details.