braintree 3.3.0 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/braintree.gemspec +1 -1
  3. data/lib/braintree.rb +2 -1
  4. data/lib/braintree/account_updater_daily_report.rb +1 -1
  5. data/lib/braintree/address.rb +1 -1
  6. data/lib/braintree/apple_pay.rb +1 -1
  7. data/lib/braintree/apple_pay_card.rb +1 -1
  8. data/lib/braintree/apple_pay_options.rb +1 -1
  9. data/lib/braintree/authorization_adjustment.rb +1 -1
  10. data/lib/braintree/client_token.rb +1 -1
  11. data/lib/braintree/configuration.rb +11 -11
  12. data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
  13. data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
  14. data/lib/braintree/credit_card.rb +2 -2
  15. data/lib/braintree/credit_card_gateway.rb +3 -3
  16. data/lib/braintree/credit_card_verification.rb +5 -5
  17. data/lib/braintree/credit_card_verification_search.rb +1 -1
  18. data/lib/braintree/customer.rb +2 -2
  19. data/lib/braintree/customer_search.rb +1 -1
  20. data/lib/braintree/disbursement.rb +1 -1
  21. data/lib/braintree/dispute.rb +1 -1
  22. data/lib/braintree/dispute_gateway.rb +2 -2
  23. data/lib/braintree/dispute_search.rb +2 -2
  24. data/lib/braintree/document_upload.rb +1 -1
  25. data/lib/braintree/error_codes.rb +7 -0
  26. data/lib/braintree/google_pay_card.rb +1 -1
  27. data/lib/braintree/granted_payment_instrument_update.rb +1 -1
  28. data/lib/braintree/graphql_client.rb +7 -7
  29. data/lib/braintree/http.rb +3 -3
  30. data/lib/braintree/local_payment_completed.rb +1 -1
  31. data/lib/braintree/local_payment_reversed.rb +19 -0
  32. data/lib/braintree/merchant.rb +1 -1
  33. data/lib/braintree/merchant_account.rb +1 -1
  34. data/lib/braintree/merchant_account_gateway.rb +1 -1
  35. data/lib/braintree/merchant_gateway.rb +1 -1
  36. data/lib/braintree/modification.rb +1 -1
  37. data/lib/braintree/oauth_credentials.rb +1 -1
  38. data/lib/braintree/oauth_gateway.rb +5 -5
  39. data/lib/braintree/payment_instrument_type.rb +10 -10
  40. data/lib/braintree/payment_method_gateway.rb +3 -3
  41. data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
  42. data/lib/braintree/plan.rb +1 -1
  43. data/lib/braintree/processor_response_types.rb +3 -3
  44. data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
  45. data/lib/braintree/samsung_pay_card.rb +1 -1
  46. data/lib/braintree/settlement_batch_summary.rb +2 -2
  47. data/lib/braintree/subscription.rb +6 -6
  48. data/lib/braintree/transaction.rb +32 -24
  49. data/lib/braintree/transaction_gateway.rb +23 -4
  50. data/lib/braintree/transaction_line_item.rb +1 -1
  51. data/lib/braintree/transaction_search.rb +3 -1
  52. data/lib/braintree/unknown_payment_method.rb +1 -1
  53. data/lib/braintree/us_bank_account.rb +3 -3
  54. data/lib/braintree/us_bank_account_verification.rb +1 -1
  55. data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
  56. data/lib/braintree/util.rb +4 -4
  57. data/lib/braintree/venmo_account.rb +1 -1
  58. data/lib/braintree/version.rb +1 -1
  59. data/lib/braintree/visa_checkout_card.rb +2 -2
  60. data/lib/braintree/webhook_notification.rb +28 -19
  61. data/lib/braintree/webhook_notification_gateway.rb +5 -5
  62. data/lib/braintree/webhook_testing_gateway.rb +10 -0
  63. data/lib/braintree/xml/generator.rb +5 -4
  64. data/lib/braintree/xml/libxml.rb +1 -1
  65. data/lib/braintree/xml/parser.rb +10 -10
  66. data/spec/integration/braintree/add_on_spec.rb +1 -1
  67. data/spec/integration/braintree/address_spec.rb +24 -24
  68. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  69. data/spec/integration/braintree/apple_pay_spec.rb +3 -3
  70. data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
  71. data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
  72. data/spec/integration/braintree/client_api/spec_helper.rb +5 -5
  73. data/spec/integration/braintree/credit_card_spec.rb +119 -119
  74. data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
  75. data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
  76. data/spec/integration/braintree/customer_search_spec.rb +8 -8
  77. data/spec/integration/braintree/customer_spec.rb +165 -165
  78. data/spec/integration/braintree/dispute_search_spec.rb +3 -3
  79. data/spec/integration/braintree/dispute_spec.rb +6 -6
  80. data/spec/integration/braintree/error_codes_spec.rb +1 -1
  81. data/spec/integration/braintree/http_spec.rb +2 -2
  82. data/spec/integration/braintree/merchant_account_spec.rb +25 -26
  83. data/spec/integration/braintree/merchant_spec.rb +12 -12
  84. data/spec/integration/braintree/oauth_spec.rb +11 -11
  85. data/spec/integration/braintree/payment_method_nonce_spec.rb +12 -12
  86. data/spec/integration/braintree/payment_method_spec.rb +165 -165
  87. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +9 -9
  88. data/spec/integration/braintree/paypal_account_spec.rb +28 -28
  89. data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
  90. data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
  91. data/spec/integration/braintree/subscription_spec.rb +133 -133
  92. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  93. data/spec/integration/braintree/test_transaction_spec.rb +10 -10
  94. data/spec/integration/braintree/transaction_search_spec.rb +93 -67
  95. data/spec/integration/braintree/transaction_spec.rb +498 -344
  96. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +20 -20
  97. data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
  98. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
  99. data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
  100. data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
  101. data/spec/integration/spec_helper.rb +2 -2
  102. data/spec/oauth_test_helper.rb +1 -1
  103. data/spec/script/httpsd.rb +6 -6
  104. data/spec/spec_helper.rb +4 -3
  105. data/spec/unit/braintree/address_spec.rb +1 -1
  106. data/spec/unit/braintree/apple_pay_card_spec.rb +1 -1
  107. data/spec/unit/braintree/client_token_spec.rb +2 -2
  108. data/spec/unit/braintree/configuration_spec.rb +42 -42
  109. data/spec/unit/braintree/credit_card_spec.rb +7 -7
  110. data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
  111. data/spec/unit/braintree/credit_card_verification_spec.rb +2 -2
  112. data/spec/unit/braintree/customer_spec.rb +3 -3
  113. data/spec/unit/braintree/disbursement_spec.rb +7 -7
  114. data/spec/unit/braintree/dispute_spec.rb +8 -8
  115. data/spec/unit/braintree/error_result_spec.rb +5 -5
  116. data/spec/unit/braintree/errors_spec.rb +8 -8
  117. data/spec/unit/braintree/http_spec.rb +5 -5
  118. data/spec/unit/braintree/merchant_account_spec.rb +1 -1
  119. data/spec/unit/braintree/payment_method_spec.rb +1 -1
  120. data/spec/unit/braintree/paypal_account_spec.rb +2 -2
  121. data/spec/unit/braintree/resource_collection_spec.rb +9 -9
  122. data/spec/unit/braintree/subscription_search_spec.rb +1 -1
  123. data/spec/unit/braintree/successful_result_spec.rb +1 -1
  124. data/spec/unit/braintree/three_d_secure_info_spec.rb +1 -1
  125. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +3 -3
  126. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  127. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  128. data/spec/unit/braintree/transaction/paypal_details_spec.rb +1 -1
  129. data/spec/unit/braintree/transaction_search_spec.rb +12 -12
  130. data/spec/unit/braintree/transaction_spec.rb +25 -17
  131. data/spec/unit/braintree/util_spec.rb +18 -18
  132. data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
  133. data/spec/unit/braintree/webhook_notification_spec.rb +72 -56
  134. data/spec/unit/braintree/xml_spec.rb +31 -31
  135. metadata +3 -3
  136. data/lib/braintree/settlement_batch.rb +0 -0
@@ -24,7 +24,7 @@ describe Braintree::Transaction do
24
24
  :country_code_alpha2 => "BT",
25
25
  :country_code_alpha3 => "BTN",
26
26
  :country_code_numeric => "064"
27
- }
27
+ },
28
28
  )
29
29
  result.success?.should == true
30
30
 
@@ -34,7 +34,7 @@ describe Braintree::Transaction do
34
34
  :channel => "MyShoppingCartProvider",
35
35
  :options => {
36
36
  :submit_for_settlement => false
37
- }
37
+ },
38
38
  )
39
39
  clone_result.success?.should == true
40
40
 
@@ -67,7 +67,7 @@ describe Braintree::Transaction do
67
67
  :credit_card => {
68
68
  :number => "5105105105105100",
69
69
  :expiration_date => "05/2012"
70
- }
70
+ },
71
71
  )
72
72
 
73
73
  result.success?.should be(true)
@@ -84,7 +84,7 @@ describe Braintree::Transaction do
84
84
  :credit_card => {
85
85
  :number => Braintree::Test::CreditCardNumbers::Visa,
86
86
  :expiration_date => "05/2009"
87
- }
87
+ },
88
88
  )
89
89
  result = Braintree::Transaction.clone_transaction(transaction.id, :amount => "112.44")
90
90
  result.success?.should be(false)
@@ -100,7 +100,7 @@ describe Braintree::Transaction do
100
100
  :credit_card => {
101
101
  :number => Braintree::Test::CreditCardNumbers::Visa,
102
102
  :expiration_date => "05/2009"
103
- }
103
+ },
104
104
  )
105
105
  clone_transaction = Braintree::Transaction.clone_transaction!(transaction.id, :amount => "112.44", :options => {:submit_for_settlement => false})
106
106
  clone_transaction.id.should_not == transaction.id
@@ -112,7 +112,7 @@ describe Braintree::Transaction do
112
112
  :credit_card => {
113
113
  :number => Braintree::Test::CreditCardNumbers::Visa,
114
114
  :expiration_date => "05/2009"
115
- }
115
+ },
116
116
  )
117
117
  expect do
118
118
  clone_transaction = Braintree::Transaction.clone_transaction!(transaction.id, :amount => "im not a number")
@@ -131,14 +131,14 @@ describe Braintree::Transaction do
131
131
  :credit_card => {
132
132
  :number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
133
133
  :expiration_date => "05/2009"
134
- }
134
+ },
135
135
  )
136
136
  result.transaction.risk_data.should be_a(Braintree::RiskData)
137
137
  result.transaction.risk_data.id.should_not be_nil
138
138
  result.transaction.risk_data.decision.should_not be_nil
139
139
  result.transaction.risk_data.decision_reasons.should_not be_nil
140
- result.transaction.risk_data.device_data_captured.should_not be_nil
141
- result.transaction.risk_data.fraud_service_provider.should_not be_nil
140
+ expect(result.transaction.risk_data).to respond_to(:device_data_captured)
141
+ expect(result.transaction.risk_data).to respond_to(:fraud_service_provider)
142
142
  expect(result.transaction.risk_data).to respond_to(:transaction_risk_score)
143
143
  end
144
144
  end
@@ -158,7 +158,7 @@ describe Braintree::Transaction do
158
158
  :customer_ip => "192.168.0.1",
159
159
  :customer_location_zip => "not-a-$#phone",
160
160
  :customer_tenure => "20#{"0" * 500}"
161
- }
161
+ },
162
162
  )
163
163
  result.success?.should == false
164
164
  result.errors.for(:transaction).for(:risk_data).on(:customer_device_id).map { |e| e.code }.should include Braintree::ErrorCodes::RiskData::CustomerDeviceIdIsTooLong
@@ -176,7 +176,7 @@ describe Braintree::Transaction do
176
176
  :credit_card => {
177
177
  :number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
178
178
  :expiration_date => "05/2009"
179
- }
179
+ },
180
180
  )
181
181
  result.transaction.credit_card_details.prepaid.should == Braintree::CreditCard::Prepaid::Yes
182
182
  result.transaction.payment_instrument_type.should == Braintree::PaymentInstrumentType::CreditCard
@@ -252,7 +252,7 @@ describe Braintree::Transaction do
252
252
  },
253
253
  ],
254
254
  }
255
- }
255
+ },
256
256
  )
257
257
  result.success?.should be(true)
258
258
  end
@@ -279,15 +279,15 @@ describe Braintree::Transaction do
279
279
  },
280
280
  ],
281
281
  }
282
- }
282
+ },
283
283
  )
284
284
  result.success?.should be(false)
285
285
  invalid_folio = Braintree::ErrorCodes::Transaction::Industry::Lodging::FolioNumberIsInvalid
286
286
  check_out_date_must_follow_check_in_date = Braintree::ErrorCodes::Transaction::Industry::Lodging::CheckOutDateMustFollowCheckInDate
287
287
  room_rate_format_is_invalid = Braintree::ErrorCodes::Transaction::Industry::Lodging::RoomRateFormatIsInvalid
288
288
  invalid_additional_charge_kind = Braintree::ErrorCodes::Transaction::Industry::AdditionalCharge::KindIsInvalid
289
- result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort.should include *[invalid_folio, check_out_date_must_follow_check_in_date, room_rate_format_is_invalid]
290
- result.errors.for(:transaction).for(:industry).for(:additional_charges).for(:index_0).on(:kind).map { |e| e.code }.sort.should include *[invalid_additional_charge_kind]
289
+ result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort.should include(*[invalid_folio, check_out_date_must_follow_check_in_date, room_rate_format_is_invalid])
290
+ result.errors.for(:transaction).for(:industry).for(:additional_charges).for(:index_0).on(:kind).map { |e| e.code }.sort.should include(*[invalid_additional_charge_kind])
291
291
  end
292
292
  end
293
293
 
@@ -309,7 +309,7 @@ describe Braintree::Transaction do
309
309
  :lodging_check_out_date => "2014-07-07",
310
310
  :lodging_name => "Royal Caribbean",
311
311
  }
312
- }
312
+ },
313
313
  )
314
314
  result.success?.should be(true)
315
315
  end
@@ -327,7 +327,7 @@ describe Braintree::Transaction do
327
327
  :data => {
328
328
  :lodging_name => "Royal Caribbean"
329
329
  }
330
- }
330
+ },
331
331
  )
332
332
  result.success?.should be(false)
333
333
  result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort.should == [Braintree::ErrorCodes::Transaction::Industry::TravelCruise::TravelPackageIsInvalid]
@@ -401,7 +401,7 @@ describe Braintree::Transaction do
401
401
  }
402
402
  ]
403
403
  }
404
- }
404
+ },
405
405
  )
406
406
  result.success?.should be(true)
407
407
  end
@@ -425,7 +425,7 @@ describe Braintree::Transaction do
425
425
  }
426
426
  ]
427
427
  }
428
- }
428
+ },
429
429
  )
430
430
  result.success?.should be(false)
431
431
  result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort.should == [Braintree::ErrorCodes::Transaction::Industry::TravelFlight::FareAmountCannotBeNegative]
@@ -444,7 +444,7 @@ describe Braintree::Transaction do
444
444
  :number => Braintree::Test::CreditCardNumbers::Elo,
445
445
  :cvv => "737",
446
446
  :expiration_date => "10/2020"
447
- }
447
+ },
448
448
  )
449
449
  result.success?.should == true
450
450
  result.transaction.id.should =~ /^\w{6,}$/
@@ -466,7 +466,7 @@ describe Braintree::Transaction do
466
466
  :credit_card => {
467
467
  :number => Braintree::Test::CreditCardNumbers::Visa,
468
468
  :expiration_date => "05/2009"
469
- }
469
+ },
470
470
  )
471
471
  result.success?.should == true
472
472
  result.transaction.id.should =~ /^\w{6,}$/
@@ -492,7 +492,7 @@ describe Braintree::Transaction do
492
492
  :credit_card => {
493
493
  :number => Braintree::Test::CreditCardNumbers::Visa,
494
494
  :expiration_date => "05/2009"
495
- }
495
+ },
496
496
  )
497
497
  expect(result.success?).to eq(true)
498
498
  expect(result.transaction.type).to eq("sale")
@@ -514,7 +514,7 @@ describe Braintree::Transaction do
514
514
  oauth_gateway = Braintree::Gateway.new(
515
515
  :client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
516
516
  :client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
517
- :logger => Logger.new("/dev/null")
517
+ :logger => Logger.new("/dev/null"),
518
518
  )
519
519
  access_token = Braintree::OAuthTestHelper.create_token(oauth_gateway, {
520
520
  :merchant_public_id => "integration_merchant_id",
@@ -523,7 +523,7 @@ describe Braintree::Transaction do
523
523
 
524
524
  gateway = Braintree::Gateway.new(
525
525
  :access_token => access_token,
526
- :logger => Logger.new("/dev/null")
526
+ :logger => Logger.new("/dev/null"),
527
527
  )
528
528
 
529
529
  result = gateway.transaction.create(
@@ -532,7 +532,7 @@ describe Braintree::Transaction do
532
532
  :credit_card => {
533
533
  :number => Braintree::Test::CreditCardNumbers::Visa,
534
534
  :expiration_date => "05/2009"
535
- }
535
+ },
536
536
  )
537
537
 
538
538
  result.success?.should == true
@@ -575,7 +575,7 @@ describe Braintree::Transaction do
575
575
  :customer_ip => "192.168.0.1",
576
576
  :customer_location_zip => "91244",
577
577
  :customer_tenure => "20",
578
- }
578
+ },
579
579
  )
580
580
 
581
581
  result.success?.should == true
@@ -585,7 +585,7 @@ describe Braintree::Transaction do
585
585
  result = Braintree::Customer.create()
