workarea-usaepay 1.0.26 → 1.0.43
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/usaepay/bogus_usaepay.rb +16 -0
- data/lib/usaepay/gateway.rb +0 -5
- data/lib/workarea/usaepay.rb +8 -3
- data/lib/workarea/usaepay/version.rb +1 -1
- data/test/models/workarea/payment/authorize/credit_card_test.decorator +99 -0
- data/test/models/workarea/payment/authorize/store_credit_test.decorator +57 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 066e821965a21f3d0161e0772755376a5463842597e36a2d4be525884b827ac0
|
4
|
+
data.tar.gz: a6a8abcb15fefcf0d4df9b9de6e1f19843dbf32958ed6241a1cc2cca2c85adc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a5908560838c2837e8fdd0a850abc743712cb7e43de1ee6bd1870d7ec72e63be8ca958afc518d68f0ddc0ba8637a24689f189625489c9f58a7265fd67054c7e
|
7
|
+
data.tar.gz: e91c1a45acf96f5698aaf62fb7f7ee012cda1aa72dcc40532f61d720c939a5a18e6434e0725d08f5b99f2ad739045c66397da92d2c2a6bea8aabb664b3c72450
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
class BogusUsaEpayGateway < BogusGateway
|
4
|
+
def verify(paysource, options)
|
5
|
+
case normalize(paysource)
|
6
|
+
when /1$/
|
7
|
+
Response.new(true, SUCCESS_MESSAGE, {:billingid => '1', :token => '1'}, :test => true, :authorization => AUTHORIZATION)
|
8
|
+
when /2$/
|
9
|
+
Response.new(false, FAILURE_MESSAGE, {:billingid => nil, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
|
10
|
+
else
|
11
|
+
raise Error, error_message(paysource)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/usaepay/gateway.rb
CHANGED
@@ -14,11 +14,6 @@ module ActiveMerchant
|
|
14
14
|
if credit_card.is_a? String
|
15
15
|
add_token(post, credit_card)
|
16
16
|
else
|
17
|
-
# Adding this override to avoid test script failures from wrokarea gems
|
18
|
-
# TODO: This should be removed from here all those test cases sould be updated
|
19
|
-
if credit_card.number == "1"
|
20
|
-
credit_card.number = "4111111111111111"
|
21
|
-
end
|
22
17
|
add_payment(post, credit_card)
|
23
18
|
add_address(post, credit_card, options)
|
24
19
|
unless credit_card.track_data.present?
|
data/lib/workarea/usaepay.rb
CHANGED
@@ -4,6 +4,7 @@ require 'workarea/admin'
|
|
4
4
|
require 'workarea/usaepay/engine'
|
5
5
|
require 'workarea/usaepay/version'
|
6
6
|
require 'usaepay/gateway'
|
7
|
+
require 'usaepay/bogus_usaepay'
|
7
8
|
|
8
9
|
module Workarea
|
9
10
|
module Usaepay
|
@@ -28,10 +29,14 @@ module Workarea
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def self.auto_initialize_gateway
|
31
|
-
if credentials.present?
|
32
|
-
|
32
|
+
if credentials.present?
|
33
|
+
if Rails.env.test?
|
34
|
+
self.gateway = ActiveMerchant::Billing::BogusUsaEpayGateway.new credentials
|
35
|
+
else
|
36
|
+
self.gateway = ActiveMerchant::Billing::UsaEpayCustom.new credentials
|
37
|
+
end
|
33
38
|
else
|
34
|
-
self.gateway = ActiveMerchant::Billing::
|
39
|
+
self.gateway = ActiveMerchant::Billing::BogusUsaEpayGateway.new
|
35
40
|
end
|
36
41
|
end
|
37
42
|
end
|
@@ -12,5 +12,104 @@ module Workarea
|
|
12
12
|
)
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
def test_complete_sets_the_transaction_attributes_on_a_failure_response
|
17
|
+
VCR.use_cassette 'credit_card/store_error_auth' do
|
18
|
+
tender.token = 2
|
19
|
+
operation = Payment::Authorize::CreditCard.new(tender, transaction)
|
20
|
+
operation.complete!
|
21
|
+
|
22
|
+
refute(transaction.success?, "expected transaction.success? to be false")
|
23
|
+
assert_instance_of(
|
24
|
+
ActiveMerchant::Billing::Response,
|
25
|
+
transaction.response
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_complete_sets_transaction_attributes_on_an_error_response
|
31
|
+
VCR.use_cassette 'credit_card/store_error_auth' do
|
32
|
+
tender.token = 3
|
33
|
+
operation = Payment::Authorize::CreditCard.new(tender, transaction)
|
34
|
+
operation.complete!
|
35
|
+
|
36
|
+
refute(transaction.success?, "expected transaction success? to be false")
|
37
|
+
assert_instance_of(
|
38
|
+
ActiveMerchant::Billing::Response,
|
39
|
+
transaction.response
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_complete_does_nothing_if_gateway_storage_fails
|
45
|
+
VCR.use_cassette 'credit_card/store_auth' do
|
46
|
+
operation = Payment::Authorize::CreditCard.new(tender, transaction)
|
47
|
+
|
48
|
+
Payment::StoreCreditCard.any_instance.stubs(:save!).returns(false)
|
49
|
+
|
50
|
+
Workarea.config.gateways.credit_card.expects(:authorize).never
|
51
|
+
|
52
|
+
operation.complete!
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_cancel_does_nothing_if_the_transaction_was_a_failure
|
57
|
+
VCR.use_cassette 'credit_card/store_auth' do
|
58
|
+
tender.number = 3
|
59
|
+
operation = Payment::Authorize::CreditCard.new(tender, transaction)
|
60
|
+
|
61
|
+
operation.gateway.expects(:void).never
|
62
|
+
operation.cancel!
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_cancel_sets_cancellation_params_on_the_transaction
|
67
|
+
VCR.use_cassette 'credit_card/store_auth' do
|
68
|
+
transaction.response = ActiveMerchant::Billing::Response.new(
|
69
|
+
true,
|
70
|
+
'Message',
|
71
|
+
{},
|
72
|
+
{ authorization: authorization }
|
73
|
+
)
|
74
|
+
|
75
|
+
operation = Payment::Authorize::CreditCard.new(tender, transaction)
|
76
|
+
operation.cancel!
|
77
|
+
|
78
|
+
assert_instance_of(
|
79
|
+
ActiveMerchant::Billing::Response,
|
80
|
+
transaction.cancellation
|
81
|
+
)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def payment
|
88
|
+
@payment ||= create_payment
|
89
|
+
end
|
90
|
+
|
91
|
+
def authorization
|
92
|
+
@authorization ||= ActiveMerchant::Billing::BogusGateway::AUTHORIZATION
|
93
|
+
end
|
94
|
+
|
95
|
+
def tender
|
96
|
+
@tender ||=
|
97
|
+
begin
|
98
|
+
payment.set_address(first_name: 'Ben', last_name: 'Crouse')
|
99
|
+
|
100
|
+
payment.build_credit_card(
|
101
|
+
number: 4111111111111111,
|
102
|
+
month: 1,
|
103
|
+
year: Time.current.year + 1,
|
104
|
+
cvv: 999
|
105
|
+
)
|
106
|
+
|
107
|
+
payment.credit_card
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def transaction
|
112
|
+
@transaction ||= tender.build_transaction(action: 'authorize', amount: 5.to_m)
|
113
|
+
end
|
15
114
|
end
|
16
115
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Workarea
|
2
|
+
decorate Payment::Authorize::StoreCreditTest, with: :usaepay_transaction do #[8]
|
3
|
+
decorated { include UsaepayTransactionVcrGateway } #[9]
|
4
|
+
def test_complete!
|
5
|
+
VCR.use_cassette 'credit_card/store_auth' do
|
6
|
+
transaction = tender.build_transaction(amount: 5.to_m)
|
7
|
+
operation = Payment::Authorize::StoreCredit.new(tender, transaction)
|
8
|
+
|
9
|
+
operation.complete!
|
10
|
+
profile.reload
|
11
|
+
|
12
|
+
assert_equal(10.to_m, profile.store_credit)
|
13
|
+
assert(transaction.success?)
|
14
|
+
assert_equal(
|
15
|
+
ActiveMerchant::Billing::Response,
|
16
|
+
transaction.response.class
|
17
|
+
)
|
18
|
+
assert_equal('purchase', transaction.action)
|
19
|
+
|
20
|
+
transaction = tender.build_transaction(amount: 100.to_m)
|
21
|
+
operation = Payment::Authorize::StoreCredit.new(tender, transaction)
|
22
|
+
|
23
|
+
operation.complete!
|
24
|
+
refute(transaction.success?)
|
25
|
+
assert(transaction.response)
|
26
|
+
assert_equal(
|
27
|
+
ActiveMerchant::Billing::Response,
|
28
|
+
transaction.response.class
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_cancel!
|
34
|
+
VCR.use_cassette 'credit_card/store_auth' do
|
35
|
+
transaction = tender.build_transaction(amount: 5.to_m, success: false)
|
36
|
+
operation = Payment::Authorize::StoreCredit.new(tender, transaction)
|
37
|
+
|
38
|
+
operation.cancel!
|
39
|
+
profile.reload
|
40
|
+
|
41
|
+
assert_equal(15.to_m, profile.store_credit)
|
42
|
+
|
43
|
+
transaction = tender.build_transaction(amount: 5.to_m, success: true)
|
44
|
+
operation = Payment::Authorize::StoreCredit.new(tender, transaction)
|
45
|
+
|
46
|
+
operation.cancel!
|
47
|
+
profile.reload
|
48
|
+
|
49
|
+
assert_equal(20.to_m, profile.store_credit)
|
50
|
+
assert_equal(
|
51
|
+
ActiveMerchant::Billing::Response,
|
52
|
+
transaction.cancellation.class
|
53
|
+
)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workarea-usaepay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.43
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gunasekaran.Raja
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: workarea
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- bin/rails
|
54
54
|
- config/initializers/workarea.rb
|
55
55
|
- config/routes.rb
|
56
|
+
- lib/usaepay/bogus_usaepay.rb
|
56
57
|
- lib/usaepay/gateway.rb
|
57
58
|
- lib/workarea/storefront/system_test.rb
|
58
59
|
- lib/workarea/usaepay.rb
|
@@ -101,6 +102,7 @@ files:
|
|
101
102
|
- test/dummy/lib/assets/.keep
|
102
103
|
- test/dummy/log/.keep
|
103
104
|
- test/models/workarea/payment/authorize/credit_card_test.decorator
|
105
|
+
- test/models/workarea/payment/authorize/store_credit_test.decorator
|
104
106
|
- test/models/workarea/payment/credit_card_integration_test.decorator
|
105
107
|
- test/support/workarea/usaepay_transaction_vcr_gateway.rb
|
106
108
|
- test/system/workarea/admin/payment_transactions_system_test.decorator
|