braintree 3.2.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/braintree.gemspec +3 -3
  3. data/lib/braintree.rb +6 -1
  4. data/lib/braintree/account_updater_daily_report.rb +1 -1
  5. data/lib/braintree/address.rb +2 -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 +14 -4
  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 +6 -4
  19. data/lib/braintree/customer_gateway.rb +2 -0
  20. data/lib/braintree/customer_search.rb +1 -1
  21. data/lib/braintree/disbursement.rb +1 -1
  22. data/lib/braintree/dispute.rb +15 -1
  23. data/lib/braintree/dispute/paypal_message.rb +15 -0
  24. data/lib/braintree/dispute_gateway.rb +2 -2
  25. data/lib/braintree/dispute_search.rb +3 -2
  26. data/lib/braintree/document_upload.rb +1 -1
  27. data/lib/braintree/error_codes.rb +10 -6
  28. data/lib/braintree/google_pay_card.rb +1 -1
  29. data/lib/braintree/granted_payment_instrument_update.rb +1 -1
  30. data/lib/braintree/graphql_client.rb +7 -7
  31. data/lib/braintree/http.rb +3 -3
  32. data/lib/braintree/local_payment_completed.rb +1 -1
  33. data/lib/braintree/local_payment_reversed.rb +19 -0
  34. data/lib/braintree/merchant.rb +1 -1
  35. data/lib/braintree/merchant_account.rb +1 -1
  36. data/lib/braintree/merchant_account_gateway.rb +1 -1
  37. data/lib/braintree/merchant_gateway.rb +1 -1
  38. data/lib/braintree/modification.rb +1 -1
  39. data/lib/braintree/oauth_credentials.rb +1 -1
  40. data/lib/braintree/oauth_gateway.rb +5 -5
  41. data/lib/braintree/payment_instrument_type.rb +10 -10
  42. data/lib/braintree/payment_method_gateway.rb +10 -7
  43. data/lib/braintree/payment_method_nonce.rb +7 -4
  44. data/lib/braintree/payment_method_nonce_details.rb +37 -0
  45. data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
  46. data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
  47. data/lib/braintree/plan.rb +1 -1
  48. data/lib/braintree/processor_response_types.rb +3 -3
  49. data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
  50. data/lib/braintree/risk_data.rb +3 -1
  51. data/lib/braintree/samsung_pay_card.rb +1 -1
  52. data/lib/braintree/settlement_batch_summary.rb +2 -2
  53. data/lib/braintree/subscription.rb +6 -6
  54. data/lib/braintree/three_d_secure_info.rb +22 -12
  55. data/lib/braintree/transaction.rb +32 -24
  56. data/lib/braintree/transaction_gateway.rb +24 -5
  57. data/lib/braintree/transaction_line_item.rb +1 -1
  58. data/lib/braintree/transaction_search.rb +3 -1
  59. data/lib/braintree/unknown_payment_method.rb +1 -1
  60. data/lib/braintree/us_bank_account.rb +3 -3
  61. data/lib/braintree/us_bank_account_verification.rb +1 -1
  62. data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
  63. data/lib/braintree/util.rb +4 -4
  64. data/lib/braintree/venmo_account.rb +1 -1
  65. data/lib/braintree/version.rb +1 -1
  66. data/lib/braintree/visa_checkout_card.rb +2 -2
  67. data/lib/braintree/webhook_notification.rb +30 -20
  68. data/lib/braintree/webhook_notification_gateway.rb +5 -5
  69. data/lib/braintree/webhook_testing_gateway.rb +30 -0
  70. data/lib/braintree/xml/generator.rb +5 -4
  71. data/lib/braintree/xml/libxml.rb +0 -1
  72. data/lib/braintree/xml/parser.rb +22 -12
  73. data/lib/braintree/xml/rexml.rb +70 -0
  74. data/spec/integration/braintree/add_on_spec.rb +1 -1
  75. data/spec/integration/braintree/address_spec.rb +28 -24
  76. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  77. data/spec/integration/braintree/apple_pay_spec.rb +3 -3
  78. data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
  79. data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
  80. data/spec/integration/braintree/client_api/spec_helper.rb +5 -5
  81. data/spec/integration/braintree/credit_card_spec.rb +213 -122
  82. data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
  83. data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
  84. data/spec/integration/braintree/customer_search_spec.rb +8 -8
  85. data/spec/integration/braintree/customer_spec.rb +282 -165
  86. data/spec/integration/braintree/dispute_search_spec.rb +28 -3
  87. data/spec/integration/braintree/dispute_spec.rb +6 -6
  88. data/spec/integration/braintree/error_codes_spec.rb +1 -1
  89. data/spec/integration/braintree/http_spec.rb +2 -2
  90. data/spec/integration/braintree/merchant_account_spec.rb +25 -26
  91. data/spec/integration/braintree/merchant_spec.rb +14 -14
  92. data/spec/integration/braintree/oauth_spec.rb +11 -11
  93. data/spec/integration/braintree/payment_method_nonce_spec.rb +28 -35
  94. data/spec/integration/braintree/payment_method_spec.rb +269 -165
  95. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +9 -9
  96. data/spec/integration/braintree/paypal_account_spec.rb +28 -28
  97. data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
  98. data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
  99. data/spec/integration/braintree/subscription_spec.rb +133 -133
  100. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  101. data/spec/integration/braintree/test_transaction_spec.rb +10 -10
  102. data/spec/integration/braintree/transaction_search_spec.rb +93 -67
  103. data/spec/integration/braintree/transaction_spec.rb +574 -360
  104. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +20 -20
  105. data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
  106. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
  107. data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
  108. data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
  109. data/spec/integration/spec_helper.rb +9 -3
  110. data/spec/oauth_test_helper.rb +1 -1
  111. data/spec/script/httpsd.rb +6 -6
  112. data/spec/spec_helper.rb +6 -3
  113. data/spec/unit/braintree/address_spec.rb +1 -1
  114. data/spec/unit/braintree/apple_pay_card_spec.rb +1 -1
  115. data/spec/unit/braintree/client_token_spec.rb +2 -2
  116. data/spec/unit/braintree/configuration_spec.rb +42 -42
  117. data/spec/unit/braintree/credit_card_spec.rb +13 -13
  118. data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
  119. data/spec/unit/braintree/credit_card_verification_spec.rb +8 -4
  120. data/spec/unit/braintree/customer_spec.rb +20 -10
  121. data/spec/unit/braintree/disbursement_spec.rb +7 -7
  122. data/spec/unit/braintree/dispute_search_spec.rb +1 -0
  123. data/spec/unit/braintree/dispute_spec.rb +34 -9
  124. data/spec/unit/braintree/error_result_spec.rb +5 -5
  125. data/spec/unit/braintree/errors_spec.rb +8 -8
  126. data/spec/unit/braintree/http_spec.rb +5 -5
  127. data/spec/unit/braintree/merchant_account_spec.rb +1 -1
  128. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
  129. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +43 -0
  130. data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
  131. data/spec/unit/braintree/payment_method_spec.rb +1 -1
  132. data/spec/unit/braintree/paypal_account_spec.rb +2 -2
  133. data/spec/unit/braintree/resource_collection_spec.rb +9 -9
  134. data/spec/unit/braintree/risk_data_spec.rb +9 -5
  135. data/spec/unit/braintree/subscription_search_spec.rb +1 -1
  136. data/spec/unit/braintree/successful_result_spec.rb +1 -1
  137. data/spec/unit/braintree/three_d_secure_info_spec.rb +32 -14
  138. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +3 -3
  139. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  140. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  141. data/spec/unit/braintree/transaction/paypal_details_spec.rb +1 -1
  142. data/spec/unit/braintree/transaction_search_spec.rb +12 -12
  143. data/spec/unit/braintree/transaction_spec.rb +25 -17
  144. data/spec/unit/braintree/util_spec.rb +18 -18
  145. data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
  146. data/spec/unit/braintree/webhook_notification_spec.rb +88 -56
  147. data/spec/unit/braintree/xml/rexml_spec.rb +51 -0
  148. data/spec/unit/braintree/xml_spec.rb +31 -31
  149. metadata +16 -8
  150. data/lib/braintree/settlement_batch.rb +0 -0
