braintree 4.13.0 → 4.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/braintree/credit_card.rb +13 -0
- data/lib/braintree/credit_card_gateway.rb +15 -3
- data/lib/braintree/payment_method_gateway.rb +15 -3
- data/lib/braintree/test/nonce.rb +1 -0
- data/lib/braintree/test/venmo_sdk.rb +2 -0
- data/lib/braintree/transaction/credit_card_details.rb +3 -0
- data/lib/braintree/transaction/local_payment_details.rb +2 -0
- data/lib/braintree/transaction/payment_receipt/card_present_data.rb +36 -0
- data/lib/braintree/transaction/payment_receipt/merchant_address.rb +19 -0
- data/lib/braintree/transaction/payment_receipt.rb +31 -0
- data/lib/braintree/transaction/us_bank_account_details.rb +1 -0
- data/lib/braintree/transaction.rb +7 -4
- data/lib/braintree/transaction_gateway.rb +15 -3
- data/lib/braintree/transaction_search.rb +6 -5
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/webhook_notification.rb +1 -0
- data/lib/braintree/webhook_testing_gateway.rb +17 -0
- data/lib/braintree.rb +3 -0
- data/spec/integration/braintree/add_on_spec.rb +9 -9
- data/spec/integration/braintree/address_spec.rb +69 -69
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +8 -8
- data/spec/integration/braintree/client_api/client_token_spec.rb +15 -15
- data/spec/integration/braintree/credit_card_spec.rb +223 -223
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
- data/spec/integration/braintree/credit_card_verification_spec.rb +52 -52
- data/spec/integration/braintree/customer_search_spec.rb +20 -20
- data/spec/integration/braintree/customer_spec.rb +313 -313
- data/spec/integration/braintree/disbursement_spec.rb +2 -2
- data/spec/integration/braintree/discount_spec.rb +9 -9
- data/spec/integration/braintree/dispute_spec.rb +87 -87
- data/spec/integration/braintree/document_upload_spec.rb +17 -17
- data/spec/integration/braintree/error_codes_spec.rb +2 -2
- data/spec/integration/braintree/http_spec.rb +28 -28
- data/spec/integration/braintree/merchant_account_spec.rb +127 -127
- data/spec/integration/braintree/merchant_spec.rb +103 -103
- data/spec/integration/braintree/oauth_spec.rb +61 -61
- data/spec/integration/braintree/payment_method_nonce_spec.rb +73 -73
- data/spec/integration/braintree/payment_method_spec.rb +389 -389
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +78 -78
- data/spec/integration/braintree/paypal_account_spec.rb +38 -38
- data/spec/integration/braintree/plan_spec.rb +15 -15
- data/spec/integration/braintree/samsung_pay_card_spec.rb +65 -65
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +51 -51
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +11 -11
- data/spec/integration/braintree/subscription_spec.rb +364 -364
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +19 -19
- data/spec/integration/braintree/transaction_line_item_spec.rb +6 -6
- data/spec/integration/braintree/transaction_search_spec.rb +198 -165
- data/spec/integration/braintree/transaction_spec.rb +1319 -1151
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -32
- data/spec/integration/braintree/us_bank_account_spec.rb +30 -30
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +18 -18
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +33 -33
- data/spec/integration/braintree/visa_checkout_card_spec.rb +57 -57
- data/spec/spec_helper.rb +9 -8
- data/spec/unit/braintree/address_spec.rb +8 -8
- data/spec/unit/braintree/base_module_spec.rb +4 -4
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +57 -57
- data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
- data/spec/unit/braintree/credit_card_spec.rb +31 -29
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +28 -28
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +9 -9
- data/spec/unit/braintree/credit_card_verification_spec.rb +17 -17
- data/spec/unit/braintree/customer_spec.rb +41 -40
- data/spec/unit/braintree/digest_spec.rb +5 -5
- data/spec/unit/braintree/disbursement_spec.rb +11 -11
- data/spec/unit/braintree/dispute_search_spec.rb +2 -2
- data/spec/unit/braintree/dispute_spec.rb +56 -56
- data/spec/unit/braintree/document_upload_spec.rb +8 -8
- data/spec/unit/braintree/enriched_customer_data_spec.rb +2 -2
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +9 -9
- data/spec/unit/braintree/http_spec.rb +8 -8
- data/spec/unit/braintree/local_payment_completed_spec.rb +11 -11
- data/spec/unit/braintree/local_payment_expired_spec.rb +2 -2
- data/spec/unit/braintree/local_payment_funded_spec.rb +6 -6
- data/spec/unit/braintree/merchant_account_spec.rb +4 -4
- data/spec/unit/braintree/modification_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +6 -6
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +7 -7
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +14 -14
- data/spec/unit/braintree/payment_method_spec.rb +19 -19
- data/spec/unit/braintree/paypal_account_spec.rb +4 -4
- data/spec/unit/braintree/resource_collection_spec.rb +7 -7
- data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +1 -1
- data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
- data/spec/unit/braintree/signature_service_spec.rb +2 -2
- data/spec/unit/braintree/subscription_search_spec.rb +17 -17
- data/spec/unit/braintree/subscription_spec.rb +8 -8
- data/spec/unit/braintree/successful_result_spec.rb +5 -5
- data/spec/unit/braintree/three_d_secure_info_spec.rb +20 -20
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -5
- data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
- data/spec/unit/braintree/transaction/local_payment_details_spec.rb +30 -0
- data/spec/unit/braintree/transaction/payment_receipt_spec.rb +73 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +9 -6
- data/spec/unit/braintree/transaction_search_spec.rb +2 -2
- data/spec/unit/braintree/transaction_spec.rb +101 -93
- data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
- data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
- data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +7 -7
- data/spec/unit/braintree/util_spec.rb +27 -27
- data/spec/unit/braintree/validation_error_collection_spec.rb +34 -34
- data/spec/unit/braintree/validation_error_spec.rb +4 -4
- data/spec/unit/braintree/venmo_profile_data_spec.rb +5 -5
- data/spec/unit/braintree/webhook_notification_spec.rb +206 -191
- data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
- data/spec/unit/braintree/xml/parser_spec.rb +8 -8
- data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
- data/spec/unit/braintree/xml_spec.rb +17 -17
- data/spec/unit/braintree_spec.rb +2 -2
- 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.
|
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
|
59
|
+
expect(result.success?).to eq(true)
|
60
60
|
utc_or_gmt = Time.now.utc.strftime("%Z")
|
61
|
-
output.string.
|
62
|
-
output.string.
|
63
|
-
output.string.
|
64
|
-
output.string.
|
65
|
-
output.string.
|
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].
|
77
|
-
response[:document_upload][:id].
|
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].
|
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].
|
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.
|
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.
|
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.
|
140
|
-
config.
|
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.
|
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.
|
162
|
-
config.
|
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.
|
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.
|
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.
|
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.
|
222
|
-
config.
|
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).
|
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).
|
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).
|
262
|
-
output.string.
|
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.
|
278
|
+
expect(output.string).to eq("")
|
279
279
|
ensure
|
280
280
|
Braintree::Configuration.logger = old_logger
|
281
281
|
end
|