glebtv-robokassa 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7306fc4420bb0b91ee8a5ee0dcb96c7c9d899671
4
- data.tar.gz: ed3e80250edfb3b67e5f72352393bb42961c1cb6
3
+ metadata.gz: 2603d83af4d291c7d117b0c5c25f116041f17d13
4
+ data.tar.gz: 073176be1596ee95e581ac853c2915417282026e
5
5
  SHA512:
6
- metadata.gz: e447b3420589c7e6404413713b292af050e55b6affe173d52b1fffd1973ae9e38c2ea673b6a30cc8d01e5282276b07525657058a7ace9fdb319e34e7dff446ae
7
- data.tar.gz: fdf218e58d40706365eee9ab3e7288b96568d9f1b9d4e5954892c6fe49b8793531867a96a96df68917c7d83b08000d428f6cc95dcf2e7ad51205784de8cc6031
6
+ metadata.gz: c31d922a42698a5c8951d24e950d5595bff006bb1ffb631a4c3b95765eb29768c06eabfec994e6c654ec53126fe8541521f26aa3e604473c81e7290f1785a98f
7
+ data.tar.gz: c189aa9f9dcd5a76b1c2e5a32ad0f7a93147b1c5384dac3fbf7156d5b53bd7db8d1e5d4c17ccbf4b8d314443cdf46eb2ee13392baff3e9c818c7d1e7ff06a441
data/README.md CHANGED
@@ -1,29 +1,121 @@
1
- # Glebtv::Robokassa
1
+ About this fork
2
+ -------
2
3
 
3
- TODO: Write a gem description
4
+ Everything I didn't need is removed. Added signature verification where possible. Fixed a lot of stuff that didn't work for me
4
5
 
5
- ## Installation
6
+ SUMMARY
7
+ -------
6
8
 
7
- Add this line to your application's Gemfile:
9
+ This gem adds robokassa support to your app.
10
+
11
+ Robokassa is payment system, that provides a single simple interface for payment systems popular in Russia.
12
+ If you have customers in Russia you can use the gem.
13
+
14
+ The first thing about this gem, is that it was oribinally desgned for spree commerce. So keep it im mind.
15
+
16
+
17
+ Using the Gem
18
+ -------------
19
+
20
+ Add the following line to your app Gemfile
8
21
 
9
22
  gem 'glebtv-robokassa'
10
23
 
11
- And then execute:
24
+ Update your bundle
25
+
26
+ bundle install
27
+
28
+ Mount engine in routes:
29
+ mount Robokassa::Engine => '/robokassa'
30
+
31
+
32
+ Create `config/initializers/robokassa.rb` with such code
33
+
34
+ ```ruby
35
+
36
+ class RoboCustom < Robokassa::Interface
37
+ def success_implementation(invoice_id, amount, language, custom_options, controller)
38
+ # this is called to show user payment success page
39
+ # Mostly secure to rely on
40
+ end
41
+
42
+ def fail_implementation(invoice_id, amount, language, custom_options, controller)
43
+ # this is called to show user payment fail page and unlock inventory stocks for order
44
+ # INSECURE
45
+ end
46
+
47
+ def notify_implementation(invoice_id, amount, custom_options, controller)
48
+ # this is called by robokassa server, to actually validate payment
49
+ # Secure.
50
+ end
51
+ end
52
+
53
+ Robokassa.interface = RoboCustom.new({
54
+ language: 'ru',
55
+ test_mode: true,
56
+ login: 'robox_login',
57
+ password1: 'asdf1234',
58
+ password2: 'qwer5678',
59
+ token: 'qwer1234' # "robokassa/notify/:token"
60
+ })
61
+ ```
62
+
63
+ In View file:
64
+
65
+ ```ERB
66
+ <% pay_url = Robokassa.interface.init_payment_url(order.id, order.amount, "Order #{order}", '', 'ru', order.user.email, {}) %>
67
+ <%= link_to "Оплатить через сервис ROBOX", pay_url %>
68
+ ```
69
+
70
+ In Robokassa account settings set:
71
+
72
+ Result URL: http://example.com/robokassa/notify
73
+ Success URL: http://example.com/robokassa/success
74
+ Fail URL: http://example.com/robokassa/fail
75
+
76
+
77
+ To overwrite controller you can do like this:
78
+
79
+ ```ruby
80
+ # coding: utf-8
81
+ class RobokassaController < Robokassa::Controller
82
+ def success
83
+ super
84
+ @payment = Payment.find(params[:InvId])
85
+ redirect_to dashboard_path, notice: "Ваш платеж на сумму #{@payment.amount} руб. успешно принят. Спасибо!"
86
+ end
87
+
88
+ def fail
89
+ super
90
+ redirect_to dashboard_path, varning: "Во время принятия платежа возникла ошибка. Мы скоро разберемся!"
91
+ end
92
+ end
93
+ ```
12
94
 
