Skip to content

Commit

Permalink
Braintree: return global_id in response
Browse files Browse the repository at this point in the history
CER-868

This field needs to be added to the transaction_hash method to
be returned in the response. This also updates the Braintree gem, which was need to make these fields available

Remote
107 tests, 212 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
31.7757% passed

Unit
95 tests, 110 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
41.0526% passed

Local
5599 tests, 77770 assertions, 0 failures, 56 errors, 0 pendings, 0 omissions, 0 notifications
98.9998% passed
  • Loading branch information
rachelkirk committed Sep 22, 2023
1 parent fdf8d37 commit 6de1589
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gem 'rubocop', '~> 0.72.0', require: false

group :test, :remote_test do
# gateway-specific dependencies, keeping these gems out of the gemspec
gem 'braintree', '>= 4.12.0'
gem 'braintree', '>= 4.14.0'
gem 'jose', '~> 1.1.3'
gem 'jwe'
gem 'mechanize'
Expand Down
11 changes: 10 additions & 1 deletion lib/active_merchant/billing/gateways/braintree_blue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,14 @@ def transaction_hash(result)
risk_data = nil
end

if transaction.payment_receipt
payment_receipt = {
'global_id' => transaction.payment_receipt.global_id
}
else
payment_receipt = nil
end

{
'order_id' => transaction.order_id,
'amount' => transaction.amount.to_s,
Expand All @@ -632,7 +640,8 @@ def transaction_hash(result)
'network_transaction_id' => transaction.network_transaction_id || nil,
'processor_response_code' => response_code_from_result(result),
'processor_authorization_code' => transaction.processor_authorization_code,
'recurring' => transaction.recurring
'recurring' => transaction.recurring,
'payment_receipt' => payment_receipt
}
end

Expand Down
7 changes: 7 additions & 0 deletions test/remote/gateways/remote_braintree_blue_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,13 @@ def test_successful_purchase_with_with_prepaid_debit_issuing_bank
assert_equal 'Unknown', response.params['braintree_transaction']['credit_card_details']['issuing_bank']
end

def test_successful_purchase_with_global_id
assert response = @gateway.purchase(@amount, @credit_card)
assert_success response
assert_equal '1000 Approved', response.message
assert_not_nil response.params['braintree_transaction']['payment_receipt']['global_id']
end

def test_unsucessful_purchase_using_a_bank_account_token_not_verified
bank_account = check({ account_number: '1000000002', routing_number: '011000015' })
response = @gateway.store(bank_account, @options.merge(@check_required_options))
Expand Down

0 comments on commit 6de1589

Please sign in to comment.