braintree 4.20.0 → 4.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5738048bf9abc767f859d8f10d42baa075a3f5986dca2a1fe6bb86b744a2a29a
4
- data.tar.gz: 994d4b0dce9d1d6da5cbf929cb4debd0460b85087396c6400ca854af3c5fb882
3
+ metadata.gz: abb377057ff689e5a04a7a2dbfa201a3243b5008898ab343ec76d02200d4ffba
4
+ data.tar.gz: 128bed5617e3793b7353fd10e76dd06afce28143f4ac5def37bc28c4efb07ce4
5
5
  SHA512:
6
- metadata.gz: 96280a78f3e0fbabdbf95f950ca6bd417c7ab02c10e23169cb3a9b829dddc59b125fbb36d6164ef108a52aaba199b5677e1e9c3f2c95e8e6e4e1468ec6ce10b8
7
- data.tar.gz: 1a9ca31d02662aaa179da5e2031bf096ecebcdef55d0f9a514cb20693d44c378933f6430ae95cc395b57da0e7b026221ee2ac0ba9061142b595db866437a5db9
6
+ metadata.gz: 1034c8cb638f8ecd4df2533fb4e22bc21710df5ce5b8c56da4801028b91322dbd0e690108081e7745e1c74c06be7290484872eb5a55f128c23cd3e5fc480bf3c
7
+ data.tar.gz: 36f48a290b8ffcfab8467d8b5b582b96d40320cf9929d996d5d703bab0cedaa0d033865c81e9b6434669fb5ca82bee911c591de5c4a9bfe0ced6c0c46fe761cd
@@ -12,6 +12,7 @@ module Braintree
12
12
  attr_reader :extended_address
13
13
  attr_reader :first_name
14
14
  attr_reader :id
15
+ attr_reader :international_phone
15
16
  attr_reader :last_name
16
17
  attr_reader :locality
17
18
  attr_reader :phone_number
@@ -76,8 +76,9 @@ module Braintree
76
76
 
77
77
  def self._shared_signature
78
78
  [:company, :country_code_alpha2, :country_code_alpha3, :country_code_numeric,
79
- :country_name, :extended_address, :first_name, :last_name, :locality, :phone_number,
80
- :postal_code, :region, :street_address]
79
+ :country_name, :extended_address, :first_name,
80
+ {:international_phone => [:country_code, :national_number]},
81
+ :last_name, :locality, :phone_number, :postal_code, :region, :street_address]
81
82
  end
82
83
 
83
84
  def self._update_signature
@@ -15,6 +15,7 @@ module Braintree
15
15
  attr_reader :google_pay_cards
16
16
  attr_reader :graphql_id
17
17
  attr_reader :id
18
+ attr_reader :international_phone
18
19
  attr_reader :last_name
19
20
  attr_reader :paypal_accounts
20
21
  attr_reader :phone
@@ -148,8 +149,8 @@ module Braintree
148
149
 
149
150
  def self._attributes
150
151
  [
151
- :addresses, :company, :credit_cards, :email, :fax, :first_name, :id, :last_name, :phone, :website,
152
- :created_at, :updated_at, :tax_identifiers
152
+ :addresses, :company, :credit_cards, :email, :fax, :first_name, :id, :international_phone,
153
+ :last_name, :phone, :website, :created_at, :updated_at, :tax_identifiers
153
154
  ]
154
155
  end
155
156
 
@@ -75,7 +75,9 @@ module Braintree
75
75
  ],
76
76
  ]
77
77
  [
78
- :company, :email, :fax, :first_name, :id, :last_name, :phone, :website,
78
+ :company, :email, :fax, :first_name, :id,
79
+ {:international_phone => [:country_code, :national_number]},
80
+ :last_name, :phone, :website,
79
81
  :device_data, :payment_method_nonce,
80
82
  {:risk_data => [:customer_browser, :customer_ip]},
81
83
  {:credit_card => credit_card_signature},
@@ -139,7 +141,9 @@ module Braintree
139
141
  ],
140
142
  ]