586
586
  address_result = Braintree::Address.create(
587
587
  :customer_id => result.customer.id,
588
- :country_code_alpha2 => "US"
588
+ :country_code_alpha2 => "US",
589
589
  )
590
590
 
591
591
  result = Braintree::Transaction.create(
@@ -596,7 +596,7 @@ describe Braintree::Transaction do
596
596
  :credit_card => {
597
597
  :number => Braintree::Test::CreditCardNumbers::Visa,
598
598
  :expiration_date => "05/2009"
599
- }
599
+ },
600
600
  )
601
601
 
602
602
  result.success?.should == true
@@ -609,7 +609,7 @@ describe Braintree::Transaction do
609
609
  :credit_card => {
610
610
  :number => Braintree::Test::CreditCardNumbers::Visa,
611
611
  :expiration_date => "05/2009"
612
- }
612
+ },
613
613
  )
614
614
  result.success?.should == false
615
615
  result.transaction.id.should =~ /^\w{6,}$/
@@ -628,7 +628,7 @@ describe Braintree::Transaction do
628
628
  :credit_card => {
629
629
  :number => Braintree::Test::CreditCardNumbers::Visa,
630
630
  :expiration_date => "05/2009"
631
- }
631
+ },
632
632
  )
633
633
  result.success?.should == false
634
634
  result.transaction.id.should =~ /^\w{6,}$/
@@ -665,7 +665,7 @@ describe Braintree::Transaction do
665
665
  :options => {
666
666
  :add_billing_address_to_payment_method => true,
667
667
  :store_in_vault => true
668
- }
668
+ },
669
669
  )
670
670
  result.success?.should == true
671
671
  transaction = result.transaction
@@ -695,7 +695,7 @@ describe Braintree::Transaction do
695
695
  :billing => {
696
696
  :country_name => "Botswana",
697
697
  :country_code_alpha2 => "US",
698
- }
698
+ },
699
699
  )
700
700
 
701
701
  result.success?.should == false
@@ -711,7 +711,7 @@ describe Braintree::Transaction do
711
711
  },
712
712
  :billing => {
713
713
  :country_code_alpha2 => "ZZ"
714
- }
714
+ },
715
715
  )
716
716
 
717
717
  result.success?.should == false
@@ -728,7 +728,7 @@ describe Braintree::Transaction do
728
728
  },
729
729
  :billing => {
730
730
  :country_code_alpha3 => "ZZZ"
731
- }
731
+ },
732
732
  )
733
733
 
734
734
  result.success?.should == false
@@ -745,7 +745,7 @@ describe Braintree::Transaction do
745
745
  },
746
746
  :billing => {
747
747
  :country_code_numeric => "FOO"
748
- }
748
+ },
749
749
  )
750
750
 
751
751
  result.success?.should == false
@@ -776,7 +776,7 @@ describe Braintree::Transaction do
776
776
  },
777
777
  :shipping => {
778
778
  :phone_number => "123-234-3456=098765"
779
- }
779
+ },
780
780
  )
781
781
 
782
782
  result.success?.should == false
@@ -792,7 +792,7 @@ describe Braintree::Transaction do
792
792
  },
793
793
  :shipping => {
794
794
  :shipping_method => "urgent"
795
- }
795
+ },
796
796
  )
797
797
 
798
798
  result.success?.should == false
@@ -808,7 +808,7 @@ describe Braintree::Transaction do
808
808
  },
809
809
  :billing => {
810
810
  :phone_number => "123-234-3456=098765"
811
- }
811
+ },
812
812
  )
813
813
 
814
814
  result.success?.should == false
@@ -832,7 +832,7 @@ describe Braintree::Transaction do
832
832
  :number => Braintree::Test::CreditCardNumbers::Visa,
833
833
  :expiration_date => "05/2009",
834
834
  :cvv => "200"
835
- }
835
+ },
836
836
  )
837
837
  result.success?.should == false
838
838
  result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::CVV
@@ -847,17 +847,17 @@ describe Braintree::Transaction do
847
847
  gateway = Braintree::Gateway.new(
848
848
  :client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
849
849
  :client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
850
- :logger => Logger.new("/dev/null")
850
+ :logger => Logger.new("/dev/null"),
851
851
  )
852
852
  result = gateway.merchant.create(
853
853
  :email => "name@email.com",
854
854
  :country_code_alpha3 => "USA",
855
- :payment_methods => ["credit_card", "paypal"]
855
+ :payment_methods => ["credit_card", "paypal"],
856
856
  )
857
857
 
858
858
  gateway = Braintree::Gateway.new(
859
859
  :access_token => result.credentials.access_token,
860
- :logger => Logger.new("/dev/null")
860
+ :logger => Logger.new("/dev/null"),
861
861
  )
862
862
 
863
863
  result = gateway.transaction.create(
@@ -866,7 +866,7 @@ describe Braintree::Transaction do
866
866
  :credit_card => {
867
867
  :number => Braintree::Test::CreditCardNumbers::Visa,
868
868
  :expiration_date => "05/2020"
869
- }
869
+ },
870
870
  )
871
871
  result.success?.should == false
872
872
  result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::ApplicationIncomplete
@@ -890,7 +890,7 @@ describe Braintree::Transaction do
890
890
  :credit_card => {
891
891
  :number => Braintree::Test::CreditCardNumbers::Visa,
892
892
  :expiration_date => "05/2009"
893
- }
893
+ },
894
894
  )
895
895
  result.success?.should == false
896
896
  result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::AVS
@@ -920,7 +920,7 @@ describe Braintree::Transaction do
920
920
  :number => Braintree::Test::CreditCardNumbers::Visa,
921
921
  :expiration_date => "05/2009",
922
922
  :cvv => "200"
923
- }
923
+ },
924
924
  )
925
925
  result.success?.should == false
926
926
  result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::AVSAndCVV
@@ -939,7 +939,7 @@ describe Braintree::Transaction do
939
939
  :number => Braintree::Test::CreditCardNumbers::Fraud,
940
940
  :expiration_date => "05/2017",
941
941
  :cvv => "333"
942
- }
942
+ },
943
943
  )
944
944
  result.success?.should == false
945
945
  result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::Fraud
@@ -954,7 +954,7 @@ describe Braintree::Transaction do
954
954
  :number => Braintree::Test::CreditCardNumbers::RiskThreshold,
955
955
  :expiration_date => "05/2017",
956
956
  :cvv => "333"
957
- }
957
+ },
958
958
  )
959
959
  result.success?.should == false
960
960
  result.transaction.gateway_rejection_reason.should == Braintree::Transaction::GatewayRejectionReason::RiskThreshold
@@ -991,7 +991,7 @@ describe Braintree::Transaction do
991
991
  :number => Braintree::Test::CreditCardNumbers::Visa,
992
992
  :expiration_month => "05",
993
993
  :expiration_year => "2011"
994
- }
994
+ },
995
995
  )
996
996
  result.success?.should == true
997
997
  result.transaction.credit_card_details.expiration_month.should == "05"
@@ -1003,7 +1003,7 @@ describe Braintree::Transaction do
1003
1003
  result = Braintree::Transaction.create(
1004
1004
  :type => "sale",
1005
1005
  :amount => Braintree::Test::TransactionAmounts::Decline,
1006
- :customer_id => 123456789
1006
+ :customer_id => 123456789,
1007
1007
  )
1008
1008
  result.success?.should == false
1009
1009
  result.errors.for(:transaction).on(:customer_id)[0].code.should == "91510"
@@ -1020,7 +1020,7 @@ describe Braintree::Transaction do
1020
1020
  },
1021
1021
  :custom_fields => {
1022
1022
  :store_me => "custom value"
1023
- }
1023
+ },
1024
1024
  )
1025
1025
  result.success?.should == true
1026
1026
  result.transaction.custom_fields.should == {:store_me => "custom value"}
@@ -1035,7 +1035,7 @@ describe Braintree::Transaction do
1035
1035
  },
1036
1036
  :custom_fields => {
1037
1037
  :store_me => ""
1038
- }
1038
+ },
1039
1039
  )
1040
1040
 
1041
1041
  result = Braintree::Transaction.find(create_result.transaction.id)
@@ -1053,7 +1053,7 @@ describe Braintree::Transaction do
1053
1053
  },
1054
1054
  :custom_fields => {
1055
1055
  :invalid_key => "custom value"
1056
- }
1056
+ },
1057
1057
  )
1058
1058
  result.success?.should == false
1059
1059
  result.errors.for(:transaction).on(:custom_fields)[0].message.should == "Custom field is invalid: invalid_key."
@@ -1072,7 +1072,7 @@ describe Braintree::Transaction do
1072
1072
  }
1073
1073
  result = Braintree::Transaction.create(params[:transaction])
1074
1074
  result.success?.should == false
1075
- result.params.should == {:transaction => {:type => 'sale', :amount => nil, :credit_card => {:expiration_date => "05/2009"}}}
1075
+ result.params.should == {:transaction => {:type => "sale", :amount => nil, :credit_card => {:expiration_date => "05/2009"}}}
1076
1076
  end
1077
1077
 
1078
1078
  it "returns errors if validations fail (tests many errors at once for spec speed)" do
@@ -1092,7 +1092,7 @@ describe Braintree::Transaction do
1092
1092
  }
1093
1093
  result = Braintree::Transaction.create(params[:transaction])
1094
1094
  result.success?.should == false
1095
- result.errors.for(:transaction).on(:base).map{|error| error.code}.should include(Braintree::ErrorCodes::Transaction::PaymentMethodDoesNotBelongToCustomer)
1095
+ result.errors.for(:transaction).on(:base).map { |error| error.code }.should include(Braintree::ErrorCodes::Transaction::PaymentMethodDoesNotBelongToCustomer)
1096
1096
  result.errors.for(:transaction).on(:customer_id)[0].code.should == Braintree::ErrorCodes::Transaction::CustomerIdIsInvalid
1097
1097
  result.errors.for(:transaction).on(:payment_method_token)[0].code.should == Braintree::ErrorCodes::Transaction::PaymentMethodTokenIsInvalid
1098
1098
  result.errors.for(:transaction).on(:type)[0].code.should == Braintree::ErrorCodes::Transaction::TypeIsInvalid
@@ -1123,7 +1123,7 @@ describe Braintree::Transaction do
1123
1123
  :credit_card => {
1124
1124
  :account_type => "credit",
1125
1125
  }
1126
- }
1126
+ },
1127
1127
  )
1128
1128
  result.success?.should == false
1129
1129
  result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::AmountNotSupportedByProcessor
@@ -1167,13 +1167,13 @@ describe Braintree::Transaction do
1167
1167
  :credit_card => {
1168
1168
  :number => Braintree::Test::CreditCardNumbers::Visa,
1169
1169
  :expiration_date => "05/2010"
1170
- }
1170
+ },
1171
1171
  )
1172
1172
  result = Braintree::Transaction.create(
1173
1173
  :type => "sale",
1174
1174
  :amount => Braintree::Test::TransactionAmounts::Authorize,
1175
1175
  :customer_id => customer.id,
1176
- :payment_method_token => customer.credit_cards[0].token + "x"
1176
+ :payment_method_token => customer.credit_cards[0].token + "x",
1177
1177
  )
1178
1178
  result.success?.should == false
1179
1179
  result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::PaymentMethodDoesNotBelongToCustomer
@@ -1185,7 +1185,7 @@ describe Braintree::Transaction do
1185
1185
  :credit_card => {
1186
1186
  :number => Braintree::Test::CreditCardNumbers::Visa,
1187
1187
  :expiration_date => "05/2010"
1188
- }
1188
+ },
1189
1189
  )
1190
1190
  result = Braintree::Transaction.create(
1191
1191
  :type => "sale",
@@ -1194,7 +1194,7 @@ describe Braintree::Transaction do
1194
1194
  :credit_card => {
1195
1195
  :number => Braintree::Test::CreditCardNumbers::Visa,
1196
1196
  :expiration_date => "12/12"
1197
- }
1197
+ },
1198
1198
  )
1199
1199
  result.success?.should == true
1200
1200
  result.transaction.credit_card_details.masked_number.should == "401288******1881"
@@ -1206,7 +1206,7 @@ describe Braintree::Transaction do
1206
1206
  :credit_card => {
1207
1207
  :number => Braintree::Test::CreditCardNumbers::Visa,
1208
1208
  :expiration_date => "05/2010"
1209
- }
1209
+ },
1210
1210
  )
1211
1211
  result = Braintree::Transaction.create(
1212
1212
  :type => "sale",
@@ -1216,7 +1216,7 @@ describe Braintree::Transaction do
1216
1216
  :number => Braintree::Test::CreditCardNumbers::Visa,
1217
1217
  :expiration_date => "12/12",
1218
1218
  },
1219
- :options => { :store_in_vault => true }
1219
+ :options => {:store_in_vault => true},
1220
1220
  )
1221
1221
  result.success?.should == true
1222
1222
  result.transaction.credit_card_details.masked_number.should == "401288******1881"
@@ -1230,7 +1230,7 @@ describe Braintree::Transaction do
1230
1230
  :credit_card => {
1231
1231
  :number => Braintree::Test::CreditCardNumbers::Visa,
1232
1232
  :expiration_date => "05/2010"
1233
- }
1233
+ },
1234
1234
  )
1235
1235
 
1236
1236
  result = Braintree::Subscription.create(
@@ -1261,7 +1261,7 @@ describe Braintree::Transaction do
1261
1261
  :never_expires => true
1262
1262
  }
1263
1263
  ]
1264
- }
1264
+ },
1265
1265
  )
1266
1266
 
1267
1267
  result.success?.should be(true)
@@ -1302,15 +1302,15 @@ describe Braintree::Transaction do
1302
1302
  :expiration_date => "05/2009"
1303
1303
  },
1304
1304
  :descriptor => {
1305
- :name => '123*123456789012345678',
1306
- :phone => '3334445555',
1305
+ :name => "123*123456789012345678",
1306
+ :phone => "3334445555",
1307
1307
  :url => "ebay.com"
1308
- }
1308
+ },
1309
1309
  )
1310
1310
  result.success?.should == true
1311
- result.transaction.descriptor.name.should == '123*123456789012345678'
1312
- result.transaction.descriptor.phone.should == '3334445555'
1313
- result.transaction.descriptor.url.should == 'ebay.com'
1311
+ result.transaction.descriptor.name.should == "123*123456789012345678"
1312
+ result.transaction.descriptor.phone.should == "3334445555"
1313
+ result.transaction.descriptor.url.should == "ebay.com"
1314
1314
  end
1315
1315
 
1316
1316
  it "has validation errors if format is invalid" do
@@ -1321,10 +1321,10 @@ describe Braintree::Transaction do
1321
1321
  :expiration_date => "05/2009"
1322
1322
  },
1323
1323
  :descriptor => {
1324
- :name => 'badcompanyname12*badproduct12',
1325
- :phone => '%bad4445555',
1326
- :url => '12345678901234'
1327
- }
1324
+ :name => "badcompanyname12*badproduct12",
1325
+ :phone => "%bad4445555",
1326
+ :url => "12345678901234"
1327
+ },
1328
1328
  )
1329
1329
  result.success?.should == false
1330
1330
  result.errors.for(:transaction).for(:descriptor).on(:name)[0].code.should == Braintree::ErrorCodes::Descriptor::NameFormatIsInvalid
@@ -1341,14 +1341,14 @@ describe Braintree::Transaction do
1341
1341
  :number => Braintree::Test::CreditCardNumbers::Visa,
1342
1342
  :expiration_date => "05/2009"
1343
1343
  },
1344
- :tax_amount => '0.05',
1344
+ :tax_amount => "0.05",
1345
1345
  :tax_exempt => false,
1346
- :purchase_order_number => '12345678901234567'
1346
+ :purchase_order_number => "12345678901234567",
1347
1347
  )
1348
1348
  result.success?.should == true
1349
1349
  result.transaction.tax_amount.should == BigDecimal("0.05")
1350
1350
  result.transaction.tax_exempt.should == false
1351
- result.transaction.purchase_order_number.should == '12345678901234567'
1351
+ result.transaction.purchase_order_number.should == "12345678901234567"
1352
1352
  end
1353
1353
 
1354
1354
  it "accepts tax_amount as a BigDecimal" do
@@ -1358,8 +1358,8 @@ describe Braintree::Transaction do
1358
1358
  :number => Braintree::Test::CreditCardNumbers::Visa,
1359
1359
  :expiration_date => "05/2009"
1360
1360
  },
1361
- :tax_amount => BigDecimal('1.99'),
1362
- :tax_exempt => true
1361
+ :tax_amount => BigDecimal("1.99"),
1362
+ :tax_exempt => true,
1363
1363
  )
1364
1364
  result.success?.should == true
1365
1365
  result.transaction.tax_amount.should == BigDecimal("1.99")
@@ -1375,7 +1375,7 @@ describe Braintree::Transaction do
1375
1375
  :number => Braintree::Test::CreditCardNumbers::Visa,
1376
1376
  :expiration_date => "05/2009"
1377
1377
  },
1378
- :tax_amount => 'abcd'
1378
+ :tax_amount => "abcd",
1379
1379
  )
1380
1380
  result.success?.should == false
1381
1381
  result.errors.for(:transaction).on(:tax_amount)[0].code.should == Braintree::ErrorCodes::Transaction::TaxAmountFormatIsInvalid
@@ -1388,7 +1388,7 @@ describe Braintree::Transaction do
1388
1388
  :number => Braintree::Test::CreditCardNumbers::Visa,
1389
1389
  :expiration_date => "05/2009"
1390
1390
  },
1391
- :purchase_order_number => 'a' * 18
1391
+ :purchase_order_number => "a" * 18,
1392
1392
  )
1393
1393
  result.success?.should == false
1394
1394
  result.errors.for(:transaction).on(:purchase_order_number)[0].code.should == Braintree::ErrorCodes::Transaction::PurchaseOrderNumberIsTooLong
