workarea-usaepay 1.0.30 → 1.0.40
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/usaepay/gateway.rb +0 -5
- data/lib/workarea/usaepay.rb +5 -1
- 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 +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4de471500e7e2b9cf03f0f61327563f5c9be841d7518222e0f869135a8dd267
|
4
|
+
data.tar.gz: ddaf0fdfc9d06cf13433e0b9351f16217b16bd37e04691cb4ce0d62c44ae5aa6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1daf19e12f6d9a92e8a82fd59ce6027fa8e439a0c9bb3b2674ca4a43dba0b39d475509241de0aee160ffd1699aa5a8c9a42bab274ecc9a4ed7a41b325e6ef74c
|
7
|
+
data.tar.gz: de0d2b17394bd57aa262a3cd85c0857f07afce18896efa1d515c0385d30d504e52e19bd468604e9901ef2548aa7ccc641554bcb32db53a0f48cefa42a7c4c99d
|
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
@@ -29,7 +29,11 @@ module Workarea
|
|
29
29
|
|
30
30
|
def self.auto_initialize_gateway
|
31
31
|
if credentials.present?
|
32
|
-
|
32
|
+
if Rails.env.test?
|
33
|
+
self.gateway = ActiveMerchant::Billing::BogusGateway.new credentials
|
34
|
+
else
|
35
|
+
self.gateway = ActiveMerchant::Billing::UsaEpayCustom.new credentials
|
36
|
+
end
|
33
37
|
else
|
34
38
|
self.gateway = ActiveMerchant::Billing::BogusGateway.new
|
35
39
|
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.40
|
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
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- test/dummy/lib/assets/.keep
|
102
102
|
- test/dummy/log/.keep
|
103
103
|
- test/models/workarea/payment/authorize/credit_card_test.decorator
|
104
|
+
- test/models/workarea/payment/authorize/store_credit_test.decorator
|
104
105
|
- test/models/workarea/payment/credit_card_integration_test.decorator
|
105
106
|
- test/support/workarea/usaepay_transaction_vcr_gateway.rb
|
106
107
|
- test/system/workarea/admin/payment_transactions_system_test.decorator
|