141
143
  [
142
- :company, :email, :fax, :first_name, :id, :last_name, :phone, :website,
144
+ :company, :email, :fax, :first_name, :id,
145
+ {:international_phone => [:country_code, :national_number]},
146
+ :last_name, :phone, :website,
143
147
  :device_data, :payment_method_nonce, :default_payment_method_token,
144
148
  {:credit_card => credit_card_signature},
145
149
  {:tax_identifiers => [:country_code, :identifier]},
@@ -185,6 +185,10 @@ module Braintree
185
185
  KindIsInvalid = "84901"
186
186
  end
187
187
 
188
+ module GooglePayCard
189
+ AndroidPayCardsAreNotAccepted = "83708"
190
+ end
191
+
188
192
  module PayPalAccount
189
193
  AuthExpired = "92911"
190
194
  CannotHaveBothAccessTokenAndConsentCode = "82903"
@@ -6,6 +6,7 @@ module Braintree
6
6
  attr_reader :created_at
7
7
  attr_reader :customer_id
8
8
  attr_reader :email
9
+ attr_reader :funding_source_description
9
10
  attr_reader :image_url
10
11
  attr_reader :payer_id
11
12
  attr_reader :revoked_at
@@ -21,6 +21,7 @@ module Braintree
21
21
  attr_reader :extended_address
22
22
  attr_reader :first_name
23
23
  attr_reader :id
24
+ attr_reader :international_phone
24
25
  attr_reader :last_name
25
26
  attr_reader :locality
26
27
  attr_reader :phone_number
@@ -8,6 +8,7 @@ module Braintree
8
8
  attr_reader :fax
9
9
  attr_reader :first_name
10
10
  attr_reader :id
11
+ attr_reader :international_phone
11
12
  attr_reader :last_name
12
13
  attr_reader :phone
13
14
  attr_reader :website
@@ -17,7 +18,7 @@ module Braintree
17
18
  end
18
19
 
19
20
  def inspect
20
- attr_order = [:id, :first_name, :last_name, :email, :company, :website, :phone, :fax]
21
+ attr_order = [:id, :first_name, :last_name, :email, :company, :website, :phone, :international_phone, :fax]
21
22
  formatted_attrs = attr_order.map do |attr|
22
23
  "#{attr}: #{send(attr).inspect}"
23
24
  end
@@ -5,11 +5,14 @@ module Braintree
5
5
 
6
6
  attr_reader :carrier
7
7
  attr_reader :id
8
+ # NEXT_MAJOR_VERSION Remove this method
9
+ # use paypal_tracker_id going forward
8
10
  attr_reader :paypal_tracking_id
11
+ attr_reader :paypal_tracker_id
9
12
  attr_reader :tracking_number
10
13
 
11
14
  def initialize(attributes)
12
- set_instance_variables_from_hash attributes unless attributes.nil?
15
+ set_instance_variables_from_hash attributes unless attributes.nil?
13
16
  end
14
17
  end
15
18
  end
@@ -121,6 +121,7 @@ module Braintree
121
121
  attr_reader :escrow_status
122
122
  attr_reader :facilitated_details
123
123
  attr_reader :facilitator_details
124
+ attr_reader :foreign_retailer
124
125
  attr_reader :gateway_rejection_reason
125
126
  attr_reader :google_pay_details
126
127
  attr_reader :graphql_id
@@ -178,7 +178,7 @@ module Braintree
178
178
 
179
179
  def submit_for_partial_settlement(authorized_transaction_id, amount = nil, options = {})
180
180
  raise ArgumentError, "authorized_transaction_id is invalid" unless authorized_transaction_id =~ /\A[0-9a-z]+\z/
181
- Util.verify_keys(TransactionGateway._submit_for_settlement_signature, options)
181
+ Util.verify_keys(TransactionGateway._submit_for_partial_settlement_signature, options)
182
182
  transaction_params = {:amount => amount}.merge(options)
183
183
  response = @config.http.post("#{@config.base_merchant_path}/transactions/#{authorized_transaction_id}/submit_for_partial_settlement", :transaction => transaction_params)
184
184
  _handle_transaction_response(response)
@@ -221,7 +221,7 @@ module Braintree
221
221
  :shared_shipping_address_id, :shipping_address_id, :shipping_amount,
222
222
  :ships_from_postal_code, :tax_amount, :tax_exempt, :three_d_secure_authentication_id,:three_d_secure_token, #Deprecated
223
223
  :transaction_source, :type, :venmo_sdk_payment_method_code, # Deprecated
224
- :sca_exemption, :currency_iso_code, :exchange_rate_quote_id,
224
+ :sca_exemption, :currency_iso_code, :exchange_rate_quote_id, :foreign_retailer,
225
225
  {:line_items => [:commodity_code, :description, :discount_amount, :image_url, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :upc_code, :upc_type, :url]},
226
226
  {:risk_data => [:customer_browser, :customer_device_id, :customer_ip, :customer_location_zip, :customer_tenure]},
227
227
  {:credit_card => [:token, :cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year, :number, {:payment_reader_card_details => [:encrypted_card_data, :key_serial_number]}, {:network_tokenization_attributes => [:cryptogram, :ecommerce_indicator, :token_requestor_id]}]},
@@ -322,6 +322,12 @@ module Braintree
322
322
  ]
323
323
  end
324
324
 
325
+ def self._submit_for_partial_settlement_signature
326
+ _submit_for_settlement_signature + [
327
+ :final_capture
328
+ ]
329
+ end
330
+
325
331
  def self._adjust_authorization_signature