@@ -1401,7 +1401,7 @@ describe Braintree::Transaction do
1401
1401
  :number => Braintree::Test::CreditCardNumbers::Visa,
1402
1402
  :expiration_date => "05/2009"
1403
1403
  },
1404
- :purchase_order_number => "\303\237\303\245\342\210\202"
1404
+ :purchase_order_number => "\303\237\303\245\342\210\202",
1405
1405
  )
1406
1406
  result.success?.should == false
1407
1407
  result.errors.for(:transaction).on(:purchase_order_number)[0].code.should == Braintree::ErrorCodes::Transaction::PurchaseOrderNumberIsInvalid
@@ -1418,7 +1418,7 @@ describe Braintree::Transaction do
1418
1418
  :number => Braintree::Test::CreditCardNumbers::Visa,
1419
1419
  :expiration_date => "12/12",
1420
1420
  },
1421
- :transaction_source => "recurring_first"
1421
+ :transaction_source => "recurring_first",
1422
1422
  )
1423
1423
  result.success?.should == true
1424
1424
  result.transaction.recurring.should == true
@@ -1432,7 +1432,7 @@ describe Braintree::Transaction do
1432
1432
  :number => Braintree::Test::CreditCardNumbers::Visa,
1433
1433
  :expiration_date => "12/12",
1434
1434
  },
1435
- :transaction_source => "recurring"
1435
+ :transaction_source => "recurring",
1436
1436
  )
1437
1437
  result.success?.should == true
1438
1438
  result.transaction.recurring.should == true
@@ -1446,7 +1446,7 @@ describe Braintree::Transaction do
1446
1446
  :number => Braintree::Test::CreditCardNumbers::Visa,
1447
1447
  :expiration_date => "12/12",
1448
1448
  },
1449
- :transaction_source => "merchant"
1449
+ :transaction_source => "merchant",
1450
1450
  )
1451
1451
  result.success?.should == true
1452
1452
  result.transaction.recurring.should == false
@@ -1460,7 +1460,7 @@ describe Braintree::Transaction do
1460
1460
  :number => Braintree::Test::CreditCardNumbers::Visa,
1461
1461
  :expiration_date => "12/12",
1462
1462
  },
1463
- :transaction_source => "moto"
1463
+ :transaction_source => "moto",
1464
1464
  )
1465
1465
  result.success?.should == true
1466
1466
  result.transaction.recurring.should == false
@@ -1474,7 +1474,7 @@ describe Braintree::Transaction do
1474
1474
  :number => Braintree::Test::CreditCardNumbers::Visa,
1475
1475
  :expiration_date => "12/12",
1476
1476
  },
1477
- :transaction_source => "invalid_value"
1477
+ :transaction_source => "invalid_value",
1478
1478
  )
1479
1479
  result.success?.should == false
1480
1480
  result.errors.for(:transaction).on(:transaction_source)[0].code.should == Braintree::ErrorCodes::Transaction::TransactionSourceIsInvalid
@@ -1494,7 +1494,7 @@ describe Braintree::Transaction do
1494
1494
  :number => Braintree::Test::CreditCardNumbers::Visa,
1495
1495
  :expiration_date => "12/12",
1496
1496
  },
1497
- :options => { :store_in_vault_on_success => true }
1497
+ :options => {:store_in_vault_on_success => true},
1498
1498
  )
1499
1499
  result.success?.should == true
1500
1500
  result.transaction.vault_customer.last_name.should == "Doe"
@@ -1513,7 +1513,7 @@ describe Braintree::Transaction do
1513
1513
  :number => Braintree::Test::CreditCardNumbers::Visa,
1514
1514
  :expiration_date => "12/12",
1515
1515
  },
1516
- :options => { :store_in_vault_on_success => true }
1516
+ :options => {:store_in_vault_on_success => true},
1517
1517
  )
1518
1518
  result.success?.should == false
1519
1519
  result.transaction.vault_customer.should be_nil
@@ -1533,7 +1533,7 @@ describe Braintree::Transaction do
1533
1533
  :number => Braintree::Test::CreditCardNumbers::Visa,
1534
1534
  :expiration_date => "12/12",
1535
1535
  },
1536
- :options => { :store_in_vault_on_success => false }
1536
+ :options => {:store_in_vault_on_success => false},
1537
1537
  )
1538
1538
  result.success?.should == true
1539
1539
  result.transaction.vault_customer.should be_nil
@@ -1551,7 +1551,7 @@ describe Braintree::Transaction do
1551
1551
  :number => Braintree::Test::CreditCardNumbers::Visa,
1552
1552
  :expiration_date => "12/12",
1553
1553
  },
1554
- :options => { :store_in_vault_on_success => false }
1554
+ :options => {:store_in_vault_on_success => false},
1555
1555
  )
1556
1556
  result.success?.should == false
1557
1557
  result.transaction.vault_customer.should be_nil
@@ -1570,7 +1570,7 @@ describe Braintree::Transaction do
1570
1570
  :number => Braintree::Test::CreditCardNumbers::Visa,
1571
1571
  :expiration_date => "12/12",
1572
1572
  },
1573
- :service_fee_amount => "1.00"
1573
+ :service_fee_amount => "1.00",
1574
1574
  )
1575
1575
  result.success?.should == true
1576
1576
  result.transaction.service_fee_amount.should == BigDecimal("1.00")
@@ -1585,7 +1585,7 @@ describe Braintree::Transaction do
1585
1585
  :number => Braintree::Test::CreditCardNumbers::Visa,
1586
1586
  :expiration_date => "12/12",
1587
1587
  },
1588
- :service_fee_amount => "1.00"
1588
+ :service_fee_amount => "1.00",
1589
1589
  )
1590
1590
  result.success?.should == false
1591
1591
  expected_error_code = Braintree::ErrorCodes::Transaction::ServiceFeeAmountNotAllowedOnMasterMerchantAccount
@@ -1600,7 +1600,7 @@ describe Braintree::Transaction do
1600
1600
  :credit_card => {
1601
1601
  :number => Braintree::Test::CreditCardNumbers::Visa,
1602
1602
  :expiration_date => "12/12",
1603
- }
1603
+ },
1604
1604
  )
1605
1605
  result.success?.should == false
1606
1606
  expected_error_code = Braintree::ErrorCodes::Transaction::SubMerchantAccountRequiresServiceFeeAmount
@@ -1610,7 +1610,7 @@ describe Braintree::Transaction do
1610
1610
  it "raises an error if service fee amount is negative" do
1611
1611
  result = Braintree::Transaction.create(
1612
1612
  :merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
1613
- :service_fee_amount => "-1.00"
1613
+ :service_fee_amount => "-1.00",
1614
1614
  )
1615
1615
  result.success?.should == false
1616
1616
  result.errors.for(:transaction).on(:service_fee_amount)[0].code.should == Braintree::ErrorCodes::Transaction::ServiceFeeAmountCannotBeNegative
@@ -1619,7 +1619,7 @@ describe Braintree::Transaction do
1619
1619
  it "raises an error if service fee amount is invalid" do
1620
1620
  result = Braintree::Transaction.create(
1621
1621
  :merchant_account_id => SpecHelper::NonDefaultSubMerchantAccountId,
1622
- :service_fee_amount => "invalid amount"
1622
+ :service_fee_amount => "invalid amount",
1623
1623
  )
1624
1624
  result.success?.should == false
1625
1625
  result.errors.for(:transaction).on(:service_fee_amount)[0].code.should == Braintree::ErrorCodes::Transaction::ServiceFeeAmountFormatIsInvalid
@@ -1637,7 +1637,7 @@ describe Braintree::Transaction do
1637
1637
  :expiration_date => "12/12",
1638
1638
  },
1639
1639
  :service_fee_amount => "10.00",
1640
- :options => {:hold_in_escrow => true}
1640
+ :options => {:hold_in_escrow => true},
1641
1641
  )
1642
1642
 
1643
1643
  result.success?.should == true
@@ -1654,7 +1654,7 @@ describe Braintree::Transaction do
1654
1654
  :expiration_date => "12/12",
1655
1655
  },
1656
1656
  :service_fee_amount => "1.00",
1657
- :options => {:hold_in_escrow => true}
1657
+ :options => {:hold_in_escrow => true},
1658
1658
  )
1659
1659
  result.success?.should == false
1660
1660
  expected_error_code = Braintree::ErrorCodes::Transaction::CannotHoldInEscrow
@@ -1667,7 +1667,7 @@ describe Braintree::Transaction do
1667
1667
  result = Braintree::Transaction.create(
1668
1668
  :type => "sale",
1669
1669
  :amount => Braintree::Test::TransactionAmounts::Authorize,
1670
- :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode
1670
+ :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode,
1671
1671
  )
1672
1672
  result.success?.should == true
1673
1673
  result.transaction.credit_card_details.bin.should == "400934"
@@ -1684,7 +1684,7 @@ describe Braintree::Transaction do
1684
1684
  },
1685
1685
  :options => {
1686
1686
  :venmo_sdk_session => Braintree::Test::VenmoSDK::Session
1687
- }
1687
+ },
1688
1688
  )
1689
1689
  result.success?.should == true
1690
1690
  result.transaction.credit_card_details.venmo_sdk?.should == false
@@ -1699,14 +1699,14 @@ describe Braintree::Transaction do
1699
1699
  :expiration_month => "11",
1700
1700
  :expiration_year => "2099",
1701
1701
  },
1702
- :share => true
1702
+ :share => true,
1703
1703
  )
1704
1704
  nonce.should_not be_nil
1705
1705
 
1706
1706
  result = Braintree::Transaction.create(
1707
1707
  :type => "sale",
1708
1708
  :amount => Braintree::Test::TransactionAmounts::Authorize,
1709
- :payment_method_nonce => nonce
1709
+ :payment_method_nonce => nonce,
1710
1710
  )
1711
1711
  result.success?.should == true
1712
1712
  end
@@ -1721,14 +1721,14 @@ describe Braintree::Transaction do
1721
1721
  },
1722
1722
  :client_token_options => {
1723
1723
  :customer_id => customer.id,
1724
- }
1724
+ },
1725
1725
  )
1726
1726
  nonce.should_not be_nil
1727
1727
 
1728
1728
  result = Braintree::Transaction.create(
1729
1729
  :type => "sale",
1730
1730
  :amount => Braintree::Test::TransactionAmounts::Authorize,
1731
- :payment_method_nonce => nonce
1731
+ :payment_method_nonce => nonce,
1732
1732
  )
1733
1733
  result.success?.should == true
1734
1734
  end
@@ -1741,14 +1741,14 @@ describe Braintree::Transaction do
1741
1741
  },
1742
1742
  :client_token_options => {
1743
1743
  :customer_id => customer.id,
1744
- }
1744
+ },
1745
1745
  )
1746
1746
  nonce.should_not be_nil
1747
1747
 
1748
1748
  result = Braintree::Transaction.create(
1749
1749
  :type => "sale",
1750
1750
  :amount => Braintree::Test::TransactionAmounts::Authorize,
1751
- :payment_method_nonce => nonce
1751
+ :payment_method_nonce => nonce,
1752
1752
  )
1753
1753
  result.success?.should == true
1754
1754
  result.transaction.paypal_details.should_not be_nil
@@ -1760,14 +1760,14 @@ describe Braintree::Transaction do
1760
1760
  nonce = nonce_for_new_payment_method(
1761
1761
  :paypal_account => {
1762
1762
  :consent_code => "PAYPAL_CONSENT_CODE",
1763
- }
1763
+ },
1764
1764
  )
1765
1765
  nonce.should_not be_nil
1766
1766
 
1767
1767
  result = Braintree::Transaction.create(
1768
1768
  :type => "sale",
1769
1769
  :amount => Braintree::Test::TransactionAmounts::Authorize,
1770
- :payment_method_nonce => nonce
1770
+ :payment_method_nonce => nonce,
1771
1771
  )
1772
1772
  result.success?.should == true
1773
1773
  result.transaction.paypal_details.should_not be_nil
@@ -1779,7 +1779,7 @@ describe Braintree::Transaction do
1779
1779
  result = Braintree::Transaction.create(
1780
1780
  :type => "sale",
1781
1781
  :amount => Braintree::Test::TransactionAmounts::Authorize,
1782
- :payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa
1782
+ :payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
1783
1783
  )
1784
1784
  result.success?.should == true
1785
1785
  result.transaction.should_not be_nil
@@ -1809,7 +1809,7 @@ describe Braintree::Transaction do
1809
1809
  :type => "sale",
1810
1810
  :amount => Braintree::Test::TransactionAmounts::Authorize,
1811
1811
  :payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
1812
- :options => { :store_in_vault_on_success => true }
1812
+ :options => {:store_in_vault_on_success => true},
1813
1813
  )
1814
1814
  result.success?.should == true
1815
1815
  result.transaction.should_not be_nil
@@ -1830,7 +1830,7 @@ describe Braintree::Transaction do
1830
1830
  result = Braintree::Transaction.create(
1831
1831
  :type => "sale",
1832
1832
  :amount => Braintree::Test::TransactionAmounts::Authorize,
1833
- :payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover
1833
+ :payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
1834
1834
  )
1835
1835
  result.success?.should == true
1836
1836
  result.transaction.should_not be_nil
@@ -1863,7 +1863,7 @@ describe Braintree::Transaction do
1863
1863
  :type => "sale",
1864
1864
  :amount => Braintree::Test::TransactionAmounts::Authorize,
1865
1865
  :payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
1866
- :options => { :store_in_vault_on_success => true }
1866
+ :options => {:store_in_vault_on_success => true},
1867
1867
  )
1868
1868
  result.success?.should == true
1869
1869
  result.transaction.should_not be_nil
@@ -1887,7 +1887,7 @@ describe Braintree::Transaction do
1887
1887
  result = Braintree::Transaction.create(
1888
1888
  :type => "sale",
1889
1889
  :amount => Braintree::Test::TransactionAmounts::Authorize,
1890
- :payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard
1890
+ :payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard,
1891
1891
  )
1892
1892
  result.success?.should == true
1893
1893
  result.transaction.should_not be_nil
@@ -1910,7 +1910,7 @@ describe Braintree::Transaction do
1910
1910
  :merchant_account_id => SpecHelper::FakeVenmoAccountMerchantAccountId,
1911
1911
  :amount => Braintree::Test::TransactionAmounts::Authorize,
1912
1912
  :payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
1913
- :options => {:store_in_vault => true}
1913
+ :options => {:store_in_vault => true},
1914
1914
  )
1915
1915
  result.should be_success
1916
1916
 
@@ -1930,7 +1930,7 @@ describe Braintree::Transaction do
1930
1930
  :merchant_account_id => SpecHelper::FakeVenmoAccountMerchantAccountId,
1931
1931
  :amount => Braintree::Test::TransactionAmounts::Authorize,
1932
1932
  :payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
1933
- :options => {:store_in_vault => true, :venmo => {:profile_id => "integration_venmo_merchant_public_id" }}
1933
+ :options => {:store_in_vault => true, :venmo => {:profile_id => "integration_venmo_merchant_public_id"}},
1934
1934
  )
1935
1935
  result.should be_success
1936
1936
  end
@@ -1940,7 +1940,7 @@ describe Braintree::Transaction do
1940
1940
  result = Braintree::Transaction.create(
1941
1941
  :type => "sale",
1942
1942
  :amount => Braintree::Test::TransactionAmounts::Authorize,
1943
- :payment_method_nonce => Braintree::Test::Nonce::AbstractTransactable
1943
+ :payment_method_nonce => Braintree::Test::Nonce::AbstractTransactable,
1944
1944
  )
1945
1945
  result.success?.should == true
1946
1946
  result.transaction.should_not be_nil
@@ -1955,7 +1955,7 @@ describe Braintree::Transaction do
1955
1955
  :paypal_account => {
1956
1956
  :payer_id => "PAYER-1234",
1957
1957
  :payment_id => "PAY-5678",
1958
- }
1958
+ },
1959
1959
  )
1960
1960
 
1961
1961
  result.success?.should == true
@@ -1969,7 +1969,7 @@ describe Braintree::Transaction do
1969
1969
  nonce = nonce_for_new_payment_method(
1970
1970
  :paypal_account => {
1971
1971
  :consent_code => "PAYPAL_CONSENT_CODE",
1972
- }
1972
+ },
1973
1973
  )
1974
1974
  nonce.should_not be_nil
1975
1975
 
@@ -1979,7 +1979,7 @@ describe Braintree::Transaction do
1979
1979
  :payment_method_nonce => nonce,
1980
1980
  :paypal_account => {
1981
1981
  :payee_id => "fake-payee-id"
1982
- }
1982
+ },
1983
1983
  )
1984
1984
 
1985
1985
  result.success?.should == true
@@ -1993,7 +1993,7 @@ describe Braintree::Transaction do
1993
1993
  nonce = nonce_for_new_payment_method(
1994
1994
  :paypal_account => {
1995
1995
  :consent_code => "PAYPAL_CONSENT_CODE",
1996
- }
1996
+ },
1997
1997
  )
1998
1998
  nonce.should_not be_nil
1999
1999
 
@@ -2004,7 +2004,7 @@ describe Braintree::Transaction do
2004
2004
  :paypal_account => {},
2005
2005
  :options => {
2006
2006
  :payee_id => "fake-payee-id"
2007
- }
2007
+ },
2008
2008
  )
2009
2009
 
2010
2010
  result.success?.should == true
@@ -2018,7 +2018,7 @@ describe Braintree::Transaction do
2018
2018
  nonce = nonce_for_new_payment_method(
2019
2019
  :paypal_account => {
2020
2020
  :consent_code => "PAYPAL_CONSENT_CODE",
2021
- }
2021
+ },
2022
2022
  )
