Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SER-1386 add ExtraData and Source GSFs #5179

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading