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
@@ -95,10 +95,14 @@ describe Braintree::MerchantAccount do
95
95
  :logger => Logger.new("/dev/null"),
96
96
  )
97
97
 
98
- result = gateway.merchant.create(
99
- :email => "name@email.com",
100
- :country_code_alpha3 => "GBR",
101
- :payment_methods => ["credit_card", "paypal"],
98
+ code = Braintree::OAuthTestHelper.create_grant(gateway, {
99
+ :merchant_public_id => "integration_merchant_id",
100
+ :scope => "read_write"
101
+ })
102
+
103
+ result = gateway.oauth.create_token_from_code(
104
+ :code => code,
105
+ :scope => "read_write",
102
106
  )
103
107
 
104
108
  gateway = Braintree::Gateway.new(
@@ -108,10 +112,8 @@ describe Braintree::MerchantAccount do
108
112
 
109
113
  result = gateway.merchant_account.all
110
114
  expect(result).to be_success
111
- expect(result.merchant_accounts.count).to eq(1)
112
- expect(result.merchant_accounts.first.currency_iso_code).to eq("GBP")
115
+ expect(result.merchant_accounts.count).to be > 0
113
116
  expect(result.merchant_accounts.first.status).to eq("active")
114
- expect(result.merchant_accounts.first.default).to eq(true)
115
117
  end
116
118
 
117
119
  it "returns all merchant accounts for read_only scoped grants" do
@@ -142,93 +144,9 @@ describe Braintree::MerchantAccount do
142
144
  end
143
145
  end
144
146
 
145
- describe "create" do
146
- it "accepts the deprecated parameters" do
147
- result = Braintree::MerchantAccount.create(DEPRECATED_APPLICATION_PARAMS)
148
-
149
- expect(result).to be_success
150
- expect(result.merchant_account.status).to eq(Braintree::MerchantAccount::Status::Pending)
151
- expect(result.merchant_account.master_merchant_account.id).to eq("sandbox_master_merchant_account")
152
- end
153
-
154
- it "creates a merchant account with the new parameters and doesn't require an id" do
155
- result = Braintree::MerchantAccount.create(VALID_APPLICATION_PARAMS)
156
-
157
- expect(result).to be_success
158
- expect(result.merchant_account.status).to eq(Braintree::MerchantAccount::Status::Pending)
159
- expect(result.merchant_account.master_merchant_account.id).to eq("sandbox_master_merchant_account")
160
- end
161
-
162
- it "allows an id to be passed" do
163
- random_number = rand(10000)
164
- sub_merchant_account_id = "sub_merchant_account_id#{random_number}"
165
- result = Braintree::MerchantAccount.create(
166
- VALID_APPLICATION_PARAMS.merge(
167
- :id => sub_merchant_account_id,
168
- ),
169
- )
170
-
171
- expect(result).to be_success
172
- expect(result.merchant_account.status).to eq(Braintree::MerchantAccount::Status::Pending)
173
- expect(result.merchant_account.id).to eq(sub_merchant_account_id)
174
- expect(result.merchant_account.master_merchant_account.id).to eq("sandbox_master_merchant_account")
175
- end
176
-
177
- it "handles unsuccessful results" do
178
- result = Braintree::MerchantAccount.create({})
179
- expect(result).not_to be_success
180
- expect(result.errors.for(:merchant_account).on(:master_merchant_account_id).first.code).to eq(Braintree::ErrorCodes::MerchantAccount::MasterMerchantAccountIdIsRequired)
181
- end
182
-
183
- it "requires all fields" do
184
- result = Braintree::MerchantAccount.create(
185
- :master_merchant_account_id => "sandbox_master_merchant_account",
186
- )
187
- expect(result).not_to be_success
188
- expect(result.errors.for(:merchant_account).on(:tos_accepted).first.code).to eq(Braintree::ErrorCodes::MerchantAccount::TosAcceptedIsRequired)
189
- end
190
-
191
- context "funding destination" do
192
- it "accepts a bank" do
193
- params = VALID_APPLICATION_PARAMS.dup
194
- params[:funding][:destination] = ::Braintree::MerchantAccount::FundingDestination::Bank
195
- result = Braintree::MerchantAccount.create(params)
196
-
197
- expect(result).to be_success
198
- end
199
-
200
- it "accepts an email" do
201
- params = VALID_APPLICATION_PARAMS.dup
202
- params[:funding][:destination] = ::Braintree::MerchantAccount::FundingDestination::Email
203
- params[:funding][:email] = "joebloggs@compuserve.com"
204
- result = Braintree::MerchantAccount.create(params)
205
-
206
- expect(result).to be_success
207
- end
208
-
209
- it "accepts a mobile_phone" do
210
- params = VALID_APPLICATION_PARAMS.dup
211
- params[:funding][:destination] = ::Braintree::MerchantAccount::FundingDestination::MobilePhone
212
- params[:funding][:mobile_phone] = "3125882300"
213
- result = Braintree::MerchantAccount.create(params)
214
-
215
- expect(result).to be_success
216
- end
217
- end
218
- end
219
-
220
- describe "create!" do
221
- it "creates a merchant account with the new parameters and doesn't require an id" do
222
- merchant_account = Braintree::MerchantAccount.create!(VALID_APPLICATION_PARAMS)
223
-
224
- expect(merchant_account.status).to eq(Braintree::MerchantAccount::Status::Pending)
225
- expect(merchant_account.master_merchant_account.id).to eq("sandbox_master_merchant_account")
226
- end
227
- end
228
-
229
147
  describe "create_for_currency" do
230
148
  it "creates a new merchant account for currency" do
231
- result = SpecHelper::create_merchant
149
+ result = SpecHelper::get_merchant
232
150
  expect(result).to be_success
233
151
 
234
152
  gateway = Braintree::Gateway.new(
@@ -237,14 +155,14 @@ describe Braintree::MerchantAccount do
237
155
  )
238
156
 
239
157
  result = gateway.merchant_account.create_for_currency(
240
- :currency => "JPY",
158
+ :currency => "AUD",
241
159
  )
242
160
  expect(result).to be_success
243
- expect(result.merchant_account.currency_iso_code).to eq("JPY")
161
+ expect(result.merchant_account.currency_iso_code).to eq("AUD")
244
162
  end
245
163
 
246
164
  it "returns error if a merchant account already exists for that currency" do
247
- result = SpecHelper::create_merchant
165
+ result = SpecHelper::get_merchant
248
166
  expect(result).to be_success
249
167
 
250
168
  gateway = Braintree::Gateway.new(
@@ -253,12 +171,12 @@ describe Braintree::MerchantAccount do
253
171
  )
254
172
 
255
173
  result = gateway.merchant_account.create_for_currency(
256
- :currency => "USD",
174
+ :currency => "CAD",
257
175
  )
258
176
  expect(result).to be_success
259
177
 
260
178
  result = gateway.merchant_account.create_for_currency(
261
- :currency => "USD",
179
+ :currency => "CAD",
262
180
  )
263
181
  expect(result).not_to be_success
264
182
 
@@ -267,7 +185,7 @@ describe Braintree::MerchantAccount do
267
185
  end
268
186
 
269
187
  it "returns error if no currency is provided" do
270
- result = SpecHelper::create_merchant
188
+ result = SpecHelper::get_merchant
271
189
  expect(result).to be_success
272
190
 
273
191
  gateway = Braintree::Gateway.new(
@@ -291,7 +209,7 @@ describe Braintree::MerchantAccount do
291
209
  end
292
210
 
293
211
  it "returns error if a currency is not supported" do
294
- result = SpecHelper::create_merchant
212
+ result = SpecHelper::get_merchant
295
213
  expect(result).to be_success
296
214
 
297
215
  gateway = Braintree::Gateway.new(
@@ -309,7 +227,7 @@ describe Braintree::MerchantAccount do
309
227
  end
310
228
 
311
229
  it "returns error if id is passed and already taken" do
312
- result = SpecHelper::create_merchant
230
+ result = SpecHelper::get_merchant
313
231
  expect(result).to be_success
314
232
 
315
233
  gateway = Braintree::Gateway.new(
@@ -319,7 +237,7 @@ describe Braintree::MerchantAccount do
319
237
 
320
238
  merchant = result.merchant
321
239
  result = gateway.merchant_account.create_for_currency(
322
- :currency => "USD",
240
+ :currency => "GBP",
323
241
  :id => merchant.merchant_accounts.first.id,
324
242
  )
325
243
  expect(result).not_to be_success
@@ -330,18 +248,6 @@ describe Braintree::MerchantAccount do
330
248
  end
331
249
 
332
250
  describe "find" do
333
- it "finds the merchant account with the given token" do
334
- result = Braintree::MerchantAccount.create(VALID_APPLICATION_PARAMS)
335
- expect(result).to be_success
336
- expect(result.merchant_account.status).to eq(Braintree::MerchantAccount::Status::Pending)
337
-
338
- id = result.merchant_account.id
339
- merchant_account = Braintree::MerchantAccount.find(id)
340
-
341
- expect(merchant_account.individual_details.first_name).to eq(VALID_APPLICATION_PARAMS[:individual][:first_name])
342
- expect(merchant_account.individual_details.last_name).to eq(VALID_APPLICATION_PARAMS[:individual][:last_name])
343
- end
344
-
345
251
  it "retrieves the currency iso code for an existing master merchant account" do
346
252
  merchant_account = Braintree::MerchantAccount.find("sandbox_master_merchant_account")
347
253
 
@@ -354,250 +260,4 @@ describe Braintree::MerchantAccount do
354
260
  end.to raise_error(Braintree::NotFoundError, "Merchant account with id non-existant not found")
355
261
  end
356
262
  end
357
-
358
- describe "update" do
359
- it "updates the Merchant Account info" do
360
- params = VALID_APPLICATION_PARAMS.clone
361
- params.delete(:tos_accepted)
362
- params.delete(:master_merchant_account_id)
363
- params[:individual][:first_name] = "John"
364
- params[:individual][:last_name] = "Doe"
365
- params[:individual][:email] = "john.doe@example.com"
366
- params[:individual][:date_of_birth] = "1970-01-01"
367
- params[:individual][:phone] = "3125551234"
368
- params[:individual][:address][:street_address] = "123 Fake St"
369
- params[:individual][:address][:locality] = "Chicago"
370
- params[:individual][:address][:region] = "IL"
371
- params[:individual][:address][:postal_code] = "60622"
372
- params[:business][:dba_name] = "James's Bloggs"
373
- params[:business][:legal_name] = "James's Bloggs Inc"
374
- params[:business][:tax_id] = "423456789"
375
- params[:business][:address][:street_address] = "999 Fake St"
376
- params[:business][:address][:locality] = "Miami"
377
- params[:business][:address][:region] = "FL"
378
- params[:business][:address][:postal_code] = "99999"
379
- params[:funding][:account_number] = "43759348798"
380
- params[:funding][:routing_number] = "071000013"
381
- params[:funding][:email] = "check@this.com"
382
- params[:funding][:mobile_phone] = "1234567890"
383
- params[:funding][:destination] = Braintree::MerchantAccount::FundingDestination::MobilePhone
384
- result = Braintree::MerchantAccount.update("sandbox_sub_merchant_account", params)
385
- expect(result).to be_success
386
- expect(result.merchant_account.status).to eq("active")
387
- expect(result.merchant_account.id).to eq("sandbox_sub_merchant_account")
388
- expect(result.merchant_account.master_merchant_account.id).to eq("sandbox_master_merchant_account")
389
- expect(result.merchant_account.individual_details.first_name).to eq("John")
390
- expect(result.merchant_account.individual_details.last_name).to eq("Doe")
391
- expect(result.merchant_account.individual_details.email).to eq("john.doe@example.com")
392
- expect(result.merchant_account.individual_details.date_of_birth).to eq("1970-01-01")
393
- expect(result.merchant_account.individual_details.phone).to eq("3125551234")
394
- expect(result.merchant_account.individual_details.address_details.street_address).to eq("123 Fake St")
395
- expect(result.merchant_account.individual_details.address_details.locality).to eq("Chicago")
396
- expect(result.merchant_account.individual_details.address_details.region).to eq("IL")
397
- expect(result.merchant_account.individual_details.address_details.postal_code).to eq("60622")
398
- expect(result.merchant_account.business_details.dba_name).to eq("James's Bloggs")
399
- expect(result.merchant_account.business_details.legal_name).to eq("James's Bloggs Inc")
400
- expect(result.merchant_account.business_details.tax_id).to eq("423456789")
401
- expect(result.merchant_account.business_details.address_details.street_address).to eq("999 Fake St")
402
- expect(result.merchant_account.business_details.address_details.locality).to eq("Miami")
403
- expect(result.merchant_account.business_details.address_details.region).to eq("FL")
404
- expect(result.merchant_account.business_details.address_details.postal_code).to eq("99999")
405
- expect(result.merchant_account.funding_details.account_number_last_4).to eq("8798")
406
- expect(result.merchant_account.funding_details.routing_number).to eq("071000013")
407
- expect(result.merchant_account.funding_details.email).to eq("check@this.com")
408
- expect(result.merchant_account.funding_details.mobile_phone).to eq("1234567890")
409
- expect(result.merchant_account.funding_details.destination).to eq(Braintree::MerchantAccount::FundingDestination::MobilePhone)
410
- expect(result.merchant_account.funding_details.descriptor).to eq("Joes Bloggs MI")
411
- end
412
-
413
- it "does not require all fields" do
414
- result = Braintree::MerchantAccount.update("sandbox_sub_merchant_account", {:individual => {:first_name => "Jose"}})
415
- expect(result).to be_success
416
- end
417
-
418
- it "handles validation errors for blank fields" do
419
- result = Braintree::MerchantAccount.update(
420
- "sandbox_sub_merchant_account", {
421
- :individual => {
422
- :first_name => "",
423
- :last_name => "",
424
- :email => "",
425
- :phone => "",
426
- :address => {
427
- :street_address => "",
428
- :postal_code => "",
429
- :locality => "",
430
- :region => "",
431
- },
432
- :date_of_birth => "",
433
- :ssn => "",
434
- },
435
- :business => {
436
- :legal_name => "",
437
- :dba_name => "",
438
- :tax_id => ""
439
- },
440
- :funding => {
441
- :destination => "",
442
- :routing_number => "",
443
- :account_number => ""
444
- },
445
- }
446
- )
447
-
448
- expect(result).not_to be_success
449
- expect(result.errors.for(:merchant_account).for(:individual).on(:first_name).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::FirstNameIsRequired])
450
- expect(result.errors.for(:merchant_account).for(:individual).on(:last_name).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::LastNameIsRequired])
451
- expect(result.errors.for(:merchant_account).for(:individual).on(:date_of_birth).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::DateOfBirthIsRequired])
452
- expect(result.errors.for(:merchant_account).for(:individual).on(:email).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::EmailIsRequired])
453
- expect(result.errors.for(:merchant_account).for(:individual).for(:address).on(:street_address).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::Address::StreetAddressIsRequired])
454
- expect(result.errors.for(:merchant_account).for(:individual).for(:address).on(:postal_code).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::Address::PostalCodeIsRequired])
455
- expect(result.errors.for(:merchant_account).for(:individual).for(:address).on(:locality).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::Address::LocalityIsRequired])
456
- expect(result.errors.for(:merchant_account).for(:individual).for(:address).on(:region).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::Address::RegionIsRequired])
457
- expect(result.errors.for(:merchant_account).for(:funding).on(:destination).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Funding::DestinationIsRequired])
458
- expect(result.errors.for(:merchant_account).on(:base)).to be_empty
459
- end
460
-
461
- it "handles validation errors for invalid fields" do
462
- result = Braintree::MerchantAccount.update(
463
- "sandbox_sub_merchant_account", {
464
- :individual => {
465
- :first_name => "<>",
466
- :last_name => "<>",
467
- :email => "bad",
468
- :phone => "999",
469
- :address => {
470
- :street_address => "nope",
471
- :postal_code => "1",
472
- :region => "QQ",
473
- },
474
- :date_of_birth => "hah",
475
- :ssn => "12345",
476
- },
477
- :business => {
478
- :legal_name => "``{}",
479
- :dba_name => "{}``",
480
- :tax_id => "bad",
481
- :address => {
482
- :street_address => "nope",
483
- :postal_code => "1",
484
- :region => "QQ",
485
- },
486
- },
487
- :funding => {
488
- :destination => "MY WALLET",
489
- :routing_number => "LEATHER",
490
- :account_number => "BACK POCKET",
491
- :email => "BILLFOLD",
492
- :mobile_phone => "TRIFOLD"
493
- },
494
- }
495
- )
496
-
497
- expect(result).not_to be_success
498
- expect(result.errors.for(:merchant_account).for(:individual).on(:first_name).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::FirstNameIsInvalid])
499
- expect(result.errors.for(:merchant_account).for(:individual).on(:last_name).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::LastNameIsInvalid])
500
- expect(result.errors.for(:merchant_account).for(:individual).on(:email).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::EmailIsInvalid])
501
- expect(result.errors.for(:merchant_account).for(:individual).on(:phone).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::PhoneIsInvalid])
502
- expect(result.errors.for(:merchant_account).for(:individual).for(:address).on(:street_address).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::Address::StreetAddressIsInvalid])
503
- expect(result.errors.for(:merchant_account).for(:individual).for(:address).on(:postal_code).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::Address::PostalCodeIsInvalid])
504
- expect(result.errors.for(:merchant_account).for(:individual).for(:address).on(:region).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::Address::RegionIsInvalid])
505
- expect(result.errors.for(:merchant_account).for(:individual).on(:ssn).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Individual::SsnIsInvalid])
506
-
507
- expect(result.errors.for(:merchant_account).for(:business).on(:legal_name).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Business::LegalNameIsInvalid])
508
- expect(result.errors.for(:merchant_account).for(:business).on(:dba_name).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Business::DbaNameIsInvalid])
509
- expect(result.errors.for(:merchant_account).for(:business).on(:tax_id).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Business::TaxIdIsInvalid])
510
- expect(result.errors.for(:merchant_account).for(:business).for(:address).on(:street_address).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Business::Address::StreetAddressIsInvalid])
511
- expect(result.errors.for(:merchant_account).for(:business).for(:address).on(:postal_code).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Business::Address::PostalCodeIsInvalid])
512
- expect(result.errors.for(:merchant_account).for(:business).for(:address).on(:region).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Business::Address::RegionIsInvalid])
513
-
514
- expect(result.errors.for(:merchant_account).for(:funding).on(:destination).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Funding::DestinationIsInvalid])
515
- expect(result.errors.for(:merchant_account).for(:funding).on(:routing_number).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Funding::RoutingNumberIsInvalid])
516
- expect(result.errors.for(:merchant_account).for(:funding).on(:account_number).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Funding::AccountNumberIsInvalid])
517
- expect(result.errors.for(:merchant_account).for(:funding).on(:email).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Funding::EmailIsInvalid])
518
- expect(result.errors.for(:merchant_account).for(:funding).on(:mobile_phone).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Funding::MobilePhoneIsInvalid])
519
-
520
- expect(result.errors.for(:merchant_account).on(:base)).to be_empty
521
- end
522
-
523
- it "handles validation errors for business fields" do
524
- result = Braintree::MerchantAccount.update(
525
- "sandbox_sub_merchant_account", {
526
- :business => {
527
- :legal_name => "",
528
- :tax_id => "111223333",
529
- },
530
- }
531
- )
532
-
533
- expect(result).not_to be_success
534
- expect(result.errors.for(:merchant_account).for(:business).on(:legal_name).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Business::LegalNameIsRequiredWithTaxId])
535
- expect(result.errors.for(:merchant_account).for(:business).on(:tax_id).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Business::TaxIdMustBeBlank])
536
-
537
- result = Braintree::MerchantAccount.update(
538
- "sandbox_sub_merchant_account", {
539
- :business => {
540
- :legal_name => "legal_name",
541
- :tax_id => "",
542
- },
543
- }
544
- )
545
-
546
- expect(result).not_to be_success
547
- expect(result.errors.for(:merchant_account).for(:business).on(:tax_id).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Business::TaxIdIsRequiredWithLegalName])
548
- end
549
-
550
- it "handles validation errors for funding fields" do
551
- result = Braintree::MerchantAccount.update(
552
- "sandbox_sub_merchant_account", {
553
- :funding => {
554
- :destination => Braintree::MerchantAccount::FundingDestination::Bank,
555
- :routing_number => "",
556
- :account_number => ""
557
- },
558
- }
559
- )
560
-
561
- expect(result).not_to be_success
562
- expect(result.errors.for(:merchant_account).for(:funding).on(:routing_number).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Funding::RoutingNumberIsRequired])
563
- expect(result.errors.for(:merchant_account).for(:funding).on(:account_number).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Funding::AccountNumberIsRequired])
564
-
565
- result = Braintree::MerchantAccount.update(
566
- "sandbox_sub_merchant_account", {
567
- :funding => {
568
- :destination => Braintree::MerchantAccount::FundingDestination::Email,
569
- :email => ""
570
- },
571
- }
572
- )
573
-
574
- expect(result).not_to be_success
575
- expect(result.errors.for(:merchant_account).for(:funding).on(:email).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Funding::EmailIsRequired])
576
-
577
- result = Braintree::MerchantAccount.update(
578
- "sandbox_sub_merchant_account", {
579
- :funding => {
580
- :destination => Braintree::MerchantAccount::FundingDestination::MobilePhone,
581
- :mobile_phone => ""
582
- },
583
- }
584
- )
585
-
586
- expect(result).not_to be_success
587
- expect(result.errors.for(:merchant_account).for(:funding).on(:mobile_phone).map(&:code)).to eq([Braintree::ErrorCodes::MerchantAccount::Funding::MobilePhoneIsRequired])
588
- end
589
- end
590
-
591
- describe "update!" do
592
- it "updates the Merchant Account info" do
593
- params = VALID_APPLICATION_PARAMS.clone
594
- params.delete(:tos_accepted)
595
- params.delete(:master_merchant_account_id)
596
- params[:individual][:first_name] = "John"
597
- params[:individual][:last_name] = "Doe"
598
- merchant_account = Braintree::MerchantAccount.update!("sandbox_sub_merchant_account", params)
599
- expect(merchant_account.individual_details.first_name).to eq("John")
600
- expect(merchant_account.individual_details.last_name).to eq("Doe")
601
- end
602
- end
603
263
  end
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
3
  describe Braintree::MerchantGateway do