@@ -8,7 +8,7 @@ describe Braintree::PayPalAccount do
8
8
  :invalid_key => "bad stuff",
9
9
  :options => {
10
10
  :invalid_option => "bad option",
11
- }
11
+ },
12
12
  )
13
13
  end.to raise_error(ArgumentError, "invalid keys: invalid_key, options[invalid_option]")
14
14
  end
@@ -17,7 +17,7 @@ describe Braintree::PayPalAccount do
17
17
  describe "self.update" do
18
18
  it "raises an exception if attributes contain an invalid key" do
19
19
  expect do
20
- Braintree::PayPalAccount.update("some_token", :invalid_key => 'val')
20
+ Braintree::PayPalAccount.update("some_token", :invalid_key => "val")
21
21
  end.to raise_error(ArgumentError, "invalid keys: invalid_key")
22
22
  end
23
23
  end
@@ -5,7 +5,7 @@ describe "Braintree::ResourceCollection" do
5
5
  it "iterates over the elements, yielding to the block in pages" do
6
6
  values = %w(a b c d e)
7
7
  collection = Braintree::ResourceCollection.new(:search_results => {:ids => [0,1,2,3,4], :page_size => 2}) do |ids|
8
- ids.map {|id| values[id] }
8
+ ids.map { |id| values[id] }
9
9
  end