2023
2023
  nonce.should_not be_nil
2024
2024
 
@@ -2030,7 +2030,7 @@ describe Braintree::Transaction do
2030
2030
  :paypal => {
2031
2031
  :payee_id => "fake-payee-id"
2032
2032
  }
2033
- }
2033
+ },
2034
2034
  )
2035
2035
 
2036
2036
  result.success?.should == true
@@ -2044,7 +2044,7 @@ describe Braintree::Transaction do
2044
2044
  nonce = nonce_for_new_payment_method(
2045
2045
  :paypal_account => {
2046
2046
  :consent_code => "PAYPAL_CONSENT_CODE",
2047
- }
2047
+ },
2048
2048
  )
2049
2049
  nonce.should_not be_nil
2050
2050
 
@@ -2054,7 +2054,7 @@ describe Braintree::Transaction do
2054
2054
  :payment_method_nonce => nonce,
2055
2055
  :paypal_account => {
2056
2056
  :payee_email => "bt_seller_us@paypal.com"
2057
- }
2057
+ },
2058
2058
  )
2059
2059
 
2060
2060
  result.success?.should == true
@@ -2068,7 +2068,7 @@ describe Braintree::Transaction do
2068
2068
  nonce = nonce_for_new_payment_method(
2069
2069
  :paypal_account => {
2070
2070
  :consent_code => "PAYPAL_CONSENT_CODE",
2071
- }
2071
+ },
2072
2072
  )
2073
2073
  nonce.should_not be_nil
2074
2074
 
@@ -2079,7 +2079,7 @@ describe Braintree::Transaction do
2079
2079
  :paypal_account => {},
2080
2080
  :options => {
2081
2081
  :payee_email => "bt_seller_us@paypal.com"
2082
- }
2082
+ },
2083
2083
  )
2084
2084
 
2085
2085
  result.success?.should == true
@@ -2093,7 +2093,7 @@ describe Braintree::Transaction do
2093
2093
  nonce = nonce_for_new_payment_method(
2094
2094
  :paypal_account => {
2095
2095
  :consent_code => "PAYPAL_CONSENT_CODE",
2096
- }
2096
+ },
2097
2097
  )
2098
2098
  nonce.should_not be_nil
2099
2099
 
@@ -2105,7 +2105,7 @@ describe Braintree::Transaction do
2105
2105
  :paypal => {
2106
2106
  :payee_email => "bt_seller_us@paypal.com"
2107
2107
  }
2108
- }
2108
+ },
2109
2109
  )
2110
2110
 
2111
2111
  result.success?.should == true
@@ -2119,7 +2119,7 @@ describe Braintree::Transaction do
2119
2119
  nonce = nonce_for_new_payment_method(
2120
2120
  :paypal_account => {
2121
2121
  :consent_code => "PAYPAL_CONSENT_CODE",
2122
- }
2122
+ },
2123
2123
  )
2124
2124
  nonce.should_not be_nil
2125
2125
 
@@ -2131,7 +2131,7 @@ describe Braintree::Transaction do
2131
2131
  :paypal => {
2132
2132
  :custom_field => "Additional info"
2133
2133
  }
2134
- }
2134
+ },
2135
2135
  )
2136
2136
 
2137
2137
  result.success?.should == true
@@ -2145,7 +2145,7 @@ describe Braintree::Transaction do
2145
2145
  nonce = nonce_for_new_payment_method(
2146
2146
  :paypal_account => {
2147
2147
  :consent_code => "PAYPAL_CONSENT_CODE",
2148
- }
2148
+ },
2149
2149
  )
2150
2150
  nonce.should_not be_nil
2151
2151
 
@@ -2157,7 +2157,7 @@ describe Braintree::Transaction do
2157
2157
  :paypal => {
2158
2158
  :description => "A great product"
2159
2159
  }
2160
- }
2160
+ },
2161
2161
  )
2162
2162
 
2163
2163
  result.success?.should == true
@@ -2171,7 +2171,7 @@ describe Braintree::Transaction do
2171
2171
  nonce = nonce_for_new_payment_method(
2172
2172
  :paypal_account => {
2173
2173
  :consent_code => "PAYPAL_CONSENT_CODE",
2174
- }
2174
+ },
2175
2175
  )
2176
2176
  nonce.should_not be_nil
2177
2177
 
@@ -2186,7 +2186,7 @@ describe Braintree::Transaction do
2186
2186
  :key2 => "value2",
2187
2187
  }
2188
2188
  }
2189
- }
2189
+ },
2190
2190
  )
2191
2191
 
2192
2192
  # note - supplementary data is not returned in response
@@ -2200,7 +2200,7 @@ describe Braintree::Transaction do
2200
2200
  SpecHelper::ThreeDSecureMerchantAccountId,
2201
2201
  :number => Braintree::Test::CreditCardNumbers::Visa,
2202
2202
  :expiration_month => "12",
2203
- :expiration_year => "2012"
2203
+ :expiration_year => "2012",
2204
2204
  )
2205
2205
 
2206
2206
  result = Braintree::Transaction.create(
@@ -2211,7 +2211,7 @@ describe Braintree::Transaction do
2211
2211
  :number => Braintree::Test::CreditCardNumbers::Visa,
2212
2212
  :expiration_date => "12/12",
2213
2213
  },
2214
- :three_d_secure_token => three_d_secure_token
2214
+ :three_d_secure_token => three_d_secure_token,
2215
2215
  )
2216
2216
 
2217
2217
  result.success?.should == true
@@ -2223,7 +2223,7 @@ describe Braintree::Transaction do
2223
2223
  :number => "4111111111111111",
2224
2224
  :expiration_month => "11",
2225
2225
  :expiration_year => "2099",
2226
- }
2226
+ },
2227
2227
  )
2228
2228
  nonce.should_not be_nil
2229
2229
  result = Braintree::Transaction.create(
@@ -2235,7 +2235,7 @@ describe Braintree::Transaction do
2235
2235
  :three_d_secure => {
2236
2236
  :required => true,
2237
2237
  }
2238
- }
2238
+ },
2239
2239
  )
2240
2240
 
2241
2241
  result.success?.should == false
@@ -2251,7 +2251,7 @@ describe Braintree::Transaction do
2251
2251
  :credit_card => {
2252
2252
  :number => Braintree::Test::CreditCardNumbers::Visa,
2253
2253
  :expiration_date => "12/12",
2254
- }
2254
+ },
2255
2255
  )
2256
2256
  result.success?.should == true
2257
2257
  end
@@ -2262,7 +2262,7 @@ describe Braintree::Transaction do
2262
2262
  SpecHelper::ThreeDSecureMerchantAccountId,
2263
2263
  :number => Braintree::Test::CreditCardNumbers::Visa,
2264
2264
  :expiration_month => "12",
2265
- :expiration_year => "2022"
2265
+ :expiration_year => "2022",
2266
2266
  )
2267
2267
 
2268
2268
  result = Braintree::Transaction.create(
@@ -2273,7 +2273,7 @@ describe Braintree::Transaction do
2273
2273
  :number => Braintree::Test::CreditCardNumbers::Visa,
2274
2274
  :expiration_date => "12/22",
2275
2275
  },
2276
- :three_d_secure_authentication_id => three_d_secure_authentication_id
2276
+ :three_d_secure_authentication_id => three_d_secure_authentication_id,
2277
2277
  )
2278
2278
 
2279
2279
  result.success?.should == true
@@ -2287,7 +2287,7 @@ describe Braintree::Transaction do
2287
2287
  :number => Braintree::Test::CreditCardNumbers::Visa,
2288
2288
  :expiration_date => "12/12",
2289
2289
  },
2290
- :three_d_secure_authentication_id => nil
2290
+ :three_d_secure_authentication_id => nil,
2291
2291
  )
2292
2292
  result.success?.should == false
2293
2293
  result.errors.for(:transaction).on(:three_d_secure_authentication_id)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureAuthenticationIdIsInvalid
@@ -2297,7 +2297,7 @@ describe Braintree::Transaction do
2297
2297
  SpecHelper::ThreeDSecureMerchantAccountId,
2298
2298
  :number => Braintree::Test::CreditCardNumbers::Visa,
2299
2299
  :expiration_month => "12",
2300
- :expiration_year => "2012"
2300
+ :expiration_year => "2012",
2301
2301
  )
2302
2302
 
2303
2303
  result = Braintree::Transaction.create(
@@ -2307,7 +2307,7 @@ describe Braintree::Transaction do
2307
2307
  :number => Braintree::Test::CreditCardNumbers::MasterCard,
2308
2308
  :expiration_date => "12/12",
2309
2309
  },
2310
- :three_d_secure_authentication_id => three_d_secure_authentication_id
2310
+ :three_d_secure_authentication_id => three_d_secure_authentication_id,
2311
2311
  )
2312
2312
  result.success?.should == false
2313
2313
  result.errors.for(:transaction).on(:three_d_secure_authentication_id)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureTransactionPaymentMethodDoesntMatchThreeDSecureAuthenticationPaymentMethod
@@ -2317,7 +2317,7 @@ describe Braintree::Transaction do
2317
2317
  SpecHelper::ThreeDSecureMerchantAccountId,
2318
2318
  :number => Braintree::Test::CreditCardNumbers::Visa,
2319
2319
  :expiration_month => "12",
2320
- :expiration_year => "2012"
2320
+ :expiration_year => "2012",
2321
2321
  )
2322
2322
 
2323
2323
  result = Braintree::Transaction.create(
@@ -2328,7 +2328,7 @@ describe Braintree::Transaction do
2328
2328
  :number => Braintree::Test::CreditCardNumbers::MasterCard,
2329
2329
  :expiration_date => "12/12",
2330
2330
  },
2331
- :three_d_secure_authentication_id => three_d_secure_authentication_id
2331
+ :three_d_secure_authentication_id => three_d_secure_authentication_id,
2332
2332
  )
2333
2333
  result.success?.should == false
2334
2334
  result.errors.for(:transaction).on(:three_d_secure_authentication_id)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureTransactionPaymentMethodDoesntMatchThreeDSecureAuthenticationPaymentMethod
@@ -2338,7 +2338,7 @@ describe Braintree::Transaction do
2338
2338
  SpecHelper::ThreeDSecureMerchantAccountId,
2339
2339
  :number => Braintree::Test::CreditCardNumbers::Visa,
2340
2340
  :expiration_month => "12",
2341
- :expiration_year => "2012"
2341
+ :expiration_year => "2012",
2342
2342
  )
2343
2343
  result = Braintree::Transaction.create(
2344
2344
  :merchant_account_id => SpecHelper::ThreeDSecureMerchantAccountId,
@@ -2358,7 +2358,7 @@ describe Braintree::Transaction do
2358
2358
  :directory_response => "Y",
2359
2359
  :cavv_algorithm => "2",
2360
2360
  :ds_transaction_id => "some_ds_id",
2361
- }
2361
+ },
2362
2362
  )
2363
2363
  result.success?.should == false
2364
2364
  result.errors.for(:transaction).on(:three_d_secure_authentication_id)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureAuthenticationIdWithThreeDSecurePassThruIsInvalid
@@ -2371,7 +2371,7 @@ describe Braintree::Transaction do
2371
2371
  SpecHelper::ThreeDSecureMerchantAccountId,
2372
2372
  :number => Braintree::Test::CreditCardNumbers::Visa,
2373
2373
  :expiration_month => "12",
2374
- :expiration_year => "2012"
2374
+ :expiration_year => "2012",
2375
2375
  )
2376
2376
 
2377
2377
  result = Braintree::Transaction.create(
@@ -2382,7 +2382,7 @@ describe Braintree::Transaction do
2382
2382
  :number => Braintree::Test::CreditCardNumbers::Visa,
2383
2383
  :expiration_date => "12/12",
2384
2384
  },
2385
- :three_d_secure_token => three_d_secure_token
2385
+ :three_d_secure_token => three_d_secure_token,
2386
2386
  )
2387
2387
 
2388
2388
  result.success?.should == true
@@ -2397,7 +2397,7 @@ describe Braintree::Transaction do
2397
2397
  :number => Braintree::Test::CreditCardNumbers::Visa,
2398
2398
  :expiration_date => "12/12",
2399
2399
  },
2400
- :three_d_secure_token => nil
2400
+ :three_d_secure_token => nil,
2401
2401
  )
2402
2402
  result.success?.should == false
2403
2403
  result.errors.for(:transaction).on(:three_d_secure_token)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureTokenIsInvalid
@@ -2408,7 +2408,7 @@ describe Braintree::Transaction do
2408
2408
  SpecHelper::ThreeDSecureMerchantAccountId,
2409
2409
  :number => Braintree::Test::CreditCardNumbers::Visa,
2410
2410
  :expiration_month => "12",
2411
- :expiration_year => "2012"
2411
+ :expiration_year => "2012",
2412
2412
  )
2413
2413
 
2414
2414
  result = Braintree::Transaction.create(
@@ -2419,7 +2419,7 @@ describe Braintree::Transaction do
2419
2419
  :number => Braintree::Test::CreditCardNumbers::MasterCard,
2420
2420
  :expiration_date => "12/12",
2421
2421
  },
2422
- :three_d_secure_token => three_d_secure_token
2422
+ :three_d_secure_token => three_d_secure_token,
2423
2423
  )
2424
2424
  result.success?.should == false
2425
2425
  result.errors.for(:transaction).on(:three_d_secure_token)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureTransactionDataDoesntMatchVerify
@@ -2443,7 +2443,7 @@ describe Braintree::Transaction do
2443
2443
  :directory_response => "Y",
2444
2444
  :cavv_algorithm => "2",
2445
2445
  :ds_transaction_id => "some_ds_id",
2446
- }
2446
+ },
2447
2447
  )
2448
2448
 
2449
2449
  result.success?.should == true
@@ -2468,7 +2468,7 @@ describe Braintree::Transaction do
2468
2468
  :directory_response => "Y",
2469
2469
  :cavv_algorithm => "2",
2470
2470
  :ds_transaction_id => "some_ds_id",
2471
- }
2471
+ },
2472
2472
  )
2473
2473
  result.success?.should == false
2474
2474
  result.errors.for(:transaction).on(:merchant_account_id)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureMerchantAccountDoesNotSupportCardType
@@ -2486,7 +2486,7 @@ describe Braintree::Transaction do
2486
2486
  :eci_flag => "",
2487
2487
  :cavv => "some_cavv",
2488
2488
  :xid => "some_xid",
2489
- }
2489
+ },
2490
2490
  )
2491
2491
  result.success?.should == false
2492
2492
  result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:eci_flag)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureEciFlagIsRequired
@@ -2509,7 +2509,7 @@ describe Braintree::Transaction do
2509
2509
  :directory_response => "Y",
2510
2510
  :cavv_algorithm => "2",
2511
2511
  :ds_transaction_id => "some_ds_id",
2512
- }
2512
+ },
2513
2513
  )
2514
2514
  result.success?.should == false
2515
2515
  result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:cavv)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureCavvIsRequired
@@ -2532,7 +2532,7 @@ describe Braintree::Transaction do
2532
2532
  :directory_response => "Y",
2533
2533
  :cavv_algorithm => "2",
2534
2534
  :ds_transaction_id => "some_ds_id",
2535
- }
2535
+ },
2536
2536
  )
2537
2537
  result.success?.should == false
2538
2538
  result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:eci_flag)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureEciFlagIsInvalid
@@ -2555,7 +2555,7 @@ describe Braintree::Transaction do
2555
2555
  :directory_response => "Y",
2556
2556
  :cavv_algorithm => "2",
2557
2557
  :ds_transaction_id => "some_ds_id",
2558
- }
2558
+ },
2559
2559
  )
2560
2560
  result.success?.should == false
2561
2561
  result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:three_d_secure_version)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureThreeDSecureVersionIsInvalid
@@ -2579,7 +2579,7 @@ describe Braintree::Transaction do
2579
2579
  :directory_response => "Y",
2580
2580
  :cavv_algorithm => "2",
2581
2581
  :ds_transaction_id => "some_ds_id",
2582
- }
2582
+ },
2583
2583
  )
2584
2584
  result.success?.should == false
2585
2585
  result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:authentication_response)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureAuthenticationResponseIsInvalid
@@ -2603,7 +2603,7 @@ describe Braintree::Transaction do
2603
2603
  :directory_response => "abc",
2604
2604
  :cavv_algorithm => "2",
2605
2605
  :ds_transaction_id => "some_ds_id",
2606
- }
2606
+ },
2607
2607
  )
2608
2608
  result.success?.should == false
2609
2609
  result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:directory_response)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureDirectoryResponseIsInvalid
@@ -2627,7 +2627,7 @@ describe Braintree::Transaction do
2627
2627
  :directory_response => "Y",
2628
2628
  :cavv_algorithm => "bad_alg",
2629
2629
  :ds_transaction_id => "some_ds_id",
2630
- }
2630
+ },
2631
2631
  )
2632
2632
  result.success?.should == false
2633
2633
  result.errors.for(:transaction).for(:three_d_secure_pass_thru).on(:cavv_algorithm)[0].code.should == Braintree::ErrorCodes::Transaction::ThreeDSecureCavvAlgorithmIsInvalid
@@ -2639,12 +2639,12 @@ describe Braintree::Transaction do
2639
2639
  it "can create a transaction" do
2640
2640
  payment_method_result = Braintree::PaymentMethod.create(
2641
2641
  :customer_id => Braintree::Customer.create.customer.id,
2642
- :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment
2642
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
2643
2643
  )
2644
2644
  result = Braintree::Transaction.create(
2645
2645
  :type => "sale",
2646
2646
  :amount => Braintree::Test::TransactionAmounts::Authorize,
2647
- :payment_method_token => payment_method_result.payment_method.token
2647
+ :payment_method_token => payment_method_result.payment_method.token,
2648
2648
  )
