workarea-usaepay 1.0.24 → 1.0.42

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: bbf794e16a05b14dda1ef36c175009077ce27e40e72454d6d86572c65715f4ab
4
- data.tar.gz: dd7de4f5f99a5b57832a17ecac583558fe98d815a3c11bbc83a187f7955f444f
3
+ metadata.gz: 24926851ec2fa052825a8b86c71264aacf016778320e20626695256fbd24312a
4
+ data.tar.gz: b4b86d36a8444791127fd6ac2c7b72607be485466cace87e17d37a21221fa198
5
5
  SHA512:
6
- metadata.gz: bd8f9d2a5b03b42b9795624f31f03cdaa288e622a56d7a2c340af2133a65fd655e392320fd73bf9aeeed260c6e16f9585b378275b2615b57c81d402e476810b7
7
- data.tar.gz: 2c44197fe50f6d960432dac143793278188f6e31debd1cf1dc31e2eba72f20c39b6edf2c65a272434162050b741d39d5a317a6ff8d974fee9bfa5bd4433981e9
6
+ metadata.gz: 492deb8c6356d86e48ce7c5964dbda4662d3b644897ce17831196e219048bf95d76aa52f89f53e2ccf05593bd3b32fe85323e247f56ac491abe7367a0a67f355
7
+ data.tar.gz: a260ca9631d4389bfc06a7c0d77f7eb888283355c997eb1632323e48b617272b29c2112948deba56c328fba90660988c48c26d7d62a5523229e0f1b774da2b65
@@ -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'}, :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
@@ -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
- ActiveMerchant::Billing::UsaEpayCustom.proxy_address = uri.host
35
- ActiveMerchant::Billing::UsaEpayCustom.proxy_port = uri.port
33
+ if Rails.env.test?
34
+ self.gateway = ActiveMerchant::Billing::BogusUsaEpayGateway.new credentials
35
+ else
36
+ self.gateway = ActiveMerchant::Billing::UsaEpayCustom.new credentials
36
37
  end
37
-
38
- self.gateway = ActiveMerchant::Billing::UsaEpayCustom.new credentials
39
38
  else
40
- self.gateway = ActiveMerchant::Billing::BogusGateway.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.24".freeze
3
+ VERSION = "1.0.42".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.24
4
+ version: 1.0.42
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