braintree 4.23.0 → 4.34.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 (130) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/address_gateway.rb +5 -0
  3. data/lib/braintree/apple_pay_card.rb +6 -0
  4. data/lib/braintree/bank_account_instant_verification_gateway.rb +38 -0
  5. data/lib/braintree/bank_account_instant_verification_jwt.rb +23 -0
  6. data/lib/braintree/bank_account_instant_verification_jwt_request.rb +21 -0
  7. data/lib/braintree/bin_data.rb +8 -2
  8. data/lib/braintree/configuration.rb +1 -1
  9. data/lib/braintree/credit_card.rb +12 -5
  10. data/lib/braintree/credit_card_gateway.rb +1 -0
  11. data/lib/braintree/credit_card_verification_gateway.rb +5 -2
  12. data/lib/braintree/customer_session_gateway.rb +195 -0
  13. data/lib/braintree/dispute.rb +1 -0
  14. data/lib/braintree/error_codes.rb +58 -104
  15. data/lib/braintree/error_result.rb +1 -1
  16. data/lib/braintree/errors.rb +2 -1
  17. data/lib/braintree/gateway.rb +12 -0
  18. data/lib/braintree/google_pay_card.rb +5 -0
  19. data/lib/braintree/graphql/enums/recommendations.rb +9 -0
  20. data/lib/braintree/graphql/enums/recommended_payment_option.rb +10 -0
  21. data/lib/braintree/graphql/inputs/create_customer_session_input.rb +44 -0
  22. data/lib/braintree/graphql/inputs/customer_recommendations_input.rb +40 -0
  23. data/lib/braintree/graphql/inputs/customer_session_input.rb +45 -0
  24. data/lib/braintree/graphql/inputs/monetary_amount_input.rb +28 -0
  25. data/lib/braintree/graphql/inputs/paypal_payee_input.rb +28 -0
  26. data/lib/braintree/graphql/inputs/paypal_purchase_unit_input.rb +31 -0
  27. data/lib/braintree/graphql/inputs/phone_input.rb +34 -0
  28. data/lib/braintree/graphql/inputs/update_customer_session_input.rb +42 -0
  29. data/lib/braintree/graphql/types/customer_recommendations_payload.rb +129 -0
  30. data/lib/braintree/graphql/types/payment_options.rb +35 -0
  31. data/lib/braintree/graphql/types/payment_recommendations.rb +35 -0
  32. data/lib/braintree/graphql/unions/customer_recommendations.rb +47 -0
  33. data/lib/braintree/graphql_client.rb +16 -0
  34. data/lib/braintree/merchant_account.rb +1 -25
  35. data/lib/braintree/merchant_account_gateway.rb +0 -81
  36. data/lib/braintree/meta_checkout_card.rb +11 -6
  37. data/lib/braintree/meta_checkout_token.rb +11 -6
  38. data/lib/braintree/payment_method_gateway.rb +9 -0
  39. data/lib/braintree/paypal_payment_resource.rb +22 -0
  40. data/lib/braintree/paypal_payment_resource_gateway.rb +36 -0
  41. data/lib/braintree/successful_result.rb +3 -0
  42. data/lib/braintree/test/credit_card.rb +5 -0
  43. data/lib/braintree/transaction/apple_pay_details.rb +7 -0
  44. data/lib/braintree/transaction/credit_card_details.rb +22 -10
  45. data/lib/braintree/transaction/google_pay_details.rb +16 -10
  46. data/lib/braintree/transaction/meta_checkout_card_details.rb +11 -2
  47. data/lib/braintree/transaction/meta_checkout_token_details.rb +13 -3
  48. data/lib/braintree/transaction/paypal_details.rb +2 -0
  49. data/lib/braintree/transaction/visa_checkout_card_details.rb +10 -2
  50. data/lib/braintree/transaction.rb +3 -26
  51. data/lib/braintree/transaction_gateway.rb +52 -31
  52. data/lib/braintree/us_bank_account_verification.rb +3 -1
  53. data/lib/braintree/version.rb +1 -1
  54. data/lib/braintree/visa_checkout_card.rb +10 -5
  55. data/lib/braintree/webhook_notification.rb +1 -4
  56. data/lib/braintree/webhook_testing_gateway.rb +16 -33
  57. data/lib/braintree/xml/{libxml.rb → nokogiri.rb} +18 -16
  58. data/lib/braintree/xml/parser.rb +4 -4
  59. data/lib/braintree.rb +21 -4
  60. data/spec/integration/braintree/advanced_search_spec.rb +7 -4
  61. data/spec/integration/braintree/apple_pay_spec.rb +6 -7
  62. data/spec/integration/braintree/bank_account_instant_verification_spec.rb +191 -0
  63. data/spec/integration/braintree/client_api/spec_helper.rb +81 -0
  64. data/spec/integration/braintree/credit_card_spec.rb +115 -1
  65. data/spec/integration/braintree/credit_card_verification_spec.rb +149 -0
  66. data/spec/integration/braintree/customer_session_spec.rb +154 -0
  67. data/spec/integration/braintree/customer_spec.rb +94 -10
  68. data/spec/integration/braintree/disbursement_spec.rb +1 -1
  69. data/spec/integration/braintree/dispute_spec.rb +13 -2
  70. data/spec/integration/braintree/merchant_account_spec.rb +19 -359
  71. data/spec/integration/braintree/merchant_spec.rb +4 -4
  72. data/spec/integration/braintree/payment_method_nonce_spec.rb +55 -0
  73. data/spec/integration/braintree/payment_method_spec.rb +57 -7
  74. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +0 -3
  75. data/spec/integration/braintree/paypal_payment_resource_spec.rb +141 -0
  76. data/spec/integration/braintree/transaction_payment_facilitator_spec.rb +119 -0
  77. data/spec/integration/braintree/transaction_search_spec.rb +38 -33
  78. data/spec/integration/braintree/transaction_spec.rb +266 -350
  79. data/spec/integration/braintree/transaction_transfer_type_spec.rb +325 -0
  80. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +0 -1
  81. data/spec/integration/braintree/us_bank_account_spec.rb +0 -3
  82. data/spec/integration/braintree/us_bank_account_verification_spec.rb +1 -1
  83. data/spec/spec_helper.rb +46 -12
  84. data/spec/unit/braintree/apple_pay_card_spec.rb +7 -0
  85. data/spec/unit/braintree/bank_account_instant_verification_gateway_spec.rb +98 -0
  86. data/spec/unit/braintree/bank_account_instant_verification_jwt_request_spec.rb +71 -0
  87. data/spec/unit/braintree/client_token_spec.rb +11 -0
  88. data/spec/unit/braintree/configuration_spec.rb +1 -1
  89. data/spec/unit/braintree/credit_card_spec.rb +27 -2
  90. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +1 -0
  91. data/spec/unit/braintree/credit_card_verification_spec.rb +17 -0
  92. data/spec/unit/braintree/customer_session_gateway_spec.rb +122 -0
  93. data/spec/unit/braintree/customer_spec.rb +2 -1
  94. data/spec/unit/braintree/dispute_spec.rb +6 -0
  95. data/spec/unit/braintree/error_result_spec.rb +28 -0
  96. data/spec/unit/braintree/google_pay_card_spec.rb +28 -0
  97. data/spec/unit/braintree/graphql/create_customer_session_input_spec.rb +102 -0
  98. data/spec/unit/braintree/graphql/customer_recommendations_input_spec.rb +80 -0
  99. data/spec/unit/braintree/graphql/customer_recommendations_spec.rb +40 -0
  100. data/spec/unit/braintree/graphql/customer_session_input_spec.rb +81 -0
  101. data/spec/unit/braintree/graphql/phone_input_spec.rb +51 -0
  102. data/spec/unit/braintree/graphql/update_customer_session_input_spec.rb +107 -0
  103. data/spec/unit/braintree/graphql_client_spec.rb +37 -0
  104. data/spec/unit/braintree/meta_checkout_card_spec.rb +61 -51
  105. data/spec/unit/braintree/meta_checkout_token_spec.rb +7 -1
  106. data/spec/unit/braintree/payment_method_nonce_spec.rb +11 -1
  107. data/spec/unit/braintree/payment_method_spec.rb +12 -0
  108. data/spec/unit/braintree/paypal_payment_resource_spec.rb +125 -0
  109. data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +37 -0
  110. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +15 -1
  111. data/spec/unit/braintree/transaction/google_pay_details_spec.rb +37 -0
  112. data/spec/unit/braintree/transaction/meta_checkout_card_details_spec.rb +28 -0
  113. data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +28 -0
  114. data/spec/unit/braintree/transaction/paypal_details_spec.rb +5 -0
  115. data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +28 -0
  116. data/spec/unit/braintree/transaction_ach_mandate_spec.rb +82 -0
  117. data/spec/unit/braintree/transaction_gateway_spec.rb +58 -11
  118. data/spec/unit/braintree/transaction_spec.rb +66 -0
  119. data/spec/unit/braintree/visa_checkout_card_spec.rb +28 -0
  120. data/spec/unit/braintree/webhook_notification_spec.rb +15 -51
  121. data/spec/unit/braintree/xml/{libxml_spec.rb → nokogiri_spec.rb} +7 -7
  122. data/spec/unit/braintree/xml/parser_spec.rb +57 -0
  123. data/spec/unit/credit_card_details_spec.rb +28 -0
  124. metadata +49 -10
  125. data/lib/braintree/merchant_account/business_details.rb +0 -17
  126. data/lib/braintree/merchant_account/funding_details.rb +0 -18
  127. data/lib/braintree/merchant_account/individual_details.rb +0 -20
  128. data/lib/ssl/securetrust_ca.crt +0 -44
  129. data/spec/unit/braintree/disbursement_spec.rb +0 -131
  130. data/spec/unit/braintree/merchant_account_spec.rb +0 -33
