braintree 4.13.0 → 4.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/credit_card.rb +13 -0
  3. data/lib/braintree/credit_card_gateway.rb +15 -3
  4. data/lib/braintree/payment_method_gateway.rb +15 -3
  5. data/lib/braintree/test/nonce.rb +1 -0
  6. data/lib/braintree/test/venmo_sdk.rb +2 -0
  7. data/lib/braintree/transaction/credit_card_details.rb +3 -0
  8. data/lib/braintree/transaction/local_payment_details.rb +2 -0
  9. data/lib/braintree/transaction/payment_receipt/card_present_data.rb +36 -0
  10. data/lib/braintree/transaction/payment_receipt/merchant_address.rb +19 -0
  11. data/lib/braintree/transaction/payment_receipt.rb +31 -0
  12. data/lib/braintree/transaction/us_bank_account_details.rb +1 -0
  13. data/lib/braintree/transaction.rb +7 -4
  14. data/lib/braintree/transaction_gateway.rb +15 -3
  15. data/lib/braintree/transaction_search.rb +6 -5
  16. data/lib/braintree/version.rb +1 -1
  17. data/lib/braintree/webhook_notification.rb +1 -0
  18. data/lib/braintree/webhook_testing_gateway.rb +17 -0
  19. data/lib/braintree.rb +3 -0
  20. data/spec/integration/braintree/add_on_spec.rb +9 -9
  21. data/spec/integration/braintree/address_spec.rb +69 -69
  22. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  23. data/spec/integration/braintree/apple_pay_spec.rb +8 -8
  24. data/spec/integration/braintree/client_api/client_token_spec.rb +15 -15
  25. data/spec/integration/braintree/credit_card_spec.rb +223 -223
  26. data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
  27. data/spec/integration/braintree/credit_card_verification_spec.rb +52 -52
  28. data/spec/integration/braintree/customer_search_spec.rb +20 -20
  29. data/spec/integration/braintree/customer_spec.rb +313 -313
  30. data/spec/integration/braintree/disbursement_spec.rb +2 -2
  31. data/spec/integration/braintree/discount_spec.rb +9 -9
  32. data/spec/integration/braintree/dispute_spec.rb +87 -87
  33. data/spec/integration/braintree/document_upload_spec.rb +17 -17
  34. data/spec/integration/braintree/error_codes_spec.rb +2 -2
  35. data/spec/integration/braintree/http_spec.rb +28 -28
  36. data/spec/integration/braintree/merchant_account_spec.rb +127 -127
  37. data/spec/integration/braintree/merchant_spec.rb +103 -103
  38. data/spec/integration/braintree/oauth_spec.rb +61 -61
  39. data/spec/integration/braintree/payment_method_nonce_spec.rb +73 -73
  40. data/spec/integration/braintree/payment_method_spec.rb +389 -389
  41. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +78 -78
  42. data/spec/integration/braintree/paypal_account_spec.rb +38 -38
  43. data/spec/integration/braintree/plan_spec.rb +15 -15
  44. data/spec/integration/braintree/samsung_pay_card_spec.rb +65 -65
  45. data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +51 -51
  46. data/spec/integration/braintree/settlement_batch_summary_spec.rb +11 -11
  47. data/spec/integration/braintree/subscription_spec.rb +364 -364
  48. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  49. data/spec/integration/braintree/test_transaction_spec.rb +19 -19
  50. data/spec/integration/braintree/transaction_line_item_spec.rb +6 -6
  51. data/spec/integration/braintree/transaction_search_spec.rb +198 -165
  52. data/spec/integration/braintree/transaction_spec.rb +1319 -1151
  53. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -32
  54. data/spec/integration/braintree/us_bank_account_spec.rb +30 -30
  55. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +18 -18
  56. data/spec/integration/braintree/us_bank_account_verification_spec.rb +33 -33
  57. data/spec/integration/braintree/visa_checkout_card_spec.rb +57 -57
  58. data/spec/spec_helper.rb +9 -8
  59. data/spec/unit/braintree/address_spec.rb +8 -8
  60. data/spec/unit/braintree/base_module_spec.rb +4 -4
  61. data/spec/unit/braintree/client_token_spec.rb +2 -2
  62. data/spec/unit/braintree/configuration_spec.rb +57 -57
  63. data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
  64. data/spec/unit/braintree/credit_card_spec.rb +31 -29
  65. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +28 -28
  66. data/spec/unit/braintree/credit_card_verification_search_spec.rb +9 -9
  67. data/spec/unit/braintree/credit_card_verification_spec.rb +17 -17
  68. data/spec/unit/braintree/customer_spec.rb +41 -40
  69. data/spec/unit/braintree/digest_spec.rb +5 -5
  70. data/spec/unit/braintree/disbursement_spec.rb +11 -11
  71. data/spec/unit/braintree/dispute_search_spec.rb +2 -2
  72. data/spec/unit/braintree/dispute_spec.rb +56 -56
  73. data/spec/unit/braintree/document_upload_spec.rb +8 -8
  74. data/spec/unit/braintree/enriched_customer_data_spec.rb +2 -2
  75. data/spec/unit/braintree/error_result_spec.rb +5 -5
  76. data/spec/unit/braintree/errors_spec.rb +9 -9
  77. data/spec/unit/braintree/http_spec.rb +8 -8
  78. data/spec/unit/braintree/local_payment_completed_spec.rb +11 -11
  79. data/spec/unit/braintree/local_payment_expired_spec.rb +2 -2
  80. data/spec/unit/braintree/local_payment_funded_spec.rb +6 -6
  81. data/spec/unit/braintree/merchant_account_spec.rb +4 -4
  82. data/spec/unit/braintree/modification_spec.rb +1 -1
  83. data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +6 -6
  84. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +7 -7
  85. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +14 -14
  86. data/spec/unit/braintree/payment_method_spec.rb +19 -19
  87. data/spec/unit/braintree/paypal_account_spec.rb +4 -4
  88. data/spec/unit/braintree/resource_collection_spec.rb +7 -7
  89. data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +1 -1
  90. data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
  91. data/spec/unit/braintree/signature_service_spec.rb +2 -2
  92. data/spec/unit/braintree/subscription_search_spec.rb +17 -17
  93. data/spec/unit/braintree/subscription_spec.rb +8 -8
  94. data/spec/unit/braintree/successful_result_spec.rb +5 -5
  95. data/spec/unit/braintree/three_d_secure_info_spec.rb +20 -20
  96. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -5
  97. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  98. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  99. data/spec/unit/braintree/transaction/local_payment_details_spec.rb +30 -0
  100. data/spec/unit/braintree/transaction/payment_receipt_spec.rb +73 -0
  101. data/spec/unit/braintree/transaction_gateway_spec.rb +9 -6
  102. data/spec/unit/braintree/transaction_search_spec.rb +2 -2
  103. data/spec/unit/braintree/transaction_spec.rb +101 -93
  104. data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
  105. data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
  106. data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
  107. data/spec/unit/braintree/us_bank_account_verification_spec.rb +7 -7
  108. data/spec/unit/braintree/util_spec.rb +27 -27
  109. data/spec/unit/braintree/validation_error_collection_spec.rb +34 -34
  110. data/spec/unit/braintree/validation_error_spec.rb +4 -4
  111. data/spec/unit/braintree/venmo_profile_data_spec.rb +5 -5
  112. data/spec/unit/braintree/webhook_notification_spec.rb +206 -191
  113. data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
  114. data/spec/unit/braintree/xml/parser_spec.rb +8 -8
  115. data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
  116. data/spec/unit/braintree/xml_spec.rb +17 -17
  117. data/spec/unit/braintree_spec.rb +2 -2
  118. metadata +7 -2