13
- $ bundle
95
+ Testing
96
+ -----
97
+ In console:
14
98
 
15
- Or install it yourself as:
99
+ Clone gem
100
+ ```bash
101
+ git clone git://github.com/shaggyone/robokassa.git
102
+ ```
16
103
 
17
- $ gem install glebtv-robokassa
104
+ Install gems and generate a dummy application (It'll be ignored by git):
105
+ ```bash
106
+ cd robokassa
107
+ bundle install
108
+ bundle exec combust
109
+ ```
18
110
 
19
- ## Usage
111
+ Run specs:
112
+ ```bash
113
+ rake spec
114
+ ```
20
115
 
21
- TODO: Write usage instructions here
116
+ Generate a dummy test application
22
117
 
23
- ## Contributing
118
+ Plans
119
+ -----
24
120
 
25
- 1. Fork it
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
121
+ I plan to add generators for views
@@ -56,7 +56,6 @@ module Robokassa
56
56
 
57
57
  def notify_validate_signature(params)
58
58
  parsed_params = map_params(params, @@notification_params_map)
59
- parsed_params[:custom_options] = Hash[params.select{ |k,v| k.starts_with?('shp') }.sort.map{|k, v| [k[3, k.size], v]}]
60
59
  if notify_response_signature(parsed_params) != parsed_params[:signature].downcase
61
60
  raise Robokassa::InvalidSignature.new
62
61
  end
@@ -75,7 +74,6 @@ module Robokassa
75
74
 
76
75
  def success_validate_signature(params)
77
76
  parsed_params = map_params(params, @@notification_params_map)
78
- parsed_params[:custom_options] = Hash[params.select{ |k,v| k.starts_with?('shp') }.sort.map{|k, v| [k[3, k.size], v]}]
79
77
  if success_response_signature(parsed_params) != parsed_params[:signature].downcase
80
78
  raise Robokassa::InvalidSignature.new
81
79
  end
@@ -137,7 +135,9 @@ module Robokassa
137
135
 
138
136
  # Maps gem parameter names, to robokassa names
139
137
  def map_params(params, map)
140
- Hash[params.map do|key, value| [(map[key] || map[key.to_sym] || key), value] end]
138
+ parsed_params = Hash[params.map do|key, value| [(map[key] || map[key.to_sym] || key), value] end]
139
+ parsed_params[:custom_options] = Hash[params.select{ |k,v| k.respond_to?(:starts_with?) && k.starts_with?('shp') }.sort.map{|k, v| [k[3, k.size].to_sym, v]}]
140
+ parsed_params
141
141
  end
142
142
 
143
143
  # make hash of options for init_payment_url
@@ -1,3 +1,3 @@
1
1
  module Robokassa
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glebtv-robokassa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebtv
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-08 00:00:00.000000000 Z
11
+ date: 2013-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  requirements: []
100
100
  rubyforge_project:
101
- rubygems_version: 2.1.11
101
+ rubygems_version: 2.1.10
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: This gem adds robokassa support to your app.