@@ -0,0 +1,325 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+ require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
3
+
4
+ describe Braintree::Transaction do
5
+ describe "self.transfer type" do
6
+ it "should create a transaction with valid transfer types and merchant account id" do
7
+ transaction_params = {
8
+ :type => "sale",
9
+ :amount => "100.00",
10
+ :merchant_account_id => "aft_first_data_wallet_transfer",
11
+ :credit_card => {
12
+ :number => "4111111111111111",
13
+ :expiration_date => "06/2026",
14
+ :cvv => "123"
15
+ },
16
+ :transfer => {
17
+ :type => "wallet_transfer",
18
+ :receiver => {
19
+ :first_name => "John",
20
+ :last_name => "Smith",
21
+ :middle_name => "D",
22
+ :address => {
23
+ :country_code_alpha2 => "US",
24
+ :locality => "LA",
25
+ :region => "CA",
26
+ :street_address => "1st Main"
27
+ }
28
+ },
29
+ :sender => {
30
+ :account_reference_number => "123456789",
31
+ :date_of_birth => Date.new(2002, 1, 2),
32
+ :first_name => "Lisa",
33
+ :last_name => "Ray",
34
+ :middle_name => "D",
35
+ :address => {
36
+ :country_code_alpha2 => "US",
37
+ :locality => "LA",
38
+ :region => "CA",
39
+ :street_address => "12th Main"
40
+ }
41
+ },
42
+ }
43
+ }
44
+
45
+ result = Braintree::Transaction.sale(transaction_params)
46
+ expect(result.success?).to eq(true)
47
+ expect(result.transaction.account_funding_transaction).to eq(true)
48
+ expect(result.transaction.status).to eq(Braintree::Transaction::Status::Authorized)
49
+ end
50
+
51
+ it "should fail on transaction with non brazil merchant" do
52
+ transaction_params = {
53
+ :type => "sale",
54
+ :amount => "100.00",
55
+ :merchant_account_id => "aft_first_data_wallet_transfer",
56
+ :credit_card => {
57
+ :number => "4111111111111111",
58
+ :expiration_date => "06/2026",
59
+ :cvv => "123"
60
+ },
61
+ :transfer => {
62
+ :type => "invalid_transfer",
63
+ },
64
+ }
65
+
66
+ result = Braintree::Transaction.sale(transaction_params)
67
+ expect(result.success?).to eq(false)
68
+ end
69
+
70
+ it "should create a transaction with valid transfer types and merchant account id" do
71
+ SpecHelper::SdwoSupportedTransferTypes.each do |transfer_type|
72
+ transaction_params = {
73
+ :type => "sale",
74
+ :amount => "100.00",
75
+ :merchant_account_id => "card_processor_brl_sdwo",
76
+ :credit_card => {
77
+ :number => "4111111111111111",
78
+ :expiration_date => "06/2026",
79
+ :cvv => "123"
80
+ },
81
+ :descriptor => {
82
+ :name => "companynme12*product1",
83
+ :phone => "1232344444",
84
+ :url => "example.com",
85
+ },
86
+ :billing => {
87
+ :first_name => "Bob James",
88
+ :country_code_alpha2 => "CA",
89
+ :extended_address => "",
90
+ :locality => "Trois-Rivires",
91
+ :region => "QC",
92
+ :postal_code => "G8Y 156",
93
+ :street_address => "2346 Boul Lane",
94
+ },
95
+ :transfer => {
96
+ :type => transfer_type,
97
+ :sender => {
98
+ :first_name => "Alice",
99
+ :last_name => "Silva",
100
+ :account_reference_number => "1000012345",
101
+ :tax_id => "12345678900",
102
+ :address => {
103
+ :street_address => "Rua das Flores, 100",
104
+ :extended_address => "2B",
105
+ :locality => "São Paulo",
106
+ :region => "SP",
107
+ :postal_code => "01001-000",
108
+ :country_code_alpha2 => "BR",
109
+ :international_phone => {
110
+ :country_code => "55",
111
+ :national_number => "1234567890"
112
+ }
113
+ }
114
+ },
115
+ :receiver => {
116
+ :first_name => "Bob",
117
+ :last_name => "Souza",
118
+ :account_reference_number => "2000012345",
119
+ :tax_id => "98765432100",
120
+ :address => {
121
+ :street_address => "Avenida Brasil, 200",
122
+ :extended_address => "2B",
123
+ :locality => "Rio de Janeiro",
124
+ :region => "RJ",
125
+ :postal_code => "20040-002",
126
+ :country_code_alpha2 => "BR",
127
+ :international_phone => {
128
+ :country_code => "55",
129
+ :national_number => "9876543210"
130
+ }
131
+ }
132
+ }
133
+ },
134
+ :options => {
135
+ :store_in_vault_on_success => true,
136
+ }
137
+ }
138
+
139
+ result = Braintree::Transaction.sale(transaction_params)
140
+ expect(result.success?).to eq(true)
141
+ expect(result.transaction.status).to eq(Braintree::Transaction::Status::Authorized)
142
+ end
143
+ end
144
+
145
+ it "should fail when transfer details are not provided" do
146
+ transaction_params = {
147
+ :type => "sale",
148
+ :amount => "100.00",
149
+ :merchant_account_id => "card_processor_brl_sdwo",
150
+ :credit_card => {
151
+ :number => "4111111111111111",
152
+ :expiration_date => "06/2026",
153
+ :cvv => "123"
154
+ },
155
+ :descriptor => {
156
+ :name => "companynme12*product1",
157
+ :phone => "1232344444",
158
+ :url => "example.com",
159
+ },
160
+ :billing => {
161
+ :first_name => "Bob James",
162
+ :country_code_alpha2 => "CA",
163
+ :extended_address => "",
164
+ :locality => "Trois-Rivires",
165
+ :region => "QC",
166
+ :postal_code => "G8Y 156",
167
+ :street_address => "2346 Boul Lane",
168
+ },
169
+ :options => {
170
+ :store_in_vault_on_success => true,
171
+ }
172
+ }
173
+
174
+ result = Braintree::Transaction.sale(transaction_params)
175
+ expect(result.success?).to eq(false)
176
+ expect(result.errors.for(:transaction).first.code).to eq(Braintree::ErrorCodes::Transaction::TransactionTransferDetailsAreMandatory)
177
+ end
178
+
179
+ it "should fail on transaction with invalid transfer type" do
180
+ transaction_params = {
181
+ :type => "sale",
182
+ :amount => "100.00",
183
+ :merchant_account_id => "card_processor_brl_sdwo",
184
+ :credit_card => {
185
+ :number => "4111111111111111",
186
+ :expiration_date => "06/2026",
187
+ :cvv => "123"
188
+ },
189
+ :descriptor => {
190
+ :name => "companynme12*product1",
191
+ :phone => "1232344444",
192
+ :url => "example.com",
193
+ },
194
+ :billing => {
195
+ :first_name => "Bob James",
196
+ :country_code_alpha2 => "CA",
197
+ :extended_address => "",
198
+ :locality => "Trois-Rivires",
199
+ :region => "QC",
200
+ :postal_code => "G8Y 156",
201
+ :street_address => "2346 Boul Lane",
202
+ },
203
+ :transfer => {
204
+ :type => "invalid_transfer_type",
205
+ :sender => {
206
+ :first_name => "Alice",
207
+ :last_name => "Silva",
208
+ :account_reference_number => "1000012345",
209
+ :tax_id => "12345678900",
210
+ :address => {
211
+ :street_address => "Rua das Flores, 100",
212
+ :extended_address => "2B",
213
+ :locality => "São Paulo",
214
+ :region => "SP",
215
+ :postal_code => "01001-000",
216
+ :country_code_alpha2 => "BR",
217
+ :international_phone => {
218
+ :country_code => "55",
219
+ :national_number => "1234567890"
220
+ }
221
+ }
222
+ },
223
+ :receiver => {
224
+ :first_name => "Bob",
225
+ :last_name => "Souza",
226
+ :account_reference_number => "2000012345",
227
+ :tax_id => "98765432100",
228
+ :address => {
229
+ :street_address => "Avenida Brasil, 200",
230
+ :extended_address => "2B",
231
+ :locality => "Rio de Janeiro",
232
+ :region => "RJ",
233
+ :postal_code => "20040-002",
234
+ :country_code_alpha2 => "BR",
235
+ :international_phone => {
236
+ :country_code => "55",
237
+ :national_number => "9876543210"
238
+ }
239
+ }
240
+ }
241
+ },
242
+ :options => {
243
+ :store_in_vault_on_success => true,
244
+ }
245
+ }
246
+
247
+ result = Braintree::Transaction.sale(transaction_params)
248
+ expect(result.success?).to eq(false)
249
+ expect(result.errors.for(:account_funding_transaction).first.code).to eq(Braintree::ErrorCodes::Transaction::TransactionTransferTypeIsInvalid)
250
+ end
251
+
252
+ it "should create a transaction when transfer type is nil" do
253
+ transaction_params = {
254
+ :type => "sale",
255
+ :amount => "100.00",
256
+ :merchant_account_id => "card_processor_brl_sdwo",
257
+ :credit_card => {
258
+ :number => "4111111111111111",
259
+ :expiration_date => "06/2026",
260
+ :cvv => "123"
261
+ },
262
+ :descriptor => {
263
+ :name => "companynme12*product1",
264
+ :phone => "1232344444",
265
+ :url => "example.com",
266
+ },
267
+ :billing => {
268
+ :first_name => "Bob James",
269
+ :country_code_alpha2 => "CA",
270
+ :extended_address => "",
271
+ :locality => "Trois-Rivires",
272
+ :region => "QC",
273
+ :postal_code => "G8Y 156",
274
+ :street_address => "2346 Boul Lane",
275
+ },
276
+ :transfer => {
277
+ :type => nil,
278
+ :sender => {
279
+ :first_name => "Alice",
280
+ :last_name => "Silva",
281
+ :account_reference_number => "1000012345",
282
+ :tax_id => "12345678900",
283
+ :address => {
284
+ :street_address => "Rua das Flores, 100",
285
+ :extended_address => "2B",
286
+ :locality => "São Paulo",
287
+ :region => "SP",
288
+ :postal_code => "01001-000",
289
+ :country_code_alpha2 => "BR",
290
+ :international_phone => {
291
+ :country_code => "55",
292
+ :national_number => "1234567890"
293
+ }
294
+ }
295
+ },
296
+ :receiver => {
297
+ :first_name => "Bob",
298
+ :last_name => "Souza",
299
+ :account_reference_number => "2000012345",
300
+ :tax_id => "98765432100",
301
+ :address => {
302
+ :street_address => "Avenida Brasil, 200",
303
+ :extended_address => "2B",
304
+ :locality => "Rio de Janeiro",
305
+ :region => "RJ",
306
+ :postal_code => "20040-002",
307
+ :country_code_alpha2 => "BR",
308
+ :international_phone => {
309
+ :country_code => "55",
310
+ :national_number => "9876543210"
311
+ }
312
+ }
313
+ }
314
+ },
315
+ :options => {
316
+ :store_in_vault_on_success => true,
317
+ }
318
+ }
319
+
320
+ result = Braintree::Transaction.sale(transaction_params)
321
+ expect(result.success?).to eq(true)
322
+ expect(result.transaction.status).to eq(Braintree::Transaction::Status::Authorized)
323
+ end
324
+ end
325
+ end
@@ -140,7 +140,6 @@ describe Braintree::Transaction do
140
140
  expect(transaction.us_bank_account_details.account_type).to eq("checking")