2649
2649
 
2650
2650
  result.should be_success
@@ -2659,13 +2659,13 @@ describe Braintree::Transaction do
2659
2659
  payment_method_token = rand(36**3).to_s(36)
2660
2660
  nonce = nonce_for_paypal_account(
2661
2661
  :consent_code => "PAYPAL_CONSENT_CODE",
2662
- :token => payment_method_token
2662
+ :token => payment_method_token,
2663
2663
  )
2664
2664
 
2665
2665
  result = Braintree::Transaction.create(
2666
2666
  :type => "sale",
2667
2667
  :amount => Braintree::Test::TransactionAmounts::Authorize,
2668
- :payment_method_nonce => nonce
2668
+ :payment_method_nonce => nonce,
2669
2669
  )
2670
2670
 
2671
2671
  result.should be_success
@@ -2681,14 +2681,14 @@ describe Braintree::Transaction do
2681
2681
  payment_method_token = rand(36**3).to_s(36)
2682
2682
  nonce = nonce_for_paypal_account(
2683
2683
  :consent_code => "PAYPAL_CONSENT_CODE",
2684
- :token => payment_method_token
2684
+ :token => payment_method_token,
2685
2685
  )
2686
2686
 
2687
2687
  result = Braintree::Transaction.create(
2688
2688
  :type => "sale",
2689
2689
  :amount => Braintree::Test::TransactionAmounts::Authorize,
2690
2690
  :payment_method_nonce => nonce,
2691
- :options => {:store_in_vault => true}
2691
+ :options => {:store_in_vault => true},
2692
2692
  )
2693
2693
 
2694
2694
  result.success?.should == true
@@ -2707,7 +2707,7 @@ describe Braintree::Transaction do
2707
2707
  :type => "sale",
2708
2708
  :amount => Braintree::Test::TransactionAmounts::Authorize,
2709
2709
  :payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
2710
- :options => {:store_in_vault => true}
2710
+ :options => {:store_in_vault => true},
2711
2711
  )
2712
2712
 
2713
2713
  result.should be_success
@@ -2722,7 +2722,7 @@ describe Braintree::Transaction do
2722
2722
  result = Braintree::Transaction.create(
2723
2723
  :type => "sale",
2724
2724
  :amount => Braintree::Test::TransactionAmounts::Authorize,
2725
- :payment_method_nonce => Braintree::Test::Nonce::LocalPayment
2725
+ :payment_method_nonce => Braintree::Test::Nonce::LocalPayment,
2726
2726
  )
2727
2727
 
2728
2728
  result.should be_success
@@ -2740,7 +2740,7 @@ describe Braintree::Transaction do
2740
2740
  result = Braintree::Transaction.create(
2741
2741
  :type => "sale",
2742
2742
  :amount => Braintree::Test::TransactionAmounts::Authorize,
2743
- :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
2743
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
2744
2744
  )
2745
2745
 
2746
2746
  result.should be_success
@@ -2752,14 +2752,14 @@ describe Braintree::Transaction do
2752
2752
  payment_method_token = rand(36**3).to_s(36)
2753
2753
  nonce = nonce_for_paypal_account(
2754
2754
  :access_token => "PAYPAL_ACCESS_TOKEN",
2755
- :token => payment_method_token
2755
+ :token => payment_method_token,
2756
2756
  )
2757
2757
 
2758
2758
  result = Braintree::Transaction.create(
2759
2759
  :type => "sale",
2760
2760
  :amount => Braintree::Test::TransactionAmounts::Authorize,
2761
2761
  :payment_method_nonce => nonce,
2762
- :options => {:store_in_vault => true}
2762
+ :options => {:store_in_vault => true},
2763
2763
  )
2764
2764
 
2765
2765
  result.success?.should == true
@@ -2779,7 +2779,7 @@ describe Braintree::Transaction do
2779
2779
  :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
2780
2780
  :options => {
2781
2781
  :submit_for_settlement => true
2782
- }
2782
+ },
2783
2783
  )
2784
2784
  result.success?.should == true
2785
2785
  result.transaction.status.should == Braintree::Transaction::Status::Settling
@@ -2790,7 +2790,7 @@ describe Braintree::Transaction do
2790
2790
  it "successfully voids a paypal transaction that's been authorized" do
2791
2791
  sale_transaction = Braintree::Transaction.sale!(
2792
2792
  :amount => Braintree::Test::TransactionAmounts::Authorize,
2793
- :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
2793
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
2794
2794
  )
2795
2795
 
2796
2796
  void_transaction = Braintree::Transaction.void!(sale_transaction.id)
@@ -2801,7 +2801,7 @@ describe Braintree::Transaction do
2801
2801
  it "fails to void a paypal transaction that's been declined" do
2802
2802
  sale_transaction = Braintree::Transaction.sale(
2803
2803
  :amount => Braintree::Test::TransactionAmounts::Decline,
2804
- :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
2804
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
2805
2805
  ).transaction
2806
2806
 
2807
2807
  expect do
@@ -2871,6 +2871,19 @@ describe Braintree::Transaction do
2871
2871
  result.transaction.amount.should == transaction.amount/2
2872
2872
  end
2873
2873
 
2874
+ it "allows merchant_account_id to be passed for the refund" do
2875
+ transaction = create_transaction_to_refund
2876
+
2877
+ result = Braintree::Transaction.refund(
2878
+ transaction.id,
2879
+ :merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
2880
+ )
2881
+
2882
+ result.success?.should == true
2883
+ result.transaction.type.should == "credit"
2884
+ result.transaction.merchant_account_id.should == SpecHelper::NonDefaultMerchantAccountId
2885
+ end
2886
+
2874
2887
  it "does not allow arbitrary options to be passed" do
2875
2888
  transaction = create_paypal_transaction_for_refund
2876
2889
 
@@ -2889,7 +2902,7 @@ describe Braintree::Transaction do
2889
2902
  it "returns an error result if unsettled" do
2890
2903
  transaction = Braintree::Transaction.sale!(
2891
2904
  :amount => Braintree::Test::TransactionAmounts::Authorize,
2892
- :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
2905
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
2893
2906
  )
2894
2907
  result = Braintree::Transaction.refund(transaction.id)
2895
2908
  result.success?.should == false
@@ -2902,7 +2915,7 @@ describe Braintree::Transaction do
2902
2915
  :payment_method_nonce => Braintree::Test::Nonce::Transactable,
2903
2916
  :options => {
2904
2917
  :submit_for_settlement => true
2905
- }
2918
+ },
2906
2919
  )
2907
2920
  config = Braintree::Configuration.instantiate
2908
2921
  response = config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
@@ -2923,7 +2936,7 @@ describe Braintree::Transaction do
2923
2936
  :payment_method_nonce => Braintree::Test::Nonce::Transactable,
2924
2937
  :options => {
2925
2938
  :submit_for_settlement => true
2926
- }
2939
+ },
2927
2940
  )
2928
2941
  config = Braintree::Configuration.instantiate
2929
2942
  response = config.http.put("#{config.base_merchant_path}/transactions/#{transaction.id}/settle")
@@ -2943,13 +2956,13 @@ describe Braintree::Transaction do
2943
2956
  it "handles bad unvalidated nonces" do
2944
2957
  nonce = nonce_for_paypal_account(
2945
2958
  :access_token => "PAYPAL_ACCESS_TOKEN",
2946
- :consent_code => "PAYPAL_CONSENT_CODE"
2959
+ :consent_code => "PAYPAL_CONSENT_CODE",
2947
2960
  )
2948
2961
 
2949
2962
  result = Braintree::Transaction.create(
2950
2963
  :type => "sale",
2951
2964
  :amount => Braintree::Test::TransactionAmounts::Authorize,
2952
- :payment_method_nonce => nonce
2965
+ :payment_method_nonce => nonce,
2953
2966
  )
2954
2967
 
2955
2968
  result.should_not be_success
@@ -2960,7 +2973,7 @@ describe Braintree::Transaction do
2960
2973
  result = Braintree::Transaction.create(
2961
2974
  :type => "sale",
2962
2975
  :amount => Braintree::Test::TransactionAmounts::Authorize,
2963
- :payment_method_nonce => "NON_EXISTENT_NONCE"
2976
+ :payment_method_nonce => "NON_EXISTENT_NONCE",
2964
2977
  )
2965
2978
 
2966
2979
  result.should_not be_success
@@ -4088,7 +4101,7 @@ describe Braintree::Transaction do
4088
4101
  :unit_of_measure => "gallon",
4089
4102
  :total_amount => "10.1",
4090
4103
  },
4091
- ['Name #2'],
4104
+ ["Name #2"],
4092
4105
  {
4093
4106
  :quantity => "2.02",
4094
4107
  :name => "Name #3",
@@ -4274,7 +4287,7 @@ describe Braintree::Transaction do
4274
4287
  customer = Braintree::Customer.create!
4275
4288
  result = Braintree::PaymentMethod.create(
4276
4289
  :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
4277
- :customer_id => customer.id
4290
+ :customer_id => customer.id,
4278
4291
  )
4279
4292
  payment_method_token = result.payment_method.token
4280
4293
 
@@ -4409,7 +4422,7 @@ describe Braintree::Transaction do
4409
4422
  :credit_card => {
4410
4423
  :account_type => "credit",
4411
4424
  }
4412
- }
4425
+ },
4413
4426
  )
4414
4427
  result.success?.should == true
4415
4428
  result.transaction.credit_card_details.account_type.should == "credit"
@@ -4428,7 +4441,7 @@ describe Braintree::Transaction do
4428
4441
  :credit_card => {
4429
4442
  :account_type => "credit",
4430
4443
  }
4431
- }
4444
+ },
4432
4445
  )
4433
4446
  result.success?.should == true
4434
4447
  result.transaction.credit_card_details.account_type.should == "credit"
@@ -4448,7 +4461,7 @@ describe Braintree::Transaction do
4448
4461
  :account_type => "debit",
4449
4462
  },
4450
4463
  :submit_for_settlement => true,
4451
- }
4464
+ },
4452
4465
  )
4453
4466
  result.success?.should == true
4454
4467
  result.transaction.credit_card_details.account_type.should == "debit"
@@ -4467,7 +4480,7 @@ describe Braintree::Transaction do
4467
4480
  :credit_card => {
4468
4481
  :account_type => "debit",
4469
4482
  },
4470
- }
4483
+ },
4471
4484
  )
4472
4485
  result.success?.should == false
4473
4486
  result.errors.for(:transaction).for(:options).for(:credit_card).on(:account_type)[0].code.should == Braintree::ErrorCodes::Transaction::Options::CreditCard::AccountTypeDebitDoesNotSupportAuths
@@ -4486,7 +4499,7 @@ describe Braintree::Transaction do
4486
4499
  :credit_card => {
4487
4500
  :account_type => "ach",
4488
4501
  },
4489
- }
4502
+ },
4490
4503
  )
4491
4504
  result.success?.should == false
4492
4505
  result.errors.for(:transaction).for(:options).for(:credit_card).on(:account_type)[0].code.should == Braintree::ErrorCodes::Transaction::Options::CreditCard::AccountTypeIsInvalid
@@ -4504,7 +4517,7 @@ describe Braintree::Transaction do
4504
4517
  :credit_card => {
4505
4518
  :account_type => "credit",
4506
4519
  },
4507
- }
4520
+ },
4508
4521
  )
4509
4522
  result.success?.should == false
4510
4523
  result.errors.for(:transaction).for(:options).for(:credit_card).on(:account_type)[0].code.should == Braintree::ErrorCodes::Transaction::Options::CreditCard::AccountTypeNotSupported
@@ -4520,7 +4533,7 @@ describe Braintree::Transaction do
4520
4533
  :credit_card => {
4521
4534
  :number => Braintree::Test::CreditCardNumbers::Visa,
4522
4535
  :expiration_date => "05/2009"
4523
- }
4536
+ },
4524
4537
  )
4525
4538
  transaction.id.should =~ /^\w{6,}$/
4526
4539
  transaction.type.should == "sale"
@@ -4538,7 +4551,7 @@ describe Braintree::Transaction do
4538
4551
  :credit_card => {
4539
4552
  :number => Braintree::Test::CreditCardNumbers::Visa,
4540
4553
  :expiration_date => "05/2009"
4541
- }
4554
+ },
4542
4555
  )
4543
4556
  end.to raise_error(Braintree::ValidationsFailed)
4544
4557
  end
@@ -4594,7 +4607,7 @@ describe Braintree::Transaction do
4594
4607
  :credit_card => {
4595
4608
  :number => Braintree::Test::CreditCardNumbers::Visa,
4596
4609
  :expiration_date => "05/2009"
4597
- }
4610
+ },
4598
4611
  )
4599
4612
  result = Braintree::Transaction.refund(transaction.id)
4600
4613
  result.success?.should == false
@@ -4631,7 +4644,7 @@ describe Braintree::Transaction do
4631
4644
  :credit_card => {
4632
4645
  :number => Braintree::Test::CreditCardNumbers::Visa,
4633
4646
  :expiration_date => "05/2009"
4634
- }
4647
+ },
4635
4648
  )
4636
4649
  result.success?.should == true
4637
4650
  result.transaction.id.should =~ /^\w{6,}$/
@@ -4687,7 +4700,7 @@ describe Braintree::Transaction do
4687
4700
  :postal_code => "60103",
4688
4701
  :country_name => "United States of America",
4689
4702
  :shipping_method => Braintree::Transaction::AddressDetails::ShippingMethod::Electronic
4690
- }
4703
+ },
4691
4704
  )
4692
4705
  result.success?.should == true
4693
4706
  transaction = result.transaction
@@ -4751,7 +4764,7 @@ describe Braintree::Transaction do
4751
4764
  :credit_card => {
4752
4765
  :number => Braintree::Test::CreditCardNumbers::Visa,
4753
4766
  :expiration_date => "05/2009"
4754
- }
4767
+ },
4755
4768
  )
4756
4769
  result.success?.should == true
4757
4770
  result.transaction.merchant_account_id.should == SpecHelper::NonDefaultMerchantAccountId
@@ -4763,7 +4776,7 @@ describe Braintree::Transaction do
4763
4776
  :credit_card => {
4764
4777
  :number => Braintree::Test::CreditCardNumbers::Visa,
4765
4778
  :expiration_date => "05/2009"
4766
- }
4779
+ },
4767
4780
  )
4768
4781
  result.success?.should == true
4769
4782
  result.transaction.merchant_account_id.should == SpecHelper::DefaultMerchantAccountId
@@ -4782,7 +4795,7 @@ describe Braintree::Transaction do
4782
4795
  },
4783
4796
  :options => {
4784
4797
  :store_in_vault => true
4785
- }
4798
+ },
4786
4799
  )
4787
4800
  result.success?.should == true
4788
4801
  transaction = result.transaction
@@ -4817,7 +4830,7 @@ describe Braintree::Transaction do
4817
4830
  :options => {
4818
4831
  :store_in_vault => true,
4819
4832
  :add_billing_address_to_payment_method => true,
4820
- }
4833
+ },
4821
4834
  )
4822
4835
  result.success?.should == true
4823
4836
  transaction = result.transaction
@@ -4862,7 +4875,7 @@ describe Braintree::Transaction do
4862
4875
  :options => {
4863
4876
  :store_in_vault => true,
4864
4877
  :store_shipping_address_in_vault => true,
4865
- }
4878
+ },
4866
4879
  )
4867
4880
  result.success?.should == true
4868
4881
  transaction = result.transaction
@@ -4888,7 +4901,7 @@ describe Braintree::Transaction do
4888
4901
  :number => "5105105105105100",
4889
4902
  :expiration_date => "05/2012"
4890
4903
  },
4891
- :options => { :store_in_vault => true }
4904
+ :options => {:store_in_vault => true},
4892
4905
  )
4893
4906
 
4894
4907
  result.success?.should == true
@@ -4906,7 +4919,7 @@ describe Braintree::Transaction do
4906
4919
  },
4907
4920
  :options => {
4908
4921
  :submit_for_settlement => true
4909
- }
4922
+ },
4910
4923
  )
4911
4924
  result.success?.should == true
4912
4925
  result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
@@ -4929,7 +4942,7 @@ describe Braintree::Transaction do
4929
4942
  },
4930
4943
  :options => {
4931
4944
  :store_in_vault => true
4932
- }
4945
+ },
4933
4946
  )
4934
4947
  result.success?.should == true
4935
4948
  transaction = result.transaction
@@ -4944,20 +4957,20 @@ describe Braintree::Transaction do
4944
4957
  :credit_card => {
4945
4958
  :number => Braintree::Test::CreditCardNumbers::Visa,
4946
4959
  :expiration_date => "05/2010"
4947
- }
4960
+ },
4948
4961
  )
4949
4962
  address = Braintree::Address.create!(
4950
4963
  :customer_id => customer.id,
4951
- :street_address => '123 Fake St.'
4964
+ :street_address => "123 Fake St.",
4952
4965
  )
4953
4966
  result = Braintree::Transaction.sale(
4954
4967
  :amount => "100",
4955
4968
  :customer_id => customer.id,
4956
- :shipping_address_id => address.id
4969
+ :shipping_address_id => address.id,
4957
4970
  )
4958
4971
  result.success?.should == true
4959
4972
  transaction = result.transaction
4960
- transaction.shipping_details.street_address.should == '123 Fake St.'
4973
+ transaction.shipping_details.street_address.should == "123 Fake St."
4961
4974
  transaction.customer_details.id.should == customer.id
4962
4975
  transaction.shipping_details.id.should == address.id
4963
4976
  end
@@ -4974,7 +4987,7 @@ describe Braintree::Transaction do
4974
4987
  }
4975
4988
  result = Braintree::Transaction.sale(params[:transaction])
4976
4989
  result.success?.should == false
