gopay 0.1.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/config/config.yml +2 -2
- data/lib/gopay/crypt.rb +3 -3
- data/lib/gopay/models/base_payment.rb +7 -4
- data/lib/gopay/version.rb +1 -1
- data/test/config_test.rb +1 -1
- data/test/test_helper.rb +8 -1
- metadata +62 -72
data/config/config.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
urls:
|
2
2
|
test:
|
3
|
-
full_integration:
|
4
|
-
wsdl:
|
3
|
+
full_integration: http://testgw.gopay.cz/gw/pay-full-v2
|
4
|
+
wsdl: http://testgw.gopay.cz/axis/EPaymentServiceV2?wsdl
|
5
5
|
base_integration: https://testgw.gopay.cz/gw/pay-base-v2
|
6
6
|
get_account_statement_url: https://testgw.gopay.cz/gw/services/get-account-statement
|
7
7
|
production:
|
data/lib/gopay/crypt.rb
CHANGED
@@ -16,12 +16,12 @@ module GoPay
|
|
16
16
|
des.encrypt
|
17
17
|
des.key = GoPay.configuration.secure_key
|
18
18
|
result = des.update(string)
|
19
|
-
result.unpack("H*")
|
19
|
+
result.unpack("H*")[0]
|
20
20
|
end
|
21
21
|
|
22
22
|
def decrypt(encrypted_data, padding_off = false)
|
23
23
|
encrypted_data = bin2hex(encrypted_data)
|
24
|
-
des = OpenSSL::Cipher
|
24
|
+
des = OpenSSL::Cipher.new("des-ede3")
|
25
25
|
des.decrypt
|
26
26
|
des.padding = 0 if padding_off
|
27
27
|
des.key = GoPay.configuration.secure_key
|
@@ -30,7 +30,7 @@ module GoPay
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def bin2hex(bin)
|
33
|
-
bin.scan(/../).map { |
|
33
|
+
bin.scan(/../).map { |tuple| tuple.hex }.pack 'c*'
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -30,8 +30,10 @@ module GoPay
|
|
30
30
|
soap.body = {"paymentCommand" => payment_command_hash}
|
31
31
|
end
|
32
32
|
self.response = soap_response.to_hash[:create_payment_response][:create_payment_return]
|
33
|
-
self.payment_session_id = response[:payment_session_id]
|
34
33
|
valid_response?(response, GoPay::STATUSES[:created])
|
34
|
+
valid = valid_response?(response, GoPay::STATUSES[:created])
|
35
|
+
self.payment_session_id = response[:payment_session_id] if valid
|
36
|
+
valid
|
35
37
|
end
|
36
38
|
|
37
39
|
def load(validated_status = nil)
|
@@ -111,9 +113,10 @@ module GoPay
|
|
111
113
|
end
|
112
114
|
|
113
115
|
def valid_identity?(params, padding_off = false)
|
114
|
-
params['targetGoId'] == target_goid.to_s
|
115
|
-
|
116
|
-
|
116
|
+
raise 'invalid targetGoId' unless params['targetGoId'] == target_goid.to_s
|
117
|
+
raise 'invalid orderNumber' unless params['orderNumber'] == order_number.to_s
|
118
|
+
raise 'invalid encryptedSignature' unless GoPay::Crypt.sha1(concat_payment_identity(params)) == GoPay::Crypt.decrypt(params['encryptedSignature'], padding_off)
|
119
|
+
true
|
117
120
|
end
|
118
121
|
|
119
122
|
def concat_payment_identity(params)
|
data/lib/gopay/version.rb
CHANGED
data/test/config_test.rb
CHANGED
@@ -7,7 +7,7 @@ class ConfigTest < Test::Unit::TestCase
|
|
7
7
|
|
8
8
|
should "load both config and country_codes yml files" do
|
9
9
|
assert_equal "Česká Republika", GoPay.configuration.country_codes["CZE"]
|
10
|
-
assert_equal "
|
10
|
+
assert_equal "http://testgw.gopay.cz/gw/pay-full-v2", GoPay.configuration.urls["full_integration"]
|
11
11
|
end
|
12
12
|
|
13
13
|
end
|
data/test/test_helper.rb
CHANGED
@@ -3,7 +3,12 @@ $: << File.join(File.expand_path(File.dirname(__FILE__)), "../lib")
|
|
3
3
|
require "rubygems"
|
4
4
|
require 'test/unit'
|
5
5
|
require "shoulda"
|
6
|
-
|
6
|
+
|
7
|
+
if RUBY_VERSION > "1.9"
|
8
|
+
require 'mocha/setup'
|
9
|
+
else
|
10
|
+
require 'mocha'
|
11
|
+
end
|
7
12
|
|
8
13
|
require "gopay"
|
9
14
|
require "awesome_print"
|
@@ -14,3 +19,5 @@ end
|
|
14
19
|
|
15
20
|
# create your own test.yml (see test.example.yml)
|
16
21
|
GoPay.configure_from_yaml(File.join(File.dirname(__FILE__), "test.yml"))
|
22
|
+
|
23
|
+
HTTPI.log = false # silences warning like HTTPI executes HTTP POST using the net_http adapter
|
metadata
CHANGED
@@ -1,74 +1,73 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: gopay
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.2'
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 1
|
10
|
-
version: 0.1.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- papricek
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-11-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: savon
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
32
22
|
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: shoulda
|
36
23
|
prerelease: false
|
37
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
25
|
none: false
|
39
|
-
requirements:
|
40
|
-
- -
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: shoulda
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
46
38
|
type: :development
|
47
|
-
version_requirements: *id002
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: mocha
|
50
39
|
prerelease: false
|
51
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
41
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: mocha
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
60
54
|
type: :development
|
61
|
-
|
62
|
-
|
63
|
-
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: GoPay is a library making it easy to access GoPay http://www.gopay.cz
|
63
|
+
paygate from Ruby. It offers some basic wrapper around soap calls in the form of
|
64
|
+
AR-like models. Its autoconfigurable from Rails.
|
65
|
+
email:
|
64
66
|
- patrikjira@gmail.com
|
65
67
|
executables: []
|
66
|
-
|
67
68
|
extensions: []
|
68
|
-
|
69
69
|
extra_rdoc_files: []
|
70
|
-
|
71
|
-
files:
|
70
|
+
files:
|
72
71
|
- .gitignore
|
73
72
|
- .rvmrc
|
74
73
|
- Gemfile
|
@@ -92,38 +91,29 @@ files:
|
|
92
91
|
- test/test_helper.rb
|
93
92
|
homepage: http://gopay.defactory.net
|
94
93
|
licenses: []
|
95
|
-
|
96
94
|
post_install_message:
|
97
95
|
rdoc_options: []
|
98
|
-
|
99
|
-
require_paths:
|
96
|
+
require_paths:
|
100
97
|
- lib
|
101
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
99
|
none: false
|
103
|
-
requirements:
|
104
|
-
- -
|
105
|
-
- !ruby/object:Gem::Version
|
106
|
-
|
107
|
-
|
108
|
-
- 0
|
109
|
-
version: "0"
|
110
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
105
|
none: false
|
112
|
-
requirements:
|
113
|
-
- -
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
|
116
|
-
segments:
|
117
|
-
- 0
|
118
|
-
version: "0"
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
119
110
|
requirements: []
|
120
|
-
|
121
111
|
rubyforge_project: gopay
|
122
112
|
rubygems_version: 1.8.21
|
123
113
|
signing_key:
|
124
114
|
specification_version: 3
|
125
115
|
summary: A little gem making integration of GoPay easy
|
126
|
-
test_files:
|
116
|
+
test_files:
|
127
117
|
- test/config_test.rb
|
128
118
|
- test/crypt_test.rb
|
129
119
|
- test/models_test.rb
|