141
141
  expect(transaction.us_bank_account_details.account_holder_name).to eq("John Doe")
142
142
  expect(transaction.us_bank_account_details.bank_name).to match(/CHASE/)
143
- expect(transaction.us_bank_account_details.ach_mandate.text).to eq("cl mandate text")
144
143
  expect(transaction.us_bank_account_details.ach_mandate.accepted_at).to be_a Time
145
144
  end
146
145
 
@@ -23,7 +23,6 @@ describe Braintree::UsBankAccount do
23
23
  expect(us_bank_account.account_type).to eq("checking")
24
24
  expect(us_bank_account.account_holder_name).to eq("John Doe")
25
25
  expect(us_bank_account.bank_name).to match(/CHASE/)
26
- expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
27
26
  expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
28
27
  end
29
28
 
@@ -63,7 +62,6 @@ describe Braintree::UsBankAccount do
63
62
  expect(us_bank_account.account_type).to eq("checking")
64
63
  expect(us_bank_account.account_holder_name).to eq("John Doe")
65
64
  expect(us_bank_account.bank_name).to match(/CHASE/)
66
- expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
67
65
  expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
68
66
  end
69
67
  end
@@ -96,7 +94,6 @@ describe Braintree::UsBankAccount do
96
94
  expect(us_bank_account.account_type).to eq("checking")