4977
- result.params.should == {:transaction => {:type => 'sale', :amount => nil, :credit_card => {:expiration_date => "05/2009"}}}
4990
+ result.params.should == {:transaction => {:type => "sale", :amount => nil, :credit_card => {:expiration_date => "05/2009"}}}
4978
4991
  result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::AmountIsRequired
4979
4992
  end
4980
4993
 
@@ -5055,7 +5068,7 @@ describe Braintree::Transaction do
5055
5068
  },
5056
5069
  :options => {
5057
5070
  :skip_advanced_fraud_checking => true
5058
- }
5071
+ },
5059
5072
  )
5060
5073
  result.success?.should == true
5061
5074
  result.transaction.risk_data.should be_nil
@@ -5149,7 +5162,7 @@ describe Braintree::Transaction do
5149
5162
  :currency_amount => "10.00",
5150
5163
  :currency_iso_code => "USD"
5151
5164
  }
5152
- }
5165
+ },
5153
5166
  )
5154
5167
  result.success?.should == true
5155
5168
  result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
@@ -5171,7 +5184,7 @@ describe Braintree::Transaction do
5171
5184
  :currency_amount => "10.00",
5172
5185
  :currency_iso_code => "USD"
5173
5186
  }
5174
- }
5187
+ },
5175
5188
  )
5176
5189
  result.success?.should == true
5177
5190
  result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
@@ -5193,7 +5206,7 @@ describe Braintree::Transaction do
5193
5206
  :currency_amount => "10.00",
5194
5207
  :currency_iso_code => "USD"
5195
5208
  }
5196
- }
5209
+ },
5197
5210
  )
5198
5211
  result.success?.should == true
5199
5212
  result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
@@ -5216,7 +5229,7 @@ describe Braintree::Transaction do
5216
5229
  :currency_amount => "10.00",
5217
5230
  :currency_iso_code => "USD"
5218
5231
  }
5219
- }
5232
+ },
5220
5233
  )
5221
5234
  result.success?.should == true
5222
5235
 
@@ -5240,7 +5253,7 @@ describe Braintree::Transaction do
5240
5253
  :currency_amount => "10.00",
5241
5254
  :currency_iso_code => "USD"
5242
5255
  }
5243
- }
5256
+ },
5244
5257
  )
5245
5258
  result.success?.should == true
5246
5259
  result.transaction.status.should == Braintree::Transaction::Status::Authorized
@@ -5265,7 +5278,7 @@ describe Braintree::Transaction do
5265
5278
  :currency_amount => "10.00",
5266
5279
  :currency_iso_code => "USD"
5267
5280
  }
5268
- }
5281
+ },
5269
5282
  )
5270
5283
  result.success?.should == true
5271
5284
  result.transaction.status.should == Braintree::Transaction::Status::Authorized
@@ -5285,7 +5298,7 @@ describe Braintree::Transaction do
5285
5298
  :credit_card => {
5286
5299
  :number => Braintree::Test::CreditCardNumbers::Visa,
5287
5300
  :expiration_date => "05/2009"
5288
- }
5301
+ },
5289
5302
  )
5290
5303
  transaction.id.should =~ /^\w{6,}$/
5291
5304
  transaction.type.should == "sale"
@@ -5302,7 +5315,7 @@ describe Braintree::Transaction do
5302
5315
  :credit_card => {
5303
5316
  :number => Braintree::Test::CreditCardNumbers::Visa,
5304
5317
  :expiration_date => "05/2009"
5305
- }
5318
+ },
5306
5319
  )
5307
5320
  end.to raise_error(Braintree::ValidationsFailed)
5308
5321
  end
@@ -5315,7 +5328,7 @@ describe Braintree::Transaction do
5315
5328
  :credit_card => {
5316
5329
  :number => Braintree::Test::CreditCardNumbers::Visa,
5317
5330
  :expiration_date => "06/2009"
5318
- }
5331
+ },
5319
5332
  )
5320
5333
  result = Braintree::Transaction.submit_for_settlement(transaction.id)
5321
5334
  result.success?.should == true
@@ -5327,7 +5340,7 @@ describe Braintree::Transaction do
5327
5340
  :credit_card => {
5328
5341
  :number => Braintree::Test::CreditCardNumbers::Visa,
5329
5342
  :expiration_date => "06/2009"
5330
- }
5343
+ },
5331
5344
  )
5332
5345
  transaction.amount.should == BigDecimal("1000.00")
5333
5346
  result = Braintree::Transaction.submit_for_settlement(transaction.id, "999.99")
@@ -5343,9 +5356,9 @@ describe Braintree::Transaction do
5343
5356
  :credit_card => {
5344
5357
  :number => Braintree::Test::CreditCardNumbers::Visa,
5345
5358
  :expiration_date => "06/2009"
5346
- }
5359
+ },
5347
5360
  )
5348
- options = { :order_id => "ABC123" }
5361
+ options = {:order_id => "ABC123"}
5349
5362
  result = Braintree::Transaction.submit_for_settlement(transaction.id, nil, options)
5350
5363
  result.success?.should == true
5351
5364
  result.transaction.order_id.should == "ABC123"
@@ -5358,13 +5371,13 @@ describe Braintree::Transaction do
5358
5371
  :credit_card => {
5359
5372
  :number => Braintree::Test::CreditCardNumbers::Visa,
5360
5373
  :expiration_date => "06/2009"
5361
- }
5374
+ },
5362
5375
  )
5363
5376
 
5364
5377
  options = {
5365
5378
  :descriptor => {
5366
- :name => '123*123456789012345678',
5367
- :phone => '3334445555',
5379
+ :name => "123*123456789012345678",
5380
+ :phone => "3334445555",
5368
5381
  :url => "ebay.com"
5369
5382
  }
5370
5383
  }
@@ -5372,9 +5385,9 @@ describe Braintree::Transaction do
5372
5385
  result = Braintree::Transaction.submit_for_settlement(transaction.id, nil, options)
5373
5386
  result.success?.should == true
5374
5387
  result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
5375
- result.transaction.descriptor.name.should == '123*123456789012345678'
5376
- result.transaction.descriptor.phone.should == '3334445555'
5377
- result.transaction.descriptor.url.should == 'ebay.com'
5388
+ result.transaction.descriptor.name.should == "123*123456789012345678"
5389
+ result.transaction.descriptor.phone.should == "3334445555"
5390
+ result.transaction.descriptor.url.should == "ebay.com"
5378
5391
  end
5379
5392
 
5380
5393
  it "raises an error if an invalid option is passed in" do
@@ -5383,10 +5396,10 @@ describe Braintree::Transaction do
5383
5396
  :credit_card => {
5384
5397
  :number => Braintree::Test::CreditCardNumbers::Visa,
5385
5398
  :expiration_date => "06/2009"
5386
- }
5399
+ },
5387
5400
  )
5388
5401
 
5389
- options = { :order_id => "ABC123", :invalid_option => "i'm invalid" }
5402
+ options = {:order_id => "ABC123", :invalid_option => "i'm invalid"}
5390
5403
 
5391
5404
  expect do
5392
5405
  Braintree::Transaction.submit_for_settlement(transaction.id, nil, options)
@@ -5396,10 +5409,11 @@ describe Braintree::Transaction do
5396
5409
  it "returns an error result if settlement is too large" do
5397
5410
  transaction = Braintree::Transaction.sale!(
5398
5411
  :amount => Braintree::Test::TransactionAmounts::Authorize,
5412
+ :merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
5399
5413
  :credit_card => {
5400
5414
  :number => Braintree::Test::CreditCardNumbers::Visa,
5401
5415
  :expiration_date => "06/2009"
5402
- }
5416
+ },
5403
5417
  )
5404
5418
  transaction.amount.should == BigDecimal("1000.00")
5405
5419
  result = Braintree::Transaction.submit_for_settlement(transaction.id, "1000.01")
@@ -5414,7 +5428,7 @@ describe Braintree::Transaction do
5414
5428
  :credit_card => {
5415
5429
  :number => Braintree::Test::CreditCardNumbers::Visa,
5416
5430
  :expiration_date => "06/2009"
5417
- }
5431
+ },
5418
5432
  ).transaction
5419
5433
  result = Braintree::Transaction.submit_for_settlement(transaction.id)
5420
5434
  result.success?.should == false
@@ -5431,7 +5445,7 @@ describe Braintree::Transaction do
5431
5445
  :number => Braintree::Test::CreditCardNumbers::Visa,
5432
5446
  :expiration_date => "06/2009"
5433
5447
  },
5434
- :service_fee_amount => "1.00"
5448
+ :service_fee_amount => "1.00",
5435
5449
  ).transaction
5436
5450
  result = Braintree::Transaction.submit_for_settlement(transaction.id, "0.01")
5437
5451
  result.success?.should == false
@@ -5454,7 +5468,7 @@ describe Braintree::Transaction do
5454
5468
  :currency_amount => "10.00",
5455
5469
  :currency_iso_code => "USD"
5456
5470
  }
5457
- }
5471
+ },
5458
5472
  )
5459
5473
  result.success?.should == true
5460
5474
 
@@ -5478,7 +5492,7 @@ describe Braintree::Transaction do
5478
5492
  :currency_amount => "10.00",
5479
5493
  :currency_iso_code => "USD"
5480
5494
  }
5481
- }
5495
+ },
5482
5496
  )
5483
5497
  result.success?.should == true
5484
5498
 
@@ -5498,7 +5512,7 @@ describe Braintree::Transaction do
5498
5512
  :discount_amount => "12.00",
5499
5513
  :tax_amount => "0",
5500
5514
  },
5501
- ]
5515
+ ],
5502
5516
  )
5503
5517
  result.success?.should == true
5504
5518
  result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
@@ -5512,9 +5526,9 @@ describe Braintree::Transaction do
5512
5526
  :credit_card => {
5513
5527
  :number => Braintree::Test::CreditCardNumbers::Visa,
5514
5528
  :expiration_date => "06/2009"
5515
- }
5529
+ },
5516
5530
  )
5517
- options = { :order_id => "ABC123" }
5531
+ options = {:order_id => "ABC123"}
5518
5532
  transaction = Braintree::Transaction.submit_for_settlement!(original_transaction.id, "0.01", options)
5519
5533
  transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
5520
5534
  transaction.id.should == original_transaction.id
@@ -5524,10 +5538,11 @@ describe Braintree::Transaction do
5524
5538
  it "raises a ValidationsFailed if unsuccessful" do
5525
5539
  transaction = Braintree::Transaction.sale!(
5526
5540
  :amount => Braintree::Test::TransactionAmounts::Authorize,
5541
+ :merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
5527
5542
  :credit_card => {
5528
5543
  :number => Braintree::Test::CreditCardNumbers::Visa,
5529
5544
  :expiration_date => "06/2009"
5530
- }
5545
+ },
5531
5546
  )
5532
5547
  transaction.amount.should == BigDecimal("1000.00")
5533
5548
  expect do
@@ -5543,18 +5558,18 @@ describe Braintree::Transaction do
5543
5558
  :amount => Braintree::Test::TransactionAmounts::Authorize,
5544
5559
  :merchant_account_id => SpecHelper::DefaultMerchantAccountId,
5545
5560
  :descriptor => {
5546
- :name => '123*123456789012345678',
5547
- :phone => '3334445555',
5561
+ :name => "123*123456789012345678",
5562
+ :phone => "3334445555",
5548
5563
  :url => "ebay.com"
5549
5564
  },
5550
- :order_id => '123',
5565
+ :order_id => "123",
5551
5566
  :credit_card => {
5552
5567
  :number => Braintree::Test::CreditCardNumbers::Visa,
5553
5568
  :expiration_date => "06/2009"
5554
5569
  },
5555
5570
  :options => {
5556
5571
  :submit_for_settlement => true
5557
- }
5572
+ },
5558
5573
  )
5559
5574
  end
5560
5575
 
@@ -5562,16 +5577,16 @@ describe Braintree::Transaction do
5562
5577
  result = Braintree::Transaction.update_details(transaction.id, {
5563
5578
  :amount => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
5564
5579
  :descriptor => {
5565
- :name => '456*123456789012345678',
5566
- :phone => '3334445555',
5580
+ :name => "456*123456789012345678",
5581
+ :phone => "3334445555",
5567
5582
  :url => "ebay.com",
5568
5583
  },
5569
- :order_id => '456'
5584
+ :order_id => "456"
5570
5585
  })
5571
5586
  result.success?.should == true
5572
5587
  result.transaction.amount.should == BigDecimal(Braintree::Test::TransactionAmounts::Authorize) - 1
5573
- result.transaction.order_id.should == '456'
5574
- result.transaction.descriptor.name.should == '456*123456789012345678'
5588
+ result.transaction.order_id.should == "456"
5589
+ result.transaction.descriptor.name.should == "456*123456789012345678"
5575
5590
  end
5576
5591
 
5577
5592
  it "raises an error when a key is invalid" do
@@ -5579,11 +5594,11 @@ describe Braintree::Transaction do
5579
5594
  Braintree::Transaction.update_details(transaction.id, {
5580
5595
  :invalid_key => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
5581
5596
  :descriptor => {
5582
- :name => '456*123456789012345678',
5583
- :phone => '3334445555',
5597
+ :name => "456*123456789012345678",
5598
+ :phone => "3334445555",
5584
5599
  :url => "ebay.com",
5585
5600
  },
5586
- :order_id => '456'
5601
+ :order_id => "456"
5587
5602
  })
5588
5603
  end.to raise_error(ArgumentError)
5589
5604
  end
@@ -5593,11 +5608,11 @@ describe Braintree::Transaction do
5593
5608
  result = Braintree::Transaction.update_details(transaction.id, {
5594
5609
  :amount => "10000",
5595
5610
  :descriptor => {
5596
- :name => '456*123456789012345678',
5597
- :phone => '3334445555',
5611
+ :name => "456*123456789012345678",
5612
+ :phone => "3334445555",
5598
5613
  :url => "ebay.com",
5599
5614
  },
5600
- :order_id => '456'
5615
+ :order_id => "456"
5601
5616
  })
5602
5617
  result.success?.should == false
5603
5618
  result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::SettlementAmountIsTooLarge
@@ -5607,11 +5622,11 @@ describe Braintree::Transaction do
5607
5622
  result = Braintree::Transaction.update_details(transaction.id, {
5608
5623
  :amount => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
5609
5624
  :descriptor => {
5610
- :name => 'invalid descriptor name',
5611
- :phone => 'invalid phone',
5612
- :url => '12345678901234'
5625
+ :name => "invalid descriptor name",
5626
+ :phone => "invalid phone",
5627
+ :url => "12345678901234"
5613
5628
  },
5614
- :order_id => '456'
5629
+ :order_id => "456"
5615
5630
  })
5616
5631
  result.success?.should == false
5617
5632
  result.errors.for(:transaction).for(:descriptor).on(:name)[0].code.should == Braintree::ErrorCodes::Descriptor::NameFormatIsInvalid
@@ -5623,11 +5638,11 @@ describe Braintree::Transaction do
5623
5638
  result = Braintree::Transaction.update_details(transaction.id, {
5624
5639
  :amount => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
5625
5640
  :descriptor => {
5626
- :name => '456*123456789012345678',
5627
- :phone => '3334445555',
5641
+ :name => "456*123456789012345678",
5642
+ :phone => "3334445555",
5628
5643
  :url => "ebay.com",
5629
5644
  },
5630
- :order_id => 'x' * 256
5645
+ :order_id => "x" * 256
5631
5646
  })
5632
5647
  result.success?.should == false
5633
5648
  result.errors.for(:transaction).on(:order_id)[0].code.should == Braintree::ErrorCodes::Transaction::OrderIdIsTooLong
@@ -5638,27 +5653,27 @@ describe Braintree::Transaction do
5638
5653
  :amount => Braintree::Test::TransactionAmounts::Authorize,
5639
5654
  :merchant_account_id => SpecHelper::FakeAmexDirectMerchantAccountId,
5640
5655
  :descriptor => {
5641
- :name => '123*123456789012345678',
5642
- :phone => '3334445555',
5656
+ :name => "123*123456789012345678",
5657
+ :phone => "3334445555",
5643
5658
  :url => "ebay.com"
5644
5659
  },
5645
- :order_id => '123',
5660
+ :order_id => "123",
5646
5661
  :credit_card => {
5647
5662
  :number => Braintree::Test::CreditCardNumbers::AmexPayWithPoints::Success,
5648
5663
  :expiration_date => "05/2009"
5649
5664
  },
5650
5665
  :options => {
5651
5666
  :submit_for_settlement => true
5652
- }
5667
+ },
5653
5668
  )
5654
5669
  result = Braintree::Transaction.update_details(transaction.id, {
5655
5670
  :amount => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
5656
5671
  :descriptor => {
5657
- :name => '456*123456789012345678',
5658
- :phone => '3334445555',
5672
+ :name => "456*123456789012345678",
5673
+ :phone => "3334445555",
5659
5674
  :url => "ebay.com",
5660
5675
  },
5661
- :order_id => '456'
5676
+ :order_id => "456"
5662
5677
  })
5663
5678
  result.success?.should == false
5664
5679
  result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::ProcessorDoesNotSupportUpdatingTransactionDetails
@@ -5672,24 +5687,24 @@ describe Braintree::Transaction do
5672
5687
  :amount => Braintree::Test::TransactionAmounts::Authorize,
5673
5688
  :merchant_account_id => SpecHelper::DefaultMerchantAccountId,
5674
5689
  :descriptor => {
5675
- :name => '123*123456789012345678',
5676
- :phone => '3334445555',
5690
+ :name => "123*123456789012345678",
5691
+ :phone => "3334445555",
5677
5692
  :url => "ebay.com"
5678
5693
  },
