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

CommerceHub: Update merchantInvoiceNumber & merchantTransactionId #5374

Merged
merged 1 commit into from
Jan 10, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
* SecurePayAU: Send order ID for payments with stored card [dacook] #3979
* Orbital: Add XSD version testing to unit test [almalee24] #5375
* Priority: fix for bin lookup [Buitragox] #5366
* CommerceHub: Update merchantInvoiceNumber & merchantTransactionId [almalee24] #5374

== Version 1.137.0 (August 2, 2024)
* Unlock dependency on `rexml` to allow fixing a CVE (#5181).
Expand Down
10 changes: 3 additions & 7 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'
if action == 'sale'
details[:merchantOrderId] = options[:order_id]
details[:merchantTransactionId] = 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
Loading