braintree 4.40.0 → 4.41.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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/client_token_gateway.rb +10 -1
  3. data/lib/braintree/credit_card_gateway.rb +8 -2
  4. data/lib/braintree/credit_card_verification_gateway.rb +2 -0
  5. data/lib/braintree/customer_gateway.rb +11 -3
  6. data/lib/braintree/http.rb +4 -2
  7. data/lib/braintree/merchant_account_gateway.rb +2 -0
  8. data/lib/braintree/payment_method_gateway.rb +6 -1
  9. data/lib/braintree/payment_method_nonce_gateway.rb +4 -0
  10. data/lib/braintree/paypal_account_gateway.rb +6 -1
  11. data/lib/braintree/plan_gateway.rb +4 -0
  12. data/lib/braintree/sepa_direct_debit_account_gateway.rb +4 -0
  13. data/lib/braintree/subscription_gateway.rb +6 -0
  14. data/lib/braintree/testing_gateway.rb +4 -0
  15. data/lib/braintree/transaction.rb +6 -0
  16. data/lib/braintree/transaction_gateway.rb +16 -7
  17. data/lib/braintree/transaction_line_item_gateway.rb +3 -1
  18. data/lib/braintree/transaction_search.rb +1 -0
  19. data/lib/braintree/us_bank_account_gateway.rb +2 -0
  20. data/lib/braintree/us_bank_account_verification_gateway.rb +4 -0
  21. data/lib/braintree/version.rb +1 -1
  22. data/spec/integration/braintree/client_api/client_token_spec.rb +14 -0
  23. data/spec/integration/braintree/customer_spec.rb +43 -0
  24. data/spec/integration/braintree/transaction_search_spec.rb +95 -0
  25. data/spec/integration/braintree/transaction_spec.rb +81 -1
  26. data/spec/unit/braintree/client_token_spec.rb +72 -0
  27. data/spec/unit/braintree/credit_card_spec.rb +26 -0
  28. data/spec/unit/braintree/credit_card_verification_spec.rb +8 -0
  29. data/spec/unit/braintree/customer_spec.rb +26 -0
  30. data/spec/unit/braintree/http_spec.rb +44 -0
  31. data/spec/unit/braintree/merchant_account_spec.rb +11 -0
  32. data/spec/unit/braintree/package_tracking_spec.rb +2 -2
  33. data/spec/unit/braintree/payment_method_nonce_spec.rb +14 -0
  34. data/spec/unit/braintree/payment_method_spec.rb +20 -0
  35. data/spec/unit/braintree/paypal_account_spec.rb +20 -0
  36. data/spec/unit/braintree/plan_gateway_spec.rb +30 -0
  37. data/spec/unit/braintree/sepa_debit_account_spec.rb +14 -0
  38. data/spec/unit/braintree/subscription_spec.rb +20 -0
  39. data/spec/unit/braintree/test_transaction_spec.rb +18 -0
  40. data/spec/unit/braintree/transaction_gateway_spec.rb +10 -0
  41. data/spec/unit/braintree/transaction_line_item_spec.rb +11 -0
  42. data/spec/unit/braintree/transaction_search_spec.rb +25 -0
  43. data/spec/unit/braintree/transaction_spec.rb +68 -6
  44. data/spec/unit/braintree/us_bank_account_spec.rb +8 -0
  45. data/spec/unit/braintree/us_bank_account_verification_spec.rb +14 -0
  46. data/spec/unit/braintree/util_spec.rb +37 -0
  47. metadata +7 -3
@@ -21,4 +21,29 @@ describe Braintree::TransactionSearch do
21
21
  search.billing_company "one"
22
22
  end.to raise_error(RuntimeError, "An operator is required")
23
23
  end
24
+
25
+ it "builds a hash for ach_type with a single value (same_day)" do
26
+ search = Braintree::TransactionSearch.new
27
+ search.ach_type.is Braintree::Transaction::AchType::SameDay
28
+ expect(search.to_hash).to eq({:ach_type => [Braintree::Transaction::AchType::SameDay]})
29
+ end
30
+
31
+ it "builds a hash for ach_type with a single value (standard)" do
32
+ search = Braintree::TransactionSearch.new
33
+ search.ach_type.is Braintree::Transaction::AchType::Standard
34
+ expect(search.to_hash).to eq({:ach_type => [Braintree::Transaction::AchType::Standard]})
35
+ end
36
+
37
+ it "builds a hash for ach_type with both values" do
38
+ search = Braintree::TransactionSearch.new
39
+ search.ach_type.in Braintree::Transaction::AchType::SameDay, Braintree::Transaction::AchType::Standard
40
+ expect(search.to_hash).to eq({:ach_type => [Braintree::Transaction::AchType::SameDay, Braintree::Transaction::AchType::Standard]})
41
+ end
42
+
43
+ it "raises if ach_type is given a value outside the allow-list" do
44
+ search = Braintree::TransactionSearch.new
45
+ expect do
46
+ search.ach_type.is "invalid_ach_type"
47
+ end.to raise_error(ArgumentError, /Invalid argument\(s\) for ach_type: invalid_ach_type/)
48
+ end
24
49
  end