5679
- :order_id => '123',
5694
+ :order_id => "123",
5680
5695
  :credit_card => {
5681
5696
  :number => Braintree::Test::CreditCardNumbers::Visa,
5682
5697
  :expiration_date => "06/2009"
5683
- }
5698
+ },
5684
5699
  )
5685
5700
  result = Braintree::Transaction.update_details(transaction.id, {
5686
5701
  :amount => Braintree::Test::TransactionAmounts::Authorize.to_f - 1,
5687
5702
  :descriptor => {
5688
- :name => '456*123456789012345678',
5689
- :phone => '3334445555',
5703
+ :name => "456*123456789012345678",
5704
+ :phone => "3334445555",
5690
5705
  :url => "ebay.com",
5691
5706
  },
5692
- :order_id => '456'
5707
+ :order_id => "456"
5693
5708
  })
5694
5709
  result.success?.should == false
5695
5710
  result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::CannotUpdateTransactionDetailsNotSubmittedForSettlement
@@ -5706,7 +5721,7 @@ describe Braintree::Transaction do
5706
5721
  :credit_card => {
5707
5722
  :number => Braintree::Test::CreditCardNumbers::Visa,
5708
5723
  :expiration_date => "06/2009"
5709
- }
5724
+ },
5710
5725
  )
5711
5726
 
5712
5727
  result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100)
@@ -5741,7 +5756,7 @@ describe Braintree::Transaction do
5741
5756
  :credit_card => {
5742
5757
  :number => Braintree::Test::CreditCardNumbers::Visa,
5743
5758
  :expiration_date => "05/2009"
5744
- }
5759
+ },
5745
5760
  )
5746
5761
 
5747
5762
  result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100, :order_id => 1234)
@@ -5757,7 +5772,7 @@ describe Braintree::Transaction do
5757
5772
  :credit_card => {
5758
5773
  :number => Braintree::Test::CreditCardNumbers::Visa,
5759
5774
  :expiration_date => "05/2009"
5760
- }
5775
+ },
5761
5776
  )
5762
5777
 
5763
5778
  result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100, :order_id => "1"*256)
@@ -5772,13 +5787,13 @@ describe Braintree::Transaction do
5772
5787
  :credit_card => {
5773
5788
  :number => Braintree::Test::CreditCardNumbers::Visa,
5774
5789
  :expiration_date => "05/2009"
5775
- }
5790
+ },
5776
5791
  )
5777
5792
 
5778
5793
  result = Braintree::Transaction.submit_for_partial_settlement(
5779
5794
  authorized_transaction.id,
5780
5795
  100,
5781
- :descriptor => { :name => "123*123456789012345678", :phone => "5555551234", :url => "url.com" }
5796
+ :descriptor => {:name => "123*123456789012345678", :phone => "5555551234", :url => "url.com"},
5782
5797
  )
5783
5798
  result.success?.should == true
5784
5799
  partial_settlement_transaction = result.transaction
@@ -5794,7 +5809,7 @@ describe Braintree::Transaction do
5794
5809
  :credit_card => {
5795
5810
  :number => Braintree::Test::CreditCardNumbers::Visa,
5796
5811
  :expiration_date => "05/2009"
5797
- }
5812
+ },
5798
5813
  )
5799
5814
 
5800
5815
  result = Braintree::Transaction.submit_for_partial_settlement(
@@ -5802,9 +5817,9 @@ describe Braintree::Transaction do
5802
5817
  100,
5803
5818
  :descriptor => {
5804
5819
  :name => "invalid_format",
5805
- :phone => '%bad4445555',
5806
- :url => '12345678901234'
5807
- }
5820
+ :phone => "%bad4445555",
5821
+ :url => "12345678901234"
5822
+ },
5808
5823
  )
5809
5824
  result.success?.should == false
5810
5825
  result.errors.for(:transaction).for(:descriptor).on(:name)[0].code.should == Braintree::ErrorCodes::Descriptor::NameFormatIsInvalid
@@ -5819,7 +5834,7 @@ describe Braintree::Transaction do
5819
5834
  :credit_card => {
5820
5835
  :number => Braintree::Test::CreditCardNumbers::AmexPayWithPoints::Success,
5821
5836
  :expiration_date => "05/2009"
5822
- }
5837
+ },
5823
5838
  )
5824
5839
 
5825
5840
  result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100)
@@ -5831,7 +5846,7 @@ describe Braintree::Transaction do
5831
5846
  authorized_transaction = Braintree::Transaction.sale!(
5832
5847
  :amount => Braintree::Test::TransactionAmounts::Authorize,
5833
5848
  :merchant_account_id => SpecHelper::FakeVenmoAccountMerchantAccountId,
5834
- :payment_method_nonce => Braintree::Test::Nonce::VenmoAccount
5849
+ :payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
5835
5850
  )
5836
5851
 
5837
5852
  result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100)
@@ -5846,7 +5861,7 @@ describe Braintree::Transaction do
5846
5861
  :credit_card => {
5847
5862
  :number => Braintree::Test::CreditCardNumbers::Visa,
5848
5863
  :expiration_date => "06/2009"
5849
- }
5864
+ },
5850
5865
  )
5851
5866
 
5852
5867
  result = Braintree::Transaction.submit_for_partial_settlement(authorized_transaction.id, 100)
@@ -5864,7 +5879,7 @@ describe Braintree::Transaction do
5864
5879
  :credit_card => {
5865
5880
  :number => Braintree::Test::CreditCardNumbers::Visa,
5866
5881
  :expiration_date => "06/2009"
5867
- }
5882
+ },
5868
5883
  )
5869
5884
 
5870
5885
  result = Braintree::Transaction.void(authorized_transaction.id)
@@ -5883,9 +5898,9 @@ describe Braintree::Transaction do
5883
5898
  :credit_card => {
5884
5899
  :number => Braintree::Test::CreditCardNumbers::Visa,
5885
5900
  :expiration_date => "06/2009"
5886
- }
5901
+ },
5887
5902
  )
5888
- options = { :order_id => "ABC123" }
5903
+ options = {:order_id => "ABC123"}
5889
5904
  transaction = Braintree::Transaction.submit_for_partial_settlement!(original_transaction.id, "0.01", options)
5890
5905
  transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
5891
5906
  transaction.order_id.should == options[:order_id]
@@ -5897,7 +5912,7 @@ describe Braintree::Transaction do
5897
5912
  :credit_card => {
5898
5913
  :number => Braintree::Test::CreditCardNumbers::Visa,
5899
5914
  :expiration_date => "06/2009"
5900
- }
5915
+ },
5901
5916
  )
5902
5917
  transaction.amount.should == BigDecimal("1000.00")
5903
5918
  expect do
@@ -5922,7 +5937,7 @@ describe Braintree::Transaction do
5922
5937
  :number => Braintree::Test::CreditCardNumbers::Visa,
5923
5938
  :expiration_date => "05/2009"
5924
5939
  },
5925
- :service_fee_amount => '1.00'
5940
+ :service_fee_amount => "1.00",
5926
5941
  )
5927
5942
 
5928
5943
  transaction.escrow_status.should be_nil
@@ -5948,7 +5963,7 @@ describe Braintree::Transaction do
5948
5963
  :number => Braintree::Test::CreditCardNumbers::Visa,
5949
5964
  :expiration_date => "05/2009"
5950
5965
  },
5951
- :service_fee_amount => '1.00'
5966
+ :service_fee_amount => "1.00",
5952
5967
  )
5953
5968
 
5954
5969
  transaction.escrow_status.should be_nil
@@ -6008,7 +6023,7 @@ describe Braintree::Transaction do
6008
6023
  :credit_card => {
6009
6024
  :number => Braintree::Test::CreditCardNumbers::Visa,
6010
6025
  :expiration_date => "05/2009"
6011
- }
6026
+ },
6012
6027
  )
6013
6028
  result.success?.should == true
6014
6029
  result.transaction.id.should =~ /^\w{6,}$/
@@ -6031,7 +6046,7 @@ describe Braintree::Transaction do
6031
6046
  }
6032
6047
  result = Braintree::Transaction.credit(params[:transaction])
6033
6048
  result.success?.should == false
6034
- result.params.should == {:transaction => {:type => 'credit', :amount => nil, :credit_card => {:expiration_date => "05/2009"}}}
6049
+ result.params.should == {:transaction => {:type => "credit", :amount => nil, :credit_card => {:expiration_date => "05/2009"}}}
6035
6050
  result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::AmountIsRequired
6036
6051
  end
6037
6052
 
@@ -6042,7 +6057,7 @@ describe Braintree::Transaction do
6042
6057
  :credit_card => {
6043
6058
  :number => Braintree::Test::CreditCardNumbers::Visa,
6044
6059
  :expiration_date => "05/2009"
6045
- }
6060
+ },
6046
6061
  )
6047
6062
  result.success?.should == true
6048
6063
  result.transaction.merchant_account_id.should == SpecHelper::NonDefaultMerchantAccountId
@@ -6054,7 +6069,7 @@ describe Braintree::Transaction do
6054
6069
  :credit_card => {
6055
6070
  :number => Braintree::Test::CreditCardNumbers::Visa,
6056
6071
  :expiration_date => "05/2009"
6057
- }
6072
+ },
6058
6073
  )
6059
6074
  result.success?.should == true
6060
6075
  result.transaction.merchant_account_id.should == SpecHelper::DefaultMerchantAccountId
@@ -6084,7 +6099,7 @@ describe Braintree::Transaction do
6084
6099
  :credit_card => {
6085
6100
  :number => Braintree::Test::CreditCardNumbers::Visa,
6086
6101
  :expiration_date => "05/2009"
6087
- }
6102
+ },
6088
6103
  )
6089
6104
  transaction.id.should =~ /^\w{6,}$/
6090
6105
  transaction.type.should == "credit"
@@ -6101,7 +6116,7 @@ describe Braintree::Transaction do
6101
6116
  :credit_card => {
6102
6117
  :number => Braintree::Test::CreditCardNumbers::Visa,
6103
6118
  :expiration_date => "05/2009"
6104
- }
6119
+ },
6105
6120
  )
6106
6121
  end.to raise_error(Braintree::ValidationsFailed)
6107
6122
  end
@@ -6115,7 +6130,7 @@ describe Braintree::Transaction do
6115
6130
  :credit_card => {
6116
6131
  :number => Braintree::Test::CreditCardNumbers::Visa,
6117
6132
  :expiration_date => "05/2009"
6118
- }
6133
+ },
6119
6134
  )
6120
6135
  result.success?.should == true
6121
6136
  created_transaction = result.transaction
@@ -6132,7 +6147,7 @@ describe Braintree::Transaction do
6132
6147
  :number => Braintree::Test::CreditCardNumbers::Visa,
6133
6148
  :expiration_date => "05/2009"
6134
6149
  },
6135
- :options => { :store_in_vault => true }
6150
+ :options => {:store_in_vault => true},
6136
6151
  )
6137
6152
  result.success?.should == true
6138
6153
  created_transaction = result.transaction
@@ -6177,7 +6192,7 @@ describe Braintree::Transaction do
6177
6192
  :credit_card => {
6178
6193
  :number => Braintree::Test::CreditCardNumbers::Visa,
6179
6194
  :expiration_date => "05/2009"
6180
- }
6195
+ },
6181
6196
  )
6182
6197
  result.success?.should == true
6183
6198
  created_transaction = result.transaction
@@ -6227,7 +6242,7 @@ describe Braintree::Transaction do
6227
6242
  :credit_card => {
6228
6243
  :number => Braintree::Test::CreditCardNumbers::Visa,
6229
6244
  :expiration_date => "05/2009"
6230
- }
6245
+ },
6231
6246
  )
6232
6247
  result.success?.should == true
6233
6248
  created_transaction = result.transaction
@@ -6296,7 +6311,7 @@ describe Braintree::Transaction do
6296
6311
  :number => Braintree::Test::CreditCardNumbers::Visa,
6297
6312
  :expiration_date => "12/12",
6298
6313
  },
6299
- :service_fee_amount => "10.00"
6314
+ :service_fee_amount => "10.00",
6300
6315
  )
6301
6316
 
6302
6317
  result.transaction.escrow_status.should be_nil
@@ -6313,7 +6328,7 @@ describe Braintree::Transaction do
6313
6328
  :credit_card => {
6314
6329
  :number => Braintree::Test::CreditCardNumbers::Visa,
6315
6330
  :expiration_date => "05/2009"
6316
- }
6331
+ },
6317
6332
  )
6318
6333
 
6319
6334
  result = Braintree::Transaction.hold_in_escrow(transaction.id)
@@ -6331,7 +6346,7 @@ describe Braintree::Transaction do
6331
6346
  :number => Braintree::Test::CreditCardNumbers::Visa,
6332
6347
  :expiration_date => "12/12",
6333
6348
  },
6334
- :service_fee_amount => "10.00"
6349
+ :service_fee_amount => "10.00",
6335
6350
  )
6336
6351
 
6337
6352
  result.transaction.escrow_status.should be_nil
@@ -6347,7 +6362,7 @@ describe Braintree::Transaction do
6347
6362
  :credit_card => {
6348
6363
  :number => Braintree::Test::CreditCardNumbers::Visa,
6349
6364
  :expiration_date => "05/2009"
6350
- }
6365
+ },
6351
6366
  )
6352
6367
 
6353
6368
  expect do
@@ -6363,7 +6378,7 @@ describe Braintree::Transaction do
6363
6378
  :credit_card => {
6364
6379
  :number => Braintree::Test::CreditCardNumbers::Visa,
6365
6380
  :expiration_date => "05/2009"
6366
- }
6381
+ },
6367
6382
  )
6368
6383
  result = Braintree::Transaction.void(transaction.id)
6369
6384
  result.success?.should == true
@@ -6377,7 +6392,7 @@ describe Braintree::Transaction do
6377
6392
  :credit_card => {
6378
6393
  :number => Braintree::Test::CreditCardNumbers::Visa,
6379
6394
  :expiration_date => "05/2009"
6380
- }
6395
+ },
6381
6396
  ).transaction
6382
6397
  result = Braintree::Transaction.void(transaction.id)
6383
6398
  result.success?.should == false
@@ -6392,7 +6407,7 @@ describe Braintree::Transaction do
6392
6407
  :credit_card => {
6393
6408
  :number => Braintree::Test::CreditCardNumbers::Visa,
6394
6409
  :expiration_date => "05/2009"
6395
- }
6410
+ },
6396
6411
  )
6397
6412
  returned_transaction = Braintree::Transaction.void!(transaction.id)
6398
6413
  returned_transaction.should == transaction
@@ -6405,7 +6420,7 @@ describe Braintree::Transaction do
6405
6420
  :credit_card => {
6406
6421
  :number => Braintree::Test::CreditCardNumbers::Visa,
6407
6422
  :expiration_date => "05/2009"
6408
- }
6423
+ },
6409
6424
  ).transaction
6410
6425
  expect do
6411
6426
  Braintree::Transaction.void!(transaction.id)
@@ -6420,7 +6435,7 @@ describe Braintree::Transaction do
6420
6435
  :credit_card => {
6421
6436
  :number => Braintree::Test::CreditCardNumbers::Visa,
6422
6437
  :expiration_date => "05/2009"
6423
- }
6438
+ },
6424
6439
  )
6425
6440
  result = Braintree::Transaction.submit_for_settlement!(transaction.id)
6426
6441
  result.status_history.size.should == 2
@@ -6478,7 +6493,7 @@ describe Braintree::Transaction do
6478
6493
  :credit_card => {
6479
6494
  :number => Braintree::Test::CreditCardNumbers::Visa,
6480
6495
  :expiration_date => "05/2010"
6481
- }
6496
+ },
6482
6497
  )
6483
6498
  transaction = Braintree::CreditCard.sale(customer.credit_cards[0].token, {:amount => "100.00"}).transaction
6484
6499
  transaction.vault_credit_card.should == customer.credit_cards[0]
@@ -6491,7 +6506,7 @@ describe Braintree::Transaction do
6491
6506
  :credit_card => {
6492
6507
  :number => Braintree::Test::CreditCardNumbers::Visa,
6493
6508
  :expiration_date => "05/2010"
6494
- }
6509
+ },
6495
6510
  )
6496
6511
  transaction.vault_credit_card.should == nil
6497
6512
  end
@@ -6503,7 +6518,7 @@ describe Braintree::Transaction do
6503
6518
  :credit_card => {
6504
6519
  :number => Braintree::Test::CreditCardNumbers::Visa,
6505
6520
  :expiration_date => "05/2010"
6506
- }
6521
+ },
6507
6522
  )
6508
6523
  transaction = Braintree::CreditCard.sale(customer.credit_cards[0].token, :amount => "100.00").transaction
6509
6524
  transaction.vault_customer.should == customer
@@ -6516,7 +6531,7 @@ describe Braintree::Transaction do
6516
6531
  :credit_card => {
6517
6532
  :number => Braintree::Test::CreditCardNumbers::Visa,
6518
6533
  :expiration_date => "05/2010"
6519
- }
6534
+ },
6520
6535
  )
6521
6536
  transaction.vault_customer.should == nil
6522
6537
  end
@@ -6531,7 +6546,7 @@ describe Braintree::Transaction do
6531
6546
  },
6532
6547
  :options => {
6533
6548
  :submit_for_settlement => true
6534
- }
6549
+ },
6535
6550
  )
6536
6551
 
6537
6552
  config = Braintree::Configuration.instantiate
@@ -6545,7 +6560,7 @@ describe Braintree::Transaction do
6545
6560
  :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
6546
6561
  :options => {
6547
6562
  :submit_for_settlement => true
6548
- }
6563
+ },
6549
6564
  )
6550
6565
 
6551
6566
  config = Braintree::Configuration.instantiate
@@ -6561,8 +6576,8 @@ describe Braintree::Transaction do
6561
6576
  :number => Braintree::Test::CreditCardNumbers::Visa,
