Skip to content

Commit

Permalink
Multiple Gateways: Resolve when/case bug
Browse files Browse the repository at this point in the history
CE-2541

There is a bug in the `case` statements where we are attempting to
resolve it conditionally with an `||`, but `case` takes a single value
or list of values

Unit:

BluePay: 30 tests, 142 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Paysafe: 16 tests, 77 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

40 tests, 236 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Remote:

CheckoutV2: 43 tests, 110 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

BluePay: 19 tests, 90 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Paysafe: 31 tests, 94 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
  • Loading branch information
naashton committed Apr 15, 2022
1 parent 9d22fb2 commit 987ac8b
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
* Rapyd: Update `type` option to `pm_type` [naashton] #4391
* Conekta: Fix remote test [javierpedrozaing] #4386
* NMI: Update post URL [jherreraa] #4380
* Multiple Gateways: Resolve when/case bug [naashton] #4399

== Version 1.125.0 (January 20, 2022)
* Wompi: support gateway [therufs] #4173
Expand Down
2 changes: 1 addition & 1 deletion lib/active_merchant/billing/gateways/blue_pay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def scheduled(options)
return unless reason_type = options.dig(:stored_credential, :reason_type)

case reason_type
when 'recurring' || 'installment'
when 'recurring', 'installment'
'Y'
when 'unscheduled'
'N'
Expand Down
2 changes: 1 addition & 1 deletion lib/active_merchant/billing/gateways/checkout_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def add_stored_credential_options(post, options = {})
end

case options[:stored_credential][:reason_type]
when 'recurring' || 'installment'
when 'recurring', 'installment'
post[:payment_type] = 'Recurring'
when 'unscheduled'
return
Expand Down
2 changes: 1 addition & 1 deletion lib/active_merchant/billing/gateways/paysafe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def add_stored_credential(post, options)
end

case options[:stored_credential][:reason_type]
when 'recurring' || 'installment'
when 'recurring', 'installment'
post[:storedCredential][:type] = 'RECURRING'
when 'unscheduled'
if options[:stored_credential][:initiator] == 'merchant'
Expand Down
8 changes: 4 additions & 4 deletions test/remote/gateways/remote_blue_pay_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_successful_purchase_with_check
assert response = @gateway.purchase(@amount, check, @options.merge(email: '[email protected]'))
assert_success response
assert response.test?
assert_equal 'App ACH Sale', response.message
assert_equal 'ACH Accepted', response.message
assert response.authorization
end

Expand Down Expand Up @@ -184,18 +184,18 @@ def test_successful_refund_with_check
assert response = @gateway.purchase(@amount, check, @options.merge(email: '[email protected]'))
assert_success response
assert response.test?
assert_equal 'App ACH Sale', response.message
assert_equal 'ACH Accepted', response.message
assert response.authorization

assert refund = @gateway.refund(@amount, response.authorization, @options.merge(doc_type: 'PPD'))
assert_success refund
assert_equal 'App ACH Void', refund.message
assert_equal 'ACH VOIDED', refund.message
end

def test_successful_credit_with_check
assert credit = @gateway.credit(@amount, check, @options.merge(doc_type: 'PPD'))
assert_success credit
assert_equal 'App ACH Credit', credit.message
assert_equal 'ACH Accepted', credit.message
end

def test_transcript_scrubbing
Expand Down
2 changes: 1 addition & 1 deletion test/remote/gateways/remote_paysafe_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def test_successful_store_and_unstore
end

def test_invalid_login
gateway = PaysafeGateway.new(username: '', password: '', account_id: '')
gateway = PaysafeGateway.new(username: 'badbunny', password: 'carrotsrock', account_id: 'rejectstew')

response = gateway.purchase(@amount, @credit_card, @options)
assert_failure response
Expand Down
2 changes: 1 addition & 1 deletion test/unit/gateways/blue_pay_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def test_message_from
end

def test_passing_stored_credentials_data_for_mit_transaction
options = @options.merge({ stored_credential: { initiator: 'merchant', reason_type: 'recurring' } })
options = @options.merge({ stored_credential: { initiator: 'merchant', reason_type: 'installment' } })
stub_comms do
@gateway.authorize(@amount, @credit_card, options)
end.check_request do |_endpoint, data, _headers|
Expand Down
2 changes: 1 addition & 1 deletion test/unit/gateways/checkout_v2_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def test_successful_purchase_with_stored_credentials
initial_options = {
stored_credential: {
initial_transaction: true,
reason_type: 'recurring'
reason_type: 'installment'
}
}
@gateway.purchase(@amount, @credit_card, initial_options)
Expand Down
2 changes: 1 addition & 1 deletion test/unit/gateways/paysafe_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_successful_purchase_with_stored_credentials
stored_credential_options = {
stored_credential: {
initial_transaction: true,
reason_type: 'recurring',
reason_type: 'installment',
initiator: 'merchant'
}
}
Expand Down

0 comments on commit 987ac8b

Please sign in to comment.