97
95
  expect(us_bank_account.account_holder_name).to eq("John Doe")
98
96
  expect(us_bank_account.bank_name).to match(/CHASE/)
99
- expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
100
97
  expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
101
98
  end
102
99
 
@@ -50,7 +50,7 @@ describe Braintree::UsBankAccountVerification do
50
50
  expect(response).to be_success
51
51
  expect(response.us_bank_account_verification.status).to eq(Braintree::UsBankAccountVerification::Status::Verified)
52
52
 
53
- us_bank_account = Braintree::UsBankAccount.find(response.us_bank_account_verification.us_bank_account[:token])
53
+ us_bank_account = Braintree::UsBankAccount.find(response.us_bank_account_verification.us_bank_account.token)
54
54
 
55
55
  expect(us_bank_account.verified).to be_truthy
56
56
  end
data/spec/spec_helper.rb CHANGED
@@ -3,8 +3,8 @@ unless defined?(SPEC_HELPER_LOADED)
3
3
  project_root = File.expand_path(File.dirname(__FILE__) + "/..")
4
4
  require "rubygems"
5
5
  require "bundler/setup"
6
- require "libxml"
7
6
  require "rspec"
7
+ require "rspec/retry"
8
8
  require "pry"
9
9
 
10
10
  braintree_lib = "#{project_root}/lib"