6562
6577
  :expiration_date => "05/2009"
6563
6578
  },
6564
- :service_fee_amount => '1.00',
6565
- :options => { :hold_in_escrow => true }
6579
+ :service_fee_amount => "1.00",
6580
+ :options => {:hold_in_escrow => true},
6566
6581
  )
6567
6582
 
6568
6583
  config = Braintree::Configuration.instantiate
@@ -6576,7 +6591,7 @@ describe Braintree::Transaction do
6576
6591
  it "can create a transaction with venmo_sdk_payment_method_code" do
6577
6592
  result = Braintree::Transaction.sale(
6578
6593
  :amount => "10.00",
6579
- :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK.generate_test_payment_method_code(Braintree::Test::CreditCardNumbers::Visa)
6594
+ :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK.generate_test_payment_method_code(Braintree::Test::CreditCardNumbers::Visa),
6580
6595
  )
6581
6596
  result.success?.should == true
6582
6597
  result.transaction.credit_card_details.venmo_sdk?.should == false
@@ -6585,7 +6600,7 @@ describe Braintree::Transaction do
6585
6600
  it "errors when an invalid payment method code is passed" do
6586
6601
  result = Braintree::Transaction.sale(
6587
6602
  :amount => "10.00",
6588
- :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::InvalidPaymentMethodCode
6603
+ :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::InvalidPaymentMethodCode,
6589
6604
  )
6590
6605
  result.success?.should == false
6591
6606
  result.message.should include("Invalid VenmoSDK payment method code")
@@ -6603,7 +6618,7 @@ describe Braintree::Transaction do
6603
6618
  },
6604
6619
  :options => {
6605
6620
  :venmo_sdk_session => Braintree::Test::VenmoSDK::Session
6606
- }
6621
+ },
6607
6622
  )
6608
6623
  result.success?.should == true
6609
6624
  result.transaction.credit_card_details.venmo_sdk?.should == false
@@ -6618,7 +6633,7 @@ describe Braintree::Transaction do
6618
6633
  },
6619
6634
  :options => {
6620
6635
  :venmo_sdk_session => Braintree::Test::VenmoSDK::InvalidSession
6621
- }
6636
+ },
6622
6637
  )
6623
6638
  result.success?.should == true
6624
6639
  result.transaction.credit_card_details.venmo_sdk?.should == false
@@ -6630,7 +6645,7 @@ describe Braintree::Transaction do
6630
6645
  it "can create a transaction for a paypal account" do
6631
6646
  result = Braintree::Transaction.sale(
6632
6647
  :amount => "10.00",
6633
- :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment
6648
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
6634
6649
  )
6635
6650
  result.success?.should == true
6636
6651
  result.transaction.paypal_details.payer_email.should == "payer@example.com"
@@ -6645,7 +6660,7 @@ describe Braintree::Transaction do
6645
6660
  :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
6646
6661
  :options => {
6647
6662
  :store_in_vault => true
6648
- }
6663
+ },
6649
6664
  )
6650
6665
  result.success?.should == true
6651
6666
  result.transaction.paypal_details.token.should_not be_nil
@@ -6658,7 +6673,7 @@ describe Braintree::Transaction do
6658
6673
  customer = Braintree::Customer.create!
6659
6674
  result = Braintree::PaymentMethod.create(
6660
6675
  :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
6661
- :customer_id => customer.id
6676
+ :customer_id => customer.id,
6662
6677
  )
6663
6678
 
6664
6679
  result.should be_success
@@ -6668,7 +6683,7 @@ describe Braintree::Transaction do
6668
6683
  result = Braintree::Transaction.sale(
6669
6684
  :amount => "100",
6670
6685
  :customer_id => customer.id,
6671
- :payment_method_token => payment_method_token
6686
+ :payment_method_token => payment_method_token,
6672
6687
  )
6673
6688
 
6674
6689
  result.should be_success
@@ -6683,7 +6698,7 @@ describe Braintree::Transaction do
6683
6698
  nonce = nonce_for_paypal_account(:token => "TOKEN")
6684
6699
  result = Braintree::Transaction.sale(
6685
6700
  :amount => "10.00",
6686
- :payment_method_nonce => nonce
6701
+ :payment_method_nonce => nonce,
6687
6702
  )
6688
6703
  result.should_not be_success
6689
6704
  result.errors.for(:transaction).for(:paypal_account).first.code.should == Braintree::ErrorCodes::PayPalAccount::IncompletePayPalAccount
@@ -6698,7 +6713,7 @@ describe Braintree::Transaction do
6698
6713
  :public_key => "oauth_app_partner_user_public_key",
6699
6714
  :private_key => "oauth_app_partner_user_private_key",
6700
6715
  :environment => Braintree::Configuration.environment,
6701
- :logger => Logger.new("/dev/null")
6716
+ :logger => Logger.new("/dev/null"),
6702
6717
  )
6703
6718
  @customer = @partner_merchant_gateway.customer.create(
6704
6719
  :first_name => "Joe",
@@ -6707,12 +6722,12 @@ describe Braintree::Transaction do
6707
6722
  :email => "joe@example.com",
6708
6723
  :phone => "312.555.1234",
6709
6724
  :fax => "614.555.5678",
6710
- :website => "www.example.com"
6725
+ :website => "www.example.com",
6711
6726
  ).customer
6712
6727
  @address = @partner_merchant_gateway.address.create(
6713
6728
  :customer_id => @customer.id,
6714
6729
  :first_name => "Testy",
6715
- :last_name => "McTesterson"
6730
+ :last_name => "McTesterson",
6716
6731
  ).address
6717
6732
  @credit_card = @partner_merchant_gateway.credit_card.create(
6718
6733
  :customer_id => @customer.id,
@@ -6723,13 +6738,13 @@ describe Braintree::Transaction do
6723
6738
  :first_name => "Adam",
6724
6739
  :last_name => "Davis",
6725
6740
  :postal_code => "95131"
6726
- }
6741
+ },
6727
6742
  ).credit_card
6728
6743
 
6729
6744
  oauth_gateway = Braintree::Gateway.new(
6730
6745
  :client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
6731
6746
  :client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
6732
- :logger => Logger.new("/dev/null")
6747
+ :logger => Logger.new("/dev/null"),
6733
6748
  )
6734
6749
  access_token = Braintree::OAuthTestHelper.create_token(oauth_gateway, {
6735
6750
  :merchant_public_id => "integration_merchant_id",
@@ -6738,7 +6753,7 @@ describe Braintree::Transaction do
6738
6753
 
6739
6754
  @granting_gateway = Braintree::Gateway.new(
6740
6755
  :access_token => access_token,
6741
- :logger => Logger.new("/dev/null")
6756
+ :logger => Logger.new("/dev/null"),
6742
6757
  )
6743
6758
 
6744
6759
  end
@@ -6748,7 +6763,7 @@ describe Braintree::Transaction do
6748
6763
 
6749
6764
  result = Braintree::Transaction.sale(
6750
6765
  :payment_method_nonce => grant_result.payment_method_nonce.nonce,
6751
- :amount => Braintree::Test::TransactionAmounts::Authorize
6766
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
6752
6767
  )
6753
6768
  result.transaction.facilitated_details.merchant_id.should == "integration_merchant_id"
6754
6769
  result.transaction.facilitated_details.merchant_name.should == "14ladders"
@@ -6764,7 +6779,7 @@ describe Braintree::Transaction do
6764
6779
 
6765
6780
  result = Braintree::Transaction.sale(
6766
6781
  :payment_method_nonce => grant_result.payment_method_nonce.nonce,
6767
- :amount => Braintree::Test::TransactionAmounts::Authorize
6782
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
6768
6783
  )
6769
6784
 
6770
6785
  result.transaction.billing_details.postal_code == "95131"
@@ -6776,7 +6791,7 @@ describe Braintree::Transaction do
6776
6791
  :shared_customer_id => @customer.id,
6777
6792
  :shared_shipping_address_id => @address.id,
6778
6793
  :shared_billing_address_id => @address.id,
6779
- :amount => Braintree::Test::TransactionAmounts::Authorize
6794
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
6780
6795
  )
6781
6796
  result.success?.should == true
6782
6797
  result.transaction.shipping_details.first_name.should == @address.first_name
@@ -6786,7 +6801,7 @@ describe Braintree::Transaction do
6786
6801
  it "facilitated details are returned on transaction created via a shared_payment_method_token" do
6787
6802
  result = @granting_gateway.transaction.sale(
6788
6803
  :shared_payment_method_token => @credit_card.token,
6789
- :amount => Braintree::Test::TransactionAmounts::Authorize
6804
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
6790
6805
  )
6791
6806
  result.transaction.facilitated_details.merchant_id.should == "integration_merchant_id"
6792
6807
  result.transaction.facilitated_details.merchant_name.should == "14ladders"
@@ -6798,12 +6813,12 @@ describe Braintree::Transaction do
6798
6813
 
6799
6814
  it "facilitated details are returned on transaction created via a shared_payment_method_nonce" do
6800
6815
  shared_nonce = @partner_merchant_gateway.payment_method_nonce.create(
6801
- @credit_card.token
6816
+ @credit_card.token,
6802
6817
  ).payment_method_nonce.nonce
6803
6818
 
6804
6819
  result = @granting_gateway.transaction.sale(
6805
6820
  :shared_payment_method_nonce => shared_nonce,
6806
- :amount => Braintree::Test::TransactionAmounts::Authorize
6821
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
6807
6822
  )
6808
6823
  result.transaction.facilitated_details.merchant_id.should == "integration_merchant_id"
6809
6824
  result.transaction.facilitated_details.merchant_name.should == "14ladders"
@@ -6816,7 +6831,7 @@ describe Braintree::Transaction do
6816
6831
 
6817
6832
  context "paypal here" do
6818
6833
  it "gets the details of an auth/capture transaction" do
6819
- result = Braintree::Transaction.find('paypal_here_auth_capture_id')
6834
+ result = Braintree::Transaction.find("paypal_here_auth_capture_id")
6820
6835
  result.payment_instrument_type.should eq(Braintree::PaymentInstrumentType::PayPalHere)
6821
6836
  result.paypal_here_details.should_not be_nil
6822
6837
 
@@ -6833,7 +6848,7 @@ describe Braintree::Transaction do
6833
6848
  end
6834
6849
 
6835
6850
  it "gets the details of a sale transaction" do
6836
- result = Braintree::Transaction.find('paypal_here_sale_id')
6851
+ result = Braintree::Transaction.find("paypal_here_sale_id")
6837
6852
  result.paypal_here_details.should_not be_nil
6838
6853
 
6839
6854
  details = result.paypal_here_details
@@ -6841,7 +6856,7 @@ describe Braintree::Transaction do
6841
6856
  end
6842
6857
 
6843
6858
  it "gets the details of a refunded sale transaction" do
6844
- result = Braintree::Transaction.find('paypal_here_refund_id')
6859
+ result = Braintree::Transaction.find("paypal_here_refund_id")
6845
6860
  result.paypal_here_details.should_not be_nil
6846
6861
 
6847
6862
  details = result.paypal_here_details
@@ -6866,7 +6881,7 @@ describe Braintree::Transaction do
6866
6881
  customer = Braintree::Customer.create!
6867
6882
  result = Braintree::PaymentMethod.create(
6868
6883
  :payment_method_nonce => Braintree::Test::Nonce::TransactableVisa,
6869
- :customer_id => customer.id
6884
+ :customer_id => customer.id,
6870
6885
  )
6871
6886
  payment_method_token = result.payment_method.token
6872
6887
 
@@ -6968,4 +6983,143 @@ describe Braintree::Transaction do
6968
6983
  expect(installment.adjustments.map(&:kind)).to match_array([Braintree::Transaction::Installment::Adjustment::Kind::Refund])
6969
6984
  end
6970
6985
  end
6986
+
6987
+ describe "Adjust Authorization" do
6988
+ let(:first_data_master_transaction_params) do
6989
+ {
6990
+ :merchant_account_id => SpecHelper::FakeFirstDataMerchantAccountId,
6991
+ :amount => "75.50",
6992
+ :credit_card => {
6993
+ :number => "5105105105105100",
6994
+ :expiration_date => "05/2012"
6995
+ }
6996
+ }
6997
+ end
6998
+ let(:first_data_visa_transaction_params) do
6999
+ {
7000
+ :merchant_account_id => SpecHelper::FakeFirstDataMerchantAccountId,
7001
+ :amount => "75.50",
7002
+ :credit_card => {
7003
+ :number => Braintree::Test::CreditCardNumbers::Visa,
7004
+ :expiration_date => "06/2009"
7005
+ }
7006
+ }
7007
+ end
7008
+ context "successful authorization" do
7009
+ it "returns success response" do
7010
+ initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params)
7011
+ expect(initial_transaction.success?).to eq(true)
7012
+
7013
+ adjustment_transaction = Braintree::Transaction.adjust_authorization(
7014
+ initial_transaction.transaction.id, "85.50"
7015
+ )
7016
+
7017
+ expect(adjustment_transaction.success?).to eq(true)
7018
+ expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("85.50"))
7019
+ end
7020
+ end
7021
+
7022
+ context "unsuccessful authorization" do
7023
+ it "returns failure, when processor does not support multi auth adjustment" do
7024
+ initial_transaction = Braintree::Transaction.sale(
7025
+ :merchant_account_id => SpecHelper::DefaultMerchantAccountId,
7026
+ :amount => "75.50",
7027
+ :credit_card => {
7028
+ :number => Braintree::Test::CreditCardNumbers::Visa,
7029
+ :expiration_date => "06/2009"
7030
+ },
7031
+ )
7032
+ expect(initial_transaction.success?).to eq(true)
7033
+
7034
+ adjustment_transaction = Braintree::Transaction.adjust_authorization(
7035
+ initial_transaction.transaction.id, "85.50"
7036
+ )
7037
+
7038
+
7039
+ expect(adjustment_transaction.success?).to eq(false)
7040
+ expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
7041
+ expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::ProcessorDoesNotSupportAuthAdjustment)
7042
+ end
7043
+
7044
+ it "returns failure response, when adjusted amount submitted is zero" do
7045
+ initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params)
7046
+ expect(initial_transaction.success?).to eq(true)
7047
+
7048
+ adjustment_transaction = Braintree::Transaction.adjust_authorization(
7049
+ initial_transaction.transaction.id, "0.0"
7050
+ )
7051
+
7052
+ expect(adjustment_transaction.success?).to eq(false)
7053
+ expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
7054
+ expect(adjustment_transaction.errors.for(:authorization_adjustment).on(:amount).first.code).to eq(Braintree::ErrorCodes::Transaction::AdjustmentAmountMustBeGreaterThanZero)
7055
+ end
7056
+
7057
+ it "returns failure response, when adjusted amount submitted same as authorized amount" do
7058
+ initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params)
7059
+ expect(initial_transaction.success?).to eq(true)
7060
+
7061
+ adjustment_transaction = Braintree::Transaction.adjust_authorization(
7062
+ initial_transaction.transaction.id, "75.50"
7063
+ )
7064
+
7065
+ expect(adjustment_transaction.success?).to eq(false)
7066
+ expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
7067
+ expect(adjustment_transaction.errors.for(:authorization_adjustment).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::NoNetAmountToPerformAuthAdjustment)
7068
+ end
7069
+
7070
+ it "returns failure, when transaction status is not authorized" do
7071
+ additional_params = {:options => {:submit_for_settlement => true}}
7072
+ initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params.merge(additional_params))
7073
+ expect(initial_transaction.success?).to eq(true)
7074
+
7075
+ adjustment_transaction = Braintree::Transaction.adjust_authorization(
7076
+ initial_transaction.transaction.id, "85.50"
7077
+ )
7078
+
7079
+ expect(adjustment_transaction.success?).to eq(false)
7080
+ expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
7081
+ expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::TransactionMustBeInStateAuthorized)
7082
+ end
7083
+
7084
+ it "returns failure, when transaction authorization type final or undefined" do
7085
+ additional_params = {:transaction_source => "recurring_first"}
7086
+ initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params.merge(additional_params))
7087
+ expect(initial_transaction.success?).to eq(true)
7088
+
7089
+ adjustment_transaction = Braintree::Transaction.adjust_authorization(
7090
+ initial_transaction.transaction.id, "85.50"
7091
+ )
7092
+
7093
+ expect(adjustment_transaction.success?).to eq(false)
7094
+ expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
7095
+ expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::TransactionIsNotEligibleForAdjustment)
7096
+ end
7097
+
7098
+ it "returns failure, when processor does not support incremental auth" do
7099
+ initial_transaction = Braintree::Transaction.sale(first_data_visa_transaction_params)
7100
+ expect(initial_transaction.success?).to eq(true)
7101
+
7102
+ adjustment_transaction = Braintree::Transaction.adjust_authorization(
7103
+ initial_transaction.transaction.id, "85.50"
7104
+ )
7105
+
7106
+ expect(adjustment_transaction.success?).to eq(false)
7107
+ expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
7108
+ expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::ProcessorDoesNotSupportIncrementalAuth)
7109
+ end
7110
+
7111
+ it "returns failure, when processor does not support auth reversal" do
7112
+ initial_transaction = Braintree::Transaction.sale(first_data_visa_transaction_params)
7113
+ expect(initial_transaction.success?).to eq(true)
7114
+
7115
+ adjustment_transaction = Braintree::Transaction.adjust_authorization(
7116
+ initial_transaction.transaction.id, "65.50"
7117
+ )
7118
+
7119
+ expect(adjustment_transaction.success?).to eq(false)
7120
+ expect(adjustment_transaction.transaction.amount.should).to eq(BigDecimal("75.50"))
7121
+ expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::ProcessorDoesNotSupportPartialAuthReversal)
7122
+ end
7123
+ end
7124
+ end
6971
7125
  end