@@ -34,7 +34,7 @@ describe Braintree::Http do
34
34
  Braintree::Configuration.logger.level = Logger::INFO
35
35
  Braintree::Customer.all
36
36
  utc_or_gmt = Time.now.utc.strftime("%Z")
37
- output.string.should include("[Braintree] [10/Oct/2009 13:55:36 #{utc_or_gmt}] POST /merchants/integration_merchant_id/customers/advanced_search_ids 200")
37
+ expect(output.string).to include("[Braintree] [10/Oct/2009 13:55:36 #{utc_or_gmt}] POST /merchants/integration_merchant_id/customers/advanced_search_ids 200")
38
38
  end
39
39
  ensure
40
40
  Braintree::Configuration.logger = old_logger
@@ -56,13 +56,13 @@ describe Braintree::Http do
56
56
  :number => Braintree::Test::CreditCardNumbers::Visa,
57
57
  :expiration_date => "05/2009",
58
58
  )
59
- result.success?.should == true
59
+ expect(result.success?).to eq(true)
60
60
  utc_or_gmt = Time.now.utc.strftime("%Z")
61
- output.string.should include("[Braintree] [10/Oct/2009 13:55:36 #{utc_or_gmt}] POST /merchants/integration_merchant_id/payment_methods")
62
- output.string.should include("[Braintree] <cardholder-name>Sam Jones</cardholder-name>")
63
- output.string.should include("[Braintree] <number>401288******1881</number>")
64
- output.string.should include("[Braintree] [10/Oct/2009 13:55:36 #{utc_or_gmt}] 201 Created")
65
- output.string.should match(/\[Braintree\] <token>\w+<\/token>/)
61
+ expect(output.string).to include("[Braintree] [10/Oct/2009 13:55:36 #{utc_or_gmt}] POST /merchants/integration_merchant_id/payment_methods")
62
+ expect(output.string).to include("[Braintree] <cardholder-name>Sam Jones</cardholder-name>")
63
+ expect(output.string).to include("[Braintree] <number>401288******1881</number>")
64
+ expect(output.string).to include("[Braintree] [10/Oct/2009 13:55:36 #{utc_or_gmt}] 201 Created")
65
+ expect(output.string).to match(/\[Braintree\] <token>\w+<\/token>/)
66
66
  end