326
332
  [
327
333
  :amount
@@ -1,7 +1,7 @@
1
1
  module Braintree
2
2
  module Version
3
3
  Major = 4
4
- Minor = 20
4
+ Minor = 21
5
5
  Tiny = 0
6
6
 
7
7
  String = "#{Major}.#{Minor}.#{Tiny}"
@@ -46,6 +46,8 @@ module Braintree
46
46
 
47
47
  RecipientUpdatedGrantedPaymentMethod = "recipient_updated_granted_payment_method"
48
48
 
49
+ RefundFailed = "refund_failed"
50
+
49
51
  SubscriptionBillingSkipped = "subscription_billing_skipped"
50
52
  SubscriptionCanceled = "subscription_canceled"
51
53
  SubscriptionChargedSuccessfully = "subscription_charged_successfully"
@@ -104,6 +104,8 @@ module Braintree
104
104
  _local_payment_reversed_sample_xml
105
105
  when Braintree::WebhookNotification::Kind::PaymentMethodCustomerDataUpdated
106
106
  _payment_method_customer_data_updated_sample_xml(id)
107
+ when Braintree::WebhookNotification::Kind::RefundFailed
108
+ _refund_failed_sample_xml(id)
107
109
  else
108
110
  _subscription_sample_xml(id)
109
111
  end
@@ -1181,5 +1183,21 @@ module Braintree
1181
1183
  </venmo-account>
1182
1184
  XML
1183
1185
  end
1186
+
1187
+ def _refund_failed_sample_xml(id)
1188
+ <<-XML
1189
+ <transaction>
1190
+ <id>#{id}</id>
1191
+ <amount>100</amount>
1192
+ <credit-card>
1193
+ <number>1234560000001234</number>
1194
+ <cvv>123</cvv>
1195
+ <card-type>MasterCard</card-type>
1196
+ </credit-card>
1197
+ <status>processor_declined</status>
1198
+ <refunded-transaction-id>1</refunded-transaction-id>
1199
+ </transaction>
1200
+ XML
1201
+ end
1184
1202
  end
1185
1203
  end
@@ -15,6 +15,7 @@ describe Braintree::Address do
15
15
  :locality => "Chicago",
16
16
  :region => "Illinois",
17
17
  :phone_number => "5551231234",
18
+ :international_phone => {:country_code => "1", :national_number => "3121234567"},
18
19
  :postal_code => "60622",
19
20
  :country_name => "United States of America",
20
21
  )
@@ -28,6 +29,8 @@ describe Braintree::Address do
28
29
  expect(result.address.locality).to eq("Chicago")
29
30
  expect(result.address.region).to eq("Illinois")
30
31
  expect(result.address.phone_number).to eq("5551231234")
32
+ expect(result.address.international_phone[:country_code]).to eq("1")
33
+ expect(result.address.international_phone[:national_number]).to eq("3121234567")
31
34
  expect(result.address.postal_code).to eq("60622")
32
35
  expect(result.address.country_name).to eq("United States of America")
33
36
  expect(result.address.country_code_alpha2).to eq("US")
@@ -241,6 +244,7 @@ describe Braintree::Address do
241
244
  :region => "Illinois",
242
245
  :postal_code => "60621",
243
246
  :country_name => "United States of America",
247
+ :international_phone => {:country_code => "1", :national_number => "3121234567"},
244
248
  )
245
249
  expect(result.success?).to eq(true)
246
250
  expect(result.address.street_address).to eq("123 E New St")
@@ -252,6 +256,8 @@ describe Braintree::Address do
252
256
  expect(result.address.country_code_alpha2).to eq("US")
253
257
  expect(result.address.country_code_alpha3).to eq("USA")
254
258
  expect(result.address.country_code_numeric).to eq("840")
259
+ expect(result.address.international_phone[:country_code]).to eq("1")
260
+ expect(result.address.international_phone[:national_number]).to eq("3121234567")
255
261
  end
256
262
 
257
263
  it "accepts country_codes" do
@@ -38,6 +38,7 @@ describe Braintree::Customer do
38
38
  :company => "Microsoft",
39
39
  :email => "bill@microsoft.com",
40
40
  :phone => "312.555.1234",
41
+ :international_phone => {:country_code => "1", :national_number => "3121234567"},
41
42
  :fax => "614.555.5678",
42
43
  :website => "www.microsoft.com",
43
44
  :tax_identifiers => [{:country_code => "US", :identifier => "987654321"}],
@@ -49,6 +50,8 @@ describe Braintree::Customer do
49
50
  expect(result.customer.company).to eq("Microsoft")
50
51
  expect(result.customer.email).to eq("bill@microsoft.com")
51
52
  expect(result.customer.phone).to eq("312.555.1234")
53
+ expect(result.customer.international_phone[:country_code]).to eq("1")
54
+ expect(result.customer.international_phone[:national_number]).to eq("3121234567")
52
55
  expect(result.customer.fax).to eq("614.555.5678")
53
56
  expect(result.customer.website).to eq("www.microsoft.com")
54
57
  expect(result.customer.created_at.between?(Time.now - 10, Time.now)).to eq(true)