@@ -40,8 +40,8 @@ describe Braintree::Transaction do
40
40
  describe "self.submit_for_settlement" do
41
41
  it "raises an ArgumentError if transaction_id is an invalid format" do
42
42
  expect do
43
- Braintree::Transaction.submit_for_settlement("invalid-transaction-id")
44
- end.to raise_error(ArgumentError, "transaction_id is invalid")
43
+ Braintree::Transaction.submit_for_settlement("invalid/transaction/id")
44
+ end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
45
45
  end
46
46
 
47
47
  it "raises an ArgumentError if options hash includes an invalid key" do
@@ -54,16 +54,16 @@ describe Braintree::Transaction do
54
54
  describe "self.adjust_authorization" do
55
55
  it "raises an ArgumentError if transaction_id is an invalid format" do
56
56
  expect do
57
- Braintree::Transaction.adjust_authorization("invalid-transaction-id", "10.00")
58
- end.to raise_error(ArgumentError, "transaction_id is invalid")
57
+ Braintree::Transaction.adjust_authorization("invalid/transaction/id", "10.00")
58
+ end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
59
59
  end
60
60
  end
61
61
 
62
62
  describe "self.update_details" do
63
63
  it "raises an ArgumentError if transaction_id is an invalid format" do
64
64
  expect do
65
- Braintree::Transaction.update_details("invalid-transaction-id")
66
- end.to raise_error(ArgumentError, "transaction_id is invalid")
65
+ Braintree::Transaction.update_details("invalid/transaction/id")
66
+ end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
67
67
  end
68
68
  end
69
69
 
@@ -604,4 +604,66 @@ describe Braintree::Transaction do
604
604
  expect(transaction.surcharge_amount).to be_nil
605
605
  end
606
606
  end
607
+
608
+ describe "path traversal" do
609
+ it "self.clone_transaction raises an exception if the transaction_id is a traversal segment" do
610
+ expect do
611
+ Braintree::Transaction.clone_transaction("../customers/some_id", :amount => "10.00")
612
+ end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
613
+ end
614
+
615
+ it "self.find raises an exception if the id is a traversal segment" do
616
+ expect do
617
+ Braintree::Transaction.find("../customers/some_id")
618
+ end.to raise_error(ArgumentError, "id contains invalid characters")
619
+ end
620
+
621
+ it "self.refund raises an exception if the transaction_id is a traversal segment" do
622
+ expect do
623
+ Braintree::Transaction.refund("../customers/some_id")
624
+ end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
625
+ end
626
+
627
+ it "self.void raises an exception if the transaction_id is a traversal segment" do
628
+ expect do
629
+ Braintree::Transaction.void("../transactions/victim_id")
630
+ end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
631
+ end
632
+
633
+ it "self.cancel_release raises an exception if the transaction_id is a traversal segment" do
634
+ expect do
635
+ Braintree::Transaction.cancel_release("../transactions/victim_id/void")
636
+ end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
637
+ end
638
+
639
+ it "self.package_tracking raises an exception if the transaction_id is a traversal segment" do
640
+ expect do
641
+ Braintree::Transaction.package_tracking("../transactions/victim_id/void", {})
642
+ end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
643
+ end
644
+
645
+ it "self.submit_for_settlement raises an exception if the transaction_id is a traversal segment" do
646
+ expect do
647
+ Braintree::Transaction.submit_for_settlement("../transactions/victim_id/void")
648
+ end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
649
+ end
650
+
651
+ it "self.adjust_authorization raises an exception if the transaction_id is a traversal segment" do
652
+ expect do
653
+ Braintree::Transaction.adjust_authorization("../transactions/victim_id/void", "10.00")
654
+ end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
655
+ end
656
+
657
+ it "self.update_details raises an exception if the transaction_id is a traversal segment" do
658
+ expect do
659
+ Braintree::Transaction.update_details("../transactions/victim_id/void")
660
+ end.to raise_error(ArgumentError, "transaction_id contains invalid characters")
661
+ end
662
+
663
+ it "self.submit_for_partial_settlement raises an exception if the authorized_transaction_id is a traversal segment" do
664
+ expect do
665
+ Braintree::Transaction.submit_for_partial_settlement("../transactions/victim_id/void")
666
+ end.to raise_error(ArgumentError, "authorized_transaction_id contains invalid characters")
667
+ end
668
+ end
607
669
  end
@@ -10,4 +10,12 @@ describe Braintree::UsBankAccount do
10
10
  expect(Braintree::UsBankAccount._new(:gateway, :default => false).default?).to eq(false)
11
11
  end
12
12
  end
13
+
14
+ describe "path traversal" do
15
+ it "self.find raises an exception if the token is a traversal segment" do
16
+ expect do
17
+ Braintree::UsBankAccount.find("../payment_methods/credit_card/victim_token")
18
+ end.to raise_error(ArgumentError, "token contains invalid characters")
19
+ end
20
+ end
13
21
  end
