braintree 4.26.0 → 4.28.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 (86) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/apple_pay_card.rb +4 -0
  3. data/lib/braintree/bin_data.rb +7 -2
  4. data/lib/braintree/configuration.rb +1 -1
  5. data/lib/braintree/credit_card.rb +11 -5
  6. data/lib/braintree/credit_card_gateway.rb +1 -0
  7. data/lib/braintree/credit_card_verification_gateway.rb +1 -0
  8. data/lib/braintree/customer_session_gateway.rb +11 -10
  9. data/lib/braintree/error_codes.rb +5 -104
  10. data/lib/braintree/google_pay_card.rb +4 -0
  11. data/lib/braintree/graphql/enums/recommendations.rb +2 -0
  12. data/lib/braintree/graphql/enums/recommended_payment_option.rb +2 -0
  13. data/lib/braintree/graphql/inputs/create_customer_session_input.rb +10 -1
  14. data/lib/braintree/graphql/inputs/customer_recommendations_input.rb +7 -8
  15. data/lib/braintree/graphql/inputs/customer_session_input.rb +6 -0
  16. data/lib/braintree/graphql/inputs/monetary_amount_input.rb +28 -0
  17. data/lib/braintree/graphql/inputs/paypal_payee_input.rb +28 -0
  18. data/lib/braintree/graphql/inputs/paypal_purchase_unit_input.rb +31 -0
  19. data/lib/braintree/graphql/inputs/phone_input.rb +2 -0
  20. data/lib/braintree/graphql/inputs/update_customer_session_input.rb +5 -0
  21. data/lib/braintree/graphql/types/customer_recommendations_payload.rb +112 -18
  22. data/lib/braintree/graphql/types/payment_options.rb +2 -0
  23. data/lib/braintree/graphql/types/payment_recommendations.rb +35 -0
  24. data/lib/braintree/graphql/unions/customer_recommendations.rb +38 -25
  25. data/lib/braintree/merchant_account.rb +1 -25
  26. data/lib/braintree/merchant_account_gateway.rb +0 -81
  27. data/lib/braintree/meta_checkout_card.rb +8 -4
  28. data/lib/braintree/meta_checkout_token.rb +10 -6
  29. data/lib/braintree/payment_method_gateway.rb +3 -0
  30. data/lib/braintree/test/credit_card.rb +4 -0
  31. data/lib/braintree/transaction/apple_pay_details.rb +4 -0
  32. data/lib/braintree/transaction/credit_card_details.rb +8 -0
  33. data/lib/braintree/transaction/google_pay_details.rb +4 -0
  34. data/lib/braintree/transaction/meta_checkout_card_details.rb +9 -3
  35. data/lib/braintree/transaction/meta_checkout_token_details.rb +11 -5
  36. data/lib/braintree/transaction/visa_checkout_card_details.rb +8 -3
  37. data/lib/braintree/transaction.rb +0 -26
  38. data/lib/braintree/transaction_gateway.rb +9 -20
  39. data/lib/braintree/version.rb +1 -1
  40. data/lib/braintree/visa_checkout_card.rb +9 -4
  41. data/lib/braintree/webhook_notification.rb +0 -4
  42. data/lib/braintree/webhook_testing_gateway.rb +0 -33
  43. data/lib/braintree.rb +4 -3
  44. data/spec/integration/braintree/credit_card_spec.rb +101 -0
  45. data/spec/integration/braintree/credit_card_verification_spec.rb +118 -0
  46. data/spec/integration/braintree/customer_session_spec.rb +59 -49
  47. data/spec/integration/braintree/customer_spec.rb +71 -4
  48. data/spec/integration/braintree/disbursement_spec.rb +1 -1
  49. data/spec/integration/braintree/merchant_account_spec.rb +0 -342
  50. data/spec/integration/braintree/payment_method_nonce_spec.rb +44 -0
  51. data/spec/integration/braintree/payment_method_spec.rb +50 -3
  52. data/spec/integration/braintree/transaction_payment_facilitator_spec.rb +119 -0
  53. data/spec/integration/braintree/transaction_spec.rb +60 -328
  54. data/spec/spec_helper.rb +1 -1
  55. data/spec/unit/braintree/apple_pay_card_spec.rb +4 -0
  56. data/spec/unit/braintree/configuration_spec.rb +1 -1
  57. data/spec/unit/braintree/credit_card_spec.rb +22 -2
  58. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +1 -0
  59. data/spec/unit/braintree/customer_session_gateway_spec.rb +10 -9
  60. data/spec/unit/braintree/customer_spec.rb +2 -1
  61. data/spec/unit/braintree/google_pay_card_spec.rb +20 -0
  62. data/spec/unit/braintree/graphql/create_customer_session_input_spec.rb +25 -4
  63. data/spec/unit/braintree/graphql/customer_recommendations_input_spec.rb +21 -51
  64. data/spec/unit/braintree/graphql/customer_recommendations_spec.rb +40 -0
  65. data/spec/unit/braintree/graphql/update_customer_session_input_spec.rb +21 -7
  66. data/spec/unit/braintree/meta_checkout_card_spec.rb +8 -0
  67. data/spec/unit/braintree/meta_checkout_token_spec.rb +4 -0
  68. data/spec/unit/braintree/payment_method_nonce_spec.rb +9 -2
  69. data/spec/unit/braintree/payment_method_spec.rb +12 -0
  70. data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +20 -0
  71. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -1
  72. data/spec/unit/braintree/transaction/google_pay_details_spec.rb +20 -0
  73. data/spec/unit/braintree/transaction/meta_checkout_card_details_spec.rb +20 -0
  74. data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +20 -0
  75. data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +20 -0
  76. data/spec/unit/braintree/transaction_gateway_spec.rb +19 -0
  77. data/spec/unit/braintree/transaction_spec.rb +8 -0
  78. data/spec/unit/braintree/visa_checkout_card_spec.rb +20 -0
  79. data/spec/unit/braintree/webhook_notification_spec.rb +0 -53
  80. data/spec/unit/credit_card_details_spec.rb +20 -0
  81. metadata +8 -7
  82. data/lib/braintree/merchant_account/business_details.rb +0 -17
  83. data/lib/braintree/merchant_account/funding_details.rb +0 -18
  84. data/lib/braintree/merchant_account/individual_details.rb +0 -20
  85. data/spec/unit/braintree/disbursement_spec.rb +0 -131
  86. data/spec/unit/braintree/merchant_account_spec.rb +0 -33
