by Zero One
Yet another Ruby wrapper for Robokassa API. Make Robokassa to work with your Rails project without pain. Rubykassa took the best from robokassa gem and Active Merchant Robokassa integration but easier to use and setup.
Add to your Gemfile
:
gem "rubykassa"
Run rails g rubykassa:install
, get an initializer with the following code:
Rubykassa.configure do |config|
config.login = ENV["ROBOKASSA_LOGIN"]
config.first_password = ENV["ROBOKASSA_FIRST_PASSWORD"]
config.second_password = ENV["ROBOKASSA_SECOND_PASSWORD"]
config.mode = :test # or :production
config.http_method = :get # or :post
config.xml_http_method = :get # or :post
end
and configure it with your credentials.
Mode is :test
by default. For production you have to use :production
.
http_method
and xml_http_method
are :get
by default but can be configured as :post
Once you are done, simply use pay_url
helper in your view:
<%= pay_url "Pay with Robokassa", ivoice_id, total_sum %>
Additionally you may want to pass extra options. There is no problem:
<%= pay_url "Pay with Robokassa", ivoice_id, total_sum, { description: "Invoice description", email: "[email protected]", currency: "WMZM", culture: :ru } %>
If you need to implement Robokassa's XML interface functionality you have to the following:
xml_interface = Rubykassa::XmlInterface.new do
self.invoice_id = your_invioce_id
self.total = your_total_sum
self.language = :ru # can be :en, :ru is default
end
then call whatever you need
xml_interface.get_currencies_list
xml_interface.get_payment_methods
xml_interface.get_rates
xml_interface.op_state
Rubies:
- 1.9.3
- 2.0.0
Rails:
- ~> 3.0.0
- ~> 3.1.0
- ~> 3.2.0
- ~> 4.0.0
This project rocks and uses MIT-LICENSE Copyright (c) 2013 Zero One