67
67
  ensure
68
68
  Braintree::Configuration.logger = old_logger
@@ -73,8 +73,8 @@ describe Braintree::Http do
73
73
  config = Braintree::Configuration.instantiate
74
74
  file = File.new("#{File.dirname(__FILE__)}/../../fixtures/files/bt_logo.png", "r")
75
75
  response = config.http.post("#{config.base_merchant_path}/document_uploads", {"document_upload[kind]" => "evidence_document"}, file)
76
- response[:document_upload][:content_type].should == "image/png"
77
- response[:document_upload][:id].should_not be_nil
76
+ expect(response[:document_upload][:content_type]).to eq("image/png")
77
+ expect(response[:document_upload][:id]).not_to be_nil
78
78
  end
79
79
 
80
80
  describe "user_agent" do
@@ -85,14 +85,14 @@ describe Braintree::Http do
85
85
  it "sets the User-Agent header using the default user agent" do
86
86
  config = Braintree::Configuration.instantiate
87
87
  response = config.http.get("#{config.base_merchant_path}/test/headers")
88
- response[:headers][:HTTP_USER_AGENT].should == "Braintree Ruby Gem #{Braintree::Version::String}"
88
+ expect(response[:headers][:HTTP_USER_AGENT]).to eq("Braintree Ruby Gem #{Braintree::Version::String}")
89
89
  end
90
90
 
91
91
  it "sets the User-Agent header using a customer user agent" do
92
92
  Braintree::Configuration.custom_user_agent = "ActiveMerchant 1.2.3"
93
93
  config = Braintree::Configuration.instantiate
94
94
  response = config.http.get("#{config.base_merchant_path}/test/headers")
95
- response[:headers][:HTTP_USER_AGENT].should == "Braintree Ruby Gem #{Braintree::Version::String} (ActiveMerchant 1.2.3)"
95
+ expect(response[:headers][:HTTP_USER_AGENT]).to eq("Braintree Ruby Gem #{Braintree::Version::String} (ActiveMerchant 1.2.3)")
96
96
  end
97
97
  end
98
98
 
@@ -102,7 +102,7 @@ describe Braintree::Http do
102
102
  original_env = Braintree::Configuration.environment
103
103
  Braintree::Configuration.environment = :sandbox
104
104
  Braintree::Configuration.ssl_version = :TLSv1
105
- Braintree::Configuration.stub(:base_merchant_path).and_return("/")
105
+ allow(Braintree::Configuration).to receive(:base_merchant_path).and_return("/")
106
106
 
107
107
  expect do
108
108
  Braintree::Configuration.instantiate.http._http_do(Net::HTTP::Get, "/login")
@@ -118,7 +118,7 @@ describe Braintree::Http do
118
118
  original_env = Braintree::Configuration.environment
119
119
  Braintree::Configuration.environment = :sandbox
120
120
  Braintree::Configuration.ssl_version = :TLSv1_2
121
- Braintree::Configuration.stub(:base_merchant_path).and_return("/")
121
+ allow(Braintree::Configuration).to receive(:base_merchant_path).and_return("/")
122
122
 
123
123
  expect do
124
124
  Braintree::Configuration.instantiate.http._http_do(Net::HTTP::Get, "/login")
@@ -136,8 +136,8 @@ describe Braintree::Http do
136
136
  original_env = Braintree::Configuration.environment
137
137
  Braintree::Configuration.environment = :development
138
138
  config = Braintree::Configuration.instantiate
139
- config.stub(:ssl?).and_return(true)
140
- config.stub(:port).and_return(SSL_TEST_PORT)
139
+ allow(config).to receive(:ssl?).and_return(true)
140
+ allow(config).to receive(:port).and_return(SSL_TEST_PORT)
141
141
 
142
142
  start_ssl_server do
143
143
  expect do
@@ -155,11 +155,11 @@ describe Braintree::Http do
155
155
  Braintree::Configuration.environment = :development
156
156
  # Random CA root file from a different certificate authority
157
157
  config = Braintree::Configuration.instantiate
158
- config.stub(:ca_file).and_return(
158
+ allow(config).to receive(:ca_file).and_return(
159
159
  File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "ssl", "geotrust_global.crt")),
160
160
  )
