Skip to content

Commit

Permalink
Shift4: add vendorReference field
Browse files Browse the repository at this point in the history
This change maps `options[:order_id]` to Shift4's `vendorReference` field

CER-563

LOCAL
5498 tests, 77341 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

760 files inspected, no offenses detected

GATEWAY UNIT TESTS
25 tests, 154 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

GATEWAY REMOTE TESTS
25 tests, 58 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
92% passed
(These failures also exist on the master branch)
  • Loading branch information
jcreiff committed Apr 27, 2023
1 parent 88022e8 commit a5f8b9e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/active_merchant/billing/gateways/shift4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def add_transaction(post, options)
post[:transaction] = {}
post[:transaction][:invoice] = options[:invoice] || Time.new.to_i.to_s[1..3] + rand.to_s[2..7]
post[:transaction][:notes] = options[:notes] if options[:notes].present?
post[:transaction][:vendorReference] = options[:order_id]

add_purchase_card(post[:transaction], options)
add_card_on_file(post[:transaction], options)
Expand Down
9 changes: 8 additions & 1 deletion test/remote/gateways/remote_shift4_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def setup
tax: '2',
customer_reference: 'D019D09309F2',
destination_postal_code: '94719',
product_descriptors: %w(Hamburger Fries Soda Cookie)
product_descriptors: %w(Hamburger Fries Soda Cookie),
order_id: '123456'
}
@customer_address = {
address1: '65 Easy St',
Expand Down Expand Up @@ -78,6 +79,12 @@ def test_successful_purchase_with_extra_options
assert_success response
end

def test_successful_purchase_passes_vendor_reference
response = @gateway.purchase(@amount, @credit_card, @options.merge(@extra_options))
assert_success response
assert_equal response_result(response)['transaction']['vendorReference'], @extra_options[:order_id]
end

def test_successful_purchase_with_stored_credential_framework
stored_credential_options = {
initial_transaction: true,
Expand Down
4 changes: 3 additions & 1 deletion test/unit/gateways/shift4_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def setup
tax: '2',
customer_reference: 'D019D09309F2',
destination_postal_code: '94719',
product_descriptors: %w(Hamburger Fries Soda Cookie)
product_descriptors: %w(Hamburger Fries Soda Cookie),
order_id: '123456'
}
@customer_address = {
address1: '123 Street',
Expand Down Expand Up @@ -63,6 +64,7 @@ def test_successful_purchase_with_extra_fields
request = JSON.parse(data)
assert_equal request['clerk']['numericId'], @extra_options[:clerk_id]
assert_equal request['transaction']['notes'], @extra_options[:notes]
assert_equal request['transaction']['vendorReference'], @extra_options[:order_id]
assert_equal request['amount']['tax'], @extra_options[:tax].to_f
assert_equal request['amount']['total'], (@amount / 100.0).to_s
assert_equal request['transaction']['purchaseCard']['customerReference'], @extra_options[:customer_reference]
Expand Down

0 comments on commit a5f8b9e

Please sign in to comment.