10
10
 
11
11
  count = 0
@@ -19,30 +19,30 @@ describe "Braintree::ResourceCollection" do
19
19
  end
20
20
 
21
21
  describe "#first" do
22
- it 'returns nil with no results' do
22
+ it "returns nil with no results" do
23
23
  values = %w(a b c d e)
24
24
  collection = Braintree::ResourceCollection.new(:search_results => {:ids => [], :page_size => 2}) do |ids|
25
- ids.map {|id| values[id] }
25
+ ids.map { |id| values[id] }
26
26
  end
27
27
 
28
28
  collection.first.should == nil
29
29
  end
30
30
 
31
- context 'with results' do
31
+ context "with results" do
32
32
  let(:collection) do
33
33
  values = %w(a b c d e)
34
34
 
35
35
  Braintree::ResourceCollection.new(:search_results => {:ids => [0,1,2,3,4], :page_size => 2}) do |ids|
36
- ids.map {|id| values[id] }
36
+ ids.map { |id| values[id] }
37
37
  end
38
38
  end
39
39
 
40
- it 'returns the first occourence' do
41
- collection.first.should == 'a'
40
+ it "returns the first occourence" do
41
+ collection.first.should == "a"
42
42
  end
43
43
 
44
- it 'returns the first N occourences' do
45
- collection.first(4).should == ['a','b','c','d']
44
+ it "returns the first N occourences" do
45
+ collection.first(4).should == ["a","b","c","d"]
46
46
  end
47
47
  end
48
48
  end
@@ -2,12 +2,14 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
3
  describe Braintree::RiskData do
4
4
  describe "#initialize" do
5
- it "sets id, decision and device_data_captured" do
6
- risk_data = Braintree::RiskData.new(:id => "123", :decision => "YOU WON $1000 DOLLARS", :device_data_captured => true, :fraud_service_provider => "kount")
5
+ it "sets id, decision, device_data_captured, decision_reasons and transaction_risk_score" do
6
+ risk_data = Braintree::RiskData.new(:id => "123", :decision => "YOU WON $1000 DOLLARS", :device_data_captured => true, :fraud_service_provider => "fraud_protection", :decision_reasons => ["reason"], :transaction_risk_score => "12")
7
7
  risk_data.id.should == "123"
8
8
  risk_data.decision.should == "YOU WON $1000 DOLLARS"
9
9
  risk_data.device_data_captured.should be_truthy
10
- risk_data.fraud_service_provider.should == "kount"
10
+ risk_data.fraud_service_provider.should == "fraud_protection"
11
+ risk_data.decision_reasons.should == ["reason"]
12
+ risk_data.transaction_risk_score.should == "12"
11
13
  end
12
14
  end
13
15
 
@@ -16,10 +18,12 @@ describe Braintree::RiskData do
16
18
  details = Braintree::RiskData.new(
17
19
  :id => "123",
18
20
  :decision => "YOU WON $1000 DOLLARS",
21
+ :decision_reasons => ["reason"],
19
22
  :device_data_captured => true,
20
- :fraud_service_provider => "kount",
23
+ :fraud_service_provider => "fraud_protection",
24
+ :transaction_risk_score => "12",
21
25
  )