@@ -34,13 +34,13 @@ unless defined?(SPEC_HELPER_LOADED)
34
34
  AibSwedenMaMerchantAccountId = "aib_swe_ma"
35
35
  AnotherUsBankMerchantAccountId = "another_us_bank_merchant_account"
36
36
  CardProcessorBRLMerchantAccountId = "card_processor_brl"
37
+ CardProcessorBRLPayFacMerchantAccountId = "card_processor_brl_payfac"
37
38
  DefaultMerchantAccountId = "sandbox_credit_card"
38
39
  FakeAmexDirectMerchantAccountId = "fake_amex_direct_usd"
39
40
  FakeFirstDataMerchantAccountId = "fake_first_data_merchant_account"
40
41
  FakeVenmoAccountMerchantAccountId = "fake_first_data_venmo_account"
41
42
  HiperBRLMerchantAccountId = "hiper_brl"
42
43
  NonDefaultMerchantAccountId = "sandbox_credit_card_non_default"
43
- NonDefaultSubMerchantAccountId = "sandbox_sub_merchant_account"
44
44
  PinlessDebitMerchantAccountId = "pinless_debit"
45
45
  ThreeDSecureMerchantAccountId = "three_d_secure_merchant_account"
46
46
  UsBankMerchantAccountId = "us_bank_merchant_account"
