Skip to content

Commit

Permalink
SER-1386 add ExtraData and Source GSFs
Browse files Browse the repository at this point in the history
Summary:
------------------------------
FlexCharge: quick fix on void call

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

Remote Test:
------------------------------
Finished in 70.477035 seconds.
19 tests, 54 assertions, 0 failures, 0 errors, 0 pendings,
1 omissions, 0 notifications
100% passed

Unit Tests:
------------------------------
Finished in 124.425603 seconds.
5959 tests, 79971 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 19, 2024
1 parent 4b4ccb9 commit 214d483
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/active_merchant/billing/gateways/flex_charge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def purchase(money, credit_card, options = {})
add_address(post, credit_card, address(options))
add_customer_data(post, options)
add_three_ds(post, options)
add_metadata(post, options)

commit(:purchase, post)
end
Expand Down Expand Up @@ -114,6 +115,11 @@ def inquire(authorization, options = {})
commit(:inquire, {}, order_id, :get)
end

def add_metadata(post, options)
post[:Source] = 'Spreedly'
post[:ExtraData] = options[:extra_data] if options[:extra_data].present?
end

private

def address(options)
Expand Down
3 changes: 2 additions & 1 deletion test/remote/gateways/remote_flex_charge_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def setup
cvv_result_code: '111',
cavv_result_code: '111',
timezone_utc_offset: '-5',
billing_address: address.merge(name: 'Cure Tester')
billing_address: address.merge(name: 'Cure Tester'),
extra_data: { hello: 'world' }.to_json
}

@cit_options = @options.merge(
Expand Down
5 changes: 4 additions & 1 deletion test/unit/gateways/flex_charge_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def setup
cavv_result_code: '111',
timezone_utc_offset: '-5',
billing_address: address.merge(name: 'Cure Tester'),
sense_key: 'abc123'
sense_key: 'abc123',
extra_data: { hello: 'world' }.to_json
}

@cit_options = {
Expand Down Expand Up @@ -108,6 +109,8 @@ def test_successful_purchase
assert_equal request['orderId'], @options[:order_id]
assert_equal request['idempotencyKey'], @options[:idempotency_key]
assert_equal request['senseKey'], 'abc123'
assert_equal request['Source'], 'Spreedly'
assert_equal request['ExtraData'], { hello: 'world' }.to_json
assert_equal request['transaction']['timezoneUtcOffset'], @options[:timezone_utc_offset]
assert_equal request['transaction']['amount'], @amount
assert_equal request['transaction']['responseCode'], @options[:response_code]
Expand Down

0 comments on commit 214d483

Please sign in to comment.