activemerchant-payline 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.env.example +5 -0
- data/.gitignore +18 -0
- data/.travis.yml +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +57 -0
- data/Rakefile +1 -0
- data/activemerchant-payline.gemspec +33 -0
- data/lib/active_merchant/billing/gateways/payline.rb +57 -0
- data/lib/active_merchant/billing/gateways/payline/payline_common.rb +368 -0
- data/lib/active_merchant/billing/gateways/payline/payline_constants.rb +83 -0
- data/lib/active_merchant/billing/gateways/payline/payline_direct_api.rb +78 -0
- data/lib/active_merchant/billing/gateways/payline/payline_management_payment_api.rb +154 -0
- data/lib/active_merchant/billing/gateways/payline/payline_status_api.rb +36 -0
- data/lib/active_merchant/billing/gateways/payline/payline_wallet_management.rb +249 -0
- data/lib/active_merchant/billing/gateways/payline/payline_web_api.rb +186 -0
- data/lib/active_merchant/billing/iso_4217_currency_codes.rb +32 -0
- data/lib/activemerchant-payline.rb +2 -0
- data/test/fixtures.yml +8 -0
- data/test/fixtures/vcr_cassettes/test_failed_create_wallet.yml +1820 -0
- data/test/fixtures/vcr_cassettes/test_failed_disable_payment_record.yml +1821 -0
- data/test/fixtures/vcr_cassettes/test_failed_disable_wallet.yml +1820 -0
- data/test/fixtures/vcr_cassettes/test_failed_do_authorization.yml +1956 -0
- data/test/fixtures/vcr_cassettes/test_failed_do_capture.yml +1890 -0
- data/test/fixtures/vcr_cassettes/test_failed_do_credit.yml +1882 -0
- data/test/fixtures/vcr_cassettes/test_failed_do_debit.yml +1981 -0
- data/test/fixtures/vcr_cassettes/test_failed_do_recurrent_wallet_payment.yml +2033 -0
- data/test/fixtures/vcr_cassettes/test_failed_do_refund.yml +1944 -0
- data/test/fixtures/vcr_cassettes/test_failed_do_reset.yml +1820 -0
- data/test/fixtures/vcr_cassettes/test_failed_do_scheduled_wallet_payment.yml +1927 -0
- data/test/fixtures/vcr_cassettes/test_failed_do_web_payment.yml +1822 -0
- data/test/fixtures/vcr_cassettes/test_failed_enable_wallet.yml +1819 -0
- data/test/fixtures/vcr_cassettes/test_failed_get_payment_record.yml +1821 -0
- data/test/fixtures/vcr_cassettes/test_failed_get_wallet.yml +1819 -0
- data/test/fixtures/vcr_cassettes/test_failed_get_web_payment_details.yml +1851 -0
- data/test/fixtures/vcr_cassettes/test_failed_immediate_wallet_payment.yml +1938 -0
- data/test/fixtures/vcr_cassettes/test_failed_manage_web_wallet.yml +1870 -0
- data/test/fixtures/vcr_cassettes/test_failed_update_wallet.yml +1820 -0
- data/test/fixtures/vcr_cassettes/test_failed_update_web_wallet.yml +1819 -0
- data/test/fixtures/vcr_cassettes/test_get_transaction_details.yml +3711 -0
- data/test/fixtures/vcr_cassettes/test_get_web_wallet.yml +1871 -0
- data/test/fixtures/vcr_cassettes/test_missing_parameters_create_web_wallet.yml +1870 -0
- data/test/fixtures/vcr_cassettes/test_missing_parameters_do_web_payment.yml +1822 -0
- data/test/fixtures/vcr_cassettes/test_successful_create_wallet.yml +1826 -0
- data/test/fixtures/vcr_cassettes/test_successful_create_web_wallet.yml +1822 -0
- data/test/fixtures/vcr_cassettes/test_successful_disable_payment_record.yml +1876 -0
- data/test/fixtures/vcr_cassettes/test_successful_disable_wallet.yml +1871 -0
- data/test/fixtures/vcr_cassettes/test_successful_do_authorization.yml +1837 -0
- data/test/fixtures/vcr_cassettes/test_successful_do_bank_transfer.yml +1826 -0
- data/test/fixtures/vcr_cassettes/test_successful_do_capture.yml +1889 -0
- data/test/fixtures/vcr_cassettes/test_successful_do_credit.yml +1829 -0
- data/test/fixtures/vcr_cassettes/test_successful_do_debit.yml +1834 -0
- data/test/fixtures/vcr_cassettes/test_successful_do_immediate_wallet_payment.yml +1875 -0
- data/test/fixtures/vcr_cassettes/test_successful_do_recurrent_wallet_payment.yml +1827 -0
- data/test/fixtures/vcr_cassettes/test_successful_do_refund.yml +1888 -0
- data/test/fixtures/vcr_cassettes/test_successful_do_reset.yml +1892 -0
- data/test/fixtures/vcr_cassettes/test_successful_do_scheduled_wallet_payment.yml +1821 -0
- data/test/fixtures/vcr_cassettes/test_successful_do_web_payment.yml +1821 -0
- data/test/fixtures/vcr_cassettes/test_successful_enable_wallet.yml +1924 -0
- data/test/fixtures/vcr_cassettes/test_successful_get_payment_record.yml +1891 -0
- data/test/fixtures/vcr_cassettes/test_successful_get_wallet.yml +1894 -0
- data/test/fixtures/vcr_cassettes/test_successful_get_web_payment_details.yml +1908 -0
- data/test/fixtures/vcr_cassettes/test_successful_manage_web_wallet.yml +1821 -0
- data/test/fixtures/vcr_cassettes/test_successful_update_wallet.yml +1825 -0
- data/test/fixtures/vcr_cassettes/test_successful_update_web_wallet.yml +1820 -0
- data/test/run_test.rb +9 -0
- data/test/test_helper.rb +350 -0
- data/test/unit/gateways/payline/payline_direct_api_test.rb +122 -0
- data/test/unit/gateways/payline/payline_management_payment_api_test.rb +197 -0
- data/test/unit/gateways/payline/payline_status_api_test.rb +30 -0
- data/test/unit/gateways/payline/payline_wallet_management_api_test.rb +297 -0
- data/test/unit/gateways/payline/payline_web_api_test.rb +221 -0
- metadata +360 -0
data/test/run_test.rb
ADDED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,350 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'dotenv/load'
|
5
|
+
|
6
|
+
require 'bundler/setup'
|
7
|
+
|
8
|
+
require 'test/unit'
|
9
|
+
require 'mocha/test_unit'
|
10
|
+
require 'vcr'
|
11
|
+
|
12
|
+
require 'yaml'
|
13
|
+
require 'json'
|
14
|
+
require 'erb'
|
15
|
+
require 'active_merchant'
|
16
|
+
#require 'comm_stub'
|
17
|
+
|
18
|
+
require 'active_support/core_ext/integer/time'
|
19
|
+
require 'active_support/core_ext/numeric/time'
|
20
|
+
require 'active_support/core_ext/time/acts_like'
|
21
|
+
|
22
|
+
VCR.configure do |config|
|
23
|
+
config.cassette_library_dir = "test/fixtures/vcr_cassettes"
|
24
|
+
config.hook_into :webmock # or :fakeweb
|
25
|
+
end
|
26
|
+
|
27
|
+
ActiveMerchant::Billing::Base.mode = :test
|
28
|
+
|
29
|
+
if ENV['DEBUG_ACTIVE_MERCHANT'] == 'true'
|
30
|
+
require 'logger'
|
31
|
+
ActiveMerchant::Billing::Gateway.logger = Logger.new(STDOUT)
|
32
|
+
ActiveMerchant::Billing::Gateway.wiredump_device = STDOUT
|
33
|
+
end
|
34
|
+
|
35
|
+
# Test gateways
|
36
|
+
class SimpleTestGateway < ActiveMerchant::Billing::Gateway
|
37
|
+
end
|
38
|
+
|
39
|
+
class SubclassGateway < SimpleTestGateway
|
40
|
+
end
|
41
|
+
|
42
|
+
module ActiveMerchant
|
43
|
+
module Assertions
|
44
|
+
AssertionClass = defined?(Minitest) ? MiniTest::Assertion : Test::Unit::AssertionFailedError
|
45
|
+
|
46
|
+
def assert_field(field, value)
|
47
|
+
clean_backtrace do
|
48
|
+
assert_equal value, @helper.fields[field]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Allows testing of negative assertions:
|
53
|
+
#
|
54
|
+
# # Instead of
|
55
|
+
# assert !something_that_is_false
|
56
|
+
#
|
57
|
+
# # Do this
|
58
|
+
# assert_false something_that_should_be_false
|
59
|
+
#
|
60
|
+
# An optional +msg+ parameter is available to help you debug.
|
61
|
+
def assert_false(boolean, message = nil)
|
62
|
+
message = build_message message, '<?> is not false or nil.', boolean
|
63
|
+
|
64
|
+
clean_backtrace do
|
65
|
+
assert_block message do
|
66
|
+
not boolean
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# An assertion of a successful response:
|
72
|
+
#
|
73
|
+
# # Instead of
|
74
|
+
# assert response.success?
|
75
|
+
#
|
76
|
+
# # DRY that up with
|
77
|
+
# assert_success response
|
78
|
+
#
|
79
|
+
# A message will automatically show the inspection of the response
|
80
|
+
# object if things go afoul.
|
81
|
+
def assert_success(response, message=nil)
|
82
|
+
clean_backtrace do
|
83
|
+
assert response.success?, build_message(nil, "#{message + "\n" if message}Response expected to succeed: <?>", response)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# The negative of +assert_success+
|
88
|
+
def assert_failure(response, message=nil)
|
89
|
+
clean_backtrace do
|
90
|
+
assert !response.success?, build_message(nil, "#{message + "\n" if message}Response expected to fail: <?>", response)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def assert_valid(model, message=nil)
|
95
|
+
errors = model.validate
|
96
|
+
|
97
|
+
clean_backtrace do
|
98
|
+
assert_equal({}, errors, (message || "Expected to be valid"))
|
99
|
+
end
|
100
|
+
|
101
|
+
errors
|
102
|
+
end
|
103
|
+
|
104
|
+
def assert_not_valid(model)
|
105
|
+
errors = model.validate
|
106
|
+
|
107
|
+
clean_backtrace do
|
108
|
+
assert_not_equal({}, errors, "Expected to not be valid")
|
109
|
+
end
|
110
|
+
|
111
|
+
errors
|
112
|
+
end
|
113
|
+
|
114
|
+
def assert_deprecation_warning(message=nil)
|
115
|
+
ActiveMerchant.expects(:deprecated).with(message ? message : anything)
|
116
|
+
yield
|
117
|
+
end
|
118
|
+
|
119
|
+
def refute(value, message = nil)
|
120
|
+
assert(!value, message)
|
121
|
+
end
|
122
|
+
|
123
|
+
def silence_deprecation_warnings
|
124
|
+
ActiveMerchant.stubs(:deprecated)
|
125
|
+
yield
|
126
|
+
end
|
127
|
+
|
128
|
+
def assert_no_deprecation_warning
|
129
|
+
ActiveMerchant.expects(:deprecated).never
|
130
|
+
yield
|
131
|
+
end
|
132
|
+
|
133
|
+
def assert_scrubbed(unexpected_value, transcript)
|
134
|
+
regexp = (Regexp === unexpected_value ? unexpected_value : Regexp.new(Regexp.quote(unexpected_value.to_s)))
|
135
|
+
refute_match regexp, transcript, "Expected the value to be scrubbed out of the transcript"
|
136
|
+
end
|
137
|
+
|
138
|
+
private
|
139
|
+
def clean_backtrace(&block)
|
140
|
+
yield
|
141
|
+
rescue AssertionClass => e
|
142
|
+
path = File.expand_path(__FILE__)
|
143
|
+
raise AssertionClass, e.message, e.backtrace.reject { |line| File.expand_path(line) =~ /#{path}/ }
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
module Fixtures
|
148
|
+
HOME_DIR = RUBY_PLATFORM =~ /mswin32/ ? ENV['HOMEPATH'] : ENV['HOME'] unless defined?(HOME_DIR)
|
149
|
+
LOCAL_CREDENTIALS = File.join(HOME_DIR.to_s, '.active_merchant/fixtures.yml') unless defined?(LOCAL_CREDENTIALS)
|
150
|
+
DEFAULT_CREDENTIALS = File.join(File.dirname(__FILE__), 'fixtures.yml') unless defined?(DEFAULT_CREDENTIALS)
|
151
|
+
|
152
|
+
private
|
153
|
+
def default_expiration_date
|
154
|
+
@default_expiration_date ||= Date.new((Time.now.year + 1), 9, 30)
|
155
|
+
end
|
156
|
+
|
157
|
+
def formatted_expiration_date(credit_card)
|
158
|
+
credit_card.expiry_date.expiration.strftime('%Y-%m')
|
159
|
+
end
|
160
|
+
|
161
|
+
def credit_card(number = '4242424242424242', options = {})
|
162
|
+
defaults = {
|
163
|
+
:number => number,
|
164
|
+
:month => default_expiration_date.month,
|
165
|
+
:year => default_expiration_date.year,
|
166
|
+
:first_name => 'Longbob',
|
167
|
+
:last_name => 'Longsen',
|
168
|
+
:verification_value => options[:verification_value] || '123',
|
169
|
+
:brand => 'visa'
|
170
|
+
}.update(options)
|
171
|
+
|
172
|
+
Billing::CreditCard.new(defaults)
|
173
|
+
end
|
174
|
+
|
175
|
+
def credit_card_with_track_data(number = '4242424242424242', options = {})
|
176
|
+
defaults = {
|
177
|
+
:track_data => '%B' + number + '^LONGSEN/L. ^15121200000000000000**123******?',
|
178
|
+
}.update(options)
|
179
|
+
|
180
|
+
Billing::CreditCard.new(defaults)
|
181
|
+
end
|
182
|
+
|
183
|
+
def network_tokenization_credit_card(number = '4242424242424242', options = {})
|
184
|
+
defaults = {
|
185
|
+
:number => number,
|
186
|
+
:month => default_expiration_date.month,
|
187
|
+
:year => default_expiration_date.year,
|
188
|
+
:first_name => 'Longbob',
|
189
|
+
:last_name => 'Longsen',
|
190
|
+
:verification_value => '123',
|
191
|
+
:brand => 'visa'
|
192
|
+
}.update(options)
|
193
|
+
|
194
|
+
Billing::NetworkTokenizationCreditCard.new(defaults)
|
195
|
+
end
|
196
|
+
|
197
|
+
def check(options = {})
|
198
|
+
defaults = {
|
199
|
+
:name => 'Jim Smith',
|
200
|
+
:bank_name => 'Bank of Elbonia',
|
201
|
+
:routing_number => '244183602',
|
202
|
+
:account_number => '15378535',
|
203
|
+
:account_holder_type => 'personal',
|
204
|
+
:account_type => 'checking',
|
205
|
+
:number => '1'
|
206
|
+
}.update(options)
|
207
|
+
|
208
|
+
Billing::Check.new(defaults)
|
209
|
+
end
|
210
|
+
|
211
|
+
def apple_pay_payment_token(options = {})
|
212
|
+
# apple_pay_json_raw should contain the JSON serialization of the object described here
|
213
|
+
# https://developer.apple.com/library/IOs//documentation/PassKit/Reference/PaymentTokenJSON/PaymentTokenJSON.htm
|
214
|
+
apple_pay_json_raw = '{"version":"EC_v1","data":"","signature":""}'
|
215
|
+
defaults = {
|
216
|
+
payment_data: ActiveSupport::JSON.decode(apple_pay_json_raw),
|
217
|
+
payment_instrument_name: "Visa 2424",
|
218
|
+
payment_network: "Visa",
|
219
|
+
transaction_identifier: "uniqueidentifier123"
|
220
|
+
}.update(options)
|
221
|
+
|
222
|
+
ActiveMerchant::Billing::ApplePayPaymentToken.new(defaults[:payment_data],
|
223
|
+
payment_instrument_name: defaults[:payment_instrument_name],
|
224
|
+
payment_network: defaults[:payment_network],
|
225
|
+
transaction_identifier: defaults[:transaction_identifier]
|
226
|
+
)
|
227
|
+
end
|
228
|
+
|
229
|
+
def address(options = {})
|
230
|
+
{
|
231
|
+
name: 'Jim Smith',
|
232
|
+
address1: '456 My Street',
|
233
|
+
address2: 'Apt 1',
|
234
|
+
company: 'Widgets Inc',
|
235
|
+
city: 'Ottawa',
|
236
|
+
state: 'ON',
|
237
|
+
zip: 'K1C2N6',
|
238
|
+
country: 'CA',
|
239
|
+
phone: '(555)555-5555',
|
240
|
+
fax: '(555)555-6666'
|
241
|
+
}.update(options)
|
242
|
+
end
|
243
|
+
|
244
|
+
def generate_unique_id
|
245
|
+
SecureRandom.hex(16)
|
246
|
+
end
|
247
|
+
|
248
|
+
def all_fixtures
|
249
|
+
@@fixtures ||= load_fixtures
|
250
|
+
end
|
251
|
+
|
252
|
+
def fixtures(key)
|
253
|
+
data = all_fixtures[key] || raise(StandardError, "No fixture data was found for '#{key}'")
|
254
|
+
|
255
|
+
data.dup
|
256
|
+
end
|
257
|
+
|
258
|
+
def load_fixtures
|
259
|
+
[DEFAULT_CREDENTIALS, LOCAL_CREDENTIALS].inject({}) do |credentials, file_name|
|
260
|
+
if File.exist?(file_name)
|
261
|
+
yaml_data = YAML.load(ERB.new(File.read(file_name)).result)
|
262
|
+
credentials.merge!(symbolize_keys(yaml_data))
|
263
|
+
end
|
264
|
+
credentials
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
def symbolize_keys(hash)
|
269
|
+
return unless hash.is_a?(Hash)
|
270
|
+
|
271
|
+
hash.symbolize_keys!
|
272
|
+
hash.each{|k,v| symbolize_keys(v)}
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
Test::Unit::TestCase.class_eval do
|
278
|
+
include ActiveMerchant::Billing
|
279
|
+
include ActiveMerchant::Assertions
|
280
|
+
include ActiveMerchant::Fixtures
|
281
|
+
|
282
|
+
def capture_transcript(gateway)
|
283
|
+
transcript = ''
|
284
|
+
gateway.class.wiredump_device = transcript
|
285
|
+
|
286
|
+
yield
|
287
|
+
|
288
|
+
transcript
|
289
|
+
end
|
290
|
+
|
291
|
+
def dump_transcript_and_fail(gateway, amount, credit_card, params)
|
292
|
+
transcript = capture_transcript(gateway) do
|
293
|
+
gateway.purchase(amount, credit_card, params)
|
294
|
+
end
|
295
|
+
|
296
|
+
File.open("transcript.log", "w") { |f| f.write(transcript) }
|
297
|
+
assert false, "A purchase transcript has been written to transcript.log for you to test scrubbing with."
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
module ActionViewHelperTestHelper
|
302
|
+
def self.included(base)
|
303
|
+
base.send(:include, ActiveMerchant::Billing::Integrations::ActionViewHelper)
|
304
|
+
base.send(:include, ActionView::Helpers::FormHelper)
|
305
|
+
base.send(:include, ActionView::Helpers::FormTagHelper)
|
306
|
+
base.send(:include, ActionView::Helpers::UrlHelper)
|
307
|
+
base.send(:include, ActionView::Helpers::TagHelper)
|
308
|
+
base.send(:include, ActionView::Helpers::CaptureHelper)
|
309
|
+
base.send(:include, ActionView::Helpers::TextHelper)
|
310
|
+
base.send(:attr_accessor, :output_buffer)
|
311
|
+
end
|
312
|
+
|
313
|
+
def setup
|
314
|
+
@controller = Class.new do
|
315
|
+
attr_reader :url_for_options
|
316
|
+
def url_for(options, *parameters_for_method_reference)
|
317
|
+
@url_for_options = options
|
318
|
+
end
|
319
|
+
end
|
320
|
+
@controller = @controller.new
|
321
|
+
@output_buffer = ''
|
322
|
+
end
|
323
|
+
|
324
|
+
protected
|
325
|
+
def protect_against_forgery?
|
326
|
+
false
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
|
331
|
+
class MockResponse
|
332
|
+
attr_reader :code, :body, :message
|
333
|
+
attr_accessor :headers
|
334
|
+
|
335
|
+
def self.succeeded(body, message="")
|
336
|
+
MockResponse.new(200, body, message)
|
337
|
+
end
|
338
|
+
|
339
|
+
def self.failed(body, http_status_code=422, message="")
|
340
|
+
MockResponse.new(http_status_code, body, message)
|
341
|
+
end
|
342
|
+
|
343
|
+
def initialize(code, body, message="", headers={})
|
344
|
+
@code, @body, @message, @headers = code, body, message, headers
|
345
|
+
end
|
346
|
+
|
347
|
+
def [](header)
|
348
|
+
@headers[header]
|
349
|
+
end
|
350
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require './test/test_helper'
|
2
|
+
require "./lib/active_merchant/billing/gateways/payline.rb"
|
3
|
+
require 'securerandom'
|
4
|
+
|
5
|
+
include ActiveMerchant::Billing
|
6
|
+
include PaylineWalletManagementAPI
|
7
|
+
|
8
|
+
class PaylineDirectApi < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
@gateway = PaylineGateway.new(fixtures(:payline))
|
11
|
+
|
12
|
+
valid_year = Date.today.year + 1 .year
|
13
|
+
|
14
|
+
@random_order_ref = SecureRandom.hex
|
15
|
+
|
16
|
+
@valid_card = { number: 4970100000325734, brand: "visa", month: 12, year: valid_year, verification_value: 123}
|
17
|
+
@invalid_card = { number: "not_a_valid_number", brand: "visa", month: 12, year: valid_year, verification_value: 123}
|
18
|
+
end
|
19
|
+
|
20
|
+
##########################################
|
21
|
+
# Tests for do_authorization request
|
22
|
+
##########################################
|
23
|
+
def test_successful_do_authorization
|
24
|
+
VCR.use_cassette("test_successful_do_authorization") do
|
25
|
+
response = @gateway.do_authorization(1000, @valid_card, order_ref: @random_order_ref,
|
26
|
+
bank_account_data: {countryCode: 'FR'}
|
27
|
+
)
|
28
|
+
|
29
|
+
assert_success response
|
30
|
+
assert_equal "Transaction approved", response.params['result']['long_message']
|
31
|
+
assert_equal "00000", response.params['result']['code']
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_failed_do_authorization
|
36
|
+
VCR.use_cassette("test_failed_do_authorization") do
|
37
|
+
# Invalid card number
|
38
|
+
response = @gateway.do_authorization(1000, @invalid_card, {order_ref: @random_order_ref})
|
39
|
+
|
40
|
+
assert_failure response
|
41
|
+
assert_equal "Invalid field format : Card Number : Bad format, please refer to the user guide", response.params['result']['long_message']
|
42
|
+
assert_equal "02305", response.params['result']['code']
|
43
|
+
|
44
|
+
# Invalid amount
|
45
|
+
response = @gateway.do_authorization("this_is_not_a_number", @valid_card, {order_ref: @random_order_ref})
|
46
|
+
|
47
|
+
assert_failure response
|
48
|
+
assert_equal "Invalid field format : Payment Amount : Must be numeric(12), ex : 15078", response.params['result']['long_message']
|
49
|
+
assert_equal "02305", response.params['result']['code']
|
50
|
+
|
51
|
+
# No order ID
|
52
|
+
response = @gateway.do_authorization(1000, @valid_card)
|
53
|
+
|
54
|
+
assert_failure response
|
55
|
+
assert_equal "Invalid field format : Order Reference : Max length 50 characters", response.params['result']['long_message']
|
56
|
+
assert_equal "02305", response.params['result']['code']
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
##########################################
|
61
|
+
# Tests for get_payment_record request
|
62
|
+
##########################################
|
63
|
+
def test_successful_get_payment_record
|
64
|
+
VCR.use_cassette("test_successful_get_payment_record") do
|
65
|
+
payment_response = @gateway.do_recurrent_wallet_payment(1000, "JaneDoe_WebWallet", {recurring: {amount: 1000, billing_cycle: :yearly}, order_ref: @random_order_ref })
|
66
|
+
payment_record_id = payment_response.params['payment_record_id']
|
67
|
+
|
68
|
+
response = @gateway.get_payment_record(payment_record_id)
|
69
|
+
|
70
|
+
assert_success response
|
71
|
+
assert_equal "Operation Successfull", response.params['result']['long_message']
|
72
|
+
assert_equal "02500", response.params['result']['code']
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_failed_get_payment_record
|
77
|
+
VCR.use_cassette("test_failed_get_payment_record") do
|
78
|
+
response = @gateway.get_payment_record("fake_payment_record_id")
|
79
|
+
|
80
|
+
assert_failure response
|
81
|
+
assert_equal "Invalid field format : PaymentRecordId : Only numeric", response.params['result']['long_message']
|
82
|
+
assert_equal "02305", response.params['result']['code']
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
##########################################
|
87
|
+
# Tests for disable_payment_record request
|
88
|
+
##########################################
|
89
|
+
def test_successful_disable_payment_record
|
90
|
+
VCR.use_cassette("test_successful_disable_payment_record") do
|
91
|
+
payment_response = @gateway.do_recurrent_wallet_payment(1000, "JaneDoe_WebWallet", {recurring: {amount: 1000, billing_cycle: :yearly}, order_ref: @random_order_ref })
|
92
|
+
payment_record_id = payment_response.params['payment_record_id']
|
93
|
+
|
94
|
+
response = @gateway.disable_payment_record(payment_record_id)
|
95
|
+
|
96
|
+
assert_success response
|
97
|
+
assert_equal "Operation Successfull", response.params['result']['long_message']
|
98
|
+
assert_equal "02500", response.params['result']['code']
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_failed_disable_payment_record
|
103
|
+
VCR.use_cassette("test_failed_disable_payment_record") do
|
104
|
+
response = @gateway.get_payment_record("fake_payment_record_id")
|
105
|
+
|
106
|
+
assert_failure response
|
107
|
+
assert_equal "Invalid field format : PaymentRecordId : Only numeric", response.params['result']['long_message']
|
108
|
+
assert_equal "02305", response.params['result']['code']
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
private
|
113
|
+
def show_response(response)
|
114
|
+
puts "----------------"
|
115
|
+
puts response.params
|
116
|
+
end
|
117
|
+
|
118
|
+
def get_payment_record_id
|
119
|
+
resp = @gateway.do_recurrent_wallet_payment(1000, "JaneDoe_WebWallet", {recurring_amount: 1000, frequency: :yearly, order_ref: "test" })
|
120
|
+
payment_record_id = resp.params["payment_record_id"]
|
121
|
+
end
|
122
|
+
end
|