Skip to content

Commit

Permalink
FlexCharge: change transactionType placement
Browse files Browse the repository at this point in the history
Summary:
------------------------------
Change FlexCharge transactionType to a new placement.

[SER-1400](https://spreedly.atlassian.net/browse/SER-1400)

Remote Test:
------------------------------
Finished in 79.263845 seconds.
20 tests, 56 assertions, 0 failures, 0 errors, 0 pendings,
1 omissions, 0 notifications
100% passed

Unit Tests:
------------------------------
Finished in 38.175694 seconds.
5963 tests, 79998 assertions, 0 failures, 0 errors, 0 pendings,
0 omissions, 0 notifications
100% passed

RuboCop:
------------------------------
798 files inspected, no offenses detected
  • Loading branch information
Heavyblade committed Jul 23, 2024
1 parent 39878f6 commit cc7ec9b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions lib/active_merchant/billing/gateways/flex_charge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ def initialize(options = {})
end

def purchase(money, credit_card, options = {})
options[:transactionType] ||= 'Purchase'
post = { transactionType: options.fetch(:transactionType, 'Purchase') }

post = {}
add_merchant_data(post, options)
add_base_data(post, options)
add_invoice(post, money, credit_card, options)
Expand Down Expand Up @@ -198,7 +197,6 @@ def add_invoice(post, money, credit_card, options)
avsResultCode: options[:avs_result_code],
cvvResultCode: options[:cvv_result_code],
cavvResultCode: options[:cavv_result_code],
transactionType: options[:transactionType],
cardNotPresent: credit_card.is_a?(String) ? false : credit_card.verification_value.blank?
}.compact
end
Expand Down
2 changes: 1 addition & 1 deletion test/remote/gateways/remote_flex_charge_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def setup
cavv_result_code: '111',
timezone_utc_offset: '-5',
billing_address: address.merge(name: 'Cure Tester'),
extra_data: { hello: 'world' }.to_json
extra_data: ''
}

@cit_options = @options.merge(
Expand Down
4 changes: 2 additions & 2 deletions test/unit/gateways/flex_charge_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def test_successful_purchase
assert_equal request['transaction']['avsResultCode'], @options[:avs_result_code]
assert_equal request['transaction']['cvvResultCode'], @options[:cvv_result_code]
assert_equal request['transaction']['cavvResultCode'], @options[:cavv_result_code]
assert_equal request['transaction']['transactionType'], 'Purchase'
assert_equal request['transactionType'], 'Purchase'
assert_equal request['payer']['email'], @options[:email]
assert_equal request['description'], @options[:description]

Expand All @@ -141,7 +141,7 @@ def test_successful_authorization
@gateway.authorize(@amount, @credit_card, @options)
end.check_request do |_method, endpoint, data, _headers|
request = JSON.parse(data)
assert_equal request['transaction']['transactionType'], 'Authorization' if /evaluate/.match?(endpoint)
assert_equal request['transactionType'], 'Authorization' if /evaluate/.match?(endpoint)
end.respond_with(successful_access_token_response, successful_purchase_response)
end

Expand Down

0 comments on commit cc7ec9b

Please # to comment.