@@ -1193,6 +1196,7 @@ describe Braintree::Customer do
1193
1196
  customer.id,
1194
1197
  :first_name => "Mr. Joe",
1195
1198
  :last_name => "Super Cool",
1199
+ :international_phone => {:country_code => "1", :national_number => "3121234567"},
1196
1200
  :custom_fields => {
1197
1201
  :store_me => "a value"
1198
1202
  },
@@ -1201,6 +1205,8 @@ describe Braintree::Customer do
1201
1205
  expect(result.customer.id).to eq(customer.id)
1202
1206
  expect(result.customer.first_name).to eq("Mr. Joe")
1203
1207
  expect(result.customer.last_name).to eq("Super Cool")
1208
+ expect(result.customer.international_phone[:country_code]).to eq("1")
1209
+ expect(result.customer.international_phone[:national_number]).to eq("3121234567")
1204
1210
  expect(result.customer.custom_fields[:store_me]).to eq("a value")
1205
1211
  end
1206
1212
 
@@ -1,18 +1,17 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+ require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
2
3
 
4
+ # NEXT_MAJOR_VERSION Remove paypal_tracking_id assertions, use paypal_tracker_id going forward
3
5
  describe Braintree::Transaction do
4
6
  describe "self.package_tracking" do
7
+ let(:customer) { Braintree::Customer.create! }
5
8
  it "returns validation error message from gateway api" do
6
- # Create Transaction
7
9
  result = Braintree::Transaction.sale(
8
10
  :amount => "100",
11
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
9
12
  :options => {
10
13
  :submit_for_settlement => true
11
14
  },
12
- :paypal_account => {
13
- :payer_id => "fake-payer-id",
14
- :payment_id => "fake-payment-id",
15
- },
16
15
  )
17
16
 
18
17
  expect(result.success?).to eq(true)
@@ -27,17 +26,12 @@ describe Braintree::Transaction do
27
26
  end
28
27
 
29
28
  it "successfully calls gateway API and adds package tracking information" do
30
-
31
- # Create Transaction
32
29
  result = Braintree::Transaction.sale(
33
30
  :amount => "100",
31
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
34
32
  :options => {
35
33
  :submit_for_settlement => true
36
34
  },
37
- :paypal_account => {
38
- :payer_id => "fake-payer-id",
39
- :payment_id => "fake-payment-id",
40
- },
41
35
  )
42
36
 
43
37
  expect(result.success?).to eq(true)
@@ -77,7 +71,8 @@ describe Braintree::Transaction do
77
71
  expect(firstPackageResult.transaction.packages[0].id).not_to be_nil
78
72
  expect(firstPackageResult.transaction.packages[0].carrier).to eq("UPS")
79
73
  expect(firstPackageResult.transaction.packages[0].tracking_number).to eq("tracking_number_1")
80
-
74
+ expect(firstPackageResult.transaction.packages[0].paypal_tracker_id).to be_nil
75
+ expect(firstPackageResult.transaction.packages[0].paypal_tracking_id).to be_nil
81
76
 
82
77
  # Create second package with 1 product
83
78
  secondPackageResult = Braintree::Transaction.package_tracking(
@@ -102,10 +97,34 @@ describe Braintree::Transaction do
102
97
  expect(secondPackageResult.transaction.packages[1].id).not_to be_nil
103
98
  expect(secondPackageResult.transaction.packages[1].carrier).to eq("FEDEX")
104
99
  expect(secondPackageResult.transaction.packages[1].tracking_number).to eq("tracking_number_2")
100
+ expect(secondPackageResult.transaction.packages[1].paypal_tracker_id).to be_nil
101
+ expect(secondPackageResult.transaction.packages[1].paypal_tracking_id).to be_nil
105
102
 
106
103
  # Find transaction gives both packages
107
- findTransaction = Braintree::Transaction.find(result.transaction.id)
108
- expect(findTransaction.packages.length).to eq(2)
104
+ transaction = Braintree::Transaction.find(result.transaction.id)
105
+ expect(transaction.packages.length).to eq(2)
106
+ expect(transaction.packages[0].id).not_to be_nil
107
+ expect(transaction.packages[0].carrier).to eq("UPS")
108
+ expect(transaction.packages[0].tracking_number).to eq("tracking_number_1")
109
+ #In test environment, since we do not have jobstream setup paypal tracker id is going to be nil, this is just to access we could access it
110
+ expect(transaction.packages[0].paypal_tracker_id).to be_nil
111
+ expect(transaction.packages[0].paypal_tracking_id).to be_nil
112
+
113
+ expect(transaction.packages[1].id).not_to be_nil
114
+ expect(transaction.packages[1].carrier).to eq("FEDEX")
115
+ expect(transaction.packages[1].tracking_number).to eq("tracking_number_2")
116
+ expect(transaction.packages[1].paypal_tracker_id).to be_nil
117
+ expect(transaction.packages[1].paypal_tracking_id).to be_nil
118
+ end
119
+
120
+ it "retrieves paypal_tracker_id successfully" do
121
+ transaction = Braintree::Transaction.find("package_tracking_tx")
122
+ expect(transaction.packages.length).to eq(2)
123
+ expect(transaction.packages[0].paypal_tracker_id).to eq("paypal_tracker_id_1")
124
+ expect(transaction.packages[0].paypal_tracking_id).to be_nil
125
+
126
+ expect(transaction.packages[1].paypal_tracker_id).to eq("paypal_tracker_id_2")
127
+ expect(transaction.packages[1].paypal_tracking_id).to be_nil
109
128
  end
110
129
  end
111
- end
130
+ end
@@ -453,7 +453,8 @@ describe Braintree::PaymentMethod do
453
453
  :payment_method_nonce => nonce,
454
454
  :customer_id => customer.id,
455
455
  :billing_address => {
456
- :street_address => "123 Abc Way"
456
+ :street_address => "123 Abc Way",
457
+ :international_phone => {:country_code => "1", :national_number => "3121234567"},
457
458
  },
458
459
  )
