WebToPay
It is a plugin which could be very useful on working with www.webtopay.com/ (www.mokejimai.lt/) billing system. The main function of this plugin is protection against forgeries that could be done by sending required parameters to the application and getting services without paying for free. This plugin could be integrated with both billing types - MACRO (VISA, MasterCard, banks etc.) and MICRO (SMS, phone calls etc.).
*It works with OpenSSL so be sure that you have installed all necessary libs or modules on your system.
Installation
cd your_application ./script/plugin install git://github.com/kristis/webtopay.git
Configuration
Create initializer config/initializers/webtopay.rb
WebToPay.configure do |config|
config.project_id = 00000
config.sign_password = 'your sign password'
end
Examples
These code slices will protect your controller actions, which work with webtopay.com billing, against forgeries.
****** Usage for MICRO and MACRO billing on controller:
- .….…
-
webtopay :activate_user, :confirm_cart # You can add here as many actions as you want
def activate_user
# write here code which do some stuff render :text => "Your user has been successfully activated. Thank you!" # it sends SMS answer
end
def confirm_cart
# write here code which do some stuff render :text => "ok" # it sends successful answer to webtopay.com crawler
end
- .….…
-
****** You can also use helper method to generate required form for MACRO billing query:
- .….…
-
<% macro_form :test => 1, :orderid => 123, :amount => 2000, :payment => ‘vb’, :country => ‘lt’, :paytext => “Billing for XX at the website XXX” do %>
Select paying method: <%= select_tag(:payment, options_for_select(['', 'vb', 'hanza', 'nord', 'snoras'])) %> <%= submit_tag "test paying" %>
<% end %>
- .….…
-
Attention!!! Be sure that you have set required option, which let sending test requests, at your webtopay.com account settings at first if you want to use test requests.
-
You can add into the helper options additional parameters or remove them according to technical specifications at www.webtopay.com/ .
TODO
-
Write more clear documentation with real examples
-
Write unit tests for each billing method (requires some testing data from www.webtopay.com/)
-
Add more settings for controller filters
Copyright © 2009 Kristijonas Urbaitis, released under the MIT license