22
- details.inspect.should == %(#<RiskData id: "123", decision: "YOU WON $1000 DOLLARS", device_data_captured: true, fraud_service_provider: "kount">)
26
+ details.inspect.should == %(#<RiskData id: "123", decision: "YOU WON $1000 DOLLARS", decision_reasons: ["reason"], device_data_captured: true, fraud_service_provider: "fraud_protection", transaction_risk_score: "12">)
23
27
  end
24
28
  end
25
29
  end
@@ -11,7 +11,7 @@ module Braintree
11
11
  Subscription::Status::Active,
12
12
  Subscription::Status::Canceled,
13
13
  Subscription::Status::Expired,
14
- Subscription::Status::PastDue
14
+ Subscription::Status::PastDue,
15
15
  )
16
16
  end.should_not raise_error
17
17
  end
@@ -5,7 +5,7 @@ describe Braintree::SuccessfulResult do
5
5
  it "sets instance variables from the values in the hash" do
6
6
  result = Braintree::SuccessfulResult.new(
7
7
  :transaction => "transaction_value",
8
- :credit_card => "credit_card_value"
8
+ :credit_card => "credit_card_value",
9
9
  )
10
10
  result.success?.should == true
11
11
  result.transaction.should == "transaction_value"
@@ -3,37 +3,55 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
3
3
  describe Braintree::ThreeDSecureInfo do
4
4
  let(:three_d_secure_info) {
5
5
  Braintree::ThreeDSecureInfo.new(
6
+ :acs_transaction_id => "acs_id",
7
+ :cavv => "cavvvalue",
8
+ :ds_transaction_id => "dstrxid",
9
+ :eci_flag => "06",
6
10
  :enrolled => "Y",
7
- :liability_shifted => true,
8
11
  :liability_shift_possible => true,
9
- :cavv => "cavvvalue",
10
- :xid => "xidvalue",
12
+ :liability_shifted => true,
13
+ :pares_status => "Y",
11
14
  :status => "authenticate_successful",
12
- :eci_flag => "06",
13
- :three_d_secure_version => "1.0.2",
14
- :ds_transaction_id => "dstrxid",
15
15
  :three_d_secure_authentication_id => "auth_id",
16
+ :three_d_secure_transaction_id => "trans_id",
17
+ :three_d_secure_version => "1.0.2",
18
+ :xid => "xidvalue",
19
+ :authentication => {
20
+ :trans_status => "authstatus",
21
+ :trans_status_reason => "authstatusreason"
22
+ },
23
+ :lookup => {
24
+ :trans_status => "lookupstatus",
25
+ :trans_status_reason => "lookupstatusreason"
26
+ },
16
27
  )
17
28
  }
18
29
 
19
30
  describe "#initialize" do
20
31
  it "sets attributes" do
21
- three_d_secure_info.enrolled.should == "Y"
22
- three_d_secure_info.status.should == "authenticate_successful"
23
- three_d_secure_info.liability_shifted.should == true
24
- three_d_secure_info.liability_shift_possible.should == true
32
+ three_d_secure_info.acs_transaction_id.should == "acs_id"
25
33
  three_d_secure_info.cavv.should == "cavvvalue"
26
- three_d_secure_info.xid.should == "xidvalue"
27
- three_d_secure_info.eci_flag.should == "06"
28
- three_d_secure_info.three_d_secure_version.should == "1.0.2"
29
34
  three_d_secure_info.ds_transaction_id.should == "dstrxid"
35
+ three_d_secure_info.eci_flag.should == "06"
36
+ three_d_secure_info.enrolled.should == "Y"
37
+ three_d_secure_info.liability_shift_possible.should == true
38
+ three_d_secure_info.liability_shifted.should == true
39
+ three_d_secure_info.pares_status.should == "Y"
40
+ three_d_secure_info.status.should == "authenticate_successful"
30
41
  three_d_secure_info.three_d_secure_authentication_id.should == "auth_id"
42
+ three_d_secure_info.three_d_secure_transaction_id.should == "trans_id"
43
+ three_d_secure_info.three_d_secure_version.should == "1.0.2"
44
+ three_d_secure_info.xid.should == "xidvalue"
45
+ three_d_secure_info.lookup[:trans_status].should == "lookupstatus"
46
+ three_d_secure_info.lookup[:trans_status_reason].should == "lookupstatusreason"
47
+ three_d_secure_info.authentication[:trans_status].should == "authstatus"
48
+ three_d_secure_info.authentication[:trans_status_reason].should == "authstatusreason"
31
49
  end
32
50
  end
33
51
 
34
52
  describe "inspect" do
35
53
  it "prints the attributes" do
36
- three_d_secure_info.inspect.should == %(#<ThreeDSecureInfo enrolled: "Y", liability_shifted: true, liability_shift_possible: true, status: "authenticate_successful", cavv: "cavvvalue", xid: "xidvalue", eci_flag: "06", three_d_secure_version: "1.0.2", ds_transaction_id: "dstrxid", three_d_secure_authentication_id: "auth_id">)
54
+ three_d_secure_info.inspect.should == %(#<ThreeDSecureInfo acs_transaction_id: "acs_id", authentication: {:trans_status=>"authstatus", :trans_status_reason=>"authstatusreason"}, cavv: "cavvvalue", ds_transaction_id: "dstrxid", eci_flag: "06", enrolled: "Y", liability_shift_possible: true, liability_shifted: true, lookup: {:trans_status=>"lookupstatus", :trans_status_reason=>"lookupstatusreason"}, pares_status: "Y", status: "authenticate_successful", three_d_secure_authentication_id: "auth_id", three_d_secure_transaction_id: "trans_id", three_d_secure_version: "1.0.2", xid: "xidvalue">)
37
55
  end
38
56
  end
39
57
 
@@ -5,7 +5,7 @@ describe Braintree::Transaction::CreditCardDetails do
5
5
  it "concats expiration_month and expiration_year" do
6
6
  details = Braintree::Transaction::CreditCardDetails.new(
7
7
  :expiration_month => "08",
8
- :expiration_year => "2009"
8
+ :expiration_year => "2009",
9
9
  )
10
10
  details.expiration_date.should == "08/2009"
11
11
  end
@@ -32,7 +32,7 @@ describe Braintree::Transaction::CreditCardDetails do
32
32
  :country_of_issuance => "Lilliput",
33
33
  :issuing_bank => "Gulliver Bank",
34
34
  :image_url => "example.com/visa.png",
35
- :unique_number_identifier => "abc123"
35
+ :unique_number_identifier => "abc123",
36
36
  )
37
37
  details.inspect.should == %(#<token: "token", bin: "123456", last_4: "6789", card_type: "Visa", expiration_date: "05/2012", cardholder_name: "The Cardholder", customer_location: "US", prepaid: "Yes", healthcare: "No", durbin_regulated: "No", debit: "Yes", commercial: "Unknown", payroll: "Unknown", product_id: "Unknown", country_of_issuance: "Lilliput", issuing_bank: "Gulliver Bank", image_url: "example.com/visa.png", unique_number_identifier: "abc123">)
38
38
  end
@@ -41,7 +41,7 @@ describe Braintree::Transaction::CreditCardDetails do
41
41
  describe "masked_number" do
42
42
  it "concatenates the bin, some *'s, and the last_4" do
43
43
  details = Braintree::Transaction::CreditCardDetails.new(
44
- :bin => "510510", :last_4 => "5100"
44
+ :bin => "510510", :last_4 => "5100",
45
45
  )
46
46
  details.masked_number.should == "510510******5100"
47
47
  end
@@ -11,7 +11,7 @@ describe Braintree::Transaction::CustomerDetails do
11
11
  :company => "Smith Co.",
12
12
  :website => "http://www.example.com",
13
13
  :phone => "6145551234",
14
- :fax => "3125551234"
14
+ :fax => "3125551234",
15
15
  )
16
16
  details.inspect.should == %(#<id: "id", first_name: "Amy", last_name: "Smith", email: "amy.smith@example.com", company: "Smith Co.", website: "http://www.example.com", phone: "6145551234", fax: "3125551234">)
17
17
  end
@@ -4,13 +4,13 @@ describe Braintree::Transaction::DisbursementDetails do
4
4
  describe "valid?" do
5
5
  it "returns true if disbursement details are initialized" do
6
6
  details = Braintree::Transaction::DisbursementDetails.new(
7
- :disbursement_date => Date.new(2013, 4, 1)
7
+ :disbursement_date => Date.new(2013, 4, 1),
8
8
  )
9
9
  details.valid?.should == true
10
10
  end
11
11
  it "returns true if disbursement details are initialized" do
12
12
  details = Braintree::Transaction::DisbursementDetails.new(
13
- :disbursement_date => nil
13
+ :disbursement_date => nil,
14
14
  )
15
15
  details.valid?.should == false
16
16
  end
@@ -27,7 +27,7 @@ describe Braintree::Transaction::PayPalDetails do
27
27
  :seller_protection_status => "seller-protection-status",
28
28
  :token => "token",
29
29
  :transaction_fee_amount => "2.00",
30
- :transaction_fee_currency_iso_code => "123"
30
+ :transaction_fee_currency_iso_code => "123",
31
31
  )
32
32
 
33
33
  expect(details.authorization_id).to eq("id")
@@ -1,19 +1,19 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
 
3
3
  describe Braintree::TransactionSearch do
4
- it "overrides previous 'is' with new 'is' for the same field" do
5
- search = Braintree::TransactionSearch.new
6
- search.billing_company.is "one"
7
- search.billing_company.is "two"
8
- search.to_hash.should == {:billing_company => {:is => "two"}}
9
- end
4
+ it "overrides previous 'is' with new 'is' for the same field" do
5
+ search = Braintree::TransactionSearch.new
6
+ search.billing_company.is "one"
7
+ search.billing_company.is "two"
8
+ search.to_hash.should == {:billing_company => {:is => "two"}}
9
+ end
10
10
 
11
- it "overrides previous 'in' with new 'in' for the same field" do
12
- search = Braintree::TransactionSearch.new
13
- search.status.in Braintree::Transaction::Status::Authorized
14
- search.status.in Braintree::Transaction::Status::SubmittedForSettlement
15
- search.to_hash.should == {:status => [Braintree::Transaction::Status::SubmittedForSettlement]}
16
- end
11
+ it "overrides previous 'in' with new 'in' for the same field" do
12
+ search = Braintree::TransactionSearch.new
13
+ search.status.in Braintree::Transaction::Status::Authorized
14
+ search.status.in Braintree::Transaction::Status::SubmittedForSettlement
15
+ search.to_hash.should == {:status => [Braintree::Transaction::Status::SubmittedForSettlement]}
16
+ end
17
17
 
18
18
  it "raises if the operator 'is' is left off" do
19
19
  search = Braintree::TransactionSearch.new
@@ -45,6 +45,14 @@ describe Braintree::Transaction do
45
45
  end
46
46
  end
47
47
 
48
+ describe "self.adjust_authorization" do
49
+ it "raises an ArgumentError if transaction_id is an invalid format" do
50
+ expect do
51
+ Braintree::Transaction.adjust_authorization("invalid-transaction-id", "10.00")
52
+ end.to raise_error(ArgumentError, "transaction_id is invalid")
53
+ end
54
+ end
55
+
48
56
  describe "self.update_details" do
49
57
  it "raises an ArgumentError if transaction_id is an invalid format" do
50
58
  expect do
@@ -66,7 +74,7 @@ describe Braintree::Transaction do
66
74
  :website => "lednerllc.com",
67
75
  :phone => "1-999-652-4189 x56883",
68
76
  :fax => "012-161-8055"
69
- }
77
+ },
70
78
  )