459
460
 
@@ -464,6 +465,8 @@ describe Braintree::PaymentMethod do
464
465
  found_credit_card = Braintree::CreditCard.find(token)
465
466
  expect(found_credit_card).not_to be_nil
466
467
  expect(found_credit_card.billing_address.street_address).to eq("123 Abc Way")
468
+ expect(found_credit_card.billing_address.international_phone[:country_code]).to eq("1")
469
+ expect(found_credit_card.billing_address.international_phone[:national_number]).to eq("3121234567")
467
470
  end
468
471
 
469
472
  it "allows passing a billing address id outside of the nonce" do
@@ -1677,12 +1680,15 @@ describe Braintree::PaymentMethod do
1677
1680
  )
1678
1681
  update_result = Braintree::PaymentMethod.update(credit_card.token,
1679
1682
  :billing_address => {
1683
+ :international_phone => {:country_code => "1", :national_number => "3121234567"},
1680
1684
  :region => "IL",
1681
1685
  :options => {:update_existing => true}
1682
1686
  },
1683
1687
  )
1684
1688
  expect(update_result.success?).to eq(true)
1685
1689
  updated_credit_card = update_result.payment_method
1690
+ expect(updated_credit_card.billing_address.international_phone[:country_code]).to eq("1")
1691
+ expect(updated_credit_card.billing_address.international_phone[:national_number]).to eq("3121234567")
1686
1692
  expect(updated_credit_card.billing_address.region).to eq("IL")
1687
1693
  expect(updated_credit_card.billing_address.street_address).to eq("123 Nigeria Ave")
1688
1694
  expect(updated_credit_card.billing_address.id).to eq(credit_card.billing_address.id)
@@ -25,6 +25,7 @@ describe Braintree::PayPalAccount do
25
25
  expect(paypal_account.created_at).not_to be_nil
26
26
  expect(paypal_account.updated_at).not_to be_nil
27
27
  expect(paypal_account.customer_id).to eq(customer.id)
28
+ expect(paypal_account.funding_source_description).to be_nil
28
29
  expect(paypal_account.revoked_at).to be_nil
29
30
  end
30
31
 
@@ -718,6 +718,49 @@ describe Braintree::Transaction do
718
718
  end
719
719
  end
720
720
 
721
+ context "foreign_retailer" do
722
+ it "returns true when foreign_retailer param is true" do
723
+ result = Braintree::Transaction.create(
724
+ :type => "sale",
725
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
726
+ :credit_card => {
727
+ :number => Braintree::Test::CreditCardNumbers::Visa,
728
+ :expiration_date => "05/2025"
729
+ },
730
+ :foreign_retailer => true,
731
+ )
732
+ expect(result).to be_success
733
+ expect(result.transaction.foreign_retailer).to be_truthy
734
+ end
735
+
736
+ it "returns nil when foreign_retailer param is false" do
737
+ result = Braintree::Transaction.create(
738
+ :type => "sale",
739
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
740
+ :credit_card => {
741
+ :number => Braintree::Test::CreditCardNumbers::Visa,
742
+ :expiration_date => "05/2025"
743
+ },
744
+ :foreign_retailer => false,
745
+ )
746
+ expect(result).to be_success
747
+ expect(result.transaction.foreign_retailer).to be_nil
748
+ end
749
+
750
+ it "returns nil when foreign_retailer param is nil" do
751
+ result = Braintree::Transaction.create(
752
+ :type => "sale",
753
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
754
+ :credit_card => {
755
+ :number => Braintree::Test::CreditCardNumbers::Visa,
756
+ :expiration_date => "05/2025"
757
+ },
758
+ )
759
+ expect(result).to be_success
760
+ expect(result.transaction.foreign_retailer).to be_nil
761
+ end
762
+ end
763
+
721
764
  it "returns a successful result if successful" do
