Skip to content

Commit

Permalink
CommerceHub: Update merchantInvoiceNumber & merchantTransactionId
Browse files Browse the repository at this point in the history
Update merchantTransactionId to be a random number and merchantInvoiceNumber
to be the order_id. Remove account_verification, primary_transaction_type
and merchant_invoice_number since they are not in use.

Remote
36 tests, 97 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
97.2222% passed
  • Loading branch information
Alma Malambo committed Jan 7, 2025
1 parent 1dd6531 commit 5935cc6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions lib/active_merchant/billing/gateways/commerce_hub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,12 @@ def add_transaction_details(post, options, action = nil)
physicalGoodsIndicator: [true, 'true'].include?(options[:physical_goods_indicator])
}

if options[:order_id].present? && action == 'sale'
details[:merchantOrderId] = options[:order_id]
details[:merchantTransactionId] = options[:order_id]
if action == 'sale'
details[:merchantOrderId] = options[:order_id] if options[:order_id]
details[:merchantTransactionId] = rand.to_s[2..13]
end

if action != 'capture'
details[:merchantInvoiceNumber] = options[:merchant_invoice_number] || rand.to_s[2..13]
details[:primaryTransactionType] = options[:primary_transaction_type]
details[:accountVerification] = options[:account_verification]
end
details[:merchantInvoiceNumber] = options[:order_id] if action != 'capture'

post[:transactionDetails] = details.compact
end
Expand Down
2 changes: 1 addition & 1 deletion test/remote/gateways/remote_commerce_hub_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def test_successful_purchase_with_failed_avs_cvv_response_codes
assert_equal 'Approved', response.message
assert_equal 'X', response.cvv_result['code']
assert_equal 'CVV check not supported for card', response.cvv_result['message']
assert_nil response.avs_result['code']
assert_equal 'Y', response.avs_result['code']
end

def test_successful_purchase_with_billing_and_shipping
Expand Down

0 comments on commit 5935cc6

Please sign in to comment.