@@ -310,25 +310,6 @@ describe Braintree::WebhookNotification do
310
310
  expect(notification.transaction.disbursement_details.disbursement_date).to eq(Date.parse("2013-07-09"))
311
311
  end
312
312
 
313
- it "builds a sample notification for a disbursement_exception webhook" do
314
- sample_notification = Braintree::WebhookTesting.sample_notification(
315
- Braintree::WebhookNotification::Kind::DisbursementException,
316
- "my_id",
317
- )
318
-
319
- notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
320
-
321
- expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::DisbursementException)
322
- expect(notification.disbursement.id).to eq("my_id")
323
- expect(notification.disbursement.transaction_ids).to eq(%W{ afv56j kj8hjk })
324
- expect(notification.disbursement.retry).to be(false)
325
- expect(notification.disbursement.success).to be(false)
326
- expect(notification.disbursement.exception_message).to eq("bank_rejected")
327
- expect(notification.disbursement.disbursement_date).to eq(Date.parse("2014-02-10"))
328
- expect(notification.disbursement.follow_up_action).to eq("update_funding_information")
329
- expect(notification.disbursement.merchant_account.id).to eq("merchant_account_token")
330
- end
331
-
332
313
  it "builds a sample notification for a disbursement webhook" do
333
314
  sample_notification = Braintree::WebhookTesting.sample_notification(
334
315
  Braintree::WebhookNotification::Kind::Disbursement,
@@ -403,40 +384,6 @@ describe Braintree::WebhookNotification do
403
384
  end
404
385
  end
405
386
 
406
- context "merchant account" do
407
- it "builds a sample notification for a merchant account approved webhook" do
408
- sample_notification = Braintree::WebhookTesting.sample_notification(
409
- Braintree::WebhookNotification::Kind::SubMerchantAccountApproved,
410
- "my_id",
411
- )
412
-
413
- notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
414
-
415
- expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::SubMerchantAccountApproved)
416
- expect(notification.merchant_account.id).to eq("my_id")
417
- expect(notification.merchant_account.status).to eq(Braintree::MerchantAccount::Status::Active)
418
- expect(notification.merchant_account.master_merchant_account.id).to eq("master_ma_for_my_id")
419
- expect(notification.merchant_account.master_merchant_account.status).to eq(Braintree::MerchantAccount::Status::Active)
420
- end
421
-
422
- it "builds a sample notification for a merchant account declined webhook" do
423
- sample_notification = Braintree::WebhookTesting.sample_notification(
424
- Braintree::WebhookNotification::Kind::SubMerchantAccountDeclined,
425
- "my_id",
426
- )
427
-
428
- notification = Braintree::WebhookNotification.parse(sample_notification[:bt_signature], sample_notification[:bt_payload])
429
-
430
- expect(notification.kind).to eq(Braintree::WebhookNotification::Kind::SubMerchantAccountDeclined)
431
- expect(notification.merchant_account.id).to eq("my_id")
432
- expect(notification.merchant_account.status).to eq(Braintree::MerchantAccount::Status::Suspended)
433
- expect(notification.merchant_account.master_merchant_account.id).to eq("master_ma_for_my_id")
434
- expect(notification.merchant_account.master_merchant_account.status).to eq(Braintree::MerchantAccount::Status::Suspended)
435
- expect(notification.message).to eq("Credit score is too low")
436
- expect(notification.errors.for(:merchant_account).on(:base).first.code).to eq(Braintree::ErrorCodes::MerchantAccount::DeclinedOFAC)
437
- end
438
- end
439
-
440
387
  context "subscription" do