722
765
  result = Braintree::Transaction.create(
723
766
  :type => "sale",
@@ -5219,6 +5262,7 @@ describe Braintree::Transaction do
5219
5262
  :locality => "Chicago",
5220
5263
  :region => "IL",
5221
5264
  :phone_number => "122-555-1237",
5265
+ :international_phone => {:country_code => "1", :national_number => "3121234567"},
5222
5266
  :postal_code => "60622",
5223
5267
  :country_name => "United States of America"
5224
5268
  },
@@ -5231,6 +5275,7 @@ describe Braintree::Transaction do
5231
5275
  :locality => "Bartlett",
5232
5276
  :region => "IL",
5233
5277
  :phone_number => "122-555-1236",
5278
+ :international_phone => {:country_code => "1", :national_number => "3121234567"},
5234
5279
  :postal_code => "60103",
5235
5280
  :country_name => "United States of America",
5236
5281
  :shipping_method => Braintree::Transaction::AddressDetails::ShippingMethod::Electronic
@@ -5277,6 +5322,9 @@ describe Braintree::Transaction do
5277
5322
  expect(transaction.billing_details.country_code_alpha2).to eq("US")
5278
5323
  expect(transaction.billing_details.country_code_alpha3).to eq("USA")
5279
5324
  expect(transaction.billing_details.country_code_numeric).to eq("840")
5325
+ expect(transaction.billing_details.phone_number).to eq("122-555-1237")
5326
+ expect(transaction.billing_details.international_phone[:country_code]).to eq("1")
5327
+ expect(transaction.billing_details.international_phone[:national_number]).to eq("3121234567")
5280
5328
  expect(transaction.shipping_details.first_name).to eq("Andrew")
5281
5329
  expect(transaction.shipping_details.last_name).to eq("Mason")
5282
5330
  expect(transaction.shipping_details.company).to eq("Braintree")
@@ -5289,6 +5337,9 @@ describe Braintree::Transaction do
5289
5337
  expect(transaction.shipping_details.country_code_alpha2).to eq("US")
5290
5338
  expect(transaction.shipping_details.country_code_alpha3).to eq("USA")
5291
5339
  expect(transaction.shipping_details.country_code_numeric).to eq("840")
5340
+ expect(transaction.shipping_details.phone_number).to eq("122-555-1236")
5341
+ expect(transaction.shipping_details.international_phone[:country_code]).to eq("1")
5342
+ expect(transaction.shipping_details.international_phone[:national_number]).to eq("3121234567")
5292
5343
  end
5293
5344
 
5294
5345
  it "allows merchant account to be specified" do
@@ -6579,6 +6630,39 @@ describe Braintree::Transaction do
6579
6630
  result = Braintree::Transaction.submit_for_partial_settlement(transaction.id, Braintree::Test::TransactionAmounts::Authorize, industry_data_flight_params)
6580
6631
  expect(result.success?).to be_truthy
6581
6632
  end
6633
+
6634
+ it "final_capture indicates the current partial_capture as final" do
6635
+ authorized_transaction = Braintree::Transaction.sale!(
6636
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
6637
+ :merchant_account_id => SpecHelper::DefaultMerchantAccountId,
6638
+ :credit_card => {
6639
+ :number => Braintree::Test::CreditCardNumbers::Visa,
6640
+ :expiration_date => "06/2009"
6641
+ },
6642
+ )
6643
+
6644
+ result1 = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100)
6645
+ expect(result1.success?).to eq(true)
6646
+ partial_settlement_transaction1 = result1.transaction
6647
+ expect(partial_settlement_transaction1.amount).to eq(100)
6648
+ expect(partial_settlement_transaction1.type).to eq(Braintree::Transaction::Type::Sale)
6649
+ expect(partial_settlement_transaction1.status).to eq(Braintree::Transaction::Status::SubmittedForSettlement)
6650
+ expect(partial_settlement_transaction1.authorized_transaction_id).to eq(authorized_transaction.id)
6651
+ refreshed_authorized_transaction1 = Braintree::Transaction.find(authorized_transaction.id)
6652
+ expect(refreshed_authorized_transaction1.status).to eq(Braintree::Transaction::Status::SettlementPending)
6653
+
6654
+ options = {:final_capture => true}
6655
+ result2 = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100, options)
6656
+ expect(result2.success?).to eq(true)
6657
+ partial_settlement_transaction2 = result2.transaction
6658
+ expect(partial_settlement_transaction2.amount).to eq(100)
6659
+ expect(partial_settlement_transaction2.type).to eq(Braintree::Transaction::Type::Sale)
6660
+ expect(partial_settlement_transaction2.status).to eq(Braintree::Transaction::Status::SubmittedForSettlement)
6661
+ expect(partial_settlement_transaction2.authorized_transaction_id).to eq(authorized_transaction.id)
6662
+
6663
+ refreshed_authorized_transaction2 = Braintree::Transaction.find(authorized_transaction.id)
6664
+ expect(refreshed_authorized_transaction2.status).to eq(Braintree::Transaction::Status::SettlementPending)
6665
+ end
6582
6666
  end
