kgestpay 0.0.1 → 0.1.1
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.
- data/lib/kgestpay.rb +102 -1
- data/test/kgestpay_test.rb +189 -3
- metadata +5 -5
data/lib/kgestpay.rb
CHANGED
@@ -1,6 +1,107 @@
|
|
1
|
+
#encoding : utf-8
|
1
2
|
module Kemen
|
3
|
+
|
2
4
|
class KGestPay
|
5
|
+
require 'soap/wsdlDriver'
|
6
|
+
|
7
|
+
def initialize(args)
|
8
|
+
raise(ArgumentError.new(" Missing argument [:shopLogin] Variable @shopLogin cannot be initiliazed.")) if args[:shopLogin].nil?
|
9
|
+
raise(ArgumentError.new(" Missing argument [:endpoint] Variable @endpoint cannot be initiliazed.")) if args[:endpoint].nil?
|
10
|
+
@shopLogin = args[:shopLogin]
|
11
|
+
@endpoint = args[:endpoint]
|
12
|
+
#create the ws instance
|
13
|
+
@ws = SOAP::WSDLDriverFactory.new("#{@endpoint}?WSDL").create_rpc_driver
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def callPagamS2S(args)
|
18
|
+
|
19
|
+
#Required arguments
|
20
|
+
[:uicCode, :amount, :shopTransactionId, :cardNumber, :expiryMonth, :expiryYear, :cvv, :buyerName, :buyerEmail].each do |arg|
|
21
|
+
raise(ArgumentError.new("Parameter [:#{arg}] is required but has not been passed")) if args[arg.to_sym].nil?
|
22
|
+
end
|
23
|
+
|
24
|
+
args[:shopLogin] = @shopLogin
|
25
|
+
|
26
|
+
#invoke the gestpay webservice method and return the result
|
27
|
+
@ws.callPagamS2S(args).callPagamS2SResult.gestPayS2S
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
def callSettleS2S(args)
|
32
|
+
|
33
|
+
#Required arguments
|
34
|
+
[:uicCode, :amount].each do |arg|
|
35
|
+
raise(ArgumentError.new("Parameter [:#{arg}] is required but has not been passed")) if args[arg.to_sym].nil?
|
36
|
+
end
|
37
|
+
|
38
|
+
#conditional requirments
|
39
|
+
raise(ArgumentError.new("One between the parameters [:bankTransID] or [:shopTransID] is required.")) if args[:bankTransID].nil? && args[:shopTransID].nil?
|
40
|
+
|
41
|
+
args[:shopLogin] = @shopLogin
|
42
|
+
|
43
|
+
#invoke the gestpay webservice method and return the result
|
44
|
+
@ws.callSettleS2S(args).callSettleS2SResult.gestPayS2S
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
def callDeleteS2S(args)
|
50
|
+
|
51
|
+
#conditional requirments
|
52
|
+
raise(ArgumentError.new("One between the parameters [:bankTransactionId] or [:shopTransactionId] is required.")) if args[:bankTransactionId].nil? && args[:shopTransactionId].nil?
|
53
|
+
|
54
|
+
args[:shopLogin] = @shopLogin
|
55
|
+
|
56
|
+
#invoke the gestpay webservice method and return the result
|
57
|
+
@ws.callDeleteS2S(args).callDeleteS2SResult.gestPayS2S
|
3
58
|
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
def callRefundS2S(args)
|
63
|
+
|
64
|
+
#Required arguments
|
65
|
+
[:uicCode, :amount].each do |arg|
|
66
|
+
raise(ArgumentError.new("Parameter [:#{arg}] is required but has not been passed")) if args[arg.to_sym].nil?
|
67
|
+
end
|
68
|
+
|
69
|
+
#conditional requirments
|
70
|
+
raise(ArgumentError.new("One between the parameters [:bankTransactionId] or [:shopTransactionId] is required.")) if args[:bankTransactionId].nil? && args[:shopTransactionId].nil?
|
71
|
+
|
72
|
+
args[:shopLogin] = @shopLogin
|
73
|
+
|
74
|
+
#invoke the gestpay webservice method and return the result
|
75
|
+
@ws.callRefundS2S(args).callRefundS2SResult.gestPayS2S
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
def callReadTrxS2S(args)
|
80
|
+
|
81
|
+
#conditional requirments
|
82
|
+
raise(ArgumentError.new("One between the parameters [:bankTransactionId] or [:shopTransactionId] is required.")) if args[:bankTransactionId].nil? && args[:shopTransactionId].nil?
|
83
|
+
|
84
|
+
args[:shopLogin] = @shopLogin
|
85
|
+
|
86
|
+
#invoke the gestpay webservice method and return the result
|
87
|
+
@ws.callReadTrxS2S(args).callReadTrxS2SResult.gestPayS2S
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
def callVerifycardS2S(args)
|
92
|
+
|
93
|
+
#Required arguments
|
94
|
+
[:shopTransactionId, :cardNumber, :expiryMonth, :expiryYear, :cvv2].each do |arg|
|
95
|
+
raise(ArgumentError.new("Parameter [:#{arg}] is required but has not been passed")) if args[arg.to_sym].nil?
|
96
|
+
end
|
97
|
+
|
98
|
+
args[:shopLogin] = @shopLogin
|
99
|
+
|
100
|
+
#invoke the gestpay webservice method and return the result
|
101
|
+
@ws.callVerifycardS2S(args).callVerifycardS2SResult.gestPayS2S
|
102
|
+
|
103
|
+
end
|
4
104
|
|
5
105
|
end
|
6
|
-
|
106
|
+
|
107
|
+
end
|
data/test/kgestpay_test.rb
CHANGED
@@ -1,9 +1,195 @@
|
|
1
|
-
|
1
|
+
#encoding : utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'test/unit'
|
5
|
+
require 'rails/all'
|
6
|
+
|
7
|
+
require_relative "../lib/kgestpay"
|
2
8
|
|
3
9
|
class KGestPayTest < Test::Unit::TestCase
|
4
10
|
|
5
|
-
def
|
6
|
-
|
11
|
+
def setup
|
12
|
+
@shopLogin = 'GESPAY51954'
|
13
|
+
@endpoint = 'https://testecomm.sella.it/gestpay/gestpayws/WSs2s.asmx'
|
14
|
+
@k = Kemen::KGestPay.new(:shopLogin => @shopLogin, :endpoint => @endpoint)
|
15
|
+
@cc = YAML::load( File.open( 'test/cc.yml' ) )
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_shoplogin_saved_as_instance_variable
|
19
|
+
assert_equal(@k.instance_variable_get(:@shopLogin),@shopLogin)
|
20
|
+
assert_equal(@k.instance_variable_get(:@endpoint),@endpoint)
|
21
|
+
assert_equal(@k.instance_variable_get(:@ws).proxy.endpoint_url,@endpoint)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_callPagamS2S_args
|
25
|
+
assert_raise(ArgumentError){@k.callPagamS2S(:amount => 1,:shopTransactionId => 1,:cardNumber => 1,:expiryMonth => 1,:expiryYear => 1,:cvv => 1,:buyerName => 1, :buyerEmail => 1)}
|
26
|
+
assert_raise(ArgumentError){@k.callPagamS2S(:uicCode => 1,:shopTransactionId => 1,:cardNumber => 1,:expiryMonth => 1,:expiryYear => 1,:cvv => 1,:buyerName => 1, :buyerEmail => 1)}
|
27
|
+
assert_raise(ArgumentError){@k.callPagamS2S(:uicCode => 1,:amount => 1,:cardNumber => 1,:expiryMonth => 1,:expiryYear => 1,:cvv => 1,:buyerName => 1, :buyerEmail => 1)}
|
28
|
+
assert_raise(ArgumentError){@k.callPagamS2S(:uicCode => 1,:amount => 1,:shopTransactionId => 1,:expiryMonth => 1,:expiryYear => 1,:cvv => 1,:buyerName => 1, :buyerEmail => 1)}
|
29
|
+
assert_raise(ArgumentError){@k.callPagamS2S(:uicCode => 1,:amount => 1,:shopTransactionId => 1,:cardNumber => 1,:expiryYear => 1,:cvv => 1,:buyerName => 1, :buyerEmail => 1)}
|
30
|
+
assert_raise(ArgumentError){@k.callPagamS2S(:uicCode => 1,:amount => 1,:shopTransactionId => 1,:cardNumber => 1,:expiryMonth => 1,:cvv => 1,:buyerName => 1, :buyerEmail => 1)}
|
31
|
+
assert_raise(ArgumentError){@k.callPagamS2S(:uicCode => 1,:amount => 1,:shopTransactionId => 1,:cardNumber => 1,:expiryMonth => 1,:expiryYear => 1,:buyerName => 1, :buyerEmail => 1)}
|
32
|
+
assert_raise(ArgumentError){@k.callPagamS2S(:uicCode => 1,:amount => 1,:shopTransactionId => 1,:cardNumber => 1,:expiryMonth => 1,:expiryYear => 1,:cvv => 1, :buyerEmail => 1)}
|
33
|
+
assert_raise(ArgumentError){@k.callPagamS2S(:uicCode => 1,:amount => 1,:shopTransactionId => 1,:cardNumber => 1,:expiryMonth => 1,:expiryYear => 1,:cvv => 1,:buyerName => 1)}
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_callPagamS2S_must_fail_passing_wrong_arguments
|
37
|
+
resp = @k.callPagamS2S(:uicCode => 1,:amount => 1,:shopTransactionId => 1,:cardNumber => 1,:expiryMonth => 1,:expiryYear => 1, :cvv => 1, :buyerName => 1, :buyerEmail => 1)
|
38
|
+
assert_equal('KO',resp.transactionResult)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_callPagamS2S_must_succeed
|
42
|
+
resp = @k.callPagamS2S(
|
43
|
+
:uicCode => 242,
|
44
|
+
:amount => 0.1,
|
45
|
+
:shopTransactionId => 2,
|
46
|
+
:cardNumber => @cc['number'],
|
47
|
+
:expiryMonth => @cc['exp_month'],
|
48
|
+
:expiryYear => @cc['exp_year'],
|
49
|
+
:cvv => @cc['cvv'],
|
50
|
+
:buyerName => @cc['name'],
|
51
|
+
:buyerEmail => @cc['email']
|
52
|
+
)
|
53
|
+
assert_equal('OK',resp.transactionResult)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_callSettle_s2s_args
|
57
|
+
assert_raise(ArgumentError){@k.callSettleS2S(:uicCode => 1,:bankTransId => 1)}
|
58
|
+
assert_raise(ArgumentError){@k.callSettleS2S(:amout => 1,:shopTransId => 1)}
|
59
|
+
assert_raise(ArgumentError){@k.callSettleS2S(:uicCode => 1,:amout => 1)}
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_callSetlleS2S_fails_with_code_2019_if_MOTO_cash_automatically
|
63
|
+
resp = @k.callPagamS2S(
|
64
|
+
:uicCode => 242,
|
65
|
+
:amount => 0.1,
|
66
|
+
:shopTransactionId => rand(1000000),
|
67
|
+
:cardNumber => @cc['number'],
|
68
|
+
:expiryMonth => @cc['exp_month'],
|
69
|
+
:expiryYear => @cc['exp_year'],
|
70
|
+
:cvv => @cc['cvv'],
|
71
|
+
:buyerName => @cc['name'],
|
72
|
+
:buyerEmail => @cc['email']
|
73
|
+
)
|
74
|
+
assert_equal('OK',resp.transactionResult)
|
75
|
+
|
76
|
+
resp2 = @k.callSettleS2S(
|
77
|
+
:bankTransID => resp.bankTransactionID,
|
78
|
+
:uicCode => 242,
|
79
|
+
:amount => 0.1
|
80
|
+
)
|
81
|
+
|
82
|
+
assert_equal('KO',resp2.transactionResult)
|
83
|
+
assert_equal('2019', resp2.errorCode)
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_callDeleteS2S_args
|
88
|
+
assert_raise(ArgumentError){@k.callDeleteS2S()}
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_callDeleteS2S_fails_with_code_2017_if_MOTO_cash_automatically
|
92
|
+
resp = @k.callPagamS2S(
|
93
|
+
:uicCode => 242,
|
94
|
+
:amount => 0.1,
|
95
|
+
:shopTransactionId => rand(1000000),
|
96
|
+
:cardNumber => @cc['number'],
|
97
|
+
:expiryMonth => @cc['exp_month'],
|
98
|
+
:expiryYear => @cc['exp_year'],
|
99
|
+
:cvv => @cc['cvv'],
|
100
|
+
:buyerName => @cc['name'],
|
101
|
+
:buyerEmail => @cc['email']
|
102
|
+
)
|
103
|
+
assert_equal('OK',resp.transactionResult)
|
104
|
+
|
105
|
+
resp2 = @k.callDeleteS2S(
|
106
|
+
:shopTransactionId => resp.shopTransactionID,
|
107
|
+
:bankTransactionId => resp.bankTransactionID
|
108
|
+
)
|
109
|
+
|
110
|
+
assert_equal('KO',resp2.transactionResult)
|
111
|
+
assert_equal('2017', resp2.errorCode)
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_callRefund_s2s_args
|
116
|
+
assert_raise(ArgumentError){@k.callRefundS2S(:uicCode => 1,:bankTransactionId => 1)}
|
117
|
+
assert_raise(ArgumentError){@k.callRefundS2S(:amout => 1,:shopTransactionId => 1)}
|
118
|
+
assert_raise(ArgumentError){@k.callRefundS2S(:uicCode => 1,:amout => 1)}
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_callRefundS2S
|
122
|
+
resp = @k.callPagamS2S(
|
123
|
+
:uicCode => 242,
|
124
|
+
:amount => 0.1,
|
125
|
+
:shopTransactionId => rand(1000000),
|
126
|
+
:cardNumber => @cc['number'],
|
127
|
+
:expiryMonth => @cc['exp_month'],
|
128
|
+
:expiryYear => @cc['exp_year'],
|
129
|
+
:cvv => @cc['cvv'],
|
130
|
+
:buyerName => @cc['name'],
|
131
|
+
:buyerEmail => @cc['email']
|
132
|
+
)
|
133
|
+
assert_equal('OK',resp.transactionResult)
|
134
|
+
|
135
|
+
resp2 = @k.callRefundS2S(
|
136
|
+
:shopTransactionId => resp.shopTransactionID,
|
137
|
+
:bankTransactionId => resp.bankTransactionID,
|
138
|
+
:uicCode => 242,
|
139
|
+
:amount => 0.1
|
140
|
+
)
|
141
|
+
|
142
|
+
assert_equal('OK',resp2.transactionResult)
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_callReadTrxS2S_args
|
147
|
+
assert_raise(ArgumentError){@k.callReadTrxS2S()}
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_callReadTrxS2S
|
151
|
+
resp = @k.callPagamS2S(
|
152
|
+
:uicCode => 242,
|
153
|
+
:amount => 0.1,
|
154
|
+
:shopTransactionId => rand(1000000),
|
155
|
+
:cardNumber => @cc['number'],
|
156
|
+
:expiryMonth => @cc['exp_month'],
|
157
|
+
:expiryYear => @cc['exp_year'],
|
158
|
+
:cvv => @cc['cvv'],
|
159
|
+
:buyerName => @cc['name'],
|
160
|
+
:buyerEmail => @cc['email']
|
161
|
+
)
|
162
|
+
assert_equal('OK',resp.transactionResult)
|
163
|
+
|
164
|
+
resp2 = @k.callReadTrxS2S(
|
165
|
+
:shopTransactionId => resp.shopTransactionID,
|
166
|
+
:bankTransactionId => resp.bankTransactionID
|
167
|
+
)
|
168
|
+
|
169
|
+
assert_equal('OK',resp2.transactionResult)
|
170
|
+
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_callVerifyCardS2S_args
|
174
|
+
assert_raise(ArgumentError){@k.callVerifycardS2S(:cardNumber => 1,:expiryMonth => 1,:expiryYear => 1,:cvv2 => 1)}
|
175
|
+
assert_raise(ArgumentError){@k.callVerifycardS2S(:shopTransactionId => 1,:expiryMonth => 1,:expiryYear => 1,:cvv2 => 1)}
|
176
|
+
assert_raise(ArgumentError){@k.callVerifycardS2S(:shopTransactionId => 1,:cardNumber => 1,:expiryYear => 1,:cvv2 => 1)}
|
177
|
+
assert_raise(ArgumentError){@k.callVerifycardS2S(:shopTransactionId => 1,:cardNumber => 1,:expiryMonth => 1,:cvv2 => 1)}
|
178
|
+
assert_raise(ArgumentError){@k.callVerifycardS2S(:shopTransactionId => 1,:cardNumber => 1,:expiryMonth => 1,:expiryYear => 1)}
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_callVerifyCardS2S
|
182
|
+
resp = @k.callVerifycardS2S(
|
183
|
+
:shopTransactionId => rand(1000000),
|
184
|
+
:cardNumber => @cc['number'],
|
185
|
+
:expiryMonth => @cc['exp_month'],
|
186
|
+
:expiryYear => @cc['exp_year'],
|
187
|
+
:cvv2 => @cc['cvv']
|
188
|
+
)
|
189
|
+
|
190
|
+
assert_equal('KO',resp.transactionResult)
|
191
|
+
assert_equal('8008', resp.errorCode)
|
192
|
+
|
7
193
|
end
|
8
194
|
|
9
195
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kgestpay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-04-
|
12
|
+
date: 2011-04-21 00:00:00.000000000 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
description: server to server implementation for gestpay gateway
|
16
|
-
email:
|
16
|
+
email: andrea.campolonghi@kemen.it
|
17
17
|
executables: []
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
@@ -21,7 +21,7 @@ files:
|
|
21
21
|
- lib/kgestpay.rb
|
22
22
|
- test/kgestpay_test.rb
|
23
23
|
has_rdoc: true
|
24
|
-
homepage:
|
24
|
+
homepage: https://github.com/kemen/KGestPay
|
25
25
|
licenses: []
|
26
26
|
post_install_message:
|
27
27
|
rdoc_options: []
|
@@ -32,7 +32,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
32
32
|
requirements:
|
33
33
|
- - ! '>='
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 1.
|
35
|
+
version: 1.9.2
|
36
36
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
37
|
none: false
|
38
38
|
requirements:
|