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
@@ -142,90 +142,6 @@ describe Braintree::MerchantAccount do
142
142
  end
143
143
  end
144
144
 
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
145
  describe "create_for_currency" do
230
146
  it "creates a new merchant account for currency" do
231
147
  result = SpecHelper::create_merchant
@@ -330,18 +246,6 @@ describe Braintree::MerchantAccount do
330
246
  end
331
247
 
332
248
  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
249
  it "retrieves the currency iso code for an existing master merchant account" do
346
250
  merchant_account = Braintree::MerchantAccount.find("sandbox_master_merchant_account")
347
251
 
@@ -354,250 +258,4 @@ describe Braintree::MerchantAccount do
354
258
  end.to raise_error(Braintree::NotFoundError, "Merchant account with id non-existant not found")
355
259
  end
356
260
  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
261
  end
@@ -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
 
@@ -240,6 +270,16 @@ describe Braintree::PaymentMethodNonce do
240
270
  expect(nonce.bin_data.prepaid_reloadable).to eq(Braintree::CreditCard::PrepaidReloadable::Yes)
241
271
  end
242
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
+
243
283
  it "returns bin_data with unknown indicators" do
244
284
  result = Braintree::PaymentMethodNonce.find("fake-valid-unknown-indicators-nonce")
245
285
 
@@ -247,7 +287,10 @@ describe Braintree::PaymentMethodNonce do
247
287
 
248
288
  expect(result).to be_success
249
289
  expect(nonce.bin_data).not_to be_nil
290
+ expect(nonce.bin_data.business).to eq(Braintree::CreditCard::Business::Unknown)
250
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)
251
294
  expect(nonce.bin_data.country_of_issuance).to eq(Braintree::CreditCard::CountryOfIssuance::Unknown)
252
295
  expect(nonce.bin_data.debit).to eq(Braintree::CreditCard::Debit::Unknown)
253
296
  expect(nonce.bin_data.durbin_regulated).to eq(Braintree::CreditCard::DurbinRegulated::Unknown)
@@ -257,6 +300,7 @@ describe Braintree::PaymentMethodNonce do
257
300
  expect(nonce.bin_data.prepaid).to eq(Braintree::CreditCard::Prepaid::Unknown)
258
301
  expect(nonce.bin_data.prepaid_reloadable).to eq(Braintree::CreditCard::PrepaidReloadable::Unknown)
259
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)
260
304
  end
261
305
 
262
306
  it "correctly raises and exception for a non existent token" do
@@ -126,8 +126,8 @@ describe Braintree::PaymentMethod do
126
126
  expect(apple_pay_card.bin).not_to be_nil
127
127
  expect(apple_pay_card.token).to eq(token)
128
128
  expect(apple_pay_card.card_type).to eq(Braintree::ApplePayCard::CardType::Visa)
129
- expect(apple_pay_card.payment_instrument_name).to eq("Visa 8886")
130
- expect(apple_pay_card.source_description).to eq("Visa 8886")
129
+ expect(apple_pay_card.payment_instrument_name).to eq("Visa 2006")
130
+ expect(apple_pay_card.source_description).to eq("Visa 2006")
131
131
  expect(apple_pay_card.default).to eq(true)
132
132
  expect(apple_pay_card.image_url).to match(/apple_pay/)
133
133
  expect(apple_pay_card.expiration_month.to_i).to be > 0
@@ -671,6 +671,30 @@ describe Braintree::PaymentMethod do
671
671
  end
672
672
  end
673
673
 
674
+ it "includes ani response when account information inquiry is sent in options" do
675
+ customer = Braintree::Customer.create!
676
+ nonce = nonce_for_new_payment_method(
677
+ :credit_card => {
678
+ :cvv => "123",
679
+ :number => Braintree::Test::CreditCardNumbers::Visa,
680
+ :expiration_date => "05/2029",
681
+ },
682
+ )
683
+ result = Braintree::PaymentMethod.create(
684
+ :payment_method_nonce => nonce,
685
+ :customer_id => customer.id,
686
+ :options => {
687
+ :verify_card => true,
688
+ :account_information_inquiry => "send_data",
689
+ },
690
+ )
691
+
692
+ expect(result).to be_success
693
+ verification = result.payment_method.verification
694
+ expect(verification.ani_first_name_response_code).not_to be_nil
695
+ expect(verification.ani_last_name_response_code).not_to be_nil
696
+ end
697
+
674
698
  context "account_type" do
675
699
  it "verifies card with account_type debit" do