6583
6667
 
6584
6668
  describe "self.submit_for_partial_settlement!" do
@@ -34,6 +34,7 @@ describe Braintree::CreditCard do
34
34
  :country_name,
35
35
  :extended_address,
36
36
  :first_name,
37
+ {:international_phone=>[:country_code, :national_number]},
37
38
  :last_name,
38
39
  :locality,
39
40
  :phone_number,
@@ -81,6 +82,7 @@ describe Braintree::CreditCard do
81
82
  :country_name,
82
83
  :extended_address,
83
84
  :first_name,
85
+ {:international_phone=>[:country_code, :national_number]},
84
86
  :last_name,
85
87
  :locality,
86
88
  :phone_number,
@@ -16,6 +16,7 @@ describe Braintree::Customer do
16
16
  :first_name => "Patrick",
17
17
  :last_name => "Smith",
18
18
  :phone => "802-483-5932",
19
+ :international_phone => {:country_code => "1", :national_number => "3121234567"},
19
20
  :website => "patrick.smith.com",
20
21
  :created_at => Time.now,
21
22
  :updated_at => Time.now,
@@ -27,6 +28,7 @@ describe Braintree::Customer do
27
28
  expect(output).to include(%q(first_name: "Patrick"))
28
29
  expect(output).to include(%q(last_name: "Smith"))
29
30
  expect(output).to include(%q(phone: "802-483-5932"))
31
+ expect(output).to include(%q(international_phone: {:country_code=>"1", :national_number=>"3121234567"}))
30
32
  expect(output).to include(%q(website: "patrick.smith.com"))
31
33
  expect(output).to include(%q(addresses: []))
32
34
  expect(output).to include(%q(credit_cards: []))
@@ -82,6 +84,7 @@ describe Braintree::Customer do
82
84
  :fax,
83
85
  :first_name,
84
86
  :id,
87
+ {:international_phone=>[:country_code, :national_number]},
85
88
  :last_name,
86
89
  :phone,
87
90
  :website,
@@ -111,6 +114,7 @@ describe Braintree::Customer do
111
114
  :country_name,
112
115
  :extended_address,
113
116
  :first_name,
117
+ {:international_phone=>[:country_code, :national_number]},
114
118
  :last_name,
115
119
  :locality,
116
120
  :phone_number,
@@ -154,6 +158,7 @@ describe Braintree::Customer do
154
158
  :country_name,
155
159
  :extended_address,
156
160
  :first_name,
161
+ {:international_phone=>[:country_code, :national_number]},
157
162
  :last_name,
158
163
  :locality,
159
164
  :phone_number,
@@ -176,6 +181,7 @@ describe Braintree::Customer do
176
181
  :fax,
177
182
  :first_name,
178
183
  :id,
184
+ {:international_phone=>[:country_code, :national_number]},
179
185
  :last_name,
180
186
  :phone,
181
187
  :website,
@@ -215,6 +221,7 @@ describe Braintree::Customer do
215
221
  :country_name,
216
222
  :extended_address,
217
223
  :first_name,
224
+ {:international_phone=>[:country_code, :national_number]},
218
225
  :last_name,
219
226
  :locality,
220
227
  :phone_number,
@@ -253,6 +260,7 @@ describe Braintree::Customer do
253
260
  :country_name,
254
261
  :extended_address,
255
262
  :first_name,
263
+ {:international_phone=>[:country_code, :national_number]},
256
264
  :last_name,
257
265
  :locality,
258
266
  :phone_number,
@@ -1,5 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
 
3
+ # NEXT_MAJOR_VERSION Remove paypal_tracking_id assertions, use paypal_tracker_id going forward
3
4
  describe "Package Tracking Unit Tests" do
4
5
  describe "creates and validates requests" do
5
6
  let(:gateway) do
@@ -39,8 +40,8 @@ describe "Package Tracking Unit Tests" do
39
40
  transaction = Braintree::Transaction._new(
40
41
  :gateway,
41
42
  :shipments => [
42
- {:id => "id1", :carrier => "UPS", :tracking_number => "tracking_number_1", :paypal_tracking_id => "pp_tracking_number_1"},
43
- {:id => "id2", :carrier => "FEDEX", :tracking_number => "tracking_number_2", :paypal_tracking_id => "pp_tracking_number_2"}
43
+ {:id => "id1", :carrier => "UPS", :tracking_number => "tracking_number_1", :paypal_tracking_id => "pp_tracking_number_1", :paypal_tracker_id => "pp_tracking_number_1"},
44
+ {:id => "id2", :carrier => "FEDEX", :tracking_number => "tracking_number_2", :paypal_tracking_id => "pp_tracking_number_2", :paypal_tracker_id => "pp_tracking_number_2"}
44
45
  ],
45
46
  )