4
4
  describe "create" do
5
- it "creates a merchant" do
5
+ xit "creates a merchant" do
6
6
  gateway = Braintree::Gateway.new(
7
7
  :client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
8
8
  :client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
@@ -59,7 +59,7 @@ describe Braintree::MerchantGateway do
59
59
  Braintree::Configuration.merchant_id = old_merchant_id_value
60
60
  end
61
61
 
62
- it "allows using a merchant_id passed in through Gateway" do
62
+ xit "allows using a merchant_id passed in through Gateway" do
63
63
  Braintree::Configuration.merchant_id = nil
64
64
 
65
65
  gateway = Braintree::Gateway.new(
@@ -87,7 +87,7 @@ describe Braintree::MerchantGateway do
87
87
  )
88
88
  end
89
89
 
90
- it "creates an EU multi currency merchant for paypal and credit_card" do
90
+ xit "creates an EU multi currency merchant for paypal and credit_card" do
91
91
  result = @gateway.merchant.create(
92
92
  :email => "name@email.com",
93
93
  :country_code_alpha3 => "GBR",
@@ -123,7 +123,7 @@ describe Braintree::MerchantGateway do
123
123
  end
124
124
 
125
125
 
126
- it "creates a paypal-only merchant that accepts multiple currencies" do
126
+ xit "creates a paypal-only merchant that accepts multiple currencies" do
127
127
  result = @gateway.merchant.create(
128
128
  :email => "name@email.com",
129
129
  :country_code_alpha3 => "GBR",
@@ -148,6 +148,16 @@ describe Braintree::PaymentMethodNonce do
148
148
  expect(nonce.details.bin).to eq("401288")
149
149
  end
150
150
 
151
+ it "returns bin_data with business set to Yes" do
152
+ result = Braintree::PaymentMethodNonce.find("fake-valid-business-nonce")
153
+
154
+ nonce = result.payment_method_nonce
155
+
156
+ expect(result).to be_success
157
+ expect(nonce.bin_data).not_to be_nil
158
+ expect(nonce.bin_data.business).to eq(Braintree::CreditCard::Business::Yes)
159
+ end
160
+
151
161
  it "returns bin_data with commercial set to Yes" do
152
162
  result = Braintree::PaymentMethodNonce.find("fake-valid-commercial-nonce")
153
163
 
@@ -158,6 +168,26 @@ describe Braintree::PaymentMethodNonce do
158
168
  expect(nonce.bin_data.commercial).to eq(Braintree::CreditCard::Commercial::Yes)
159
169
  end
160
170
 
171
+ it "returns bin_data with consumer set to Yes" do
172
+ result = Braintree::PaymentMethodNonce.find("fake-valid-consumer-nonce")
173
+
174
+ nonce = result.payment_method_nonce
175
+
176
+ expect(result).to be_success
177
+ expect(nonce.bin_data).not_to be_nil
178
+ expect(nonce.bin_data.consumer).to eq(Braintree::CreditCard::Consumer::Yes)
179
+ end
180
+
181
+ it "returns bin_data with corporate set to Yes" do
182
+ result = Braintree::PaymentMethodNonce.find("fake-valid-corporate-nonce")
183
+
184
+ nonce = result.payment_method_nonce
185
+
186
+ expect(result).to be_success
187
+ expect(nonce.bin_data).not_to be_nil
188
+ expect(nonce.bin_data.corporate).to eq(Braintree::CreditCard::Corporate::Yes)
189
+ end
190
+
161
191
  it "returns bin_data with country_of_issuance set to CAN" do
162
192
  result = Braintree::PaymentMethodNonce.find("fake-valid-country-of-issuance-cad-nonce")
163
193
 
@@ -230,6 +260,26 @@ describe Braintree::PaymentMethodNonce do
230
260
  expect(nonce.bin_data.prepaid).to eq(Braintree::CreditCard::Prepaid::Yes)
231
261
  end
232
262
 
263
+ it "returns bin_data with prepaid_reloadable set to Yes" do
264
+ result = Braintree::PaymentMethodNonce.find("fake-valid-prepaid-reloadable-nonce")
265
+
266
+ nonce = result.payment_method_nonce
267
+
268
+ expect(result).to be_success
269
+ expect(nonce.bin_data).not_to be_nil
270
+ expect(nonce.bin_data.prepaid_reloadable).to eq(Braintree::CreditCard::PrepaidReloadable::Yes)
271
+ end
272
+
273
+ it "returns bin_data with purchase set to Yes" do
274
+ result = Braintree::PaymentMethodNonce.find("fake-valid-purchase-nonce")
275
+
276
+ nonce = result.payment_method_nonce
277
+
278
+ expect(result).to be_success
279
+ expect(nonce.bin_data).not_to be_nil
280
+ expect(nonce.bin_data.purchase).to eq(Braintree::CreditCard::Purchase::Yes)
281
+ end
282
+
233
283
  it "returns bin_data with unknown indicators" do
234
284
  result = Braintree::PaymentMethodNonce.find("fake-valid-unknown-indicators-nonce")
235
285
 
@@ -237,7 +287,10 @@ describe Braintree::PaymentMethodNonce do
237
287
 
238
288
  expect(result).to be_success
239
289
  expect(nonce.bin_data).not_to be_nil
290
+ expect(nonce.bin_data.business).to eq(Braintree::CreditCard::Business::Unknown)
240
291
  expect(nonce.bin_data.commercial).to eq(Braintree::CreditCard::Commercial::Unknown)
292
+ expect(nonce.bin_data.consumer).to eq(Braintree::CreditCard::Consumer::Unknown)
293
+ expect(nonce.bin_data.corporate).to eq(Braintree::CreditCard::Corporate::Unknown)
241
294
  expect(nonce.bin_data.country_of_issuance).to eq(Braintree::CreditCard::CountryOfIssuance::Unknown)
242
295
  expect(nonce.bin_data.debit).to eq(Braintree::CreditCard::Debit::Unknown)
243
296
  expect(nonce.bin_data.durbin_regulated).to eq(Braintree::CreditCard::DurbinRegulated::Unknown)
@@ -245,7 +298,9 @@ describe Braintree::PaymentMethodNonce do
245
298
  expect(nonce.bin_data.issuing_bank).to eq(Braintree::CreditCard::IssuingBank::Unknown)
246
299
  expect(nonce.bin_data.payroll).to eq(Braintree::CreditCard::Payroll::Unknown)
247
300
  expect(nonce.bin_data.prepaid).to eq(Braintree::CreditCard::Prepaid::Unknown)
301
+ expect(nonce.bin_data.prepaid_reloadable).to eq(Braintree::CreditCard::PrepaidReloadable::Unknown)
248
302
  expect(nonce.bin_data.product_id).to eq(Braintree::CreditCard::ProductId::Unknown)
303
+ expect(nonce.bin_data.purchase).to eq(Braintree::CreditCard::Purchase::Unknown)
249
304
  end
250
305
 
251
306
  it "correctly raises and exception for a non existent token" do