676
700
  nonce = nonce_for_new_payment_method(
@@ -1228,7 +1252,7 @@ describe Braintree::PaymentMethod do
1228
1252
  expect(apple_pay_card.image_url).to match(/apple_pay/)
1229
1253
  expect(apple_pay_card.expiration_month.to_i).to be > 0
1230
1254
  expect(apple_pay_card.expiration_year.to_i).to be > 0
1231
- expect(apple_pay_card.source_description).to eq("Visa 8886")
1255
+ expect(apple_pay_card.source_description).to eq("Visa 2006")
1232
1256
  expect(apple_pay_card.customer_id).to eq(customer.id)
1233
1257
  apple_pay_card.merchant_token_identifier == "DNITHE302308980427388297"
1234
1258
  apple_pay_card.source_card_last4 == "2006"
@@ -1588,6 +1612,29 @@ describe Braintree::PaymentMethod do
1588
1612
  end
1589
1613
  end
1590
1614
 
1615
+ it "includes ani response after updating the options with account information inquiry" do
1616
+ customer = Braintree::Customer.create!
1617
+ credit_card = Braintree::CreditCard.create!(
1618
+ :customer_id => customer.id,
1619
+ :cvv => "123",
1620
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1621
+ :expiration_date => "05/2032",
1622
+ )
1623
+ update_result = Braintree::PaymentMethod.update(
1624
+ credit_card.token,
1625
+ :options => {
1626
+ :verify_card => true,
1627
+ :account_information_inquiry => "send_data",
1628
+ },
1629
+ )
1630
+
1631
+ expect(update_result).to be_success
1632
+ verification = update_result.payment_method.verification
1633
+ expect(verification.ani_first_name_response_code).not_to be_nil
1634
+ expect(verification.ani_last_name_response_code).not_to be_nil
1635
+ end
1636
+
1637
+
1591
1638
  context "verification_currency_iso_code" do
1592
1639
  it "validates verification_currency_iso_code and updates the credit card " do
1593
1640
  customer = Braintree::Customer.create!
@@ -0,0 +1,119 @@
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
+
6
+ describe "self.sale" do
7
+
8
+ it "should create a transaction with sub merchant and payment facilitator for a payfac merchant" do
9
+ transaction_params = {
10
+ :type => "sale",
11
+ :amount => "100.00",
12
+ :merchant_account_id => SpecHelper::CardProcessorBRLPayFacMerchantAccountId,
13
+ :credit_card => {
14
+ :number => "4111111111111111",
15
+ :expiration_date => "06/2026",
16
+ :cvv => "123",
17
+ },
18
+ :descriptor => {
19
+ :name => "companynme12*product12",
20
+ :phone => "1232344444",
21
+ :url => "example.com",
22
+ },
23
+ :billing => {
24
+ :first_name => "Bob James",
25
+ :country_code_alpha2 => "CA",
26
+ :extended_address => "",
27
+ :locality => "Trois-Rivires",
28
+ :region => "QC",
29
+ :postal_code => "G8Y 156",
30
+ :street_address => "2346 Boul Lane",
31
+ },
32
+ :payment_facilitator => {
33
+ :payment_facilitator_id => "98765432109",
34
+ :sub_merchant => {
35
+ :reference_number => "123456789012345",
36
+ :tax_id => "99112233445577",
37
+ :legal_name => "Fooda",
38
+ :address => {
39
+ :street_address => "10880 Ibitinga",
40
+ :locality => "Araraquara",
41
+ :region => "SP",
42
+ :country_code_alpha2 => "BR",
43
+ :postal_code => "13525000",
44
+ :international_phone => {
45
+ :country_code => "55",
46
+ :national_number => "9876543210",
47
+ },
48
+ },
49
+ },
50
+ },
51
+ :options => {
52
+ :store_in_vault_on_success => true,
53
+ },
54
+ }
55
+
56
+ result = Braintree::Transaction.sale(transaction_params)
57
+ expect(result.success?).to eq(true)
58
+ expect(result.transaction.status).to eq(Braintree::Transaction::Status::Authorized)
59
+ end
60
+
61
+ it "should fail on transaction with payment facilitator and non brazil merchant" do
62
+ transaction_params = {
63
+ :type => "sale",
64
+ :amount => "100.00",
65
+ :credit_card => {
66
+ :number => "4111111111111111",
67
+ :expiration_date => "06/2026",
68
+ :cvv => "123",
69
+ },
70
+ :descriptor => {
71
+ :name => "companynme12*product12",
72
+ :phone => "1232344444",
73
+ :url => "example.com",
74
+ },
75
+ :billing => {
76
+ :first_name => "Bob James",
77
+ :country_code_alpha2 => "CA",
78
+ :extended_address => "",
79
+ :locality => "Trois-Rivires",
80
+ :region => "QC",
81
+ :postal_code => "G8Y 156",
82
+ :street_address => "2346 Boul Lane",
83
+ },
84
+ :payment_facilitator => {
85
+ :payment_facilitator_id => "98765432109",
86
+ :sub_merchant => {
87
+ :reference_number => "123456789012345",
88
+ :tax_id => "99112233445577",
89
+ :legal_name => "Fooda",
90
+ :address => {
91
+ :street_address => "10880 Ibitinga",
92
+ :locality => "Araraquara",
93
+ :region => "SP",
94
+ :country_code_alpha2 => "BR",
95
+ :postal_code => "13525000",
96
+ :international_phone => {
97
+ :country_code => "55",
98
+ :national_number => "9876543210",
99
+ },
100
+ },
101
+ },
102
+ },
103
+ :options => {
104
+ :store_in_vault_on_success => true,
105
+ },
106
+ }
107
+
108
+ ezp_gateway = Braintree::Gateway.new(
109
+ :environment => :development,
110
+ :merchant_id => "pp_credit_ezp_merchant",
111
+ :public_key => "pp_credit_ezp_merchant_public_key",
112
+ :private_key => "pp_credit_ezp_merchant_private_key",
113
+ )
114
+
115
+ result = ezp_gateway.transaction.sale(transaction_params)
116
+ expect(result.errors.for(:transaction).first.code).to eq(Braintree::ErrorCodes::PaymentFacilitator::PaymentFacilitatorNotApplicable)
117
+ end
118
+ end
119
+ end