@@ -77,6 +77,13 @@ unless defined?(SPEC_HELPER_LOADED)
77
77
  :billing_day_of_month => 5
78
78
  }
79
79
 
80
+ SdwoSupportedTransferTypes = [
81
+ "account_to_account",
82
+ "boleto_ticket",
83
+ "person_to_person",
84
+ "wallet_transfer"
85
+ ]
86
+
80
87
  AddOnIncrease10 = "increase_10"
81
88
  AddOnIncrease20 = "increase_20"
82
89
  AddOnIncrease30 = "increase_30"
@@ -113,18 +120,40 @@ unless defined?(SPEC_HELPER_LOADED)
113
120
  response[:three_d_secure_verification][:three_d_secure_authentication_id]
114
121
  end
115
122
 
116
- def self.create_merchant(params={})
123
+ def self.get_merchant(params={})
117
124
  gateway = Braintree::Gateway.new(
118
125
  :client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
119
126
  :client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
120
127
  :logger => Logger.new("/dev/null"),
121
128
  )
122
129
 
123
- gateway.merchant.create({
124
- :email => "name@email.com",
125
- :country_code_alpha3 => "GBR",
126
- :payment_methods => ["credit_card", "paypal"],
127
- }.merge!(params))
130
+ code = Braintree::OAuthTestHelper.create_grant(gateway, {
131
+ :merchant_public_id => "partner_merchant_id",
132
+ :scope => "read_write"
133
+ })
134
+
135
+ result = gateway.oauth.create_token_from_code(
136
+ :code => code,
137
+ :scope => "read_write",
138
+ )
139
+
140
+ merchant_gateway = Braintree::Gateway.new(
141
+ :access_token => result.credentials.access_token,
142
+ :logger => Logger.new("/dev/null"),
143
+ )
144
+
145
+ ma_result = merchant_gateway.merchant_account.all
146
+
147
+ merchant_obj = OpenStruct.new(
148
+ :id => "partner_merchant_id",
149
+ :merchant_accounts => ma_result.merchant_accounts,
150
+ )
151
+
152
+ OpenStruct.new(
153
+ :success? => true,
154
+ :credentials => result.credentials,
155
+ :merchant => merchant_obj,
156
+ )
128
157
  end