161
- config.stub(:ssl?).and_return(true)
162
- config.stub(:port).and_return(SSL_TEST_PORT)
161
+ allow(config).to receive(:ssl?).and_return(true)
162
+ allow(config).to receive(:port).and_return(SSL_TEST_PORT)
163
163
 
164
164
  start_ssl_server do
165
165
  expect do
@@ -175,7 +175,7 @@ describe Braintree::Http do
175
175
  begin
176
176
  original_env = Braintree::Configuration.environment
177
177
  Braintree::Configuration.environment = :qa
178
- Braintree::Configuration.stub(:base_merchant_path).and_return("/")
178
+ allow(Braintree::Configuration).to receive(:base_merchant_path).and_return("/")
179
179
 
180
180
  expect do
181
181
  Braintree::Configuration.instantiate.http._http_do(Net::HTTP::Get, "/login")
@@ -189,7 +189,7 @@ describe Braintree::Http do
189
189
  begin
190
190
  original_env = Braintree::Configuration.environment
191
191
  Braintree::Configuration.environment = :sandbox
192
- Braintree::Configuration.stub(:base_merchant_path).and_return("/")
192
+ allow(Braintree::Configuration).to receive(:base_merchant_path).and_return("/")
193
193
 
194
194
  expect do
195
195
  Braintree::Configuration.instantiate.http._http_do(Net::HTTP::Get, "/login")
@@ -203,7 +203,7 @@ describe Braintree::Http do
203
203
  begin
204
204
  original_env = Braintree::Configuration.environment
205
205
  Braintree::Configuration.environment = :production
206
- Braintree::Configuration.stub(:base_merchant_path).and_return("/")
206
+ allow(Braintree::Configuration).to receive(:base_merchant_path).and_return("/")
207
207
 
208
208
  expect do
209
209
  Braintree::Configuration.instantiate.http._http_do(Net::HTTP::Get, "/login")
@@ -218,8 +218,8 @@ describe Braintree::Http do
218
218
  original_env = Braintree::Configuration.environment
219
219
  Braintree::Configuration.environment = :sandbox
220
220
  config = Braintree::Configuration.instantiate
221
- config.stub(:base_merchant_path).and_return("/")
222
- config.stub(:ca_file).and_return("does_not_exist")
221
+ allow(config).to receive(:base_merchant_path).and_return("/")
222
+ allow(config).to receive(:ca_file).and_return("does_not_exist")
223
223
 
224
224
  expect do
225
225
  config.http._http_do(Net::HTTP::Get, "/login")
@@ -234,13 +234,13 @@ describe Braintree::Http do
234
234
  describe "self._verify_ssl_certificate" do
235
235
  it "is false if preverify is false" do
236
236
  context = OpenSSL::X509::StoreContext.new(OpenSSL::X509::Store.new)
237
- Braintree::Configuration.instantiate.http._verify_ssl_certificate(false, context).should == false
237
+ expect(Braintree::Configuration.instantiate.http._verify_ssl_certificate(false, context)).to eq(false)
238
238
  end
239
239
 
240
240
  it "returns false if ssl_context doesn't have an error code of 0" do
241
241
  context = OpenSSL::X509::StoreContext.new(OpenSSL::X509::Store.new)
242
242
  context.error = 19 # ca_file incorrect, self-signed
243
- Braintree::Configuration.instantiate.http._verify_ssl_certificate(true, context).should == false
243
+ expect(Braintree::Configuration.instantiate.http._verify_ssl_certificate(true, context)).to eq(false)
244
244
  end
245
245
 
246
246
  it "doesn't raise if there is no error" do
@@ -258,8 +258,8 @@ describe Braintree::Http do
258
258
  utc_or_gmt = Time.now.utc.strftime("%Z")
259
259
  context = OpenSSL::X509::StoreContext.new(OpenSSL::X509::Store.new)
260
260
  context.error = 19
261
- Braintree::Configuration.instantiate.http._verify_ssl_certificate(false, context).should == false
262
- output.string.should include("SSL Verification failed -- Preverify: false, Error: self signed certificate in certificate chain (19)")
261
+ expect(Braintree::Configuration.instantiate.http._verify_ssl_certificate(false, context)).to eq(false)
262
+ expect(output.string).to include("SSL Verification failed -- Preverify: false, Error: self signed certificate in certificate chain (19)")
263
263
  ensure
264
264
  Braintree::Configuration.logger = old_logger
265
265
  end
@@ -275,7 +275,7 @@ describe Braintree::Http do
275
275
  expect do
276
276
  Braintree::Configuration.instantiate.http._verify_ssl_certificate(true, context)
277
277
  end.to_not raise_error
278
- output.string.should == ""
278
+ expect(output.string).to eq("")
279
279
  ensure
280
280
  Braintree::Configuration.logger = old_logger
281
281
  end