71
79
  transaction.customer_details.id.should == "123"
72
80
  transaction.customer_details.first_name.should == "Adam"
@@ -88,7 +96,7 @@ describe Braintree::Transaction do
88
96
  :settlement_currency_exchange_rate => "1",
89
97
  :funds_held => false,
90
98
  :success => true
91
- }
99
+ },
92
100
  )
93
101
  disbursement = transaction.disbursement_details
94
102
  disbursement.disbursement_date.should == Date.parse("2013-04-03")
@@ -119,7 +127,7 @@ describe Braintree::Transaction do
119
127
  :product_id => "Unknown",
120
128
  :country_of_issuance => "Narnia",
121
129
  :issuing_bank => "Mr Tumnus"
122
- }
130
+ },
123
131
  )
124
132
  transaction.credit_card_details.token.should == "mzg2"
125
133
  transaction.credit_card_details.bin.should == "411111"
@@ -147,7 +155,7 @@ describe Braintree::Transaction do
147
155
  :liability_shifted => true,
148
156
  :liability_shift_possible => true,
149
157
  :status => "authenticate_successful",
150
- }
158
+ },
151
159
  )
152
160
 
153
161
  transaction.three_d_secure_info.enrolled.should == "Y"
@@ -161,9 +169,9 @@ describe Braintree::Transaction do
161
169
  transaction = Braintree::Transaction._new(
162
170
  :gateway,
163
171
  :status_history => [
164
- { :timestamp => time, :amount => "12.00", :transaction_source => "API",
165
- :user => "larry", :status => Braintree::Transaction::Status::Authorized },
166
- { :timestamp => Time.utc(2010,1,15), :amount => "12.00", :transaction_source => "API",
172
+ {:timestamp => time, :amount => "12.00", :transaction_source => "API",
173
+ :user => "larry", :status => Braintree::Transaction::Status::Authorized},
174
+ {:timestamp => Time.utc(2010,1,15), :amount => "12.00", :transaction_source => "API",
167
175
  :user => "curly", :status => "scheduled_for_settlement"}
168
176
  ])
169
177
  transaction.status_history.size.should == 2
@@ -180,8 +188,8 @@ describe Braintree::Transaction do
180
188
  transaction = Braintree::Transaction._new(
181
189
  :gateway,
182
190
  :authorization_adjustments => [
183
- { :timestamp => timestamp, :processor_response_code => "1000", :processor_response_text => "Approved", :amount => "12.00", :success => true },
184
- { :timestamp => timestamp, :processor_response_code => "3000", :processor_response_text => "Processor Network Unavailable - Try Again", :amount => "12.34", :success => false },
191
+ {:timestamp => timestamp, :processor_response_code => "1000", :processor_response_text => "Approved", :amount => "12.00", :success => true},
192
+ {:timestamp => timestamp, :processor_response_code => "3000", :processor_response_text => "Processor Network Unavailable - Try Again", :amount => "12.34", :success => false},
185
193
  ])
186
194
  transaction.authorization_adjustments.size.should == 2
187
195
  transaction.authorization_adjustments[0].amount.should == "12.00"
@@ -199,7 +207,7 @@ describe Braintree::Transaction do
199
207
  it "handles receiving custom as an empty string" do
200
208
  transaction = Braintree::Transaction._new(
201
209
  :gateway,
202
- :custom => "\n "
210
+ :custom => "\n ",
203
211
  )
204
212
  end
205
213
 
@@ -217,7 +225,7 @@ describe Braintree::Transaction do
217
225
  it "handles nil risk_data" do
218
226
  transaction = Braintree::Transaction._new(
219
227
  :gateway,
220
- :risk_data => nil
228
+ :risk_data => nil,
221
229
  )
222
230
  transaction.risk_data.should be_nil
223
231
  end
@@ -225,7 +233,7 @@ describe Braintree::Transaction do
225
233
  it "accepts network_transaction_id" do
226
234
  transaction = Braintree::Transaction._new(
227
235
  :gateway,
228
- :network_transaction_id => "123456789012345"
236
+ :network_transaction_id => "123456789012345",
229
237
  )
230
238
  transaction.network_transaction_id.should == "123456789012345"
231
239
  end
@@ -307,8 +315,8 @@ describe Braintree::Transaction do
307
315
  end
308
316
 
309
317
  describe "sale" do
310
- let(:mock_response) { {:transaction => {}}}
311
- let(:http_stub) { double('http_stub').as_null_object }
318
+ let(:mock_response) { {:transaction => {}} }
319
+ let(:http_stub) { double("http_stub").as_null_object }
312
320
 
313
321
  RSpec::Matchers.define :skip_advanced_fraud_check_value_is do |value|
314
322
  match { |params| params[:transaction][:options][:skip_advanced_fraud_checking] == value }
@@ -326,7 +334,7 @@ describe Braintree::Transaction do
326
334
  },