129
158
 
130
159
  def self.stub_time_dot_now(desired_time)
@@ -188,10 +217,10 @@ unless defined?(SPEC_HELPER_LOADED)
188
217
  end
189
218
 
190
219
  def matches?(xml_string)
191
- @libxml_parse = Braintree::Xml::Parser.hash_from_xml(xml_string)
192
- if @libxml_parse != @expected_hash
193
- @results = @libxml_parse
194
- @failed_parser = "libxml"
220
+ @xml_parse = Braintree::Xml::Parser.hash_from_xml(xml_string)
221
+ if @xml_parse != @expected_hash
222
+ @results = @xml_parse
223
+ @failed_parser = "xml"
195
224
  false
196
225
  else
197
226
  true
@@ -228,4 +257,9 @@ RSpec.configure do |config|
228
257
  config.mock_with :rspec do |mock|
229
258
  mock.syntax = [:should, :expect]
230
259
  end
260
+
261
+ config.verbose_retry = true
262
+ config.display_try_failure_messages = true
263
+ config.default_retry_count = 3
264
+ config.default_sleep_interval = 1
231
265
  end
@@ -19,9 +19,12 @@ describe Braintree::ApplePayCard do
19
19
  street_address: "123 Sesame Street",
20
20
  },
21
21
  :bin => "411111",
22
+ :business => "No",
22
23
  :card_type => "Apple Pay - MasterCard",
23
24
  :cardholder_name => "John Miller",
24
25
  :commercial => "No",
26
+ :consumer => "No",
27
+ :corporate => "No",
25
28
  :country_of_issuance => "USA",
26
29
  :created_at => Time.now,
27
30
  :customer_id => "cid1",
@@ -33,13 +36,16 @@ describe Braintree::ApplePayCard do
33
36
  :expired => false,
34
37
  :healthcare => "No",
35
38
  :image_url => nil,
39
+ :is_device_token => false,
36
40
  :issuing_bank => "Big Bad Bank",
37
41
  :last_4 => "9876",
38
42
  :merchant_token_identifier => "merchant-token-123",
39
43
  :payment_instrument_name => nil,
40
44
  :payroll => "No",
41
45
  :prepaid => "No",
46
+ :prepaid_reloadable => "No",
42
47
  :product_id => "MAC",
48
+ :purchase => "No",
43
49
  :source_card_last4 => "1234",
44
50
  :source_description => "blah",