46
47
  expect(transaction.packages.size).to eq(2)
@@ -48,11 +49,13 @@ describe "Package Tracking Unit Tests" do
48
49
  expect(transaction.packages[0].carrier).to eq("UPS")
49
50
  expect(transaction.packages[0].tracking_number).to eq("tracking_number_1")
50
51
  expect(transaction.packages[0].paypal_tracking_id).to eq("pp_tracking_number_1")
52
+ expect(transaction.packages[0].paypal_tracker_id).to eq("pp_tracking_number_1")
51
53
 
52
54
  expect(transaction.packages[1].id).to eq("id2")
53
55
  expect(transaction.packages[1].carrier).to eq("FEDEX")
54
56
  expect(transaction.packages[1].tracking_number).to eq("tracking_number_2")
55
57
  expect(transaction.packages[1].paypal_tracking_id).to eq("pp_tracking_number_2")
58
+ expect(transaction.packages[1].paypal_tracker_id).to eq("pp_tracking_number_2")
56
59
  end
57
60
 
58
61
  it "doesn't blow up if no shipments are present in the transaction response" do
@@ -11,9 +11,10 @@ describe Braintree::Transaction::CustomerDetails do
11
11
  :company => "Smith Co.",
12
12
  :website => "http://www.example.com",
13
13
  :phone => "6145551234",
14
+ :international_phone => {:country_code=>"1", :national_number=>"3121234567"},
14
15
  :fax => "3125551234",
15
16
  )
16
- expect(details.inspect).to eq(%(#<id: "id", first_name: "Amy", last_name: "Smith", email: "amy.smith@example.com", company: "Smith Co.", website: "http://www.example.com", phone: "6145551234", fax: "3125551234">))
17
+ expect(details.inspect).to eq(%(#<id: "id", first_name: "Amy", last_name: "Smith", email: "amy.smith@example.com", company: "Smith Co.", website: "http://www.example.com", phone: "6145551234", international_phone: {:country_code=>\"1\", :national_number=>\"3121234567\"}, fax: "3125551234">))
17
18
  end
18
19
  end
19
20
  end
@@ -40,7 +40,7 @@ describe Braintree::TransactionGateway do
40
40
  :shared_shipping_address_id, :shipping_address_id, :shipping_amount,
41
41
  :ships_from_postal_code, :tax_amount, :tax_exempt, :three_d_secure_authentication_id,:three_d_secure_token, #Deprecated
42
42
  :transaction_source, :type, :venmo_sdk_payment_method_code, #Deprecated
43
- :sca_exemption, :currency_iso_code, :exchange_rate_quote_id,
43
+ :sca_exemption, :currency_iso_code, :exchange_rate_quote_id, :foreign_retailer,
44
44
  {:line_items => [:commodity_code, :description, :discount_amount, :image_url, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :upc_code, :upc_type, :url]},
45
45
  {:risk_data => [:customer_browser, :customer_device_id, :customer_ip, :customer_location_zip, :customer_tenure]},
46
46
  {:credit_card => [:token, :cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year, :number, {:payment_reader_card_details => [:encrypted_card_data, :key_serial_number]}, {:network_tokenization_attributes => [:cryptogram, :ecommerce_indicator, :token_requestor_id]}]},
@@ -140,5 +140,9 @@ describe Braintree::TransactionGateway do
140
140
  :line_items => [:commodity_code, :description, :discount_amount, :image_url, :kind, :name, :product_code, :quantity, :tax_amount, :total_amount, :unit_amount, :unit_of_measure, :unit_tax_amount, :upc_code, :upc_type, :url],
141
141
  ])
142
142
  end
143
+
144
+ it "creates transaction gateway submit for partial settlement signature" do
145
+ expect(Braintree::TransactionGateway._submit_for_partial_settlement_signature).to include(:final_capture)
146
+ end
143
147
  end
144
148
  end
@@ -941,4 +941,16 @@ describe Braintree::WebhookNotification do
941
941
  end.to raise_error(Braintree::InvalidChallenge, /challenge contains non-hex characters/)
942
942
  end
943
943
  end
944
+
945
+ describe "refund failed" do
946
+ it "builds a sample notification for refund failed" do
947
+ sample_notification = Braintree::WebhookTesting.sample_notification(
948
+ Braintree::WebhookNotification::Kind::RefundFailed,
949
+ "my_id",
950
+ )
951
+ notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
952
+ expect(notification.kind.should).to eq(Braintree::WebhookNotification::Kind::RefundFailed)
953
+ expect(notification.transaction.id).to eq("my_id")
954
+ end
955
+ end
944
956
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: braintree
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.20.0
4
+ version: 4.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braintree
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-26 00:00:00.000000000 Z
11
+ date: 2024-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder