braintree 3.3.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -10,7 +10,7 @@ describe Braintree::ErrorResult do
|
|
10
10
|
:params => "params",
|
11
11
|
:errors => {:errors => []},
|
12
12
|
:extra => "is ignored",
|
13
|
-
:message => "foo bar"
|
13
|
+
:message => "foo bar",
|
14
14
|
)
|
15
15
|
end.to_not raise_error
|
16
16
|
end
|
@@ -36,7 +36,7 @@ describe Braintree::ErrorResult do
|
|
36
36
|
:params => "params",
|
37
37
|
:errors => {},
|
38
38
|
:verification => {},
|
39
|
-
:transaction => nil
|
39
|
+
:transaction => nil,
|
40
40
|
)
|
41
41
|
result.inspect.should include("credit_card_verification: #<Braintree::CreditCardVerification status: ")
|
42
42
|
end
|
@@ -47,7 +47,7 @@ describe Braintree::ErrorResult do
|
|
47
47
|
:params => "params",
|
48
48
|
:errors => {},
|
49
49
|
:verification => nil,
|
50
|
-
:transaction => nil
|
50
|
+
:transaction => nil,
|
51
51
|
)
|
52
52
|
result.inspect.should_not include("credit_card_verification")
|
53
53
|
end
|
@@ -58,7 +58,7 @@ describe Braintree::ErrorResult do
|
|
58
58
|
:params => "params",
|
59
59
|
:errors => {},
|
60
60
|
:verification => nil,
|
61
|
-
:transaction => {}
|
61
|
+
:transaction => {},
|
62
62
|
)
|
63
63
|
result.inspect.should include("transaction: #<Braintree::Transaction id: ")
|
64
64
|
end
|
@@ -69,7 +69,7 @@ describe Braintree::ErrorResult do
|
|
69
69
|
:params => "params",
|
70
70
|
:errors => {},
|
71
71
|
:verification => nil,
|
72
|
-
:transaction => nil
|
72
|
+
:transaction => nil,
|
73
73
|
)
|
74
74
|
result.inspect.should_not include("transaction")
|
75
75
|
end
|
@@ -4,7 +4,7 @@ describe Braintree::Errors do
|
|
4
4
|
describe "for" do
|
5
5
|
it "accesses errors for the given scope" do
|
6
6
|
errors = Braintree::Errors.new(
|
7
|
-
:level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]}
|
7
|
+
:level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]},
|
8
8
|
)
|
9
9
|
errors.for(:level1).size.should == 1
|
10
10
|
errors.for(:level1)[0].code.should == "code1"
|
@@ -12,7 +12,7 @@ describe Braintree::Errors do
|
|
12
12
|
|
13
13
|
it "returns nil if there are no errors at the given scope" do
|
14
14
|
errors = Braintree::Errors.new(
|
15
|
-
:level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]}
|
15
|
+
:level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]},
|
16
16
|
)
|
17
17
|
errors.for(:no_errors_here).should == nil
|
18
18
|
end
|
@@ -21,7 +21,7 @@ describe Braintree::Errors do
|
|
21
21
|
describe "inspect" do
|
22
22
|
it "is better than the default inspect" do
|
23
23
|
errors = Braintree::Errors.new(
|
24
|
-
:level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]}
|
24
|
+
:level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]},
|
25
25
|
)
|
26
26
|
errors.inspect.should == "#<Braintree::Errors level1:[(code1) message]>"
|
27
27
|
end
|
@@ -33,7 +33,7 @@ describe Braintree::Errors do
|
|
33
33
|
:level2 => {
|
34
34
|
:errors => [{:code => "code2", :attribute => "attr2", :message => "message2"}],
|
35
35
|
}
|
36
|
-
}
|
36
|
+
},
|
37
37
|
)
|
38
38
|
errors.inspect.should == "#<Braintree::Errors level1:[(code1) message], level1/level2:[(code2) message2]>"
|
39
39
|
end
|
@@ -48,7 +48,7 @@ describe Braintree::Errors do
|
|
48
48
|
:errors => [{:code => "code3", :attribute => "attr3", :message => "message3"}],
|
49
49
|
}
|
50
50
|
}
|
51
|
-
}
|
51
|
+
},
|
52
52
|
)
|
53
53
|
errors.inspect.should == "#<Braintree::Errors level1:[(code1) message], level1/level2:[(code2) message2], level1/level2/level3:[(code3) message3]>"
|
54
54
|
end
|
@@ -65,7 +65,7 @@ describe Braintree::Errors do
|
|
65
65
|
{:code => "3", :attribute => "attr3", :message => "message3"}
|
66
66
|
],
|
67
67
|
}
|
68
|
-
}
|
68
|
+
},
|
69
69
|
)
|
70
70
|
errors.map { |e| e.code }.sort.should == %w[1 2 3]
|
71
71
|
end
|
@@ -74,7 +74,7 @@ describe Braintree::Errors do
|
|
74
74
|
describe "size" do
|
75
75
|
it "returns the number of validation errors at the first level if only has one level" do
|
76
76
|
errors = Braintree::Errors.new(
|
77
|
-
:level1 => {:errors => [{:code => "1", :attribute => "attr", :message => "message"}]}
|
77
|
+
:level1 => {:errors => [{:code => "1", :attribute => "attr", :message => "message"}]},
|
78
78
|
)
|
79
79
|
errors.size.should == 1
|
80
80
|
end
|
@@ -89,7 +89,7 @@ describe Braintree::Errors do
|
|
89
89
|
{:code => "3", :attribute => "attr3", :message => "message3"}
|
90
90
|
],
|
91
91
|
}
|
92
|
-
}
|
92
|
+
},
|
93
93
|
)
|
94
94
|
errors.size.should == 3
|
95
95
|
end
|
@@ -67,7 +67,7 @@ END
|
|
67
67
|
:proxy_address => "localhost",
|
68
68
|
:proxy_port => 8080,
|
69
69
|
:proxy_user => "user",
|
70
|
-
:proxy_pass => "test"
|
70
|
+
:proxy_pass => "test",
|
71
71
|
)
|
72
72
|
|
73
73
|
http = Braintree::Http.new(config)
|
@@ -75,7 +75,7 @@ END
|
|
75
75
|
"Net::HTTP",
|
76
76
|
:open_timeout= => nil,
|
77
77
|
:read_timeout= => nil,
|
78
|
-
:start => nil
|
78
|
+
:start => nil,
|
79
79
|
)
|
80
80
|
|
81
81
|
Net::HTTP.should_receive(:new).with(nil, nil, "localhost", 8080, "user", "test").and_return(net_http_instance)
|
@@ -86,7 +86,7 @@ END
|
|
86
86
|
it "accepts a partially specified proxy" do
|
87
87
|
config = Braintree::Configuration.new(
|
88
88
|
:proxy_address => "localhost",
|
89
|
-
:proxy_port => 8080
|
89
|
+
:proxy_port => 8080,
|
90
90
|
)
|
91
91
|
|
92
92
|
http = Braintree::Http.new(config)
|
@@ -94,7 +94,7 @@ END
|
|
94
94
|
"Net::HTTP",
|
95
95
|
:open_timeout= => nil,
|
96
96
|
:read_timeout= => nil,
|
97
|
-
:start => nil
|
97
|
+
:start => nil,
|
98
98
|
)
|
99
99
|
|
100
100
|
Net::HTTP.should_receive(:new).with(nil, nil, "localhost", 8080, nil, nil).and_return(net_http_instance)
|
@@ -109,7 +109,7 @@ END
|
|
109
109
|
"Net::HTTP",
|
110
110
|
:open_timeout= => nil,
|
111
111
|
:read_timeout= => nil,
|
112
|
-
:start => nil
|
112
|
+
:start => nil,
|
113
113
|
)
|
114
114
|
|
115
115
|
Net::HTTP.should_receive(:new).with(nil, nil).and_return(net_http_instance)
|
@@ -13,7 +13,7 @@ describe Braintree::MerchantAccount do
|
|
13
13
|
nil,
|
14
14
|
:id => "merchant_account",
|
15
15
|
:status => "active",
|
16
|
-
:master_merchant_account => {:id => "master_merchant_account", :status => "active", :master_merchant_account => nil}
|
16
|
+
:master_merchant_account => {:id => "master_merchant_account", :status => "active", :master_merchant_account => nil},
|
17
17
|
)
|
18
18
|
|
19
19
|
master_merchant_account = "#<Braintree::MerchantAccount: id: \"master_merchant_account\", status: \"active\", master_merchant_account: nil>"
|
@@ -28,7 +28,7 @@ describe Braintree::PaymentMethod do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
describe "delete" do
|
31
|
-
let(:http_stub) { double(
|
31
|
+
let(:http_stub) { double("http_stub").as_null_object }
|
32
32
|
it "accepts revoke_all_grants option with value true" do
|
33
33
|
Braintree::Http.stub(:new).and_return http_stub
|
34
34
|
http_stub.should_receive(:delete).with("/merchants/integration_merchant_id/payment_methods/any/some_token?revoke_all_grants=true")
|
@@ -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 =>
|
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
|
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
|
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
|
41
|
-
collection.first.should ==
|
40
|
+
it "returns the first occourence" do
|
41
|
+
collection.first.should == "a"
|
42
42
|
end
|
43
43
|
|
44
|
-
it
|
45
|
-
collection.first(4).should == [
|
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
|
@@ -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"
|
@@ -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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
{
|
165
|
-
:user => "larry", :status => Braintree::Transaction::Status::Authorized
|
166
|
-
{
|
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
|
-
{
|
184
|
-
{
|
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(
|
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
|