45
51
  :subscriptions => [
@@ -88,6 +94,7 @@ describe Braintree::ApplePayCard do
88
94
  card = Braintree::ApplePayCard._new(:gateway, attributes)
89
95
 
90
96
  expect(card.merchant_token_identifier).to_not be_nil
97
+ expect(card.is_device_token).to_not be_nil
91
98
  expect(card.source_card_last4).to_not be_nil
92
99
  end
93
100
  end
@@ -0,0 +1,98 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::BankAccountInstantVerificationGateway do
4
+ let(:gateway) { double("gateway") }
5
+ let(:config) { double("config") }
6
+ let(:graphql_client) { double("graphql_client") }
7
+ let(:bank_account_instant_verification_gateway) { Braintree::BankAccountInstantVerificationGateway.new(gateway) }
8
+
9
+ before do
10
+ allow(gateway).to receive(:config).and_return(config)
11
+ allow(gateway).to receive(:graphql_client).and_return(graphql_client)
12
+ end
13
+
14
+ describe "create_jwt" do
15
+ let(:request) do
16
+ Braintree::BankAccountInstantVerificationJwtRequest.new(
17
+ :business_name => "Test Business",
18
+ :return_url => "https://example.com/success",
19
+ :cancel_url => "https://example.com/cancel",
20
+ )
21
+ end
22
+
23
+ it "returns success result with valid response" do
24
+ mock_response = {
25
+ :data => {
26
+ :createBankAccountInstantVerificationJwt => {
27
+ :jwt => "test-jwt-token"
28
+ }
29
+ }
30
+ }
31
+
32
+ allow(graphql_client).to receive(:query).and_return(mock_response)
33
+
34
+ result = bank_account_instant_verification_gateway.create_jwt(request)
35
+
36
+ expect(result.success?).to eq(true)
37
+ expect(result.bank_account_instant_verification_jwt).not_to be_nil
38
+ expect(result.bank_account_instant_verification_jwt.jwt).to eq("test-jwt-token")
39
+ end
40
+
41
+ it "returns error result with validation errors" do
42
+ mock_response = {
43
+ :errors => [
44
+ {
45
+ :message => "Validation error",
46
+ :extensions => {}
47
+ }
48
+ ]
49
+ }
50
+
51
+ allow(graphql_client).to receive(:query).and_return(mock_response)
52
+
53
+ result = bank_account_instant_verification_gateway.create_jwt(request)
54
+
55
+ expect(result.success?).to eq(false)
56
+ expect(result.errors).not_to be_nil
57
+ end
58
+
59
+ it "calls GraphQL client with correct mutation" do
60
+ mock_response = {
61
+ :data => {
62
+ :createBankAccountInstantVerificationJwt => {
63
+ :jwt => "test-jwt-token"
64
+ }
65
+ }
66
+ }
67
+
68
+ expect(graphql_client).to receive(:query).with(
69
+ /mutation CreateBankAccountInstantVerificationJwt/,
70
+ {:input=>{:businessName=>"Test Business", :cancelUrl=>"https://example.com/cancel", :returnUrl=>"https://example.com/success"}},
71
+ ).and_return(mock_response)
72
+
73
+ bank_account_instant_verification_gateway.create_jwt(request)
74
+ end
75
+
76
+ it "works with minimal request" do
77
+ minimal_request = Braintree::BankAccountInstantVerificationJwtRequest.new(
78
+ :business_name => "Test Business",
79
+ :return_url => "https://example.com/success",
80
+ )
81
+
82
+ mock_response = {
83
+ :data => {
84
+ :createBankAccountInstantVerificationJwt => {
85
+ :jwt => "test-jwt-token"
86
+ }
87
+ }
88
+ }
89
+
90
+ allow(graphql_client).to receive(:query).and_return(mock_response)
91
+
92
+ result = bank_account_instant_verification_gateway.create_jwt(minimal_request)
93
+
94
+ expect(result.success?).to eq(true)
95
+ expect(result.bank_account_instant_verification_jwt.jwt).to eq("test-jwt-token")
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,71 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::BankAccountInstantVerificationJwtRequest do
4
+ describe "to_graphql_variables" do
5
+ it "includes all fields when present" do
6
+ request = Braintree::BankAccountInstantVerificationJwtRequest.new(
7
+ :business_name => "Test Business",
8
+ :return_url => "https://example.com/success",
9
+ :cancel_url => "https://example.com/cancel",
10
+ )
11
+
12
+ variables = request.to_graphql_variables
13
+
14
+ expect(variables).not_to be_nil
15
+ expect(variables).to have_key(:input)
16
+
17
+ input = variables[:input]
18
+
19
+ expect(input[:businessName]).to eq("Test Business")
20
+ expect(input[:returnUrl]).to eq("https://example.com/success")
21
+ expect(input[:cancelUrl]).to eq("https://example.com/cancel")
22
+ end
23
+
24
+ it "only includes non-null fields" do
25
+ request = Braintree::BankAccountInstantVerificationJwtRequest.new(
26
+ :business_name => "Test Business",
27
+ :return_url => "https://example.com/success",
28
+ )
29
+
30
+ variables = request.to_graphql_variables
31
+
32
+ input = variables[:input]
33
+
34
+ expect(input[:businessName]).to eq("Test Business")
35
+ expect(input[:returnUrl]).to eq("https://example.com/success")
36
+ expect(input).not_to have_key(:cancelUrl)
37
+ end
38
+
39
+ it "handles empty request" do
40
+ request = Braintree::BankAccountInstantVerificationJwtRequest.new
41
+
42
+ variables = request.to_graphql_variables
43
+
44
+ expect(variables).to eq({:input => {}})
45
+ end
46
+ end
47
+
48
+ describe "attribute accessors" do
49
+ it "allows setting and getting all attributes and initializes with hash of attributes" do
50
+ request = Braintree::BankAccountInstantVerificationJwtRequest.new(
51
+ :business_name => "Test Business",
52
+ :return_url => "https://example.com/success",
53
+ :cancel_url => "https://example.com/cancel",
54
+ )
55
+
56
+ expect(request.business_name).to eq("Test Business")
57
+ expect(request.return_url).to eq("https://example.com/success")
58
+ expect(request.cancel_url).to eq("https://example.com/cancel")
59
+
60
+ new_request = Braintree::BankAccountInstantVerificationJwtRequest.new
61
+
62
+ new_request.business_name = "Updated Business"
63
+ new_request.return_url = "https://example.com/updated"
64
+ new_request.cancel_url = "https://example.com/updated-cancel"
65
+
66
+ expect(new_request.business_name).to eq("Updated Business")
67
+ expect(new_request.return_url).to eq("https://example.com/updated")
68
+ expect(new_request.cancel_url).to eq("https://example.com/updated-cancel")
69
+ end
70
+ end
71
+ end