327
335
  :options => {
328
336
  :skip_advanced_fraud_checking => true
329
- }
337
+ },
330
338
  )
331
339
  end
332
340
 
@@ -342,7 +350,7 @@ describe Braintree::Transaction do
342
350
  },
343
351
  :options => {
344
352
  :skip_advanced_fraud_checking => false
345
- }
353
+ },
346
354
  )
347
355
  end
348
356
 
@@ -358,7 +366,7 @@ describe Braintree::Transaction do
358
366
  },
359
367
  :options => {
360
368
  :submit_for_settlement => false
361
- }
369
+ },
362
370
  )
363
371
  end
364
372
  end
@@ -11,12 +11,12 @@ describe Braintree::Util do
11
11
  end
12
12
 
13
13
  it "symbolizes nested keys" do
14
- hash = {"a" => {"b" => {"c" => "d" }}}
14
+ hash = {"a" => {"b" => {"c" => "d"}}}
15
15
  Braintree::Util.symbolize_keys(hash).should == {:a => {:b => {:c => "d"}}}
16
16
  end
17
17
 
18
18
  it "symbolizes nested keys in arrays" do
19
- hash = {"a" => ["b" => {"c" => "d" }]}
19
+ hash = {"a" => ["b" => {"c" => "d"}]}
20
20
  Braintree::Util.symbolize_keys(hash).should == {:a => [:b => {:c => "d"}]}