@@ -95,4 +95,18 @@ describe Braintree::UsBankAccountVerification do
95
95
  expect(verification).not_to eq(same_id_different_object)
96
96
  end
97
97
  end
98
+
99
+ describe "path traversal" do
100
+ it "self.find raises an exception if the id is a traversal segment" do
101
+ expect do
102
+ Braintree::UsBankAccountVerification.find("../verifications/victim_id")
103
+ end.to raise_error(ArgumentError, "id contains invalid characters")
104
+ end
105
+
106
+ it "self.confirm_micro_transfer_amounts raises an exception if the id is a traversal segment" do
107
+ expect do
108
+ Braintree::UsBankAccountVerification.confirm_micro_transfer_amounts("../verifications/victim_id", ["0.01", "0.02"])
109
+ end.to raise_error(ArgumentError, "id contains invalid characters")
110
+ end
111
+ end
98
112
  end
@@ -417,4 +417,41 @@ describe Braintree::Util do
417
417
  expect(Braintree::Util.url_decode("foo%3Fbar")).to eq("foo?bar")
418
418
  end
419
419
  end
420
+
421
+ describe "self.invalid_path_segment?" do
422
+ [
423
+ "customer123",
424
+ "CUSTOMER_123",
425
+ "a-b_c-D9",
426
+ "1234567890",
427
+ "a",
428
+ 123,
429
+ ].each do |valid_segment|
430
+ it "returns false for a valid segment #{valid_segment.inspect}" do
431
+ expect(Braintree::Util.invalid_path_segment?(valid_segment)).to eq(false)
432
+ end
433
+ end
434
+
435
+ [
436
+ "",
437
+ " ",
438
+ ".",
439
+ "..",
440
+ "foo/bar",
441
+ "foo\\bar",
442
+ "foo%bar",
443
+ "..%2f..%2fvictim",
444
+ "%2e%2e",
445
+ "../../victim_customer/addresses/victim_address",
446
+ "abc.def",
447
+ "abc def",
448
+ nil,
449
+ {},
450
+ [],
451
+ ].each do |invalid_segment|
452
+ it "returns true for an invalid segment #{invalid_segment.inspect}" do
453
+ expect(Braintree::Util.invalid_path_segment?(invalid_segment)).to eq(true)
454
+ end
455
+ end
456
+ end
420
457
  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.40.0
4
+ version: 4.41.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braintree
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-08-05 00:00:00.000000000 Z
11
+ date: 2026-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -356,6 +356,7 @@ files:
356
356
  - spec/unit/braintree/local_payment_context_spec.rb
357
357
  - spec/unit/braintree/local_payment_expired_spec.rb
358
358
  - spec/unit/braintree/local_payment_funded_spec.rb
359
+ - spec/unit/braintree/merchant_account_spec.rb
359
360
  - spec/unit/braintree/meta_checkout_card_details_spec.rb
360
361
  - spec/unit/braintree/meta_checkout_card_spec.rb
361
362
  - spec/unit/braintree/meta_checkout_token_details_spec.rb
@@ -370,6 +371,7 @@ files:
370
371
  - spec/unit/braintree/payment_method_spec.rb
371
372
  - spec/unit/braintree/paypal_account_spec.rb
372
373
  - spec/unit/braintree/paypal_payment_resource_spec.rb
374
+ - spec/unit/braintree/plan_gateway_spec.rb
373
375
  - spec/unit/braintree/resource_collection_spec.rb
374
376
  - spec/unit/braintree/risk_data/liability_shift.rb
375
377
  - spec/unit/braintree/risk_data_spec.rb
@@ -380,6 +382,7 @@ files:
380
382
  - spec/unit/braintree/subscription_search_spec.rb
381
383
  - spec/unit/braintree/subscription_spec.rb
382
384
  - spec/unit/braintree/successful_result_spec.rb
385
+ - spec/unit/braintree/test_transaction_spec.rb
383
386
  - spec/unit/braintree/three_d_secure_info_spec.rb
384
387
  - spec/unit/braintree/transaction/apple_pay_details_spec.rb
385
388
  - spec/unit/braintree/transaction/credit_card_details_spec.rb
@@ -396,6 +399,7 @@ files:
396
399
  - spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb
397
400
  - spec/unit/braintree/transaction_ach_mandate_spec.rb
398
401
  - spec/unit/braintree/transaction_gateway_spec.rb
402
+ - spec/unit/braintree/transaction_line_item_spec.rb
399
403
  - spec/unit/braintree/transaction_search_spec.rb
400
404
  - spec/unit/braintree/transaction_spec.rb
401
405
  - spec/unit/braintree/unknown_payment_method_spec.rb
@@ -438,7 +442,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
438
442
  - !ruby/object:Gem::Version
439
443
  version: '0'
440
444
  requirements: []
441
- rubygems_version: 3.3.15
445
+ rubygems_version: 3.5.22
442
446
  signing_key:
443
447
  specification_version: 4
444
448
  summary: Braintree Ruby Server SDK