workarea-usaepay 1.0.23 → 1.0.41

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a9838bb33de37fbad345fa70f4a4a79e38608b22688a8de616a8a307226902b
4
- data.tar.gz: c4dc0075368f4b7eecbc8dceeafee0600167a422fbd73c6f500527f328549db2
3
+ metadata.gz: a89c33058a70e4bc964c5ea6d27236a766005795d057e477d91e272b49a02ed7
4
+ data.tar.gz: 764b16194460342703c2ab33df722611c59b01dc74d1b44fe722bc8e6b7c89f3
5
5
  SHA512:
6
- metadata.gz: 46431e7b62b228a9294d65487594ffd7f2c68956e2d2500292fcdbbd360a3a8aa78861beb77e583080d37a86056fbdb72693a00fa1d06e4c5a2f394ca8c65445
7
- data.tar.gz: 4b06d211e3785331926550978aa356f42399bd21c64542bf826d425ce9631e488e4c4b9bc95782c832c81b7d58d153835dae74b31c54ca40d042a5ed0cefce8a
6
+ metadata.gz: d888fc34dffa6aa984ceef47b4c7cca7b90df786f613feadcf11814975105e33eb8d8044ee5ae7514c2ac334d2aeeecceafbe89154205635bf1d3737403e48a3
7
+ data.tar.gz: eb57c2ef96819e31b17e0a50ca359cab881405f2e8cbf0a4e50cc897a64b4fea8ad4423cab9728a7ef1e50e552085b61351f4ed7c06bda75a9263efff164e944
@@ -0,0 +1,9 @@
1
+ module ActiveMerchant
2
+ module Billing
3
+ class BogusUsaEpayGateway < BogusGateway
4
+ def verify(paysource, options)
5
+ authorize(1, paysource, options)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -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?
@@ -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
@@ -29,15 +30,13 @@ module Workarea
29
30
 
30
31
  def self.auto_initialize_gateway
31
32
  if credentials.present?
32
- # if ENV['HTTP_PROXY'].present?
33
- # uri = URI.parse(ENV['HTTP_PROXY'])
34
- # Workarea::UsaEpay::Gateway.proxy_address = uri.host
35
- # Workarea::UsaEpay::Gateway.proxy_port = uri.port
36
- # end
37
-
38
- self.gateway = ActiveMerchant::Billing::UsaEpayCustom.new credentials
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
39
38
  else
40
- self.gateway = ActiveMerchant::Billing::BogusCreditCardGateway.new
39
+ self.gateway = ActiveMerchant::Billing::BogusUsaEpayGateway.new
41
40
  end
42
41
  end
43
42
  end
@@ -1,5 +1,5 @@
1
1
  module Workarea
2
2
  module Usaepay
3
- VERSION = "1.0.23".freeze
3
+ VERSION = "1.0.41".freeze
4
4
  end
5
5
  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.23
4
+ version: 1.0.41
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-16 00:00:00.000000000 Z
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