21
21
  end
22
22
  end
@@ -44,7 +44,7 @@ describe Braintree::Util do
44
44
  :nested_allowed => "ok",
45
45
  :nested_allowed2 => "also ok",
46
46
  :nested_invalid => "bad"
47
- }
47
+ },
48
48
  )
49
49
  end.to raise_error(ArgumentError, "invalid keys: nested[nested_invalid], top_level_invalid")
50
50
  end
@@ -57,7 +57,7 @@ describe Braintree::Util do
57
57
  :custom_fields => {
58
58
  :custom_allowed => "ok",
59
59
  :custom_allowed2 => "also ok",
60
- }
60
+ },
61
61
  )
62
62
  end.to_not raise_error
63
63
  end
@@ -70,7 +70,7 @@ describe Braintree::Util do
70
70
  :custom_fields => {
71
71
  :bad_nesting => "very bad"
72
72
  }
73
- }
73
+ },
74
74
  )
75
75
  end.to raise_error(ArgumentError, "invalid keys: allowed[custom_fields][bad_nesting]")
76
76
  end
@@ -89,7 +89,7 @@ describe Braintree::Util do
89
89
  :super_deep_allowed => "yep",
90
90
  :real_deep_invalid => "nope"
91
91
  }
92
- }
92
+ },
93
93
  )
94
94
  end.to raise_error(ArgumentError, "invalid keys: nested[deeply_allowed][real_deep_invalid], nested[nested_invalid], top_level_invalid")
95
95
  end
@@ -101,7 +101,7 @@ describe Braintree::Util do
101
101
  :add_ons => {
102
102
  :update => [{:amount => 10}],
103
103
  :add => [{:amount => 5}]
104
- }
104
+ },
105
105
  )
106
106
  end.to_not raise_error
107
107
  end
@@ -113,7 +113,7 @@ describe Braintree::Util do
113
113
  :add_ons => {
114
114
  :update => [{:foo => 10}],
115
115
  :add => [{:bar => 5}]
116
- }
116
+ },
117
117
  )
118
118
  end.to raise_error(ArgumentError, /invalid keys: add_ons\[add\]\[bar\], add_ons\[update\]\[foo\]/)
119
119
  end
@@ -127,7 +127,7 @@ describe Braintree::Util do
127
127
  :custom_fields => {
128
128
  :custom_allowed => "ok",
129
129
  :custom_allowed2 => "also ok",
130
- }
130
+ },
131
131
  )
132
132
  expect(response).to eq(true)
133
133
  end
@@ -147,7 +147,7 @@ describe Braintree::Util do
147
147
  :add_ons => {
148
148
  :update => [{:foo => 10}],
149
149
  :add => [{:bar => 5}]
150
- }
150
+ },
151
151
  )
152
152
  expect(response).to eq(false)
153
153
  end
@@ -165,7 +165,7 @@ describe Braintree::Util do
165
165
  :super_deep_allowed => "yep",
166
166
  :real_deep_invalid => "nope"
167
167
  }
168
- }
168
+ },
169
169
  )
170
170
  expect(response).to eq(false)
171
171
  end
@@ -200,13 +200,13 @@ describe Braintree::Util do
200
200
  describe "self._flatten_valid_keys" do
201
201
  it "flattens hash keys" do
202
202
  Braintree::Util._flatten_valid_keys(
203
- [:top_level, {:nested => [:nested_allowed, :nested_allowed2]}]
203
+ [:top_level, {:nested => [:nested_allowed, :nested_allowed2]}],
204
204
  ).should == ["nested[nested_allowed2]", "nested[nested_allowed]", "top_level"]
205
205
  end
206
206
 
207
207
  it "allows wildcards with the :_any_key_ symbol" do
208
208
  Braintree::Util._flatten_valid_keys(
209
- [:top_level, {:nested => :_any_key_}]
209
+ [:top_level, {:nested => :_any_key_}],
210
210
  ).should == ["nested[_any_key_]", "top_level"]
211
211
  end
212
212
  end
@@ -236,11 +236,11 @@ describe Braintree::Util do
236
236
  result.should == []
237
237
  end
238
238
 
239
- it "raises an UnexpectedError if nil data is provided" do
240
- expect do
241
- Braintree::Util.extract_attribute_as_array(nil, :abc)
242
- end.to raise_error(Braintree::UnexpectedError, /Unprocessable entity due to an invalid request/)
243
- end
239
+ it "raises an UnexpectedError if nil data is provided" do
240
+ expect do
241
+ Braintree::Util.extract_attribute_as_array(nil, :abc)
242
+ end.to raise_error(Braintree::UnexpectedError, /Unprocessable entity due to an invalid request/)
243
+ end
244
244
  end
245
245
 
246
246
  describe "self.hash_to_query_string" do