441
388
  it "builds a sample notification for a subscription billing skipped webhook" do
442
389
  sample_notification = Braintree::WebhookTesting.sample_notification(
@@ -5,4 +5,24 @@ describe Braintree::CreditCardDetails do
5
5
  card = Braintree::CreditCardDetails._new(:gateway, {:prepaid_reloadable => "No"})
6
6
  expect(card.prepaid_reloadable).to eq("No")
7
7
  end
8
+
9
+ it "initializes business correctly" do
10
+ card = Braintree::CreditCardDetails._new(:gateway, {:business => "No"})
11
+ expect(card.business).to eq("No")
12
+ end
13
+
14
+ it "initializes consumer correctly" do
15
+ card = Braintree::CreditCardDetails._new(:gateway, {:consumer => "No"})
16
+ expect(card.consumer).to eq("No")
17
+ end
18
+
19
+ it "initializes corporate correctly" do
20
+ card = Braintree::CreditCardDetails._new(:gateway, {:corporate => "No"})
21
+ expect(card.corporate).to eq("No")
22
+ end
23
+
24
+ it "initializes purchase correctly" do
25
+ card = Braintree::CreditCardDetails._new(:gateway, {:purchase => "No"})
26
+ expect(card.purchase).to eq("No")
27
+ end
8
28
  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.26.0
4
+ version: 4.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braintree
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-03 00:00:00.000000000 Z
11
+ date: 2025-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -114,10 +114,14 @@ files:
114
114
  - lib/braintree/graphql/inputs/create_customer_session_input.rb
115
115
  - lib/braintree/graphql/inputs/customer_recommendations_input.rb
116
116
  - lib/braintree/graphql/inputs/customer_session_input.rb
117
+ - lib/braintree/graphql/inputs/monetary_amount_input.rb
118
+ - lib/braintree/graphql/inputs/paypal_payee_input.rb
119
+ - lib/braintree/graphql/inputs/paypal_purchase_unit_input.rb
117
120
  - lib/braintree/graphql/inputs/phone_input.rb
118
121
  - lib/braintree/graphql/inputs/update_customer_session_input.rb
119
122
  - lib/braintree/graphql/types/customer_recommendations_payload.rb
120
123
  - lib/braintree/graphql/types/payment_options.rb
124
+ - lib/braintree/graphql/types/payment_recommendations.rb
121
125
  - lib/braintree/graphql/unions/customer_recommendations.rb
122
126
  - lib/braintree/graphql_client.rb
123
127
  - lib/braintree/http.rb
@@ -129,9 +133,6 @@ files:
129
133
  - lib/braintree/merchant.rb
130
134
  - lib/braintree/merchant_account.rb
131
135
  - lib/braintree/merchant_account/address_details.rb
132
- - lib/braintree/merchant_account/business_details.rb
133
- - lib/braintree/merchant_account/funding_details.rb
134
- - lib/braintree/merchant_account/individual_details.rb
135
136
  - lib/braintree/merchant_account_gateway.rb
136
137
  - lib/braintree/merchant_gateway.rb
137
138
  - lib/braintree/meta_checkout_card.rb
@@ -280,6 +281,7 @@ files:
280
281
  - spec/integration/braintree/test/transaction_amounts_spec.rb
281
282
  - spec/integration/braintree/test_transaction_spec.rb
282
283
  - spec/integration/braintree/transaction_line_item_spec.rb
284
+ - spec/integration/braintree/transaction_payment_facilitator_spec.rb
283
285
  - spec/integration/braintree/transaction_search_spec.rb
284
286
  - spec/integration/braintree/transaction_spec.rb
285
287
  - spec/integration/braintree/transaction_us_bank_account_spec.rb
@@ -308,7 +310,6 @@ files:
308
310
  - spec/unit/braintree/customer_session_gateway_spec.rb
309
311
  - spec/unit/braintree/customer_spec.rb
310
312
  - spec/unit/braintree/digest_spec.rb
311
- - spec/unit/braintree/disbursement_spec.rb
312
313
  - spec/unit/braintree/dispute_search_spec.rb
313
314
  - spec/unit/braintree/dispute_spec.rb
314
315
  - spec/unit/braintree/document_upload_spec.rb
@@ -323,6 +324,7 @@ files:
323
324
  - spec/unit/braintree/google_pay_card_spec.rb
324
325
  - spec/unit/braintree/graphql/create_customer_session_input_spec.rb
325
326
  - spec/unit/braintree/graphql/customer_recommendations_input_spec.rb
327
+ - spec/unit/braintree/graphql/customer_recommendations_spec.rb
326
328
  - spec/unit/braintree/graphql/customer_session_input_spec.rb
327
329
  - spec/unit/braintree/graphql/phone_input_spec.rb
328
330
  - spec/unit/braintree/graphql/update_customer_session_input_spec.rb
@@ -331,7 +333,6 @@ files:
331
333
  - spec/unit/braintree/local_payment_completed_spec.rb
332
334
  - spec/unit/braintree/local_payment_expired_spec.rb
333
335
  - spec/unit/braintree/local_payment_funded_spec.rb
334
- - spec/unit/braintree/merchant_account_spec.rb
335
336
  - spec/unit/braintree/meta_checkout_card_details_spec.rb
336
337
  - spec/unit/braintree/meta_checkout_card_spec.rb
337
338
  - spec/unit/braintree/meta_checkout_token_details_spec.rb
@@ -1,17 +0,0 @@
1
- module Braintree
2
- class MerchantAccount
3
- class BusinessDetails
4
- include BaseModule
5
-
6
- attr_reader :address_details
7
- attr_reader :dba_name
8
- attr_reader :legal_name
9
- attr_reader :tax_id
10
-
11
- def initialize(attributes)
12
- set_instance_variables_from_hash attributes unless attributes.nil?
13
- @address_details = MerchantAccount::AddressDetails.new(@address)
14
- end
15
- end
16
- end
17
- end
@@ -1,18 +0,0 @@
1
- module Braintree
2
- class MerchantAccount
3
- class FundingDetails
4
- include BaseModule
5
-
6
- attr_reader :account_number_last_4
7
- attr_reader :descriptor
8
- attr_reader :destination
9
- attr_reader :email
10
- attr_reader :mobile_phone
11
- attr_reader :routing_number
12
-
13
- def initialize(attributes)
14
- set_instance_variables_from_hash attributes unless attributes.nil?
15
- end
16
- end
17
- end
18
- end
@@ -1,20 +0,0 @@
1
- module Braintree
2
- class MerchantAccount
3
- class IndividualDetails
4
- include BaseModule
5
-
6
- attr_reader :address_details
7
- attr_reader :date_of_birth
8
- attr_reader :email
9
- attr_reader :first_name
10
- attr_reader :last_name
11
- attr_reader :phone
12
- attr_reader :ssn_last_4
13
-
14
- def initialize(attributes)
15
- set_instance_variables_from_hash attributes unless attributes.nil?
16
- @address_details = MerchantAccount::AddressDetails.new(@address)
17
- end
18
- end
19
- end
20
- end
@@ -1,131 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
-
3
- describe Braintree::Disbursement do
4
- describe "new" do
5
- it "is protected" do
6
- expect do
7
- Braintree::Disbursement.new
8
- end.to raise_error(NoMethodError, /protected method .new/)
9
- end
10
- end
11
-
12
- describe "inspect" do
13
- it "prints attributes of disbursement object" do
14
- disbursement = Braintree::Disbursement._new(
15
- :gateway,
16
- :id => "123456",
17
- :merchant_account => {
18
- :id => "sandbox_sub_merchant_account",
19
- :master_merchant_account => {
20
- :id => "sandbox_master_merchant_account",
21
- :status => "active"
22
- },
23
- :status => "active"
24
- },
25
- :transaction_ids => ["sub_merchant_transaction"],
26
- :amount => "100.00",
27
- :disbursement_date => "2013-04-10",
28
- :exception_message => "invalid_account_number",
29
- :follow_up_action => "update",
30
- :retry => false,
31
- :success => false,
32
- )
33
-
34
- expect(disbursement.inspect).to include('id: "123456"')
35
- expect(disbursement.inspect).to include('amount: "100.0"')
36
- expect(disbursement.inspect).to include('exception_message: "invalid_account_number"')
37
- expect(disbursement.inspect).to include("disbursement_date: 2013-04-10")
38
- expect(disbursement.inspect).to include('follow_up_action: "update"')
39
- expect(disbursement.inspect).to include("merchant_account: #<Braintree::MerchantAccount: ")
40
- expect(disbursement.inspect).to include('transaction_ids: ["sub_merchant_transaction"]')
41
- expect(disbursement.inspect).to include("retry: false")
42
- expect(disbursement.inspect).to include("success: false")
43
- end
44
- end
45
-
46
- describe "success?" do
47
- it "is an alias of success" do
48
- disbursement = Braintree::Disbursement._new(
49
- :gateway,
50
- :merchant_account => {
51
- :id => "sandbox_sub_merchant_account",
52
- :master_merchant_account => {
53
- :id => "sandbox_master_merchant_account",
54
- :status => "active"
55
- },
56
- :status => "active"
57
- },
58
- :success => false,
59
- :disbursement_date => "2013-04-10",
60
- )
61
- expect(disbursement.success?).to eq(false)
62
-
63
- disbursement = Braintree::Disbursement._new(
64
- :gateway,
65
- :merchant_account => {
66
- :id => "sandbox_sub_merchant_account",
67
- :master_merchant_account => {
68
- :id => "sandbox_master_merchant_account",
69
- :status => "active"
70
- },
71
- :status => "active"
72
- },
73
- :success => true,
74
- :disbursement_date => "2013-04-10",
75
- )
76
- expect(disbursement.success?).to eq(true)
77
- end
78
- end
79
-
80
- describe "credit?" do
81
- subject do
82
- described_class._new(
83
- :gateway,
84
- merchant_account: {
85
- id: "sandbox_master_merchant_account",
86
- status: "active",
87
- },
88
- success: true,
89
- amount: "100.00",
90
- disbursement_type: type,
91
- disbursement_date: "2013-04-10",
92
- )
93
- end
94
-
95
- context "when the disbursement type is credit" do
96
- let(:type) { described_class::Types::Credit }
97
- it { is_expected.to be_credit }
98
- end
99
-
100
- context "when the disbursement type is not credit" do
101
- let(:type) { described_class::Types::Debit }
102
- it { is_expected.not_to be_credit }
103
- end
104
- end
105
-
106
- describe "debit?" do
107
- subject do
108
- described_class._new(
109
- :gateway,
110
- merchant_account: {
111
- id: "sandbox_master_merchant_account",
112
- status: "active",
113
- },
114
- success: true,
115
- amount: "100.00",
116
- disbursement_type: type,
117
- disbursement_date: "2013-04-10",
118
- )
119
- end
120
-
121
- context "when the disbursement type is debit" do
122
- let(:type) { described_class::Types::Debit }
123
- it { is_expected.to be_debit }
124
- end
125
-
126
- context "when the disbursement type is not debit" do
127
- let(:type) { described_class::Types::Credit }
128
- it { is_expected.not_to be_debit }
129
- end
130
- end
131
- end
@@ -1,33 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
-
3
- describe Braintree::MerchantAccount do
4
- describe "#inspect" do
5
- it "is a string representation of the merchant account" do
6
- account = Braintree::MerchantAccount._new(nil, :id => "merchant_account", :status => "active", :master_merchant_account => nil)
7
-
8
- expect(account.inspect).to eq("#<Braintree::MerchantAccount: id: \"merchant_account\", status: \"active\", master_merchant_account: nil>")
9
- end
10
-
11
- it "handles a master merchant account" do
12
- account = Braintree::MerchantAccount._new(
13
- nil,
14
- :id => "merchant_account",
15
- :status => "active",
16
- :master_merchant_account => {:id => "master_merchant_account", :status => "active", :master_merchant_account => nil},
17
- )
18
-
19
- master_merchant_account = "#<Braintree::MerchantAccount: id: \"master_merchant_account\", status: \"active\", master_merchant_account: nil>"
20
- expect(account.inspect).to eq("#<Braintree::MerchantAccount: id: \"merchant_account\", status: \"active\", master_merchant_account: #{master_merchant_account}>")
21
- end
22
- end
23
-
24
- describe "default?" do
25
- it "is an alias of default" do
26
- account = Braintree::MerchantAccount._new(nil, :default => false)
27
- expect(account.default?).to eq(false)
28
- account = Braintree::MerchantAccount._new(nil, :default => true)
29
- expect(account.default?).to eq(true)
30
- end
31
- end
32
- end
33
-