braintree 3.3.0 → 3.4.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.
- checksums.yaml +4 -4
- data/braintree.gemspec +1 -1
- data/lib/braintree.rb +2 -1
- data/lib/braintree/account_updater_daily_report.rb +1 -1
- data/lib/braintree/address.rb +1 -1
- data/lib/braintree/apple_pay.rb +1 -1
- data/lib/braintree/apple_pay_card.rb +1 -1
- data/lib/braintree/apple_pay_options.rb +1 -1
- data/lib/braintree/authorization_adjustment.rb +1 -1
- data/lib/braintree/client_token.rb +1 -1
- data/lib/braintree/configuration.rb +11 -11
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
- data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
- data/lib/braintree/credit_card.rb +2 -2
- data/lib/braintree/credit_card_gateway.rb +3 -3
- data/lib/braintree/credit_card_verification.rb +5 -5
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +2 -2
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/disbursement.rb +1 -1
- data/lib/braintree/dispute.rb +1 -1
- data/lib/braintree/dispute_gateway.rb +2 -2
- data/lib/braintree/dispute_search.rb +2 -2
- data/lib/braintree/document_upload.rb +1 -1
- data/lib/braintree/error_codes.rb +7 -0
- data/lib/braintree/google_pay_card.rb +1 -1
- data/lib/braintree/granted_payment_instrument_update.rb +1 -1
- data/lib/braintree/graphql_client.rb +7 -7
- data/lib/braintree/http.rb +3 -3
- data/lib/braintree/local_payment_completed.rb +1 -1
- data/lib/braintree/local_payment_reversed.rb +19 -0
- data/lib/braintree/merchant.rb +1 -1
- data/lib/braintree/merchant_account.rb +1 -1
- data/lib/braintree/merchant_account_gateway.rb +1 -1
- data/lib/braintree/merchant_gateway.rb +1 -1
- data/lib/braintree/modification.rb +1 -1
- data/lib/braintree/oauth_credentials.rb +1 -1
- data/lib/braintree/oauth_gateway.rb +5 -5
- data/lib/braintree/payment_instrument_type.rb +10 -10
- data/lib/braintree/payment_method_gateway.rb +3 -3
- data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
- data/lib/braintree/plan.rb +1 -1
- data/lib/braintree/processor_response_types.rb +3 -3
- data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
- data/lib/braintree/samsung_pay_card.rb +1 -1
- data/lib/braintree/settlement_batch_summary.rb +2 -2
- data/lib/braintree/subscription.rb +6 -6
- data/lib/braintree/transaction.rb +32 -24
- data/lib/braintree/transaction_gateway.rb +23 -4
- data/lib/braintree/transaction_line_item.rb +1 -1
- data/lib/braintree/transaction_search.rb +3 -1
- data/lib/braintree/unknown_payment_method.rb +1 -1
- data/lib/braintree/us_bank_account.rb +3 -3
- data/lib/braintree/us_bank_account_verification.rb +1 -1
- data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
- data/lib/braintree/util.rb +4 -4
- data/lib/braintree/venmo_account.rb +1 -1
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +2 -2
- data/lib/braintree/webhook_notification.rb +28 -19
- data/lib/braintree/webhook_notification_gateway.rb +5 -5
- data/lib/braintree/webhook_testing_gateway.rb +10 -0
- data/lib/braintree/xml/generator.rb +5 -4
- data/lib/braintree/xml/libxml.rb +1 -1
- data/lib/braintree/xml/parser.rb +10 -10
- data/spec/integration/braintree/add_on_spec.rb +1 -1
- data/spec/integration/braintree/address_spec.rb +24 -24
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +3 -3
- data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
- data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
- data/spec/integration/braintree/client_api/spec_helper.rb +5 -5
- data/spec/integration/braintree/credit_card_spec.rb +119 -119
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
- data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
- data/spec/integration/braintree/customer_search_spec.rb +8 -8
- data/spec/integration/braintree/customer_spec.rb +165 -165
- data/spec/integration/braintree/dispute_search_spec.rb +3 -3
- data/spec/integration/braintree/dispute_spec.rb +6 -6
- data/spec/integration/braintree/error_codes_spec.rb +1 -1
- data/spec/integration/braintree/http_spec.rb +2 -2
- data/spec/integration/braintree/merchant_account_spec.rb +25 -26
- data/spec/integration/braintree/merchant_spec.rb +12 -12
- data/spec/integration/braintree/oauth_spec.rb +11 -11
- data/spec/integration/braintree/payment_method_nonce_spec.rb +12 -12
- data/spec/integration/braintree/payment_method_spec.rb +165 -165
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +9 -9
- data/spec/integration/braintree/paypal_account_spec.rb +28 -28
- data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
- data/spec/integration/braintree/subscription_spec.rb +133 -133
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +10 -10
- data/spec/integration/braintree/transaction_search_spec.rb +93 -67
- data/spec/integration/braintree/transaction_spec.rb +498 -344
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +20 -20
- data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
- data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
- data/spec/integration/spec_helper.rb +2 -2
- data/spec/oauth_test_helper.rb +1 -1
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec_helper.rb +4 -3
- data/spec/unit/braintree/address_spec.rb +1 -1
- data/spec/unit/braintree/apple_pay_card_spec.rb +1 -1
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +42 -42
- data/spec/unit/braintree/credit_card_spec.rb +7 -7
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_verification_spec.rb +2 -2
- data/spec/unit/braintree/customer_spec.rb +3 -3
- data/spec/unit/braintree/disbursement_spec.rb +7 -7
- data/spec/unit/braintree/dispute_spec.rb +8 -8
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +8 -8
- data/spec/unit/braintree/http_spec.rb +5 -5
- data/spec/unit/braintree/merchant_account_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_spec.rb +1 -1
- data/spec/unit/braintree/paypal_account_spec.rb +2 -2
- data/spec/unit/braintree/resource_collection_spec.rb +9 -9
- data/spec/unit/braintree/subscription_search_spec.rb +1 -1
- data/spec/unit/braintree/successful_result_spec.rb +1 -1
- data/spec/unit/braintree/three_d_secure_info_spec.rb +1 -1
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +3 -3
- 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/paypal_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction_search_spec.rb +12 -12
- data/spec/unit/braintree/transaction_spec.rb +25 -17
- data/spec/unit/braintree/util_spec.rb +18 -18
- data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
- data/spec/unit/braintree/webhook_notification_spec.rb +72 -56
- data/spec/unit/braintree/xml_spec.rb +31 -31
- metadata +3 -3
- data/lib/braintree/settlement_batch.rb +0 -0
data/spec/spec_helper.rb
CHANGED
|
@@ -40,6 +40,7 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
|
40
40
|
AdyenMerchantAccountId = "adyen_ma"
|
|
41
41
|
HiperBRLMerchantAccountId = "hiper_brl"
|
|
42
42
|
CardProcessorBRLMerchantAccountId = "card_processor_brl"
|
|
43
|
+
FakeFirstDataMerchantAccountId = "fake_first_data_merchant_account"
|
|
43
44
|
|
|
44
45
|
TrialPlan = {
|
|
45
46
|
:description => "Plan for integration tests -- with trial",
|
|
@@ -88,13 +89,13 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
|
88
89
|
:environment => Braintree::Configuration.environment,
|
|
89
90
|
:merchant_id => "test_merchant_id",
|
|
90
91
|
:public_key => "test_public_key",
|
|
91
|
-
:private_key => "test_private_key"
|
|
92
|
+
:private_key => "test_private_key",
|
|
92
93
|
)
|
|
93
94
|
|
|
94
95
|
def self.make_past_due(subscription, number_of_days_past_due = 1)
|
|
95
96
|
config = Braintree::Configuration.instantiate
|
|
96
97
|
config.http.put(
|
|
97
|
-
"#{config.base_merchant_path}/subscriptions/#{subscription.id}/make_past_due?days_past_due=#{number_of_days_past_due}"
|
|
98
|
+
"#{config.base_merchant_path}/subscriptions/#{subscription.id}/make_past_due?days_past_due=#{number_of_days_past_due}",
|
|
98
99
|
)
|
|
99
100
|
end
|
|
100
101
|
|
|
@@ -113,7 +114,7 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
|
113
114
|
gateway = Braintree::Gateway.new(
|
|
114
115
|
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
|
115
116
|
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
|
116
|
-
:logger => Logger.new("/dev/null")
|
|
117
|
+
:logger => Logger.new("/dev/null"),
|
|
117
118
|
)
|
|
118
119
|
|
|
119
120
|
gateway.merchant.create({
|
|
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
|
3
3
|
describe Braintree::Address do
|
|
4
4
|
describe "==" do
|
|
5
5
|
it "returns true if given an address with the same id and customer_id" do
|
|
6
|
-
first = Braintree::Address._new(:gateway, :customer_id => "c1", :id =>
|
|
6
|
+
first = Braintree::Address._new(:gateway, :customer_id => "c1", :id => "a1")
|
|
7
7
|
second = Braintree::Address._new(:gateway, :customer_id => "c1", :id => "a1")
|
|
8
8
|
|
|
9
9
|
first.should == second
|
|
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
|
3
3
|
describe Braintree::ApplePayCard do
|
|
4
4
|
describe "bin" do
|
|
5
5
|
it "returns Apple pay card bin" do
|
|
6
|
-
Braintree::ApplePayCard._new(:gateway, bin:
|
|
6
|
+
Braintree::ApplePayCard._new(:gateway, bin: "411111").bin.should == "411111"
|
|
7
7
|
end
|
|
8
8
|
end
|
|
9
9
|
|
|
@@ -16,7 +16,7 @@ module Braintree
|
|
|
16
16
|
expect {
|
|
17
17
|
client_token = Braintree::ClientToken.generate(
|
|
18
18
|
:public_key => "bad_key",
|
|
19
|
-
:created_at => "bad_time"
|
|
19
|
+
:created_at => "bad_time",
|
|
20
20
|
)
|
|
21
21
|
}.to raise_error(ArgumentError, /created_at, public_key/)
|
|
22
22
|
end
|
|
@@ -27,7 +27,7 @@ module Braintree
|
|
|
27
27
|
it "raises an ArgumentError if #{option_name} is present" do
|
|
28
28
|
expect do
|
|
29
29
|
Braintree::ClientToken.generate(
|
|
30
|
-
option_name.to_sym => true
|
|
30
|
+
option_name.to_sym => true,
|
|
31
31
|
)
|
|
32
32
|
end.to raise_error(ArgumentError, /#{option_name}/)
|
|
33
33
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "stringio"
|
|
2
2
|
|
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
4
4
|
|
|
@@ -22,26 +22,26 @@ describe Braintree::Configuration do
|
|
|
22
22
|
describe "initialize" do
|
|
23
23
|
it "accepts merchant credentials" do
|
|
24
24
|
config = Braintree::Configuration.new(
|
|
25
|
-
:merchant_id =>
|
|
26
|
-
:public_key =>
|
|
27
|
-
:private_key =>
|
|
25
|
+
:merchant_id => "merchant_id",
|
|
26
|
+
:public_key => "public_key",
|
|
27
|
+
:private_key => "private_key",
|
|
28
28
|
)
|
|
29
29
|
|
|
30
|
-
config.merchant_id.should ==
|
|
31
|
-
config.public_key.should ==
|
|
32
|
-
config.private_key.should ==
|
|
30
|
+
config.merchant_id.should == "merchant_id"
|
|
31
|
+
config.public_key.should == "public_key"
|
|
32
|
+
config.private_key.should == "private_key"
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
it "accepts partner credentials" do
|
|
36
36
|
config = Braintree::Configuration.new(
|
|
37
|
-
:partner_id =>
|
|
38
|
-
:public_key =>
|
|
39
|
-
:private_key =>
|
|
37
|
+
:partner_id => "partner_id",
|
|
38
|
+
:public_key => "public_key",
|
|
39
|
+
:private_key => "private_key",
|
|
40
40
|
)
|
|
41
41
|
|
|
42
|
-
config.merchant_id.should ==
|
|
43
|
-
config.public_key.should ==
|
|
44
|
-
config.private_key.should ==
|
|
42
|
+
config.merchant_id.should == "partner_id"
|
|
43
|
+
config.public_key.should == "public_key"
|
|
44
|
+
config.private_key.should == "private_key"
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
it "raises if combining client_id/secret with access_token" do
|
|
@@ -49,7 +49,7 @@ describe Braintree::Configuration do
|
|
|
49
49
|
Braintree::Configuration.new(
|
|
50
50
|
:client_id => "client_id$development$integration_client_id",
|
|
51
51
|
:client_secret => "client_secret$development$integration_client_secret",
|
|
52
|
-
:access_token => "access_token$development$integration_merchant_id$fb27c79dd"
|
|
52
|
+
:access_token => "access_token$development$integration_merchant_id$fb27c79dd",
|
|
53
53
|
)
|
|
54
54
|
end.to raise_error(Braintree::ConfigurationError, /mixed credential types/)
|
|
55
55
|
end
|
|
@@ -62,7 +62,7 @@ describe Braintree::Configuration do
|
|
|
62
62
|
:merchant_id => "merchant_id",
|
|
63
63
|
:public_key => "public_key",
|
|
64
64
|
:private_key => "private_key",
|
|
65
|
-
:environment => "development"
|
|
65
|
+
:environment => "development",
|
|
66
66
|
)
|
|
67
67
|
end.to raise_error(Braintree::ConfigurationError, /mixed credential types/)
|
|
68
68
|
end
|
|
@@ -96,21 +96,21 @@ describe Braintree::Configuration do
|
|
|
96
96
|
|
|
97
97
|
it "accepts proxy params" do
|
|
98
98
|
config = Braintree::Configuration.new(
|
|
99
|
-
:proxy_address =>
|
|
99
|
+
:proxy_address => "localhost",
|
|
100
100
|
:proxy_port => 8080,
|
|
101
|
-
:proxy_user =>
|
|
102
|
-
:proxy_pass =>
|
|
101
|
+
:proxy_user => "user",
|
|
102
|
+
:proxy_pass => "test",
|
|
103
103
|
)
|
|
104
104
|
|
|
105
|
-
config.proxy_address.should ==
|
|
105
|
+
config.proxy_address.should == "localhost"
|
|
106
106
|
config.proxy_port.should == 8080
|
|
107
|
-
config.proxy_user.should ==
|
|
108
|
-
config.proxy_pass.should ==
|
|
107
|
+
config.proxy_user.should == "user"
|
|
108
|
+
config.proxy_pass.should == "test"
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
it "accepts ssl version" do
|
|
112
112
|
config = Braintree::Configuration.new(
|
|
113
|
-
:ssl_version => :TLSv1_2
|
|
113
|
+
:ssl_version => :TLSv1_2,
|
|
114
114
|
)
|
|
115
115
|
|
|
116
116
|
config.ssl_version.should == :TLSv1_2
|
|
@@ -146,14 +146,14 @@ describe Braintree::Configuration do
|
|
|
146
146
|
Braintree::Configuration.environment = :sandbox
|
|
147
147
|
ca_file = Braintree::Configuration.instantiate.ca_file
|
|
148
148
|
ca_file.should match(/api_braintreegateway_com\.ca\.crt$/)
|
|
149
|
-
File.
|
|
149
|
+
File.exist?(ca_file).should == true
|
|
150
150
|
end
|
|
151
151
|
|
|
152
152
|
it "production" do
|
|
153
153
|
Braintree::Configuration.environment = :production
|
|
154
154
|
ca_file = Braintree::Configuration.instantiate.ca_file
|
|
155
155
|
ca_file.should match(/api_braintreegateway_com\.ca\.crt$/)
|
|
156
|
-
File.
|
|
156
|
+
File.exist?(ca_file).should == true
|
|
157
157
|
end
|
|
158
158
|
end
|
|
159
159
|
|
|
@@ -238,12 +238,12 @@ describe Braintree::Configuration do
|
|
|
238
238
|
|
|
239
239
|
it "allows the environment to be set with a string value" do
|
|
240
240
|
expect do
|
|
241
|
-
Braintree::Configuration.environment =
|
|
241
|
+
Braintree::Configuration.environment = "sandbox"
|
|
242
242
|
end.not_to raise_error
|
|
243
243
|
end
|
|
244
244
|
|
|
245
245
|
it "sets the environment as a symbol" do
|
|
246
|
-
Braintree::Configuration.environment =
|
|
246
|
+
Braintree::Configuration.environment = "sandbox"
|
|
247
247
|
expect(Braintree::Configuration.environment).to eq :sandbox
|
|
248
248
|
end
|
|
249
249
|
end
|
|
@@ -326,15 +326,15 @@ describe Braintree::Configuration do
|
|
|
326
326
|
|
|
327
327
|
it "is 3000 or GATEWAY_PORT environment variable for development" do
|
|
328
328
|
Braintree::Configuration.environment = :development
|
|
329
|
-
old_gateway_port = ENV[
|
|
329
|
+
old_gateway_port = ENV["GATEWAY_PORT"]
|
|
330
330
|
begin
|
|
331
|
-
ENV[
|
|
331
|
+
ENV["GATEWAY_PORT"] = nil
|
|
332
332
|
Braintree::Configuration.instantiate.port.should == 3000
|
|
333
333
|
|
|
334
|
-
ENV[
|
|
335
|
-
Braintree::Configuration.instantiate.port.should ==
|
|
334
|
+
ENV["GATEWAY_PORT"] = "1234"
|
|
335
|
+
Braintree::Configuration.instantiate.port.should == "1234"
|
|
336
336
|
ensure
|
|
337
|
-
ENV[
|
|
337
|
+
ENV["GATEWAY_PORT"] = old_gateway_port
|
|
338
338
|
end
|
|
339
339
|
end
|
|
340
340
|
end
|
|
@@ -359,15 +359,15 @@ describe Braintree::Configuration do
|
|
|
359
359
|
describe "graphql_server" do
|
|
360
360
|
it "is localhost or GRAPHQL_HOST environment variable for development" do
|
|
361
361
|
Braintree::Configuration.environment = :development
|
|
362
|
-
old_gateway_url = ENV[
|
|
362
|
+
old_gateway_url = ENV["GRAPHQL_HOST"]
|
|
363
363
|
begin
|
|
364
|
-
ENV[
|
|
364
|
+
ENV["GRAPHQL_HOST"] = nil
|
|
365
365
|
Braintree::Configuration.instantiate.graphql_server.should == "graphql.bt.local"
|
|
366
366
|
|
|
367
|
-
ENV[
|
|
368
|
-
Braintree::Configuration.instantiate.graphql_server.should ==
|
|
367
|
+
ENV["GRAPHQL_HOST"] = "gateway"
|
|
368
|
+
Braintree::Configuration.instantiate.graphql_server.should == "gateway"
|
|
369
369
|
ensure
|
|
370
|
-
ENV[
|
|
370
|
+
ENV["GRAPHQL_HOST"] = old_gateway_url
|
|
371
371
|
end
|
|
372
372
|
end
|
|
373
373
|
end
|
|
@@ -375,15 +375,15 @@ describe Braintree::Configuration do
|
|
|
375
375
|
describe "server" do
|
|
376
376
|
it "is localhost or GATEWAY_HOST environment variable for development" do
|
|
377
377
|
Braintree::Configuration.environment = :development
|
|
378
|
-
old_gateway_url = ENV[
|
|
378
|
+
old_gateway_url = ENV["GATEWAY_HOST"]
|
|
379
379
|
begin
|
|
380
|
-
ENV[
|
|
380
|
+
ENV["GATEWAY_HOST"] = nil
|
|
381
381
|
Braintree::Configuration.instantiate.server.should == "localhost"
|
|
382
382
|
|
|
383
|
-
ENV[
|
|
384
|
-
Braintree::Configuration.instantiate.server.should ==
|
|
383
|
+
ENV["GATEWAY_HOST"] = "gateway"
|
|
384
|
+
Braintree::Configuration.instantiate.server.should == "gateway"
|
|
385
385
|
ensure
|
|
386
|
-
ENV[
|
|
386
|
+
ENV["GATEWAY_HOST"] = old_gateway_url
|
|
387
387
|
end
|
|
388
388
|
end
|
|
389
389
|
|
|
@@ -468,7 +468,7 @@ describe Braintree::Configuration do
|
|
|
468
468
|
it "masks the private_key" do
|
|
469
469
|
config = Braintree::Configuration.new(:private_key => "secret_key")
|
|
470
470
|
config.inspect.should include('@private_key="[FILTERED]"')
|
|
471
|
-
config.inspect.should_not include(
|
|
471
|
+
config.inspect.should_not include("secret_key")
|
|
472
472
|
end
|
|
473
473
|
end
|
|
474
474
|
|
|
@@ -4,7 +4,7 @@ describe Braintree::CreditCard do
|
|
|
4
4
|
describe "self.create" do
|
|
5
5
|
it "raises an exception if attributes contain an invalid key" do
|
|
6
6
|
expect do
|
|
7
|
-
Braintree::CreditCard.create(:invalid_key =>
|
|
7
|
+
Braintree::CreditCard.create(:invalid_key => "val")
|
|
8
8
|
end.to raise_error(ArgumentError, "invalid keys: invalid_key")
|
|
9
9
|
end
|
|
10
10
|
end
|
|
@@ -203,7 +203,7 @@ describe Braintree::CreditCard do
|
|
|
203
203
|
credit_card = Braintree::CreditCard._new(
|
|
204
204
|
:gateway,
|
|
205
205
|
:bin => "510510",
|
|
206
|
-
:last_4 => "5100"
|
|
206
|
+
:last_4 => "5100",
|
|
207
207
|
)
|
|
208
208
|
credit_card.masked_number.should == "510510******5100"
|
|
209
209
|
end
|
|
@@ -215,7 +215,7 @@ describe Braintree::CreditCard do
|
|
|
215
215
|
:gateway,
|
|
216
216
|
:bin => "510510",
|
|
217
217
|
:last_4 => "5100",
|
|
218
|
-
:is_network_tokenized => true
|
|
218
|
+
:is_network_tokenized => true,
|
|
219
219
|
)
|
|
220
220
|
credit_card.is_network_tokenized?.should == true
|
|
221
221
|
end
|
|
@@ -225,7 +225,7 @@ describe Braintree::CreditCard do
|
|
|
225
225
|
:gateway,
|
|
226
226
|
:bin => "510510",
|
|
227
227
|
:last_4 => "5100",
|
|
228
|
-
:is_network_tokenized => false
|
|
228
|
+
:is_network_tokenized => false,
|
|
229
229
|
)
|
|
230
230
|
credit_card.is_network_tokenized?.should == false
|
|
231
231
|
end
|
|
@@ -234,7 +234,7 @@ describe Braintree::CreditCard do
|
|
|
234
234
|
describe "self.update" do
|
|
235
235
|
it "raises an exception if attributes contain an invalid key" do
|
|
236
236
|
expect do
|
|
237
|
-
Braintree::CreditCard.update(:gateway, :invalid_key =>
|
|
237
|
+
Braintree::CreditCard.update(:gateway, :invalid_key => "val")
|
|
238
238
|
end.to raise_error(ArgumentError, "invalid keys: invalid_key")
|
|
239
239
|
end
|
|
240
240
|
end
|
|
@@ -250,8 +250,8 @@ describe Braintree::CreditCard do
|
|
|
250
250
|
describe "self._new" do
|
|
251
251
|
describe "initializing verification" do
|
|
252
252
|
it "picks the youngest verification" do
|
|
253
|
-
verification1 = {
|
|
254
|
-
verification2 = {
|
|
253
|
+
verification1 = {:created_at => Time.now, :id => 123}
|
|
254
|
+
verification2 = {:created_at => Time.now - 3600, :id => 456}
|
|
255
255
|
credit_card = Braintree::CreditCard._new(Braintree::Configuration.gateway, {:verifications => [verification1, verification2]})
|
|
256
256
|
credit_card.verification.id.should == 123
|
|
257
257
|
end
|
|
@@ -30,7 +30,7 @@ describe Braintree::CreditCardVerification do
|
|
|
30
30
|
:cvv_response_code => "I",
|
|
31
31
|
:processor_response_code => "2000",
|
|
32
32
|
:processor_response_text => "Do Not Honor",
|
|
33
|
-
:merchant_account_id => "some_id"
|
|
33
|
+
:merchant_account_id => "some_id",
|
|
34
34
|
)
|
|
35
35
|
|
|
36
36
|
verification.status.should == Braintree::CreditCardVerification::Status::Verified
|
|
@@ -44,7 +44,7 @@ describe Braintree::CreditCardVerification do
|
|
|
44
44
|
|
|
45
45
|
it "accepts network_transaction_id" do
|
|
46
46
|
verification = Braintree::CreditCardVerification._new(
|
|
47
|
-
:network_transaction_id => "123456789012345"
|
|
47
|
+
:network_transaction_id => "123456789012345",
|
|
48
48
|
)
|
|
49
49
|
expect(verification.network_transaction_id).to eq "123456789012345"
|
|
50
50
|
end
|
|
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
|
3
3
|
describe Braintree::Customer do
|
|
4
4
|
describe "inspect" do
|
|
5
5
|
it "includes the id first" do
|
|
6
|
-
output = Braintree::Customer._new(:gateway, {:first_name =>
|
|
6
|
+
output = Braintree::Customer._new(:gateway, {:first_name => "Dan", :id => "1234"}).inspect
|
|
7
7
|
output.should include("#<Braintree::Customer id: \"1234\",")
|
|
8
8
|
end
|
|
9
9
|
|
|
@@ -18,7 +18,7 @@ describe Braintree::Customer do
|
|
|
18
18
|
:phone => "802-483-5932",
|
|
19
19
|
:website => "patrick.smith.com",
|
|
20
20
|
:created_at => Time.now,
|
|
21
|
-
:updated_at => Time.now
|
|
21
|
+
:updated_at => Time.now,
|
|
22
22
|
)
|
|
23
23
|
output = customer.inspect
|
|
24
24
|
output.should include(%q(company: "Company"))
|
|
@@ -290,7 +290,7 @@ describe Braintree::Customer do
|
|
|
290
290
|
:paypal_accounts => [
|
|
291
291
|
{:token => "paypal_1"},
|
|
292
292
|
{:token => "paypal_2"}
|
|
293
|
-
]
|
|
293
|
+
],
|
|
294
294
|
)
|
|
295
295
|
|
|
296
296
|
customer.credit_cards.size.should == 2
|
|
@@ -28,18 +28,18 @@ describe Braintree::Disbursement do
|
|
|
28
28
|
:exception_message => "invalid_account_number",
|
|
29
29
|
:follow_up_action => "update",
|
|
30
30
|
:retry => false,
|
|
31
|
-
:success => false
|
|
31
|
+
:success => false,
|
|
32
32
|
)
|
|
33
33
|
|
|
34
34
|
disbursement.inspect.should include('id: "123456"')
|
|
35
35
|
disbursement.inspect.should include('amount: "100.0"')
|
|
36
36
|
disbursement.inspect.should include('exception_message: "invalid_account_number"')
|
|
37
|
-
disbursement.inspect.should include(
|
|
37
|
+
disbursement.inspect.should include("disbursement_date: 2013-04-10")
|
|
38
38
|
disbursement.inspect.should include('follow_up_action: "update"')
|
|
39
|
-
disbursement.inspect.should include(
|
|
39
|
+
disbursement.inspect.should include("merchant_account: #<Braintree::MerchantAccount: ")
|
|
40
40
|
disbursement.inspect.should include('transaction_ids: ["sub_merchant_transaction"]')
|
|
41
|
-
disbursement.inspect.should include(
|
|
42
|
-
disbursement.inspect.should include(
|
|
41
|
+
disbursement.inspect.should include("retry: false")
|
|
42
|
+
disbursement.inspect.should include("success: false")
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
45
|
|
|
@@ -56,7 +56,7 @@ describe Braintree::Disbursement do
|
|
|
56
56
|
:status => "active"
|
|
57
57
|
},
|
|
58
58
|
:success => false,
|
|
59
|
-
:disbursement_date => "2013-04-10"
|
|
59
|
+
:disbursement_date => "2013-04-10",
|
|
60
60
|
)
|
|
61
61
|
disbursement.success?.should == false
|
|
62
62
|
|
|
@@ -71,7 +71,7 @@ describe Braintree::Disbursement do
|
|
|
71
71
|
:status => "active"
|
|
72
72
|
},
|
|
73
73
|
:success => true,
|
|
74
|
-
:disbursement_date => "2013-04-10"
|
|
74
|
+
:disbursement_date => "2013-04-10",
|
|
75
75
|
)
|
|
76
76
|
disbursement.success?.should == true
|
|
77
77
|
end
|
|
@@ -137,13 +137,13 @@ describe Braintree::Dispute do
|
|
|
137
137
|
it "does not raise an exception if the optional parameters are valid" do
|
|
138
138
|
Braintree::Http.stub(:new).and_return double.as_null_object
|
|
139
139
|
expect do
|
|
140
|
-
Braintree::Dispute.add_file_evidence("dispute_id", {
|
|
140
|
+
Braintree::Dispute.add_file_evidence("dispute_id", {category: "GENERAL", document_id: "document_id"})
|
|
141
141
|
end.to_not raise_error
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
it "raises an exception if the optional params contain invalid keys" do
|
|
145
145
|
expect do
|
|
146
|
-
Braintree::Dispute.add_file_evidence("dispute_id", {
|
|
146
|
+
Braintree::Dispute.add_file_evidence("dispute_id", {random_param: ""})
|
|
147
147
|
end.to raise_error(ArgumentError)
|
|
148
148
|
end
|
|
149
149
|
|
|
@@ -151,7 +151,7 @@ describe Braintree::Dispute do
|
|
|
151
151
|
Braintree::Http.stub(:new).and_return double.as_null_object
|
|
152
152
|
|
|
153
153
|
expect do
|
|
154
|
-
Braintree::Dispute.add_file_evidence("dispute_id", {
|
|
154
|
+
Braintree::Dispute.add_file_evidence("dispute_id", {category: 3, document_id: "document_id"})
|
|
155
155
|
end.to raise_error(ArgumentError)
|
|
156
156
|
end
|
|
157
157
|
end
|
|
@@ -200,31 +200,31 @@ describe Braintree::Dispute do
|
|
|
200
200
|
it "does not raise an exception if the optional parameters are valid" do
|
|
201
201
|
Braintree::Http.stub(:new).and_return double.as_null_object
|
|
202
202
|
expect do
|
|
203
|
-
Braintree::Dispute.add_text_evidence("dispute_id", {
|
|
203
|
+
Braintree::Dispute.add_text_evidence("dispute_id", {content: "a", category: "", sequence_number: 3})
|
|
204
204
|
end.to_not raise_error
|
|
205
205
|
end
|
|
206
206
|
|
|
207
207
|
it "raises an exception if the optional params contain invalid keys" do
|
|
208
208
|
expect do
|
|
209
|
-
Braintree::Dispute.add_text_evidence("dispute_id", {
|
|
209
|
+
Braintree::Dispute.add_text_evidence("dispute_id", {random_param: ""})
|
|
210
210
|
end.to raise_error(ArgumentError)
|
|
211
211
|
end
|
|
212
212
|
|
|
213
213
|
it "raises an exception if sequence_number is provided and not an integer" do
|
|
214
214
|
expect do
|
|
215
|
-
Braintree::Dispute.add_text_evidence("dispute_id", {
|
|
215
|
+
Braintree::Dispute.add_text_evidence("dispute_id", {sequence_number: "abc"})
|
|
216
216
|
end.to raise_error(ArgumentError)
|
|
217
217
|
end
|
|
218
218
|
|
|
219
219
|
it "raises an exception if the param tag is not a string" do
|
|
220
220
|
expect do
|
|
221
|
-
Braintree::Dispute.add_text_evidence("dispute_id", {
|
|
221
|
+
Braintree::Dispute.add_text_evidence("dispute_id", {tag: 3})
|
|
222
222
|
end.to raise_error(ArgumentError)
|
|
223
223
|
end
|
|
224
224
|
|
|
225
225
|
it "raises an exception if the param category is not a string" do
|
|
226
226
|
expect do
|
|
227
|
-
Braintree::Dispute.add_text_evidence("dispute_id", {
|
|
227
|
+
Braintree::Dispute.add_text_evidence("dispute_id", {category: 3})
|
|
228
228
|
end.to raise_error(ArgumentError)
|
|
229
229
|
end
|
|
230
230
|
end
|