rubykassa 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/app/controllers/robokassa_controller.rb +1 -1
- data/lib/rubykassa/payment_interface.rb +11 -4
- data/lib/rubykassa/signature_generator.rb +14 -10
- data/lib/rubykassa/version.rb +1 -1
- data/lib/rubykassa.rb +5 -5
- data/spec/rubykassa/payment_interface_spec.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e32aed2ec5fcba1f0a2da295982531f30bc09639
|
4
|
+
data.tar.gz: 97b7a4036c09d345cd29becd995e259642786e37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 780f5632372166c33f2eef59a63308a46ac87ad36a1f9db16e764763e42bf8acd7e1efeda195679435e45737cbd2972bad21e6ada74bdceec34114476d8102f2
|
7
|
+
data.tar.gz: 3402f01d6f369a09c850d5514941681367134c172516cf2f776d7c472cb6a99bf63446dcf67c010c80d0118a47e65005ed92bd93604d3b8d3b683dda5bd8ad3a
|
data/CHANGELOG.md
CHANGED
@@ -20,6 +20,7 @@ module Rubykassa
|
|
20
20
|
|
21
21
|
def initialize &block
|
22
22
|
instance_eval &block if block_given?
|
23
|
+
shpfy_params
|
23
24
|
end
|
24
25
|
|
25
26
|
def test_mode?
|
@@ -30,10 +31,10 @@ module Rubykassa
|
|
30
31
|
test_mode? ? "http://test.robokassa.ru/Index.aspx" : "https://merchant.roboxchange.com/Index.aspx"
|
31
32
|
end
|
32
33
|
|
33
|
-
def pay_url(
|
34
|
-
|
34
|
+
def pay_url(extra_params = {})
|
35
|
+
extra_params = extra_params.slice(:currency, :description, :email, :culture)
|
35
36
|
|
36
|
-
"#{base_url}?" + initial_options.merge(
|
37
|
+
"#{base_url}?" + initial_options.merge(extra_params).map do |key, value|
|
37
38
|
if key =~ /^shp/
|
38
39
|
"#{key}=#{value}"
|
39
40
|
else
|
@@ -48,7 +49,13 @@ module Rubykassa
|
|
48
49
|
total: @total,
|
49
50
|
invoice_id: @invoice_id,
|
50
51
|
signature: generate_signature_for(:payment)
|
51
|
-
}.merge(Hash[@params.sort.map {|param_name| [
|
52
|
+
}.merge(Hash[@params.sort.map {|param_name| [param_name[0], param_name[1]]}])
|
52
53
|
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def shpfy_params
|
58
|
+
@params = @params.map {|param_name| ["shp#{param_name[0]}".to_sym, param_name[1]]}
|
59
|
+
end
|
53
60
|
end
|
54
61
|
end
|
@@ -2,22 +2,26 @@
|
|
2
2
|
module Rubykassa
|
3
3
|
module SignatureGenerator
|
4
4
|
def generate_signature_for kind
|
5
|
-
raise ArgumentError, "Available kinds are only :payment, :result or :success" unless [:success, :payment, :result].include? kind
|
6
|
-
|
7
|
-
custom_params_string = custom_params.present? ? ":#{custom_params}" : ""
|
8
|
-
|
9
|
-
Digest::MD5.hexdigest(params_string(kind, custom_params_string))
|
5
|
+
raise ArgumentError, "Available kinds are only :payment, :result or :success" unless [:success, :payment, :result].include? kind
|
6
|
+
Digest::MD5.hexdigest(params_string(kind))
|
10
7
|
end
|
11
8
|
|
12
|
-
def params_string kind
|
9
|
+
def params_string kind
|
13
10
|
string = case kind
|
14
11
|
when :payment
|
15
|
-
[Rubykassa.login, @total, @invoice_id, Rubykassa.first_password].join(":")
|
12
|
+
[Rubykassa.login, @total, @invoice_id, Rubykassa.first_password, custom_params].flatten.join(":")
|
16
13
|
when :result
|
17
|
-
[@total, @invoice_id, Rubykassa.second_password].join(":")
|
14
|
+
[@total, @invoice_id, Rubykassa.second_password, custom_params].flatten.join(":")
|
18
15
|
when :success
|
19
|
-
[@total, @invoice_id, Rubykassa.first_password].join(":")
|
16
|
+
[@total, @invoice_id, Rubykassa.first_password, custom_params].flatten.join(":")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def custom_params
|
21
|
+
@params.sort.inject([]) do |result, element|
|
22
|
+
result << element.join("=") if element[0] =~ /^shp/
|
23
|
+
result
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
23
|
-
end
|
27
|
+
end
|
data/lib/rubykassa/version.rb
CHANGED
data/lib/rubykassa.rb
CHANGED
@@ -18,11 +18,11 @@ module Rubykassa
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
def pay_url invoice_id, total,
|
21
|
+
def pay_url invoice_id, total, custom_params, extra_params = {}
|
22
22
|
Rubykassa::PaymentInterface.new do
|
23
|
-
self.total
|
24
|
-
self.invoice_id
|
25
|
-
self.params
|
26
|
-
end.pay_url(
|
23
|
+
self.total = total
|
24
|
+
self.invoice_id = invoice_id
|
25
|
+
self.params = custom_params
|
26
|
+
end.pay_url(extra_params)
|
27
27
|
end
|
28
28
|
end
|
@@ -18,11 +18,11 @@ describe Rubykassa::PaymentInterface do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should return correct pay_url" do
|
21
|
-
@payment_interface.pay_url.should == "http://test.robokassa.ru/Index.aspx?MrchLogin=your_login&OutSum=1200&InvId=12&SignatureValue=
|
21
|
+
@payment_interface.pay_url.should == "http://test.robokassa.ru/Index.aspx?MrchLogin=your_login&OutSum=1200&InvId=12&SignatureValue=bf0504363d89638669e057932857316c&shpfoo=bar"
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should return correct pay_url when additional options passed" do
|
25
|
-
@payment_interface.pay_url({description: "desc", culture: "ru", email: "foo@bar.com", currency: ""}).should == "http://test.robokassa.ru/Index.aspx?MrchLogin=your_login&OutSum=1200&InvId=12&SignatureValue=
|
25
|
+
@payment_interface.pay_url({description: "desc", culture: "ru", email: "foo@bar.com", currency: ""}).should == "http://test.robokassa.ru/Index.aspx?MrchLogin=your_login&OutSum=1200&InvId=12&SignatureValue=bf0504363d89638669e057932857316c&shpfoo=bar&IncCurrLabel=&Desc=desc&Email=foo@bar.com&Culture=ru"
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should return correct initial_options" do
|
@@ -30,7 +30,7 @@ describe Rubykassa::PaymentInterface do
|
|
30
30
|
login: "your_login",
|
31
31
|
total: 1200,
|
32
32
|
invoice_id: 12,
|
33
|
-
signature: "
|
33
|
+
signature: "bf0504363d89638669e057932857316c",
|
34
34
|
shpfoo: "bar"
|
35
35
|
}
|
36
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubykassa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Kishenin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|