Skip to content

Commit

Permalink
Support braintree 3.0.1 (#3987)
Browse files Browse the repository at this point in the history
* Bump braintree gem version

* Changes to support braintree 3.0.x
There are two changes required to support braintree 3.0.x

1. lib/active_merchant/billing/gateways/braintree_blue.rb is hardcoded
   to support specific braintree versions. I have updated this to
support versions 3.0.x

2. The android_pay_card parameter has been renamed to google_pay_card. I
   have modified Billing::Gateways::BraintreeBlue#add_payment_method to
hand in google_pay_card, instead of android_pay_card.

* updated tests to use google_pay_card

* Update changelog
  • Loading branch information
Smittttty authored May 28, 2021
1 parent 01a0b64 commit d2da0da
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
= ActiveMerchant CHANGELOG

== HEAD
* Braintree: Bump required braintree gem version to 3.0.1
* Stripe PI: ensure `setup_future_sage` and `off_session` work when using SetupIntents.
* Orbital: Update commit to accept retry_logic in params [jessiagee] #3890
* Orbital: Update remote 3DS tests [jessiagee] #3892
Expand Down
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.62.0', require: false

group :test, :remote_test do
# gateway-specific dependencies, keeping these gems out of the gemspec
gem 'braintree', '>= 2.98.0', '< 3.0'
gem 'braintree', '>= 3.0.0', '<= 3.0.1'
gem 'jwe'
gem 'mechanize'
end
4 changes: 2 additions & 2 deletions lib/active_merchant/billing/gateways/braintree_blue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
raise 'Could not load the braintree gem. Use `gem install braintree` to install it.'
end

raise "Need braintree gem >= 2.78.0. Run `gem install braintree --version '~>2.78'` to get the correct version." unless Braintree::Version::Major == 2 && Braintree::Version::Minor >= 78
raise "Need braintree gem >= 3.0.0. Run `gem install braintree --version '~>3.0.0'` to get the correct version." unless Braintree::Version::Major == 3 && Braintree::Version::Minor == 0

module ActiveMerchant #:nodoc:
module Billing #:nodoc:
Expand Down Expand Up @@ -801,7 +801,7 @@ def add_payment_method(parameters, credit_card_or_vault_id, options)
eci_indicator: credit_card_or_vault_id.eci
}
elsif credit_card_or_vault_id.source == :android_pay || credit_card_or_vault_id.source == :google_pay
parameters[:android_pay_card] = {
parameters[:google_pay_card] = {
number: credit_card_or_vault_id.number,
cryptogram: credit_card_or_vault_id.payment_cryptogram,
expiration_month: credit_card_or_vault_id.month.to_s.rjust(2, '0'),
Expand Down
4 changes: 2 additions & 2 deletions test/unit/gateways/braintree_blue_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ def test_android_pay_card
first_name: 'Longbob', last_name: 'Longsen' },
options: { store_in_vault: false, submit_for_settlement: nil, hold_in_escrow: nil },
custom_fields: nil,
android_pay_card: {
google_pay_card: {
number: '4111111111111111',
expiration_month: '09',
expiration_year: (Time.now.year + 1).to_s,
Expand Down Expand Up @@ -986,7 +986,7 @@ def test_google_pay_card
first_name: 'Longbob', last_name: 'Longsen' },
options: { store_in_vault: false, submit_for_settlement: nil, hold_in_escrow: nil },
custom_fields: nil,
android_pay_card: {
google_pay_card: {
number: '4111111111111111',
expiration_month: '09',
expiration_year: (Time.now.year + 1).to_s,
Expand Down

0 comments on commit d2da0da

Please sign in to comment.