workarea-payware_connect 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +20 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
- data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/workflows/ci.yml +54 -0
- data/.gitignore +13 -0
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +63 -0
- data/CODE_OF_CONDUCT.md +3 -0
- data/CONTRIBUTING.md +3 -0
- data/Gemfile +9 -0
- data/LICENSE.md +3 -0
- data/README.md +53 -0
- data/Rakefile +54 -0
- data/app/models/workarea/payment/authorize/credit_card.decorator +37 -0
- data/app/models/workarea/payment/capture/credit_card.decorator +14 -0
- data/app/models/workarea/payment/payware_credit_card.decorator +24 -0
- data/app/models/workarea/payment/purchase/credit_card.decorator +37 -0
- data/app/models/workarea/payment/refund/credit_card.decorator +14 -0
- data/app/models/workarea/payment/store_credit_card.decorator +13 -0
- data/app/workers/workarea/save_user_order_details.decorator +33 -0
- data/bin/rails +18 -0
- data/config/initializers/00_defaults.rb +1 -0
- data/doc/PWCTestAccount_WorldPay ecom.pages +0 -0
- data/doc/validation/(Completed v2)PAYware Connect Validation Worksheet 2015 V2 .doc +0 -0
- data/doc/validation/(Completed v3)PAYware Connect Validation Worksheet 2015 V2 .doc +0 -0
- data/doc/validation/PAYware Connect Validation Letter Weblinc 09-11-2015.pdf +0 -0
- data/doc/validation/PAYware Connect Validation Letter Weblinc 10-21-2015.pdf +0 -0
- data/lib/active_merchant/billing/bogus_payware_connect_gateway.rb +130 -0
- data/lib/active_merchant/billing/payware_connect_gateway.rb +137 -0
- data/lib/active_merchant/billing/payware_connect_gateway/actions/authorize.rb +63 -0
- data/lib/active_merchant/billing/payware_connect_gateway/actions/capture.rb +26 -0
- data/lib/active_merchant/billing/payware_connect_gateway/actions/purchase.rb +59 -0
- data/lib/active_merchant/billing/payware_connect_gateway/actions/refund.rb +29 -0
- data/lib/active_merchant/billing/payware_connect_gateway/actions/void.rb +20 -0
- data/lib/active_merchant/billing/payware_connect_gateway/admin_actions/add_contract.rb +9 -0
- data/lib/active_merchant/billing/payware_connect_gateway/admin_actions/add_customer.rb +9 -0
- data/lib/active_merchant/billing/payware_connect_gateway/admin_actions/add_customer_and_contract.rb +10 -0
- data/lib/active_merchant/billing/payware_connect_gateway/admin_actions/update_contract.rb +9 -0
- data/lib/active_merchant/billing/payware_connect_gateway/admin_actions/update_customer.rb +9 -0
- data/lib/active_merchant/billing/payware_connect_gateway/admin_xml_builder.rb +105 -0
- data/lib/active_merchant/billing/payware_connect_gateway/xml_builder.rb +35 -0
- data/lib/active_merchant/billing/payware_response.rb +9 -0
- data/lib/validation.rb +25 -0
- data/lib/workarea/payware_connect.rb +43 -0
- data/lib/workarea/payware_connect/engine.rb +8 -0
- data/lib/workarea/payware_connect/version.rb +5 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/config/manifest.js +4 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/jobs/application_job.rb +2 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +34 -0
- data/test/dummy/bin/update +29 -0
- data/test/dummy/config.ru +5 -0
- data/test/dummy/config/application.rb +24 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +9 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +56 -0
- data/test/dummy/config/environments/production.rb +86 -0
- data/test/dummy/config/environments/test.rb +44 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/new_framework_defaults.rb +23 -0
- data/test/dummy/config/initializers/workarea.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/puma.rb +47 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/db/seeds.rb +3 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/test/dummy/public/apple-touch-icon.png +0 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/integration/workarea/storefront/checkout_side_effects_integration_test.decorator +44 -0
- data/test/lib/active_merchant/billing/payware_connect_gateway_test.rb +280 -0
- data/test/models/workarea/payment/authorize/credit_card_test.decorator +47 -0
- data/test/models/workarea/payment/capture/credit_card_test.decorator +33 -0
- data/test/models/workarea/payment/credit_card_integration_test.decorator +25 -0
- data/test/models/workarea/payment/payware_credit_card_test.rb +44 -0
- data/test/models/workarea/payment/purchase/credit_card_test.decorator +54 -0
- data/test/models/workarea/payment/refund/credit_card_test.decorator +33 -0
- data/test/models/workarea/payment/store_credit_card_test.decorator +10 -0
- data/test/support/workarea/payware_connect_gateway_vcr_config.rb +24 -0
- data/test/system/workarea/admin/payment_transactions_system_test.decorator +37 -0
- data/test/test_helper.rb +12 -0
- data/test/vcr_cassettes/credit_card/auth_capture.yml +127 -0
- data/test/vcr_cassettes/credit_card/auth_void.yml +126 -0
- data/test/vcr_cassettes/credit_card/purchase_void.yml +126 -0
- data/test/vcr_cassettes/credit_card/store_auth.yml +67 -0
- data/test/vcr_cassettes/credit_card/store_purchase.yml +67 -0
- data/test/vcr_cassettes/payware/add_contract.yml +99 -0
- data/test/vcr_cassettes/payware/add_customer.yml +52 -0
- data/test/vcr_cassettes/payware/authorize_credit_card.yml +67 -0
- data/test/vcr_cassettes/payware/authorize_customer_and_contract.yml +161 -0
- data/test/vcr_cassettes/payware/authorize_for_0_credit_card.yml +67 -0
- data/test/vcr_cassettes/payware/authorize_for_0_troutd.yml +130 -0
- data/test/vcr_cassettes/payware/authorize_troutd.yml +130 -0
- data/test/vcr_cassettes/payware/capture.yml +127 -0
- data/test/vcr_cassettes/payware/refund.yml +223 -0
- data/test/vcr_cassettes/payware/refund_troutd.yml +128 -0
- data/test/vcr_cassettes/payware/void_authorization.yml +126 -0
- data/test/workers/workarea/save_user_order_details_test.decorator +56 -0
- data/workarea-payware_connect.gemspec +18 -0
- metadata +190 -0
@@ -0,0 +1,280 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module ActiveMerchant
|
4
|
+
module Billing
|
5
|
+
class PaywareConnectGatewayTest < Workarea::TestCase
|
6
|
+
def test_add_customer
|
7
|
+
customer_id = generate_id
|
8
|
+
response = VCR.use_cassette("payware/add_customer") do
|
9
|
+
gateway.add_customer(
|
10
|
+
customer_id: customer_id,
|
11
|
+
email: email,
|
12
|
+
billing_address: billing_address
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
assert(response.success?)
|
17
|
+
assert_equal("SUCCESS", response.message)
|
18
|
+
assert_equal("1", response.params["AdminResponse"]["Status_Code"])
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_add_contract
|
22
|
+
customer_id = generate_id
|
23
|
+
contract_id = generate_id
|
24
|
+
|
25
|
+
response = VCR.use_cassette("payware/add_contract") do
|
26
|
+
gateway.add_customer(
|
27
|
+
customer_id: customer_id,
|
28
|
+
email: email,
|
29
|
+
billing_address: billing_address
|
30
|
+
)
|
31
|
+
gateway.add_contract(
|
32
|
+
customer_id: customer_id,
|
33
|
+
contract_id: contract_id,
|
34
|
+
credit_card: credit_card
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
assert(response.success?)
|
39
|
+
assert_equal("SUCCESS", response.message)
|
40
|
+
assert_equal("1", response.params["AdminResponse"]["Status_Code"])
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_authorize_customer_and_contract
|
44
|
+
customer_id = generate_id
|
45
|
+
contract_id = generate_id
|
46
|
+
|
47
|
+
response = VCR.use_cassette("payware/authorize_customer_and_contract") do
|
48
|
+
gateway.add_customer(
|
49
|
+
customer_id: customer_id,
|
50
|
+
email: email,
|
51
|
+
billing_address: billing_address
|
52
|
+
)
|
53
|
+
gateway.add_contract(
|
54
|
+
customer_id: customer_id,
|
55
|
+
contract_id: contract_id,
|
56
|
+
credit_card: credit_card
|
57
|
+
)
|
58
|
+
gateway.authorize(
|
59
|
+
1000,
|
60
|
+
customer_id: customer_id,
|
61
|
+
contract_id: contract_id
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
assert(response.success?)
|
66
|
+
assert_equal("TAS584", response.authorization)
|
67
|
+
assert_equal("10.00", response.params["RESPONSE"]["TRANS_AMOUNT"])
|
68
|
+
assert_equal("95860", response.troutd)
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_authorize_credit_card
|
72
|
+
response = VCR.use_cassette("payware/authorize_credit_card") do
|
73
|
+
gateway.authorize(
|
74
|
+
1000,
|
75
|
+
credit_card: credit_card,
|
76
|
+
billing_address: billing_address
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
80
|
+
assert(response.success?)
|
81
|
+
assert(response.authorization.present?)
|
82
|
+
assert_equal("10.00", response.params["RESPONSE"]["TRANS_AMOUNT"])
|
83
|
+
assert(response.troutd.present?)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_authorize_zero_dollar_credit_card
|
87
|
+
response = VCR.use_cassette("payware/authorize_for_0_credit_card") do
|
88
|
+
gateway.authorize(
|
89
|
+
0,
|
90
|
+
credit_card: credit_card,
|
91
|
+
billing_address: billing_address
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
assert(response.success?)
|
96
|
+
assert(response.authorization.present?)
|
97
|
+
assert(response.troutd.present?)
|
98
|
+
assert_equal("0.00", response.params["RESPONSE"]["TRANS_AMOUNT"])
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_authorize_for_troutd
|
102
|
+
response = VCR.use_cassette("payware/authorize_troutd") do
|
103
|
+
first_response = gateway.authorize(
|
104
|
+
1000,
|
105
|
+
credit_card: credit_card,
|
106
|
+
billing_address: billing_address
|
107
|
+
)
|
108
|
+
|
109
|
+
troutd = first_response.troutd
|
110
|
+
gateway.authorize(
|
111
|
+
500,
|
112
|
+
troutd: troutd,
|
113
|
+
billing_address: billing_address
|
114
|
+
)
|
115
|
+
end
|
116
|
+
|
117
|
+
assert(response.success?)
|
118
|
+
assert(response.authorization.present?)
|
119
|
+
assert(response.troutd.present?)
|
120
|
+
assert_equal("5.00", response.params["RESPONSE"]["TRANS_AMOUNT"])
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_authorize_for_zero_dollar_with_troutd
|
124
|
+
response = VCR.use_cassette("payware/authorize_for_0_troutd") do
|
125
|
+
first_response = gateway.authorize(
|
126
|
+
1000,
|
127
|
+
credit_card: credit_card,
|
128
|
+
billing_address: billing_address
|
129
|
+
)
|
130
|
+
|
131
|
+
troutd = first_response.troutd
|
132
|
+
gateway.authorize(
|
133
|
+
0,
|
134
|
+
troutd: troutd,
|
135
|
+
billing_address: billing_address
|
136
|
+
)
|
137
|
+
end
|
138
|
+
|
139
|
+
assert(response.success?)
|
140
|
+
assert(response.authorization.present?)
|
141
|
+
assert(response.troutd.present?)
|
142
|
+
assert_equal("0.00", response.params["RESPONSE"]["TRANS_AMOUNT"])
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_refund
|
146
|
+
customer_id = generate_id
|
147
|
+
contract_id = generate_id
|
148
|
+
|
149
|
+
response = VCR.use_cassette("payware/refund") do
|
150
|
+
gateway.add_customer(
|
151
|
+
customer_id: customer_id,
|
152
|
+
email: email,
|
153
|
+
billing_address: billing_address
|
154
|
+
)
|
155
|
+
gateway.add_contract(
|
156
|
+
customer_id: customer_id,
|
157
|
+
contract_id: contract_id,
|
158
|
+
credit_card: credit_card
|
159
|
+
)
|
160
|
+
gateway.authorize(
|
161
|
+
1000,
|
162
|
+
customer_id: customer_id,
|
163
|
+
contract_id: contract_id
|
164
|
+
)
|
165
|
+
gateway.refund(
|
166
|
+
1000,
|
167
|
+
customer_id: customer_id,
|
168
|
+
contract_id: contract_id
|
169
|
+
)
|
170
|
+
end
|
171
|
+
|
172
|
+
assert(response.success?)
|
173
|
+
assert_equal("10.00", response.params["RESPONSE"]["TRANS_AMOUNT"])
|
174
|
+
end
|
175
|
+
|
176
|
+
def test_refund_troutd
|
177
|
+
VCR.use_cassette("payware/refund_troutd") do
|
178
|
+
authorization = gateway.authorize(
|
179
|
+
1000,
|
180
|
+
credit_card: credit_card,
|
181
|
+
billing_address: billing_address
|
182
|
+
)
|
183
|
+
|
184
|
+
troutd = authorization.params["RESPONSE"]["TROUTD"]
|
185
|
+
|
186
|
+
refund = gateway.refund(
|
187
|
+
1000,
|
188
|
+
troutd: troutd
|
189
|
+
)
|
190
|
+
|
191
|
+
assert(refund.success?)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def test_capture
|
196
|
+
VCR.use_cassette("payware/capture") do
|
197
|
+
authorization = gateway.authorize(
|
198
|
+
1000,
|
199
|
+
credit_card: credit_card,
|
200
|
+
billing_address: billing_address
|
201
|
+
)
|
202
|
+
|
203
|
+
troutd = authorization.params["RESPONSE"]["TROUTD"]
|
204
|
+
|
205
|
+
capture = gateway.capture(1000, troutd)
|
206
|
+
|
207
|
+
assert(capture.success?)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def test_void_authorization
|
212
|
+
VCR.use_cassette("payware/void_authorization") do
|
213
|
+
authorization = gateway.authorize(
|
214
|
+
100,
|
215
|
+
credit_card: credit_card,
|
216
|
+
billing_address: billing_address
|
217
|
+
)
|
218
|
+
|
219
|
+
assert(authorization.success?)
|
220
|
+
|
221
|
+
troutd = authorization.params["RESPONSE"]["TROUTD"]
|
222
|
+
|
223
|
+
void = gateway.void(troutd)
|
224
|
+
|
225
|
+
assert(void.success?)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
private
|
230
|
+
|
231
|
+
def credit_card_params
|
232
|
+
{
|
233
|
+
first_name: "Mike",
|
234
|
+
last_name: "Dalton",
|
235
|
+
month: 12,
|
236
|
+
year: Time.now.year + 1,
|
237
|
+
verification_value: "999"
|
238
|
+
}
|
239
|
+
end
|
240
|
+
|
241
|
+
def credit_card
|
242
|
+
params = credit_card_params.merge(
|
243
|
+
number: "4111111111111111",
|
244
|
+
brand: "visa"
|
245
|
+
)
|
246
|
+
ActiveMerchant::Billing::CreditCard.new(params)
|
247
|
+
end
|
248
|
+
|
249
|
+
def billing_address
|
250
|
+
Workarea::Address.new(
|
251
|
+
first_name: "Mike",
|
252
|
+
last_name: "Dalton",
|
253
|
+
street: "22 S. 3rd St.",
|
254
|
+
city: "Philadelphia",
|
255
|
+
region: "PA",
|
256
|
+
postal_code: "19406",
|
257
|
+
phone_number: "215-555-5555"
|
258
|
+
)
|
259
|
+
end
|
260
|
+
|
261
|
+
def gateway
|
262
|
+
ActiveMerchant::Billing::PaywareConnectGateway.new(
|
263
|
+
client_id: "17270300010001",
|
264
|
+
login: "apiuser",
|
265
|
+
password: "6GHMg7ur",
|
266
|
+
merchant_key: "49BC6225-4B49-4585-8D34-07DCA05CF3937FD6C525-8AEE-4916-BEEC-BDB",
|
267
|
+
test: true
|
268
|
+
)
|
269
|
+
end
|
270
|
+
|
271
|
+
def email
|
272
|
+
"mdalton@weblinc.com"
|
273
|
+
end
|
274
|
+
|
275
|
+
def generate_id
|
276
|
+
(1 + rand(100000)).to_s
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Workarea
|
2
|
+
decorate Payment::Authorize::CreditCardTest, with: :payware_connect do
|
3
|
+
def test_complete_does_nothing_if_gateway_storage_fails
|
4
|
+
# no op tokenize and authorize is one step
|
5
|
+
end
|
6
|
+
|
7
|
+
def test_complete_authorizes_on_the_credit_card_gateway
|
8
|
+
operation = Payment::Authorize::CreditCard.new(tender, transaction)
|
9
|
+
|
10
|
+
original_authorize = Workarea.config.gateways.credit_card.method(:authorize)
|
11
|
+
Workarea.config.gateways.credit_card.expects(:authorize)
|
12
|
+
.returns(original_authorize.call(transaction.amount.cents, { credit_card: tender.to_active_merchant }))
|
13
|
+
|
14
|
+
operation.complete!
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_cancel_voids_with_the_authorization_from_the_transaction
|
18
|
+
transaction.response = ActiveMerchant::Billing::Response.new(
|
19
|
+
true,
|
20
|
+
'Message',
|
21
|
+
{ 'RESPONSE' => { 'TROUTD' => troutd } },
|
22
|
+
{ authorization: authorization }
|
23
|
+
)
|
24
|
+
|
25
|
+
operation = Payment::Authorize::CreditCard.new(tender, transaction)
|
26
|
+
|
27
|
+
original_void = operation.gateway.method(:void)
|
28
|
+
operation.gateway.expects(:void)
|
29
|
+
.with(authorization)
|
30
|
+
.returns(original_void.call(authorization))
|
31
|
+
|
32
|
+
operation.cancel!
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_complete_saves_the_partial_number
|
36
|
+
Payment::Authorize::CreditCard.new(tender, transaction).complete!
|
37
|
+
|
38
|
+
assert(tender.partial_number.present?)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def troutd
|
44
|
+
@authorization ||= ActiveMerchant::Billing::BogusGateway::AUTHORIZATION
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Workarea
|
2
|
+
decorate Payment::Capture::CreditCardTest, with: :payware_connect do
|
3
|
+
def test_complete_captures_on_the_credit_card_gateway
|
4
|
+
operation = Payment::Capture::CreditCard.new(payment.credit_card, transaction)
|
5
|
+
|
6
|
+
original_capture = Workarea.config.gateways.credit_card.method(:capture)
|
7
|
+
Workarea.config.gateways.credit_card
|
8
|
+
.expects(:capture)
|
9
|
+
.with(500, troutd)
|
10
|
+
.returns(original_capture.call(500, troutd))
|
11
|
+
|
12
|
+
operation.complete!
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def reference
|
18
|
+
@reference ||= Payment::Transaction.new(
|
19
|
+
amount: 5.to_m,
|
20
|
+
response: ActiveMerchant::Billing::Response.new(
|
21
|
+
true,
|
22
|
+
'Message',
|
23
|
+
{ 'RESPONSE' => { 'TROUTD' => troutd } },
|
24
|
+
{ authorization: authorization }
|
25
|
+
)
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
def troutd
|
30
|
+
@troutd ||= ActiveMerchant::Billing::BogusGateway::AUTHORIZATION
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Workarea
|
2
|
+
decorate Payment::CreditCardIntegrationTest, with: :payware_connect do
|
3
|
+
decorated do
|
4
|
+
setup :setup_gateway
|
5
|
+
teardown :reset_gateway
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def setup_gateway
|
11
|
+
@_old_gateway = Workarea.config.gateways.credit_card
|
12
|
+
Workarea.config.gateways.credit_card = ActiveMerchant::Billing::PaywareConnectGateway.new(
|
13
|
+
client_id: "17270300010001",
|
14
|
+
login: "apiuser",
|
15
|
+
password: "6GHMg7ur",
|
16
|
+
merchant_key: "49BC6225-4B49-4585-8D34-07DCA05CF3937FD6C525-8AEE-4916-BEEC-BDB",
|
17
|
+
test: true
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def reset_gateway
|
22
|
+
Workarea.config.gateways.credit_card = @_old_gateway
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
class Payment
|
5
|
+
class PaywareCreditCardTest < Workarea::TestCase
|
6
|
+
def test_partial_number
|
7
|
+
payment = Payment.new(
|
8
|
+
address: {
|
9
|
+
first_name: "eric",
|
10
|
+
last_name: "pigeon",
|
11
|
+
street: "22 s 4rd st weblinc",
|
12
|
+
city: "philadelphia",
|
13
|
+
country: Country["US"],
|
14
|
+
region: "PA",
|
15
|
+
postal_code: "19106"
|
16
|
+
}
|
17
|
+
)
|
18
|
+
payment.set_credit_card(number: "4111111111111111", month: "01", year: next_year.to_s, cvv: 111)
|
19
|
+
assert payment.credit_card.partial_number.present?
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_partial_number_from_saved_card
|
23
|
+
profile = create_payment_profile
|
24
|
+
saved_card = create_saved_credit_card(profile: profile)
|
25
|
+
|
26
|
+
payment = Payment.new(
|
27
|
+
profile: profile,
|
28
|
+
address: {
|
29
|
+
first_name: "eric",
|
30
|
+
last_name: "pigeon",
|
31
|
+
street: "22 s 4rd st weblinc",
|
32
|
+
city: "philadelphia",
|
33
|
+
country: Country["US"],
|
34
|
+
region: "PA",
|
35
|
+
postal_code: "19106"
|
36
|
+
}
|
37
|
+
)
|
38
|
+
|
39
|
+
payment.set_credit_card(saved_card_id: saved_card.id)
|
40
|
+
assert payment.credit_card.partial_number.present?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Workarea
|
2
|
+
decorate Payment::Purchase::CreditCardTest, with: :payware_connect do
|
3
|
+
def test_complete_does_nothing_if_gateway_storage_fails
|
4
|
+
# no op store and purchase are one transaction
|
5
|
+
end
|
6
|
+
|
7
|
+
def test_complete_purchase_on_the_credit_card_gateway
|
8
|
+
operation = Payment::Purchase::CreditCard.new(tender, transaction)
|
9
|
+
|
10
|
+
original_purchase = Workarea.config.gateways.credit_card.method(:purchase)
|
11
|
+
Workarea.config.gateways.credit_card
|
12
|
+
.expects(:purchase)
|
13
|
+
.returns(
|
14
|
+
original_purchase.call(
|
15
|
+
transaction.amount.cents,
|
16
|
+
{ credit_card: tender.to_active_merchant }
|
17
|
+
)
|
18
|
+
)
|
19
|
+
|
20
|
+
operation.complete!
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_cancel_voids_with_the_authorization_from_the_transaction
|
24
|
+
transaction.response = ActiveMerchant::Billing::Response.new(
|
25
|
+
true,
|
26
|
+
'Message',
|
27
|
+
{ 'RESPONSE' => { 'TROUTD' => troutd } },
|
28
|
+
{ authorization: authorization }
|
29
|
+
)
|
30
|
+
|
31
|
+
operation = Payment::Purchase::CreditCard.new(tender, transaction)
|
32
|
+
|
33
|
+
original_void = operation.gateway.method(:void)
|
34
|
+
operation.gateway
|
35
|
+
.expects(:void)
|
36
|
+
.with(authorization)
|
37
|
+
.returns(original_void.call(authorization))
|
38
|
+
|
39
|
+
operation.cancel!
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_complete_saves_the_partial_number
|
43
|
+
Payment::Purchase::CreditCard.new(tender, transaction).complete!
|
44
|
+
|
45
|
+
assert(tender.partial_number.present?)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def troutd
|
51
|
+
@troutd ||= ActiveMerchant::Billing::BogusGateway::AUTHORIZATION
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|