ruby-saferpay 0.0.2 → 0.0.3
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/ruby-saferpay.rb +157 -82
- data/lib/ruby-saferpay/version.rb +1 -1
- data/test/test_ruby-saferpay.rb +61 -51
- metadata +1 -1
data/lib/ruby-saferpay.rb
CHANGED
@@ -9,6 +9,7 @@ require 'net/https'
|
|
9
9
|
require 'uri'
|
10
10
|
require 'net/https'
|
11
11
|
require 'hpricot'
|
12
|
+
require 'ostruct'
|
12
13
|
|
13
14
|
class Saferpay
|
14
15
|
|
@@ -53,13 +54,15 @@ class Saferpay
|
|
53
54
|
{:code => 301, :short_message => 'Authentication Error', :long_message => 'An error happened during the authentication request. The merchant application could choose to:\n- continue the payment without authentication or\n- ask customer for other payment method or\n- stop the payment.'}
|
54
55
|
]
|
55
56
|
attr_reader :error
|
56
|
-
def initialize(
|
57
|
-
if
|
58
|
-
result = Hpricot.parse(
|
59
|
-
elsif
|
60
|
-
result =
|
61
|
-
elsif
|
62
|
-
result =
|
57
|
+
def initialize(saferpay_response)
|
58
|
+
if saferpay_response.is_a? String
|
59
|
+
result = Hpricot.parse(saferpay_response).at('idp').attributes['result'].to_i rescue 152
|
60
|
+
elsif saferpay_response.is_a? Hash
|
61
|
+
result = saferpay_response['result'].to_i rescue 152
|
62
|
+
elsif saferpay_response.is_a? Fixnum
|
63
|
+
result = saferpay_response
|
64
|
+
elsif saferpay_response.is_a? OpenStruct
|
65
|
+
result = saferpay_response.response
|
63
66
|
else
|
64
67
|
result = 152 # Unknown error
|
65
68
|
end
|
@@ -82,17 +85,17 @@ class Saferpay
|
|
82
85
|
CURRENCIES = ['CHF','CZK','DKK','EUR','GBP','PLN','SEK','USD']
|
83
86
|
|
84
87
|
attr_accessor :account_id
|
85
|
-
attr_reader :
|
88
|
+
attr_reader :current_request
|
86
89
|
|
87
|
-
def initialize( account_id = "99867-94913159", pan = "9451123100000004", expiry_date =
|
90
|
+
def initialize( account_id = "99867-94913159", pan = "9451123100000004", expiry_date = '1107', cvc = '', name = '', tolerance = 0 )
|
88
91
|
Saferpay.check_install
|
89
|
-
@
|
92
|
+
@current_request = nil
|
90
93
|
|
91
|
-
@account_id = account_id
|
92
|
-
@pan = pan
|
93
|
-
@expiry_date= expiry_date
|
94
|
-
@cvc = cvc
|
95
|
-
@name = name
|
94
|
+
@account_id = account_id.gsub(/[\s]/,'').chomp
|
95
|
+
@pan = pan.gsub(/[\s]/,'').chomp
|
96
|
+
@expiry_date= expiry_date.gsub(/[\s]/,'').chomp
|
97
|
+
@cvc = cvc.gsub(/[\s]/,'').chomp
|
98
|
+
@name = name.chomp
|
96
99
|
@tolerance = tolerance # Amount tolerance in percent. The finally captured amount is AMOUNT + TOLERANCE
|
97
100
|
end
|
98
101
|
|
@@ -107,61 +110,48 @@ class Saferpay
|
|
107
110
|
end
|
108
111
|
|
109
112
|
def details( transaction_id = nil )
|
110
|
-
transaction_id = @
|
111
|
-
|
112
|
-
|
113
|
-
do_direct_cc cmd
|
113
|
+
transaction_id = @current_request.transaction_id if transaction_id.nil?
|
114
|
+
raise ArgumentError, "Cannot retrieve transaction details without a transaction id." if transaction_id.nil?
|
115
|
+
req = Request.new(:inquiry, :transaction_id => transaction_id)
|
116
|
+
do_direct_cc req.cmd
|
114
117
|
end
|
115
118
|
|
116
119
|
def reserve( amount, currency )
|
117
120
|
check_params amount, currency
|
118
|
-
@
|
119
|
-
|
120
|
-
:currency => currency,
|
121
|
-
:accountid => @account_id,
|
122
|
-
:pan => @pan,
|
123
|
-
:exp => @expiry_date
|
124
|
-
)
|
125
|
-
do_direct_cc
|
121
|
+
@current_request = Request.new(:reserve, :amount => amount, :currency => currency, :accountid => @account_id, :pan => @pan, :exp => @expiry_date)
|
122
|
+
do_direct_cc( @current_request.cmd )
|
126
123
|
end
|
127
124
|
|
128
125
|
def refund( amount, currency )
|
129
126
|
check_params amount, currency
|
130
|
-
@
|
131
|
-
|
132
|
-
:currency => currency,
|
133
|
-
:accountid => @account_id,
|
134
|
-
:pan => @pan,
|
135
|
-
:exp => @expiry_date,
|
136
|
-
:action => "Credit"
|
137
|
-
)
|
138
|
-
do_direct_cc
|
127
|
+
@current_request = Request.new(:refund, :amount => amount, :currency => currency, :accountid => @account_id, :pan => @pan, :exp => @expiry_date)
|
128
|
+
do_direct_cc @current_request.cmd
|
139
129
|
end
|
140
130
|
|
141
131
|
def refund_last
|
142
|
-
|
132
|
+
raise ArgumentError, "No current request to refund." if @current_request.transaction_id.nil?
|
133
|
+
refund_transaction @current_request.transaction_id
|
143
134
|
end
|
144
135
|
|
145
|
-
def refund_transaction( transaction_id )
|
146
|
-
|
147
|
-
|
136
|
+
def refund_transaction( transaction_id = nil )
|
137
|
+
raise ArgumentError, "Cannot refund without transaction_id" if transaction_id.nil?
|
138
|
+
@current_request = Request.new(:refund_transaction, :transaction_id => transaction_id)
|
139
|
+
do_direct_cc @current_request.cmd
|
148
140
|
end
|
149
141
|
|
150
142
|
# Capture the amount of the transaction with id transaction_id
|
151
143
|
# Defaults to capturing the current transaction's amount.
|
152
144
|
def capture( transaction_id = nil, token = nil, params = nil )
|
153
|
-
transaction_id = @
|
154
|
-
|
155
|
-
|
156
|
-
do_direct_cc cmd
|
145
|
+
transaction_id = @current_request.transaction_id if transaction_id.nil?
|
146
|
+
@current_request = Request.new( :capture, :transaction_id => transaction_id )
|
147
|
+
do_direct_cc @current_request.cmd
|
157
148
|
end
|
158
149
|
|
159
150
|
def cancel( transaction_id = nil, token = nil )
|
160
|
-
transaction_id = @
|
161
|
-
token = @
|
162
|
-
|
163
|
-
|
164
|
-
capture transaction_id, token, params
|
151
|
+
transaction_id = @current_request.transaction_id if transaction_id.nil?
|
152
|
+
token = @current_request.token if token.nil?
|
153
|
+
@current_request = Request.new( :cancel, :transaction_id => transaction_id )
|
154
|
+
do_direct_cc @current_request.cmd
|
165
155
|
end
|
166
156
|
|
167
157
|
# Direct debit on aquierer's bank account.
|
@@ -172,13 +162,10 @@ class Saferpay
|
|
172
162
|
check_params amount, currency
|
173
163
|
raise AttributeError, "Account number is a ten digit number" unless account_number.length == 10
|
174
164
|
raise AttributeError, "BLZ is a eight digit number" unless blz.length == 8
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
:track2 => "\";59#{blz}=#{account_number}\""
|
180
|
-
)
|
181
|
-
do_direct_cc
|
165
|
+
|
166
|
+
track2 = "\";59#{blz}=#{account_number}\"" # Weird, huh?
|
167
|
+
@current_request = Request.new(:debit_card_reserve, :amount => amount, :currency => currency, :accountid => @account_id, :track2 => track2 )
|
168
|
+
do_direct_cc @current_request.cmd
|
182
169
|
end
|
183
170
|
alias :lastschrift :debit_card_reserve
|
184
171
|
|
@@ -187,7 +174,7 @@ class Saferpay
|
|
187
174
|
# couple of more methods to handle the paycomplete and other types of messages.
|
188
175
|
# Take it for what it is: a stub)
|
189
176
|
def payinit( amount, currency, description, backlink = 'http://localhost', faillink = 'http://localhost', successlink = 'http://localhost', notifyurl = 'http://localhost')
|
190
|
-
@
|
177
|
+
@current_request = TransactionParams.new(
|
191
178
|
:amount => amount,
|
192
179
|
:currency => currency,
|
193
180
|
:description => description,
|
@@ -197,7 +184,7 @@ class Saferpay
|
|
197
184
|
:successlink => successlink,
|
198
185
|
:notifyurl => notifyurl
|
199
186
|
)
|
200
|
-
cmd = "#{BASEDIR}#{EXECUTABLE} -payinit -p #{CONFIG} -a #{@
|
187
|
+
cmd = "#{BASEDIR}#{EXECUTABLE} -payinit -p #{CONFIG} -a #{@current_request.to_s}"
|
201
188
|
logger.debug "#{self.class}#payinit Will execute command:\n#{cmd}"
|
202
189
|
payinit = %x{#{cmd} 2>&1}
|
203
190
|
|
@@ -244,33 +231,45 @@ class Saferpay
|
|
244
231
|
|
245
232
|
private
|
246
233
|
|
247
|
-
# Execute the saferpay
|
248
|
-
# TODO:
|
249
|
-
|
250
|
-
|
234
|
+
# Execute the saferpay command and return a response object (an OpenStruct with the attributes in the <IDP/> element as methods)
|
235
|
+
# TODO: clean this mess
|
236
|
+
# TODO: should raise or return response with success == false?
|
237
|
+
# TODO: get rid of OpenStruct and populate a Request object instead (all calls to this method initializes the @current_request ivar, _except_ details() that need to work out-of-context)
|
238
|
+
# TODO: move some stuff to class methods?
|
239
|
+
def do_direct_cc( cmd )
|
240
|
+
# cmd = "#{BASEDIR}#{EXECUTABLE} -exec -p #{CONFIG} -m Authorization -a #{@current_request.to_s}" if cmd.nil?
|
251
241
|
cmd_result = %x{#{cmd} 2>&1}
|
242
|
+
#logger.debug "#{self.class}#do_direct_cc Got a result:\n\t#{cmd_result}\n\tCommand: #{cmd}\n-------------------\n"
|
252
243
|
|
253
244
|
unless $?.success?
|
254
245
|
logger.error "#{self.class}#do_direct_cc FAILED \nError status: #{$?.inspect}\nCommand:#{cmd}\nCommand result: #{cmd_result}"
|
255
246
|
raise TransactionError.new(cmd_result)
|
256
247
|
else
|
257
248
|
unless cmd_result.empty?
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
249
|
+
response_hsh = Hpricot.parse(cmd_result).at('idp').attributes # A hash
|
250
|
+
response = OpenStruct.new( response_hsh.merge('success' => false, :transaction_id => response_hsh['id']) )
|
251
|
+
#logger.debug "#{self.class}#do_direct_cc Have response object?\n\tresponse: #{response.inspect}\n\tOriginal hash: #{response_hsh.inspect}\n\tSTDOUT: #{cmd_result}"
|
252
|
+
if response.result === "0"
|
253
|
+
response.success = true
|
254
|
+
@current_request.transaction_id = response.transaction_id
|
255
|
+
@current_request.token = response.token
|
256
|
+
elsif response.msgtype == 'InquiryResponse'
|
257
|
+
if response.transaction_id
|
258
|
+
response.success = true
|
259
|
+
response.result = "0"
|
260
|
+
else
|
261
|
+
logger.error "#{self.class}#do_direct_cc FAILED INQUIRY \nError status: #{$?.inspect}\nCommand:#{cmd}\nCommand result: #{cmd_result}"
|
262
|
+
raise TransactionError.new(response)
|
263
|
+
end
|
265
264
|
else
|
266
265
|
logger.error "#{self.class}#do_direct_cc FAILED \nError status: #{$?.inspect}\nCommand:#{cmd}\nCommand result: #{cmd_result}"
|
267
|
-
raise TransactionError.new(
|
266
|
+
raise TransactionError.new(response)
|
268
267
|
end
|
269
268
|
else
|
270
|
-
|
269
|
+
response = OpenStruct.new(:response => '0', 'success?' => true)
|
271
270
|
end
|
272
271
|
end
|
273
|
-
|
272
|
+
response
|
274
273
|
end
|
275
274
|
|
276
275
|
def check_params(amount, currency) #:nodoc:
|
@@ -340,18 +339,94 @@ private
|
|
340
339
|
true
|
341
340
|
end
|
342
341
|
|
343
|
-
class
|
344
|
-
|
342
|
+
class Request
|
343
|
+
attr_reader :cmd, :type, :accountid, :account_id, :amount, :currency, :pan, :exp, :expiry_date, :cvc, :track2
|
344
|
+
attr_accessor :transaction_id, :token
|
345
|
+
def initialize(type = :authorization, args = {})
|
346
|
+
logger = Saferpay.logger
|
347
|
+
# logger.debug "#{self.class}#initialize ARGS: #{args.inspect}"
|
348
|
+
# logger.debug "#{self.class}#initialize #{type.to_s.capitalize}. Required attributes are:...."
|
349
|
+
opts = nil
|
350
|
+
attrs = nil
|
351
|
+
mess = nil
|
352
|
+
case type
|
353
|
+
when :authorization, :auth, :reserve
|
354
|
+
op = 'exec'
|
355
|
+
mess = 'Authorization'
|
356
|
+
attrs = {:amount => args[:amount], :currency => args[:currency], :accountid => args[:accountid], :pan => args[:pan], :exp => args[:exp]}
|
357
|
+
when :debit_card_reserve, :lastschrift
|
358
|
+
op = 'exec'
|
359
|
+
mess = 'Authorization'
|
360
|
+
attrs = {:amount => args[:amount], :currency => args[:currency], :accountid => args[:accountid], :track2 => args[:track2]}
|
361
|
+
when :capture
|
362
|
+
raise ArgumentError, "#{type.to_s.capitalize}: missing required parameter \"transaction_id\"" unless args[:transaction_id]
|
363
|
+
op = 'capt'
|
364
|
+
opts = "-i #{args[:transaction_id]} -t \"(not used)\""
|
365
|
+
when :refund
|
366
|
+
op = 'exec'
|
367
|
+
mess = 'Authorization'
|
368
|
+
attrs = {:action => 'Debit', :amount => args[:amount], :currency => args[:currency], :accountid => args[:accountid], :pan => args[:pan], :exp => args[:exp]}
|
369
|
+
when :refund_transaction
|
370
|
+
raise ArgumentError, "#{type.to_s.capitalize}: missing required parameter \"transaction_id\"" unless args[:transaction_id]
|
371
|
+
op = 'capt'
|
372
|
+
opts = "-i #{args[:transaction_id]} -t \"(not used)\""
|
373
|
+
when :cancel
|
374
|
+
raise ArgumentError, "#{type.to_s.capitalize}: missing required parameter \"transaction_id\"" unless args[:transaction_id]
|
375
|
+
op = 'capt'
|
376
|
+
opts = "-i #{args[:transaction_id]} -t \"(not used)\""
|
377
|
+
attrs = {:action => 'Cancel'}
|
378
|
+
when :inquiry, :details, :info
|
379
|
+
op = 'exec'
|
380
|
+
mess = 'Inquiry'
|
381
|
+
attrs = {:type => 'Transaction', :id => args[:transaction_id]}
|
382
|
+
end
|
383
|
+
message = mess.nil? ? '' : "-m #{mess}"
|
345
384
|
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
385
|
+
# Check for missing values and complain; Compile attributes string
|
386
|
+
if attrs
|
387
|
+
attrs.each{|attr, value|
|
388
|
+
raise ArgumentError, "#{type.to_s.capitalize}: missing required parameter \"#{attr}\"" if(value.nil? || value.to_s.empty? || (value.is_a?(Fixnum) && value == 0))
|
389
|
+
}
|
390
|
+
attrs = '-a ' + attrs.map{|k,v| "#{k.to_s.upcase} #{v}" }.join(" -a ")
|
391
|
+
end
|
392
|
+
|
393
|
+
# TODO: fill all ivars and class_eval them to be attr_reader-able
|
394
|
+
@amount = args[:amount]
|
395
|
+
@pan = args[:pan]
|
396
|
+
@exp = args[:exp]; @expiry_date = @exp
|
397
|
+
@currency = args[:currency]
|
398
|
+
@cvc = args[:cvc]
|
399
|
+
@track2 = args[:track2]
|
400
|
+
@accountid = args[:accountid]; @account_id = @accountid
|
401
|
+
@transaction_id = args[:transaction_id]
|
402
|
+
@type = type
|
403
|
+
@cmd = "#{Saferpay::BASEDIR}#{Saferpay::EXECUTABLE} -#{op} -p #{Saferpay::CONFIG} #{message} #{opts} #{attrs}"
|
351
404
|
end
|
352
405
|
|
353
|
-
def
|
354
|
-
|
406
|
+
def to_hash
|
407
|
+
self.instance_variables.inject({}){|hsh,ivar| hsh.merge(ivar.gsub(/@/,'').to_sym => self.instance_variable_get(ivar))}
|
355
408
|
end
|
409
|
+
|
356
410
|
end
|
357
|
-
end
|
411
|
+
end
|
412
|
+
# Example response messages
|
413
|
+
# Sucessful auth:
|
414
|
+
# <IDP MSGTYPE="AuthorizationResponse" AUTHMESSAGE="" ACCOUNTID="99867-94913159" PROVIDERID="90" PROVIDERNAME="Saferpay Test Card" CONTRACTNUMBER="123456789" CCCOUNTRY="XX" ID="3vQ3nvbp4bM8SAlEtd1lbAM0SSnA" TOKEN="(unused)" RESULT="0" AUTHCODE="074869"/>
|
415
|
+
# Failed auths
|
416
|
+
# <IDP MSGTYPE="AuthorizationResponse" MESSAGE="request was not processed" AUTHMESSAGE="Access Denied" ACCOUNTID="99867-9491" RESULT="5"/>
|
417
|
+
# <IDP MSGTYPE="AuthorizationResponse" MESSAGE="request was not processed" AUTHMESSAGE="currency 'EURR' is unknown" ACCOUNTID="99867-94913159" RECEIPTDATA="" RESULT="83"/>
|
418
|
+
# <IDP MSGTYPE="AuthorizationResponse" MESSAGE="request was not processed" AUTHMESSAGE="no contract available" ACCOUNTID="99867-94913159" RECEIPTDATA="" RESULT="67"/>
|
419
|
+
# Sucessful inquiry
|
420
|
+
# <IDP MSGTYPE="InquiryResponse" ID="3vQ3nvbp4bM8SAlEtd1lbAM0SSnA" PAN="9451123100000004" TRACK2=";9451123100000004=0711?0" EXP="0711" CCCOUNTRY="XX"
|
421
|
+
# CVC="no" ACCOUNTID="99867-94913159" CONTRACTNUMBER="123456789" AMOUNT="300" CURRENCY="EUR" PROVIDERID="90" PROVIDERNAME="Saferpay Test Card"
|
422
|
+
# AUTHCODE="074869" AUTHMESSAGE="" AUTHDATE="20070815 17:37:12" APPLICATION="Saferpay Card Authorization Interface" ECI="0" SETTLED="no" ACTION="Debit"
|
423
|
+
# CANCELLED="no" CLOSED="no"/>
|
424
|
+
# Failed inquiry
|
425
|
+
# "" (empty if ID is bad)
|
426
|
+
# <IDP MSGTYPE="InquiryResponse" MESSAGE="request was not processed"/>
|
427
|
+
# Sucessful capture:
|
428
|
+
# ""
|
429
|
+
# Successful cancel
|
430
|
+
# ""
|
431
|
+
# Failed cancel
|
432
|
+
# ERROR: 0x80040213 (the request failed)
|
data/test/test_ruby-saferpay.rb
CHANGED
@@ -57,6 +57,16 @@ class SaferpayTest < Test::Unit::TestCase
|
|
57
57
|
assert_raise( NoMethodError ) { @sfp2.refund_last }
|
58
58
|
end
|
59
59
|
|
60
|
+
def test_refund_transcation
|
61
|
+
assert_nothing_raised{
|
62
|
+
res = @sfp.reserve( 6666, 'EUR' )
|
63
|
+
@sfp.refund_transaction( res.transaction_id )
|
64
|
+
}
|
65
|
+
|
66
|
+
assert_raise( ArgumentError ) { @sfp.refund_transaction }
|
67
|
+
end
|
68
|
+
|
69
|
+
|
60
70
|
def test_capture
|
61
71
|
@sfp.reserve( 600, 'EUR' )
|
62
72
|
assert @sfp.capture
|
@@ -69,48 +79,48 @@ class SaferpayTest < Test::Unit::TestCase
|
|
69
79
|
@sfp.capture
|
70
80
|
assert @sfp.cancel
|
71
81
|
end
|
72
|
-
|
73
|
-
def test_debit_card_reserve
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_details
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_pay
|
102
|
-
|
103
|
-
|
104
|
-
end
|
82
|
+
#
|
83
|
+
# def test_debit_card_reserve
|
84
|
+
# assert_raise( ArgumentError ) { @sfp.debit_card_reserve }
|
85
|
+
# assert_raise( Saferpay::TransactionError ) {
|
86
|
+
# @sfp.debit_card_reserve(100200, "EUR", "1234567890", "12345678")
|
87
|
+
# assert_is_authorization_response res
|
88
|
+
# }
|
89
|
+
# end
|
90
|
+
#
|
91
|
+
# def test_details
|
92
|
+
# assert_raise ( NoMethodError ) { @sfp.details }
|
93
|
+
# assert_nothing_raised{
|
94
|
+
# @sfp.reserve( 3000, "USD" )
|
95
|
+
# @sfp.capture
|
96
|
+
# @sfp.details
|
97
|
+
# }
|
98
|
+
#
|
99
|
+
# assert_nothing_raised{
|
100
|
+
# res = @sfp.reserve( 1000, "USD" )
|
101
|
+
# @sfp.capture
|
102
|
+
#
|
103
|
+
# res2 = @sfp.reserve( 1100, "USD" )
|
104
|
+
# @sfp.capture
|
105
|
+
#
|
106
|
+
# assert_not_equal @sfp.details( res.transaction_id ), @sfp.details( res2.transaction_id )
|
107
|
+
# assert_not_equal @sfp.details( res.transaction_id ), @sfp.details
|
108
|
+
# }
|
109
|
+
# end
|
110
|
+
#
|
111
|
+
# def test_pay
|
112
|
+
# res = @sfp.pay( 4000 )
|
113
|
+
# assert_is_inquiry_response res
|
114
|
+
# end
|
105
115
|
|
106
116
|
|
107
117
|
private
|
108
118
|
def assert_is_inquiry_response(res)
|
109
|
-
assert_instance_of
|
119
|
+
assert_instance_of OpenStruct, res
|
110
120
|
assert_is_saferpay_response res
|
111
121
|
require_these = [:pan, :track2, :exp, :cccountry, :cvc, :accountid, :contractnumber, :amount, :currency, :providerid, :providername, :authcode,:authmessage, :authdate, :application, :eci, :settled, :settledate, :action, :cancelled, :closed]
|
112
|
-
assert require_these.all?{ |param| res.
|
113
|
-
assert res
|
122
|
+
assert require_these.all?{ |param| res.respond_to? param.to_s }, "Required parameter is missing in response: #{res.inspect}"
|
123
|
+
assert res.msgtype == "InquiryResponse", "Msgtype is not \"InquiryResponse\""
|
114
124
|
end
|
115
125
|
|
116
126
|
#<IDP MSGTYPE="InquiryResponse"
|
@@ -138,25 +148,25 @@ private
|
|
138
148
|
# CLOSED="no"
|
139
149
|
#/>
|
140
150
|
def assert_is_authorization_response(res)
|
141
|
-
assert_instance_of
|
151
|
+
assert_instance_of OpenStruct, res
|
142
152
|
assert_is_saferpay_response res
|
143
|
-
assert res
|
144
|
-
assert res.
|
145
|
-
assert res
|
146
|
-
assert res.
|
147
|
-
assert res
|
153
|
+
assert res.msgtype == "AuthorizationResponse", "Msgtype is not \"AuthorizationResponse\""
|
154
|
+
assert res.respond_to?( 'result' ), "No result code received in response"
|
155
|
+
assert res.result == "0", "Result code is not Zero (\"0\")"
|
156
|
+
assert res.respond_to?( 'token' ), "No token in response"
|
157
|
+
assert res.token == "(unused)", "Token is not \"(unused)\""
|
148
158
|
end
|
149
159
|
|
150
160
|
def assert_is_saferpay_response(res)
|
151
|
-
assert res.
|
152
|
-
assert res
|
153
|
-
assert res.
|
154
|
-
assert res.
|
155
|
-
assert res.
|
156
|
-
assert res.
|
157
|
-
assert res.
|
158
|
-
assert res.
|
159
|
-
assert res.
|
161
|
+
assert res.respond_to?( 'accountid' ), "No accountid received in response"
|
162
|
+
assert res.accountid == @accountid, "Accountid is not the test accountid"
|
163
|
+
assert res.respond_to?( 'msgtype' ), "No msgtype in response"
|
164
|
+
assert res.respond_to?( 'authcode' ), "No authcode in response"
|
165
|
+
assert res.respond_to?( 'id' ), "No id in response"
|
166
|
+
assert res.respond_to?( 'providerid' ), "No providerid in response"
|
167
|
+
assert res.respond_to?( 'providername' ), "No providername in response"
|
168
|
+
assert res.respond_to?( 'cccountry' ), "No cccountry in response"
|
169
|
+
assert res.respond_to?( 'contractnumber' ), "No contractnumber in response"
|
160
170
|
end
|
161
171
|
|
162
172
|
end
|
metadata
CHANGED