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
@@ -0,0 +1,197 @@
|
|
1
|
+
require './test/test_helper'
|
2
|
+
require "./lib/active_merchant/billing/gateways/payline.rb"
|
3
|
+
require 'securerandom'
|
4
|
+
|
5
|
+
include ActiveMerchant::Billing
|
6
|
+
|
7
|
+
class PaylineManagementPaymentApi < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
@gateway = PaylineGateway.new(fixtures(:payline))
|
10
|
+
|
11
|
+
valid_year = Date.today.year + 1 .year
|
12
|
+
@random_order_ref = SecureRandom.hex
|
13
|
+
@valid_card = { number: 4970100000325734, brand: "visa", month: 12, year: valid_year, verification_value: 123}
|
14
|
+
@invalid_card = { number: "not_a_valid_number", brand: "visa", month: 12, year: valid_year, verification_value: 123}
|
15
|
+
end
|
16
|
+
|
17
|
+
##########################################
|
18
|
+
# Tests for do_bank_transfer request
|
19
|
+
# Works only between those two banks: "crédit mutuel Arkéa" and "société générale"
|
20
|
+
# TODO
|
21
|
+
##########################################
|
22
|
+
def test_successful_do_bank_transfer
|
23
|
+
VCR.use_cassette("test_successful_do_bank_transfer") do
|
24
|
+
response = @gateway.do_bank_transfer(1000, creditor: {bic: "CMTEST", iban: 'FR1420041010050500013M02606', name: "Jane Doe account"})
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
##########################################
|
29
|
+
# Tests for do_credit request
|
30
|
+
##########################################
|
31
|
+
def test_successful_do_credit
|
32
|
+
VCR.use_cassette("test_successful_do_credit") do
|
33
|
+
response = @gateway.do_credit(1000, @valid_card, @random_order_ref)
|
34
|
+
|
35
|
+
assert_success response
|
36
|
+
assert_equal "Transaction approved", response.params['result']['long_message']
|
37
|
+
assert_equal "00000", response.params['result']['code']
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_failed_do_credit
|
42
|
+
VCR.use_cassette("test_failed_do_credit") do
|
43
|
+
# Incorrect amount
|
44
|
+
response = @gateway.do_credit("invalid_amount", @valid_card, @random_order_ref)
|
45
|
+
|
46
|
+
assert_failure response
|
47
|
+
assert_equal "Invalid field format : Payment Amount : Must be numeric(12), ex : 15078", response.params['result']['long_message']
|
48
|
+
assert_equal "02305", response.params['result']['code']
|
49
|
+
|
50
|
+
# Invalid card
|
51
|
+
response = @gateway.do_credit(1000, @invalid_card, @random_order_ref)
|
52
|
+
|
53
|
+
assert_failure response
|
54
|
+
assert_equal "Invalid field format : Card Number : Bad format, please refer to the user guide", response.params['result']['long_message']
|
55
|
+
assert_equal "02305", response.params['result']['code']
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
##########################################
|
60
|
+
# Tests for do_debit request
|
61
|
+
##########################################
|
62
|
+
def test_successful_do_debit
|
63
|
+
VCR.use_cassette("test_successful_do_debit") do
|
64
|
+
response = @gateway.do_debit(1000, @valid_card, @random_order_ref, authorization: { number: 12345, date: I18n.l(Time.now, format: "%d/%m/%Y %H:%M") })
|
65
|
+
|
66
|
+
assert_success response
|
67
|
+
assert_equal "Transaction approved", response.params['result']['long_message']
|
68
|
+
assert_equal "00000", response.params['result']['code']
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_failed_do_debit
|
73
|
+
VCR.use_cassette("test_failed_do_debit") do
|
74
|
+
# Invalid amount
|
75
|
+
response = @gateway.do_debit("invalid_amount", @valid_card, @random_order_ref, authorization: { number: 12345, date: I18n.l(Time.now, format: "%d/%m/%Y %H:%M") })
|
76
|
+
|
77
|
+
assert_failure response
|
78
|
+
assert_equal "Invalid field format : Payment Amount : Must be numeric(12), ex : 15078", response.params['result']['long_message']
|
79
|
+
assert_equal "02305", response.params['result']['code']
|
80
|
+
|
81
|
+
# Invalid card
|
82
|
+
response = @gateway.do_debit(1000, @invalid_card, @random_order_ref, authorization: { number: 12345, date: I18n.l(Time.now, format: "%d/%m/%Y %H:%M") })
|
83
|
+
|
84
|
+
assert_failure response
|
85
|
+
assert_equal "Invalid field format : Card Number : Bad format, please refer to the user guide", response.params['result']['long_message']
|
86
|
+
assert_equal "02305", response.params['result']['code']
|
87
|
+
|
88
|
+
# No order ref
|
89
|
+
response = @gateway.do_debit(1000, @valid_card, "", authorization: { number: 12345, date: I18n.l(Time.now, format: "%d/%m/%Y %H:%M") })
|
90
|
+
|
91
|
+
assert_failure response
|
92
|
+
assert_equal "Invalid field format : Order Reference : Max length 50 characters", response.params['result']['long_message']
|
93
|
+
assert_equal "02305", response.params['result']['code']
|
94
|
+
|
95
|
+
# No authorization
|
96
|
+
response = @gateway.do_debit("invalid_amount", @valid_card, @random_order_ref)
|
97
|
+
|
98
|
+
assert_failure response
|
99
|
+
assert_equal "Invalid field format : authorizationNumber is missing or empty : null", response.params['result']['long_message']
|
100
|
+
assert_equal "02305", response.params['result']['code']
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
##########################################
|
105
|
+
# Tests for do_capture request
|
106
|
+
##########################################
|
107
|
+
def test_successful_do_capture
|
108
|
+
VCR.use_cassette("test_successful_do_capture") do
|
109
|
+
transaction = @gateway.do_authorization(1000, @valid_card, {order_ref: @random_order_ref, action: :authorization })
|
110
|
+
transaction_id = transaction.params["transaction"]['id']
|
111
|
+
|
112
|
+
response = @gateway.do_capture(1000, transaction_id, mode: "CPT")
|
113
|
+
|
114
|
+
assert_success response
|
115
|
+
assert_equal "Transaction approved", response.params['result']['long_message']
|
116
|
+
assert_equal "00000", response.params['result']['code']
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_failed_do_capture
|
121
|
+
VCR.use_cassette("test_failed_do_capture") do
|
122
|
+
# Already a validated transaction
|
123
|
+
transaction = @gateway.do_authorization(1000, @valid_card, {order_ref: @random_order_ref, action: :purchase})
|
124
|
+
transaction_id = transaction.params["transaction"]['id']
|
125
|
+
|
126
|
+
response = @gateway.do_capture(1000, transaction_id, {currency: "EUR", mode: "CPT"})
|
127
|
+
|
128
|
+
assert_failure response
|
129
|
+
assert_equal "The amount is invalid", response.params['result']['long_message']
|
130
|
+
assert_equal "02110", response.params['result']['code']
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
##########################################
|
135
|
+
# Tests for do_refund request
|
136
|
+
##########################################
|
137
|
+
def test_successful_do_refund
|
138
|
+
VCR.use_cassette("test_successful_do_refund") do
|
139
|
+
transaction = @gateway.do_authorization(1000, @valid_card, {order_ref: @random_order_ref, action: :purchase})
|
140
|
+
transaction_id = transaction.params["transaction"]['id']
|
141
|
+
|
142
|
+
response = @gateway.do_refund(1000, transaction_id, { currency: "EUR", mode: "CPT"})
|
143
|
+
|
144
|
+
assert_success response
|
145
|
+
assert_equal "Transaction approved", response.params['result']['long_message']
|
146
|
+
assert_equal "00000", response.params['result']['code']
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_failed_do_refund
|
151
|
+
VCR.use_cassette("test_failed_do_refund") do
|
152
|
+
transaction = @gateway.do_authorization(1000, @valid_card, {order_ref: @random_order_ref, action: :purchase})
|
153
|
+
|
154
|
+
transaction_id = transaction.params["transaction"]['id']
|
155
|
+
|
156
|
+
# Not a valid amount
|
157
|
+
response = @gateway.do_refund('NOT A VALID AMOUNT', transaction_id, { currency: "EUR", mode: "CPT"})
|
158
|
+
|
159
|
+
assert_failure response
|
160
|
+
assert_equal "Invalid field format : Payment Amount : Must be numeric(12), ex : 15078", response.params['result']['long_message']
|
161
|
+
assert_equal "02305", response.params['result']['code']
|
162
|
+
|
163
|
+
# fake transaction ID
|
164
|
+
response = @gateway.do_refund(1000, 'fake_transaction_id', { currency: "EUR", mode: "CPT"})
|
165
|
+
|
166
|
+
assert_failure response
|
167
|
+
assert_equal "Transaction ID is invalid.", response.params['result']['long_message']
|
168
|
+
assert_equal "02301", response.params['result']['code']
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
##########################################
|
173
|
+
# Tests for do_reset request
|
174
|
+
##########################################
|
175
|
+
def test_successful_do_reset
|
176
|
+
VCR.use_cassette("test_successful_do_reset") do
|
177
|
+
transaction = @gateway.do_authorization(1000, @valid_card, {order_ref: @random_order_ref, action: :purchase})
|
178
|
+
transaction_id = transaction.params["transaction"]['id']
|
179
|
+
|
180
|
+
response = @gateway.do_reset(transaction_id)
|
181
|
+
|
182
|
+
assert_success response
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def test_failed_do_reset
|
187
|
+
VCR.use_cassette("test_failed_do_reset") do
|
188
|
+
# Fake transaction ID
|
189
|
+
response = @gateway.do_reset('fake_transaction_id')
|
190
|
+
|
191
|
+
assert_failure response
|
192
|
+
assert_equal "Transaction ID is invalid.", response.params['result']['long_message']
|
193
|
+
assert_equal "02301", response.params['result']['code']
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require './test/test_helper'
|
2
|
+
require "./lib/active_merchant/billing/gateways/payline.rb"
|
3
|
+
|
4
|
+
include ActiveMerchant::Billing
|
5
|
+
|
6
|
+
class PaylineStatusApi < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@gateway = PaylineGateway.new(fixtures(:payline))
|
9
|
+
|
10
|
+
@random_order_ref = SecureRandom.hex
|
11
|
+
@valid_card = { number: 4970100000325734, brand: "visa", month: 12, year: Date.today.year + 1.year, verification_value: 123}
|
12
|
+
end
|
13
|
+
|
14
|
+
##########################################
|
15
|
+
# Tests for get_transaction_details request
|
16
|
+
##########################################
|
17
|
+
def test_get_transaction_details
|
18
|
+
VCR.use_cassette("test_get_transaction_details") do
|
19
|
+
transaction_id = @gateway.do_authorization(1000, @valid_card, order_ref: @random_order_ref,
|
20
|
+
bank_account_data: {countryCode: 'FR'}
|
21
|
+
).params['transaction']['id']
|
22
|
+
|
23
|
+
response = @gateway.get_transaction_details(transaction_id)
|
24
|
+
|
25
|
+
assert_success response
|
26
|
+
assert_equal "Transaction approved", response.params['result']['long_message']
|
27
|
+
assert_equal "00000", response.params['result']['code']
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,297 @@
|
|
1
|
+
require './test/test_helper'
|
2
|
+
require "./lib/active_merchant/billing/gateways/payline.rb"
|
3
|
+
|
4
|
+
include ActiveMerchant::Billing
|
5
|
+
|
6
|
+
class PaylineWalletManagementApi < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@gateway = PaylineGateway.new(fixtures(:payline))
|
9
|
+
|
10
|
+
valid_year = Date.today.year + 1 .year
|
11
|
+
@random_order_ref = SecureRandom.hex
|
12
|
+
@valid_card = { number: 4970100000325734, brand: "visa", month: 12, year: valid_year, verification_value: 123}
|
13
|
+
@invalid_card = { number: "not_a_valid_number", brand: "visa", month: 12, year: valid_year, verification_value: 123}
|
14
|
+
end
|
15
|
+
|
16
|
+
##########################################
|
17
|
+
# Tests for create_wallet request
|
18
|
+
##########################################
|
19
|
+
def test_successful_create_wallet
|
20
|
+
VCR.use_cassette("test_successful_create_wallet") do
|
21
|
+
response = @gateway.create_wallet({wallet_id: "JaneDoe_Wallet", card: @valid_card})
|
22
|
+
|
23
|
+
assert_success response
|
24
|
+
assert_equal "Operation Successfull", response.params['result']['long_message']
|
25
|
+
assert_equal "02500", response.params['result']['code']
|
26
|
+
|
27
|
+
assert_equal "497010XXXXXX5734", response.params['card']['number']
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_failed_create_wallet
|
32
|
+
VCR.use_cassette("test_failed_create_wallet") do
|
33
|
+
# No wallet info
|
34
|
+
response = @gateway.create_wallet({})
|
35
|
+
|
36
|
+
assert_failure response
|
37
|
+
assert_equal "Invalid value for ", response.params['result']['long_message']
|
38
|
+
assert_equal "02308", response.params['result']['code']
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
##########################################
|
43
|
+
# Tests for disable_wallet request
|
44
|
+
##########################################
|
45
|
+
def test_successful_disable_wallet
|
46
|
+
VCR.use_cassette("test_successful_disable_wallet") do
|
47
|
+
response = @gateway.disable_wallet("1234567", "JaneDoe_Wallet")
|
48
|
+
|
49
|
+
assert_success response
|
50
|
+
assert_equal "Operation Successfull", response.params['result']['long_message']
|
51
|
+
assert_equal "02500", response.params['result']['code']
|
52
|
+
|
53
|
+
@gateway.enable_wallet("1234567", "JohnDoe_Wallet")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_failed_disable_wallet
|
58
|
+
VCR.use_cassette("test_failed_disable_wallet") do
|
59
|
+
# No wallet info
|
60
|
+
response = @gateway.disable_wallet("1234567", "Inexisting_wallet")
|
61
|
+
|
62
|
+
assert_success response
|
63
|
+
assert_equal "Can not disable some wallet(s) [Inexisting_wallet do not exist]", response.params['result']['long_message']
|
64
|
+
assert_equal "02517", response.params['result']['code']
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
##########################################
|
69
|
+
# Tests for do_immediate_wallet_payment request
|
70
|
+
##########################################
|
71
|
+
def test_successful_do_immediate_wallet_payment
|
72
|
+
VCR.use_cassette("test_successful_do_immediate_wallet_payment") do
|
73
|
+
@gateway.enable_wallet("1234567", "JaneDoe_Wallet")
|
74
|
+
response = @gateway.do_immediate_wallet_payment(1000, "JaneDoe_Wallet",
|
75
|
+
{
|
76
|
+
order_ref: @random_order_ref,
|
77
|
+
currency: "EUR",
|
78
|
+
authentication_3D_secure: {}
|
79
|
+
}
|
80
|
+
)
|
81
|
+
|
82
|
+
assert_success response
|
83
|
+
assert_equal "Transaction approved", response.params['result']['long_message']
|
84
|
+
assert_equal "00000", response.params['result']['code']
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_failed_immediate_wallet_payment
|
89
|
+
VCR.use_cassette("test_failed_immediate_wallet_payment") do
|
90
|
+
# Fake wallet
|
91
|
+
response = @gateway.do_immediate_wallet_payment(1000, "Fakewallet",
|
92
|
+
{
|
93
|
+
order_ref: @random_order_ref,
|
94
|
+
authentication_3D_secure: {}
|
95
|
+
}
|
96
|
+
)
|
97
|
+
|
98
|
+
assert_failure response
|
99
|
+
assert_equal "Wallet does not exist", response.params['result']['long_message']
|
100
|
+
assert_equal "02503", response.params['result']['code']
|
101
|
+
|
102
|
+
# No order ref
|
103
|
+
response = @gateway.do_immediate_wallet_payment(1000, "JaneDoe_Wallet",
|
104
|
+
{
|
105
|
+
authentication_3D_secure: {}
|
106
|
+
}
|
107
|
+
)
|
108
|
+
|
109
|
+
assert_failure response
|
110
|
+
assert_equal "Invalid field format : Order Reference : Max length 50 characters", response.params['result']['long_message']
|
111
|
+
assert_equal "02305", response.params['result']['code']
|
112
|
+
|
113
|
+
# Invalid amount
|
114
|
+
response = @gateway.do_immediate_wallet_payment("not_a_number", "JaneDoe_Wallet",
|
115
|
+
{
|
116
|
+
order_ref: @random_order_ref,
|
117
|
+
currency: "EUR",
|
118
|
+
authentication_3D_secure: {}
|
119
|
+
}
|
120
|
+
)
|
121
|
+
|
122
|
+
assert_failure response
|
123
|
+
assert_equal "Invalid field format : Payment Amount : Must be numeric(12), ex : 15078", response.params['result']['long_message']
|
124
|
+
assert_equal "02305", response.params['result']['code']
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
##########################################
|
129
|
+
# Tests for do_recurrent_wallet_payment request
|
130
|
+
##########################################
|
131
|
+
def test_successful_do_recurrent_wallet_payment
|
132
|
+
VCR.use_cassette("test_successful_do_recurrent_wallet_payment") do
|
133
|
+
response = @gateway.do_recurrent_wallet_payment(1000, "JaneDoe_WebWallet", {recurring: {amount: 1000, billing_cycle: :yearly}, order_ref: @random_order_ref })
|
134
|
+
|
135
|
+
assert_success response
|
136
|
+
assert_equal "Operation Successfull", response.params['result']['long_message']
|
137
|
+
assert_equal "02500", response.params['result']['code']
|
138
|
+
assert_equal "1000", response.params['billing_record_list']['billing_record']['amount']
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_failed_do_recurrent_wallet_payment
|
143
|
+
VCR.use_cassette("test_failed_do_recurrent_wallet_payment") do
|
144
|
+
# Fake wallet
|
145
|
+
response = @gateway.do_recurrent_wallet_payment(1000, "FAKEWALLET", {recurring: {amount: 1000, billing_cycle: :yearly}, order_ref: @random_order_ref })
|
146
|
+
|
147
|
+
assert_failure response
|
148
|
+
assert_equal "Contract not associated with card", response.params['result']['long_message']
|
149
|
+
assert_equal "02842", response.params['result']['code']
|
150
|
+
|
151
|
+
# Wrong Amount
|
152
|
+
response = @gateway.do_recurrent_wallet_payment("not_a_correct_amount", "JaneDoe_WebWallet", {recurring: {amount: 1000, billing_cycle: :yearly}, order_ref: @random_order_ref })
|
153
|
+
|
154
|
+
assert_failure response
|
155
|
+
assert_equal "Internal Error", response.params['result']['long_message']
|
156
|
+
assert_equal "02101", response.params['result']['code']
|
157
|
+
|
158
|
+
# Missing Recurring Amount
|
159
|
+
response = @gateway.do_recurrent_wallet_payment(1000, "JaneDoe_WebWallet", {recurring: { billing_cycle: :yearly }, order_ref: "test" })
|
160
|
+
|
161
|
+
assert_failure response
|
162
|
+
assert_equal "Invalid field format : Recurring amount : Must be numeric(12), ex : 15078", response.params['result']['long_message']
|
163
|
+
assert_equal "02305", response.params['result']['code']
|
164
|
+
|
165
|
+
# Missing Frequency
|
166
|
+
response = @gateway.do_recurrent_wallet_payment(1000, "JaneDoe_WebWallet", { recurring: {amount: 1000}, order_ref: @random_order_ref })
|
167
|
+
|
168
|
+
assert_failure response
|
169
|
+
assert_equal "Invalid field format : Recurring billingCycle : Must be numeric(2), ex : 10, 20...", response.params['result']['long_message']
|
170
|
+
assert_equal "02305", response.params['result']['code']
|
171
|
+
|
172
|
+
# Missing Order ID
|
173
|
+
response = @gateway.do_recurrent_wallet_payment(1000, "JaneDoe_WebWallet", recurring: {amount: 1000, billing_cycle: :yearly })
|
174
|
+
|
175
|
+
assert_failure response
|
176
|
+
assert_equal "Internal Error", response.params['result']['long_message']
|
177
|
+
assert_equal "02101", response.params['result']['code']
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
##########################################
|
182
|
+
# Test for do_scheduled_wallet_payment request
|
183
|
+
##########################################
|
184
|
+
def test_successful_do_scheduled_wallet_payment
|
185
|
+
VCR.use_cassette("test_successful_do_scheduled_wallet_payment") do
|
186
|
+
response = @gateway.do_scheduled_wallet_payment(1000, 'JaneDoe_WebWallet', order_ref: @random_order_ref, scheduled_data: Time.now + 1.day)
|
187
|
+
|
188
|
+
assert_success response
|
189
|
+
assert_equal "Operation Successfull", response.params['result']['long_message']
|
190
|
+
assert_equal "02500", response.params['result']['code']
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_failed_do_scheduled_wallet_payment
|
195
|
+
VCR.use_cassette("test_failed_do_scheduled_wallet_payment") do
|
196
|
+
# Invalid amount
|
197
|
+
response = @gateway.do_scheduled_wallet_payment('invalid_amount', 'JaneDoe_WebWallet', order_ref: @random_order_ref, scheduled_data: Time.now + 1.day)
|
198
|
+
|
199
|
+
assert_failure response
|
200
|
+
assert_equal "Invalid field format : Payment Amount : Must be numeric(12), ex : 15078", response.params['result']['long_message']
|
201
|
+
assert_equal "02305", response.params['result']['code']
|
202
|
+
|
203
|
+
# Fake wallet
|
204
|
+
response = @gateway.do_scheduled_wallet_payment(1000, 'FakeWallet', order_ref: @random_order_ref, scheduled_data: Time.now + 1.day)
|
205
|
+
|
206
|
+
assert_failure response
|
207
|
+
assert_equal "Contract not associated with card", response.params['result']['long_message']
|
208
|
+
assert_equal "02842", response.params['result']['code']
|
209
|
+
|
210
|
+
# No order ref
|
211
|
+
response = @gateway.do_scheduled_wallet_payment(1000, 'JaneDoe_WebWallet', scheduled_data: Time.now + 1.day)
|
212
|
+
|
213
|
+
assert_failure response
|
214
|
+
assert_equal "Invalid field format : Order Reference : Max length 50 characters", response.params['result']['long_message']
|
215
|
+
assert_equal "02305", response.params['result']['code']
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
##########################################
|
220
|
+
# Tests for enable_wallet request
|
221
|
+
##########################################
|
222
|
+
def test_successful_enable_wallet
|
223
|
+
VCR.use_cassette("test_successful_enable_wallet") do
|
224
|
+
@gateway.create_wallet({wallet_id: "JaneAndJohnWallet", card: @valid_card})
|
225
|
+
@gateway.disable_wallet("1234567", "JaneAndJohnWallet")
|
226
|
+
response = @gateway.enable_wallet("1234567", "JaneAndJohnWallet")
|
227
|
+
|
228
|
+
assert_success response
|
229
|
+
assert_equal "Operation Successfull", response.params['result']['long_message']
|
230
|
+
assert_equal "02500", response.params['result']['code']
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
def test_failed_enable_wallet
|
235
|
+
VCR.use_cassette("test_failed_enable_wallet") do
|
236
|
+
# No wallet info
|
237
|
+
response = @gateway.enable_wallet("1234567", "Inexisting_wallet")
|
238
|
+
|
239
|
+
assert_failure response
|
240
|
+
assert_equal "Wallet does not exist", response.params['result']['long_message']
|
241
|
+
assert_equal "02503", response.params['result']['code']
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
##########################################
|
246
|
+
# Tests for get_wallet request
|
247
|
+
##########################################
|
248
|
+
def test_successful_get_wallet
|
249
|
+
VCR.use_cassette("test_successful_get_wallet") do
|
250
|
+
@gateway.create_wallet({wallet_id: "JaneDoe_Wallet", card: @valid_card})
|
251
|
+
response = @gateway.get_wallet("1234567", "JaneDoe_Wallet")
|
252
|
+
|
253
|
+
assert_success response
|
254
|
+
assert_equal "Operation Successfull", response.params['result']['long_message']
|
255
|
+
assert_equal "02500", response.params['result']['code']
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
def test_failed_get_wallet
|
260
|
+
VCR.use_cassette("test_failed_get_wallet") do
|
261
|
+
# No wallet info
|
262
|
+
response = @gateway.get_wallet("1234567", "Inexisting_wallet")
|
263
|
+
|
264
|
+
assert_failure response
|
265
|
+
assert_equal "Wallet does not exist", response.params['result']['long_message']
|
266
|
+
assert_equal "02503", response.params['result']['code']
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
##########################################
|
271
|
+
# Tests for update_wallet request
|
272
|
+
##########################################
|
273
|
+
def test_successful_update_wallet
|
274
|
+
VCR.use_cassette("test_successful_update_wallet") do
|
275
|
+
@valid_card.merge!({ number: 370000000000002, brand: "amex"})
|
276
|
+
response = @gateway.update_wallet({wallet_id: "JaneDoe_Wallet", card: @valid_card})
|
277
|
+
|
278
|
+
assert_success response
|
279
|
+
assert_equal "Operation Successfull", response.params['result']['long_message']
|
280
|
+
assert_equal "02500", response.params['result']['code']
|
281
|
+
|
282
|
+
assert_equal "37000XXXXXX0002", response.params['card']['number']
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
def test_failed_update_wallet
|
287
|
+
VCR.use_cassette("test_failed_update_wallet") do
|
288
|
+
# No wallet info
|
289
|
+
response = @gateway.update_wallet({})
|
290
|
+
|
291
|
+
assert_failure response
|
292
|
+
assert_equal "Wallet does not exist", response.params['result']['long_message']
|
293
|
+
assert_equal "02503", response.params['result']['code']
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
end
|