braintree 2.104.0 → 4.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/braintree.gemspec +7 -4
- data/lib/braintree/account_updater_daily_report.rb +1 -1
- data/lib/braintree/address.rb +2 -23
- data/lib/braintree/apple_pay.rb +1 -1
- data/lib/braintree/apple_pay_card.rb +11 -1
- data/lib/braintree/apple_pay_options.rb +1 -1
- data/lib/braintree/authorization_adjustment.rb +1 -1
- data/lib/braintree/base_module.rb +6 -0
- data/lib/braintree/bin_data.rb +9 -2
- data/lib/braintree/client_token.rb +1 -1
- data/lib/braintree/configuration.rb +12 -12
- 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 -77
- data/lib/braintree/credit_card_gateway.rb +17 -36
- data/lib/braintree/credit_card_verification.rb +18 -5
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +9 -78
- data/lib/braintree/customer_gateway.rb +2 -23
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/disbursement.rb +1 -1
- data/lib/braintree/{transaction/coinbase_details.rb → dispute/paypal_message.rb} +5 -6
- data/lib/braintree/dispute/{history_event.rb → status_history.rb} +3 -1
- data/lib/braintree/dispute.rb +32 -8
- data/lib/braintree/dispute_gateway.rb +4 -9
- data/lib/braintree/dispute_search.rb +6 -3
- data/lib/braintree/document_upload.rb +1 -1
- data/lib/braintree/enriched_customer_data.rb +21 -0
- data/lib/braintree/error_codes.rb +150 -171
- data/lib/braintree/exceptions.rb +5 -3
- data/lib/braintree/exchange_rate.rb +13 -0
- data/lib/braintree/exchange_rate_quote.rb +24 -0
- data/lib/braintree/exchange_rate_quote_gateway.rb +35 -0
- data/lib/braintree/exchange_rate_quote_input.rb +21 -0
- data/lib/braintree/exchange_rate_quote_request.rb +18 -0
- data/lib/braintree/exchange_rate_quote_response.rb +18 -0
- data/lib/braintree/gateway.rb +4 -14
- data/lib/braintree/{android_pay_card.rb → google_pay_card.rb} +11 -3
- data/lib/braintree/granted_payment_instrument_update.rb +1 -1
- data/lib/braintree/graphql_client.rb +7 -7
- data/lib/braintree/http.rb +4 -3
- data/lib/braintree/local_payment_completed.rb +2 -2
- data/lib/braintree/local_payment_expired.rb +21 -0
- data/lib/braintree/local_payment_funded.rb +22 -0
- 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 +3 -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 -14
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
- data/lib/braintree/payment_method_gateway.rb +15 -17
- data/lib/braintree/payment_method_nonce.rb +7 -4
- data/lib/braintree/payment_method_nonce_details.rb +37 -0
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
- data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
- data/lib/braintree/payment_method_parser.rb +1 -8
- data/lib/braintree/plan.rb +21 -1
- data/lib/braintree/plan_gateway.rb +100 -0
- data/lib/braintree/processor_response_types.rb +3 -3
- data/lib/braintree/resource_collection.rb +8 -3
- data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
- data/lib/braintree/risk_data/liability_shift.rb +22 -0
- data/lib/braintree/risk_data.rb +5 -1
- data/lib/braintree/samsung_pay_card.rb +1 -1
- data/lib/braintree/settlement_batch_summary.rb +2 -2
- data/lib/braintree/subscription.rb +11 -11
- data/lib/braintree/successful_result.rb +3 -2
- data/lib/braintree/test/credit_card.rb +1 -0
- data/lib/braintree/test/nonce.rb +4 -23
- data/lib/braintree/three_d_secure_info.rb +22 -12
- data/lib/braintree/transaction/disbursement_details.rb +1 -0
- data/lib/braintree/transaction/{android_pay_details.rb → google_pay_details.rb} +1 -1
- data/lib/braintree/transaction/installment/adjustment.rb +33 -0
- data/lib/braintree/transaction/installment.rb +28 -0
- data/lib/braintree/transaction/paypal_details.rb +3 -0
- data/lib/braintree/transaction/subscription_details.rb +2 -0
- data/lib/braintree/transaction.rb +65 -120
- data/lib/braintree/transaction_gateway.rb +39 -27
- data/lib/braintree/transaction_line_item.rb +1 -1
- data/lib/braintree/transaction_review.rb +18 -0
- data/lib/braintree/transaction_search.rb +5 -3
- 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 +21 -6
- data/lib/braintree/venmo_account.rb +1 -1
- data/lib/braintree/venmo_profile_data.rb +23 -0
- data/lib/braintree/version.rb +2 -2
- data/lib/braintree/visa_checkout_card.rb +2 -2
- data/lib/braintree/webhook_notification.rb +44 -30
- data/lib/braintree/webhook_notification_gateway.rb +5 -5
- data/lib/braintree/webhook_testing_gateway.rb +104 -43
- data/lib/braintree/xml/generator.rb +5 -4
- data/lib/braintree/xml/parser.rb +22 -35
- data/lib/braintree/xml/rexml.rb +4 -5
- data/lib/braintree.rb +28 -23
- data/spec/integration/braintree/add_on_spec.rb +1 -1
- data/spec/integration/braintree/address_spec.rb +30 -113
- 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 -31
- data/spec/integration/braintree/credit_card_spec.rb +219 -593
- 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 +484 -513
- data/spec/integration/braintree/dispute_search_spec.rb +35 -6
- data/spec/integration/braintree/dispute_spec.rb +6 -7
- data/spec/integration/braintree/error_codes_spec.rb +1 -1
- data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
- data/spec/integration/braintree/graphql_client_spec.rb +0 -2
- data/spec/integration/braintree/http_spec.rb +2 -2
- data/spec/integration/braintree/merchant_account_spec.rb +28 -29
- data/spec/integration/braintree/merchant_spec.rb +14 -14
- data/spec/integration/braintree/oauth_spec.rb +11 -11
- data/spec/integration/braintree/payment_method_nonce_spec.rb +29 -35
- data/spec/integration/braintree/payment_method_spec.rb +535 -270
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +17 -13
- data/spec/integration/braintree/paypal_account_spec.rb +28 -28
- data/spec/integration/braintree/plan_spec.rb +82 -0
- 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 +144 -149
- 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 +175 -70
- data/spec/integration/braintree/transaction_spec.rb +955 -894
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -26
- 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 +16 -7
- data/spec/oauth_test_helper.rb +1 -1
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec_helper.rb +8 -14
- data/spec/unit/braintree/address_spec.rb +1 -9
- data/spec/unit/braintree/apple_pay_card_spec.rb +7 -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 +13 -32
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_verification_spec.rb +8 -4
- data/spec/unit/braintree/customer_spec.rb +21 -22
- data/spec/unit/braintree/disbursement_spec.rb +7 -7
- data/spec/unit/braintree/dispute_search_spec.rb +3 -0
- data/spec/unit/braintree/dispute_spec.rb +75 -21
- data/spec/unit/braintree/enriched_customer_data_spec.rb +32 -0
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +8 -8
- data/spec/unit/braintree/exchange_rate_quote_input_spec.rb +42 -0
- data/spec/unit/braintree/exchange_rate_quote_request_spec.rb +82 -0
- data/spec/unit/braintree/exchange_rate_quote_response_spec.rb +52 -0
- data/spec/unit/braintree/exchange_rate_quote_spec.rb +42 -0
- data/spec/unit/braintree/exchange_rate_spec.rb +23 -0
- data/spec/unit/braintree/http_spec.rb +10 -8
- data/spec/unit/braintree/local_payment_completed_spec.rb +14 -0
- data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
- data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
- data/spec/unit/braintree/merchant_account_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +45 -0
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +43 -0
- data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
- 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 +30 -1
- data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
- data/spec/unit/braintree/risk_data_spec.rb +38 -8
- 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 +32 -14
- 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/installment_spec.rb +25 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +7 -1
- data/spec/unit/braintree/transaction_search_spec.rb +12 -12
- data/spec/unit/braintree/transaction_spec.rb +36 -54
- data/spec/unit/braintree/util_spec.rb +55 -21
- data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
- data/spec/unit/braintree/venmo_profile_data_spec.rb +32 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +166 -57
- data/spec/unit/braintree/xml/parser_spec.rb +21 -16
- data/spec/unit/braintree/xml_spec.rb +31 -31
- metadata +62 -30
- data/lib/braintree/amex_express_checkout_card.rb +0 -40
- data/lib/braintree/coinbase_account.rb +0 -34
- data/lib/braintree/europe_bank_account.rb +0 -36
- data/lib/braintree/europe_bank_account_gateway.rb +0 -17
- data/lib/braintree/ideal_payment.rb +0 -61
- data/lib/braintree/ideal_payment_gateway.rb +0 -19
- data/lib/braintree/masterpass_card.rb +0 -83
- data/lib/braintree/settlement_batch.rb +0 -0
- data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -21
- data/lib/braintree/transaction/ideal_payment_details.rb +0 -19
- data/lib/braintree/transaction/masterpass_card_details.rb +0 -49
- data/lib/braintree/transparent_redirect.rb +0 -40
- data/lib/braintree/transparent_redirect_gateway.rb +0 -105
- data/spec/hacks/tcp_socket.rb +0 -18
- data/spec/integration/braintree/coinbase_spec.rb +0 -34
- data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
- data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
- data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
@@ -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
|
@@ -17,45 +17,38 @@ describe Braintree::Transaction do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
describe "self.create_from_transparent_redirect" do
|
21
|
-
it "raises an exception if the query string is forged" do
|
22
|
-
expect do
|
23
|
-
Braintree::Transaction.create_from_transparent_redirect("http_status=200&forged=query_string")
|
24
|
-
end.to raise_error(Braintree::ForgedQueryString)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
20
|
describe "self.find" do
|
29
21
|
it "raises error if passed empty string" do
|
30
22
|
expect do
|
31
23
|
Braintree::Transaction.find("")
|
32
|
-
end.to raise_error(ArgumentError)
|
24
|
+
end.to raise_error(ArgumentError, "id can not be empty")
|
33
25
|
end
|
34
26
|
|
35
27
|
it "raises error if passed empty string wth space" do
|
36
28
|
expect do
|
37
29
|
Braintree::Transaction.find(" ")
|
38
|
-
end.to raise_error(ArgumentError)
|
30
|
+
end.to raise_error(ArgumentError, "id can not be empty")
|
39
31
|
end
|
40
32
|
|
41
33
|
it "raises error if passed nil" do
|
42
34
|
expect do
|
43
35
|
Braintree::Transaction.find(nil)
|
44
|
-
end.to raise_error(ArgumentError)
|
36
|
+
end.to raise_error(ArgumentError, "id can not be empty")
|
45
37
|
end
|
46
38
|
end
|
47
39
|
|
48
|
-
describe "self.
|
49
|
-
it "
|
50
|
-
|
51
|
-
|
40
|
+
describe "self.submit_for_settlement" do
|
41
|
+
it "raises an ArgumentError if transaction_id is an invalid format" do
|
42
|
+
expect do
|
43
|
+
Braintree::Transaction.submit_for_settlement("invalid-transaction-id")
|
44
|
+
end.to raise_error(ArgumentError, "transaction_id is invalid")
|
52
45
|
end
|
53
46
|
end
|
54
47
|
|
55
|
-
describe "self.
|
48
|
+
describe "self.adjust_authorization" do
|
56
49
|
it "raises an ArgumentError if transaction_id is an invalid format" do
|
57
50
|
expect do
|
58
|
-
Braintree::Transaction.
|
51
|
+
Braintree::Transaction.adjust_authorization("invalid-transaction-id", "10.00")
|
59
52
|
end.to raise_error(ArgumentError, "transaction_id is invalid")
|
60
53
|
end
|
61
54
|
end
|
@@ -81,7 +74,7 @@ describe Braintree::Transaction do
|
|
81
74
|
:website => "lednerllc.com",
|
82
75
|
:phone => "1-999-652-4189 x56883",
|
83
76
|
:fax => "012-161-8055"
|
84
|
-
}
|
77
|
+
},
|
85
78
|
)
|
86
79
|
transaction.customer_details.id.should == "123"
|
87
80
|
transaction.customer_details.first_name.should == "Adam"
|
@@ -103,10 +96,10 @@ describe Braintree::Transaction do
|
|
103
96
|
:settlement_currency_exchange_rate => "1",
|
104
97
|
:funds_held => false,
|
105
98
|
:success => true
|
106
|
-
}
|
99
|
+
},
|
107
100
|
)
|
108
101
|
disbursement = transaction.disbursement_details
|
109
|
-
disbursement.disbursement_date.should == "2013-04-03"
|
102
|
+
disbursement.disbursement_date.should == Date.parse("2013-04-03")
|
110
103
|
disbursement.settlement_amount.should == "120.00"
|
111
104
|
disbursement.settlement_currency_iso_code.should == "USD"
|
112
105
|
disbursement.settlement_currency_exchange_rate.should == "1"
|
@@ -134,7 +127,7 @@ describe Braintree::Transaction do
|
|
134
127
|
:product_id => "Unknown",
|
135
128
|
:country_of_issuance => "Narnia",
|
136
129
|
:issuing_bank => "Mr Tumnus"
|
137
|
-
}
|
130
|
+
},
|
138
131
|
)
|
139
132
|
transaction.credit_card_details.token.should == "mzg2"
|
140
133
|
transaction.credit_card_details.bin.should == "411111"
|
@@ -162,7 +155,7 @@ describe Braintree::Transaction do
|
|
162
155
|
:liability_shifted => true,
|
163
156
|
:liability_shift_possible => true,
|
164
157
|
:status => "authenticate_successful",
|
165
|
-
}
|
158
|
+
},
|
166
159
|
)
|
167
160
|
|
168
161
|
transaction.three_d_secure_info.enrolled.should == "Y"
|
@@ -171,33 +164,14 @@ describe Braintree::Transaction do
|
|
171
164
|
transaction.three_d_secure_info.liability_shift_possible.should == true
|
172
165
|
end
|
173
166
|
|
174
|
-
it "sets up ideal_payment_details" do
|
175
|
-
transaction = Braintree::Transaction._new(
|
176
|
-
:gateway,
|
177
|
-
:ideal_payment => {
|
178
|
-
:ideal_payment_id => "idealpayment_abc_123",
|
179
|
-
:ideal_transaction_id => "1150000008857321",
|
180
|
-
:masked_iban => "12************7890",
|
181
|
-
:bic => "RABONL2U",
|
182
|
-
:image_url => "http://www.example.com/ideal.png"
|
183
|
-
}
|
184
|
-
)
|
185
|
-
|
186
|
-
transaction.ideal_payment_details.ideal_payment_id.should == "idealpayment_abc_123"
|
187
|
-
transaction.ideal_payment_details.ideal_transaction_id.should == "1150000008857321"
|
188
|
-
transaction.ideal_payment_details.masked_iban.should == "12************7890"
|
189
|
-
transaction.ideal_payment_details.bic.should == "RABONL2U"
|
190
|
-
transaction.ideal_payment_details.image_url.should == "http://www.example.com/ideal.png"
|
191
|
-
end
|
192
|
-
|
193
167
|
it "sets up history attributes in status_history" do
|
194
168
|
time = Time.utc(2010,1,14)
|
195
169
|
transaction = Braintree::Transaction._new(
|
196
170
|
:gateway,
|
197
171
|
:status_history => [
|
198
|
-
{
|
199
|
-
:user => "larry", :status => Braintree::Transaction::Status::Authorized
|
200
|
-
{
|
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",
|
201
175
|
:user => "curly", :status => "scheduled_for_settlement"}
|
202
176
|
])
|
203
177
|
transaction.status_history.size.should == 2
|
@@ -214,8 +188,8 @@ describe Braintree::Transaction do
|
|
214
188
|
transaction = Braintree::Transaction._new(
|
215
189
|
:gateway,
|
216
190
|
:authorization_adjustments => [
|
217
|
-
{
|
218
|
-
{
|
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},
|
219
193
|
])
|
220
194
|
transaction.authorization_adjustments.size.should == 2
|
221
195
|
transaction.authorization_adjustments[0].amount.should == "12.00"
|
@@ -233,7 +207,7 @@ describe Braintree::Transaction do
|
|
233
207
|
it "handles receiving custom as an empty string" do
|
234
208
|
transaction = Braintree::Transaction._new(
|
235
209
|
:gateway,
|
236
|
-
:custom => "\n "
|
210
|
+
:custom => "\n ",
|
237
211
|
)
|
238
212
|
end
|
239
213
|
|
@@ -251,7 +225,7 @@ describe Braintree::Transaction do
|
|
251
225
|
it "handles nil risk_data" do
|
252
226
|
transaction = Braintree::Transaction._new(
|
253
227
|
:gateway,
|
254
|
-
:risk_data => nil
|
228
|
+
:risk_data => nil,
|
255
229
|
)
|
256
230
|
transaction.risk_data.should be_nil
|
257
231
|
end
|
@@ -259,11 +233,19 @@ describe Braintree::Transaction do
|
|
259
233
|
it "accepts network_transaction_id" do
|
260
234
|
transaction = Braintree::Transaction._new(
|
261
235
|
:gateway,
|
262
|
-
:network_transaction_id => "123456789012345"
|
236
|
+
:network_transaction_id => "123456789012345",
|
263
237
|
)
|
264
238
|
transaction.network_transaction_id.should == "123456789012345"
|
265
239
|
end
|
266
240
|
|
241
|
+
it "accepts ach_return_code" do
|
242
|
+
transaction = Braintree::Transaction._new(
|
243
|
+
:gateway,
|
244
|
+
:ach_return_code => "R01",
|
245
|
+
)
|
246
|
+
expect(transaction.ach_return_code).to eq("R01")
|
247
|
+
end
|
248
|
+
|
267
249
|
it "accepts network_response code and network_response_text" do
|
268
250
|
transaction = Braintree::Transaction._new(
|
269
251
|
:gateway,
|
@@ -341,8 +323,8 @@ describe Braintree::Transaction do
|
|
341
323
|
end
|
342
324
|
|
343
325
|
describe "sale" do
|
344
|
-
let(:mock_response) { {:transaction => {}}}
|
345
|
-
let(:http_stub) { double(
|
326
|
+
let(:mock_response) { {:transaction => {}} }
|
327
|
+
let(:http_stub) { double("http_stub").as_null_object }
|
346
328
|
|
347
329
|
RSpec::Matchers.define :skip_advanced_fraud_check_value_is do |value|
|
348
330
|
match { |params| params[:transaction][:options][:skip_advanced_fraud_checking] == value }
|
@@ -360,7 +342,7 @@ describe Braintree::Transaction do
|
|
360
342
|
},
|
361
343
|
:options => {
|
362
344
|
:skip_advanced_fraud_checking => true
|
363
|
-
}
|
345
|
+
},
|
364
346
|
)
|
365
347
|
end
|
366
348
|
|
@@ -376,7 +358,7 @@ describe Braintree::Transaction do
|
|
376
358
|
},
|
377
359
|
:options => {
|
378
360
|
:skip_advanced_fraud_checking => false
|
379
|
-
}
|
361
|
+
},
|
380
362
|
)
|
381
363
|
end
|
382
364
|
|
@@ -392,7 +374,7 @@ describe Braintree::Transaction do
|
|
392
374
|
},
|
393
375
|
:options => {
|
394
376
|
:submit_for_settlement => false
|
395
|
-
}
|
377
|
+
},
|
396
378
|
)
|
397
379
|
end
|
398
380
|
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,12 +165,28 @@ 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
|
172
172
|
end
|
173
173
|
|
174
|
+
describe "self.replace_key" do
|
175
|
+
it "replaces the target key with the replacement key" do
|
176
|
+
Braintree::Util.replace_key(
|
177
|
+
{:a => {:b => "some value"}},
|
178
|
+
:b,
|
179
|
+
:c).should == {:a => {:c => "some value"}}
|
180
|
+
end
|
181
|
+
|
182
|
+
it "returns hash with all of the original keys if the target key does not exist" do
|
183
|
+
Braintree::Util.replace_key(
|
184
|
+
{:some_key => "some value"},
|
185
|
+
:not_found,
|
186
|
+
:new_key).should == {:some_key => "some value"}
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
174
190
|
describe "self._flatten_hash_keys" do
|
175
191
|
it "flattens hash keys" do
|
176
192
|
Braintree::Util._flatten_hash_keys(:nested => {
|
@@ -184,13 +200,13 @@ describe Braintree::Util do
|
|
184
200
|
describe "self._flatten_valid_keys" do
|
185
201
|
it "flattens hash keys" do
|
186
202
|
Braintree::Util._flatten_valid_keys(
|
187
|
-
[:top_level, {:nested => [:nested_allowed, :nested_allowed2]}]
|
203
|
+
[:top_level, {:nested => [:nested_allowed, :nested_allowed2]}],
|
188
204
|
).should == ["nested[nested_allowed2]", "nested[nested_allowed]", "top_level"]
|
189
205
|
end
|
190
206
|
|
191
207
|
it "allows wildcards with the :_any_key_ symbol" do
|
192
208
|
Braintree::Util._flatten_valid_keys(
|
193
|
-
[:top_level, {:nested => :_any_key_}]
|
209
|
+
[:top_level, {:nested => :_any_key_}],
|
194
210
|
).should == ["nested[_any_key_]", "top_level"]
|
195
211
|
end
|
196
212
|
end
|
@@ -220,11 +236,11 @@ describe Braintree::Util do
|
|
220
236
|
result.should == []
|
221
237
|
end
|
222
238
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
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
|
228
244
|
end
|
229
245
|
|
230
246
|
describe "self.hash_to_query_string" do
|
@@ -259,7 +275,7 @@ describe Braintree::Util do
|
|
259
275
|
"UNSUPPORTED_CLIENT" => Braintree::UpgradeRequiredError,
|
260
276
|
"RESOURCE_LIMIT" => Braintree::TooManyRequestsError,
|
261
277
|
"INTERNAL" => Braintree::ServerError,
|
262
|
-
"SERVICE_AVAILABILITY" => Braintree::
|
278
|
+
"SERVICE_AVAILABILITY" => Braintree::ServiceUnavailableError,
|
263
279
|
}
|
264
280
|
|
265
281
|
errors.each do |graphQLError, exception|
|
@@ -321,6 +337,18 @@ describe Braintree::Util do
|
|
321
337
|
end.to raise_error(Braintree::AuthorizationError)
|
322
338
|
end
|
323
339
|
|
340
|
+
it "raises a NotFoundError if resource is not found" do
|
341
|
+
expect do
|
342
|
+
Braintree::Util.raise_exception_for_status_code(404)
|
343
|
+
end.to raise_error(Braintree::NotFoundError)
|
344
|
+
end
|
345
|
+
|
346
|
+
it "raises a RequestTimeoutError if the request times out" do
|
347
|
+
expect do
|
348
|
+
Braintree::Util.raise_exception_for_status_code(408)
|
349
|
+
end.to raise_error(Braintree::RequestTimeoutError)
|
350
|
+
end
|
351
|
+
|
324
352
|
it "raises an UpgradeRequired if the client library is EOL'd" do
|
325
353
|
expect do
|
326
354
|
Braintree::Util.raise_exception_for_status_code(426)
|
@@ -339,10 +367,16 @@ describe Braintree::Util do
|
|
339
367
|
end.to raise_error(Braintree::ServerError)
|
340
368
|
end
|
341
369
|
|
342
|
-
it "raises a
|
370
|
+
it "raises a ServiceUnavailableError if the server is unavailable" do
|
343
371
|
expect do
|
344
372
|
Braintree::Util.raise_exception_for_status_code(503)
|
345
|
-
end.to raise_error(Braintree::
|
373
|
+
end.to raise_error(Braintree::ServiceUnavailableError)
|
374
|
+
end
|
375
|
+
|
376
|
+
it "raises a GatewayTimeoutError if the gateway times out" do
|
377
|
+
expect do
|
378
|
+
Braintree::Util.raise_exception_for_status_code(504)
|
379
|
+
end.to raise_error(Braintree::GatewayTimeoutError)
|
346
380
|
end
|
347
381
|
|
348
382
|
it "raises an UnexpectedError if some other code is returned" do
|
@@ -5,7 +5,7 @@ describe Braintree::ValidationErrorCollection do
|
|
5
5
|
context "blue response" do
|
6
6
|
describe "initialize" do
|
7
7
|
it "builds an error object given an array of hashes" do
|
8
|
-
hash = {:errors => [{
|
8
|
+
hash = {:errors => [{:attribute => "some model attribute", :code => 1, :message => "bad juju"}]}
|
9
9
|
collection = Braintree::ValidationErrorCollection.new(hash)
|
10
10
|
error = collection[0]
|
11
11
|
error.attribute.should == "some model attribute"
|
@@ -17,9 +17,9 @@ describe Braintree::ValidationErrorCollection do
|
|
17
17
|
describe "for" do
|
18
18
|
it "provides access to nested errors" do
|
19
19
|
hash = {
|
20
|
-
:errors => [{
|
20
|
+
:errors => [{:attribute => "some model attribute", :code => 1, :message => "bad juju"}],
|
21
21
|
:nested => {
|
22
|
-
:errors => [{
|
22
|
+
:errors => [{:attribute => "number", :code => 2, :message => "badder juju"}]
|
23
23
|
}
|
24
24
|
}
|
25
25
|
errors = Braintree::ValidationErrorCollection.new(hash)
|
@@ -45,7 +45,7 @@ describe Braintree::ValidationErrorCollection do
|
|
45
45
|
],
|
46
46
|
:level1 => {
|
47
47
|
:errors => [{:attribute => "name", :code => "code2", :message => "message2"}]
|
48
|
-
}
|
48
|
+
},
|
49
49
|
)
|
50
50
|
errors.inspect.should == "#<Braintree::ValidationErrorCollection errors:[(code1) message1], level1:[(code2) message2]>"
|
51
51
|
end
|
@@ -60,7 +60,7 @@ describe Braintree::ValidationErrorCollection do
|
|
60
60
|
:level2 => {
|
61
61
|
:errors => [{:attribute => "name", :code => "code3", :message => "message3"}],
|
62
62
|
}
|
63
|
-
}
|
63
|
+
},
|
64
64
|
)
|
65
65
|
errors.inspect.should == "#<Braintree::ValidationErrorCollection errors:[(code1) message1], level1:[(code2) message2], level1/level2:[(code3) message3]>"
|
66
66
|
end
|
@@ -74,12 +74,12 @@ describe Braintree::ValidationErrorCollection do
|
|
74
74
|
{:attribute => "not name", :code => 3, :message => "is invalid"}
|
75
75
|
])
|
76
76
|
errors.on("name").size.should == 2
|
77
|
-
errors.on("name").map{ |e| e.code }.should == [1, 2]
|
77
|
+
errors.on("name").map { |e| e.code }.should == [1, 2]
|
78
78
|
end
|
79
79
|
|
80
80
|
it "has indifferent access" do
|
81
81
|
errors = Braintree::ValidationErrorCollection.new(:errors => [
|
82
|
-
{
|
82
|
+
{:attribute => "name", :code => 3, :message => "is too long"},
|
83
83
|
])
|
84
84
|
errors.on(:name).size.should == 1
|
85
85
|
errors.on(:name)[0].code.should == 3
|
@@ -99,10 +99,10 @@ describe Braintree::ValidationErrorCollection do
|
|
99
99
|
|
100
100
|
it "returns the size of nested errors as well" do
|
101
101
|
errors = Braintree::ValidationErrorCollection.new(
|
102
|
-
:errors => [{
|
102
|
+
:errors => [{:attribute => "some model attribute", :code => 1, :message => "bad juju"}],
|
103
103
|
:nested => {
|
104
|
-
:errors => [{
|
105
|
-
}
|
104
|
+
:errors => [{:attribute => "number", :code => 2, :message => "badder juju"}]
|
105
|
+
},
|
106
106
|
)
|
107
107
|
errors.deep_size.should == 2
|
108
108
|
end
|
@@ -110,17 +110,17 @@ describe Braintree::ValidationErrorCollection do
|
|
110
110
|
it "returns the size of multiple nestings of errors" do
|
111
111
|
errors = Braintree::ValidationErrorCollection.new(
|
112
112
|
:errors => [
|
113
|
-
{
|
114
|
-
{
|
113
|
+
{:attribute => "one", :code => 1, :message => "bad juju"},
|
114
|
+
{:attribute => "two", :code => 1, :message => "bad juju"}],
|
115
115
|
:nested => {
|
116
|
-
:errors => [{
|
116
|
+
:errors => [{:attribute => "three", :code => 2, :message => "badder juju"}],
|
117
117
|
:nested_again => {
|
118
|
-
:errors => [{
|
118
|
+
:errors => [{:attribute => "four", :code => 2, :message => "badder juju"}]
|
119
119
|
}
|
120
120
|
},
|
121
121
|
:same_level => {
|
122
|
-
:errors => [{
|
123
|
-
}
|
122
|
+
:errors => [{:attribute => "five", :code => 2, :message => "badder juju"}],
|
123
|
+
},
|
124
124
|
)
|
125
125
|
errors.deep_size.should == 5
|
126
126
|
end
|
@@ -130,17 +130,17 @@ describe Braintree::ValidationErrorCollection do
|
|
130
130
|
it "returns errors from all levels" do
|
131
131
|
errors = Braintree::ValidationErrorCollection.new(
|
132
132
|
:errors => [
|
133
|
-
{
|
134
|
-
{
|
133
|
+
{:attribute => "one", :code => 1, :message => "bad juju"},
|
134
|
+
{:attribute => "two", :code => 2, :message => "bad juju"}],
|
135
135
|
:nested => {
|
136
|
-
:errors => [{
|
136
|
+
:errors => [{:attribute => "three", :code => 3, :message => "badder juju"}],
|
137
137
|
:nested_again => {
|
138
|
-
:errors => [{
|
138
|
+
:errors => [{:attribute => "four", :code => 4, :message => "badder juju"}]
|
139
139
|
}
|
140
140
|
},
|
141
141
|
:same_level => {
|
142
|
-
:errors => [{
|
143
|
-
}
|
142
|
+
:errors => [{:attribute => "five", :code => 5, :message => "badder juju"}],
|
143
|
+
},
|
144
144
|
)
|
145
145
|
errors.deep_errors.map { |e| e.code }.sort.should == [1, 2, 3, 4, 5]
|
146
146
|
end
|
@@ -150,27 +150,27 @@ describe Braintree::ValidationErrorCollection do
|
|
150
150
|
it "returns errors on one level" do
|
151
151
|
errors = Braintree::ValidationErrorCollection.new(
|
152
152
|
:errors => [
|
153
|
-
{
|
154
|
-
{
|
153
|
+
{:attribute => "one", :code => 1, :message => "bad juju"},
|
154
|
+
{:attribute => "two", :code => 2, :message => "bad juju"}],
|
155
155
|
:nested => {
|
156
|
-
:errors => [{
|
156
|
+
:errors => [{:attribute => "three", :code => 3, :message => "badder juju"}],
|
157
157
|
:nested_again => {
|
158
|
-
:errors => [{
|
158
|
+
:errors => [{:attribute => "four", :code => 4, :message => "badder juju"}]
|
159
159
|
}
|
160
|
-
}
|
160
|
+
},
|
161
161
|
)
|
162
|
-
errors.shallow_errors.map {|e| e.code}.should == [1, 2]
|
163
|
-
errors.for(:nested).shallow_errors.map {|e| e.code}.should == [3]
|
162
|
+
errors.shallow_errors.map { |e| e.code }.should == [1, 2]
|
163
|
+
errors.for(:nested).shallow_errors.map { |e| e.code }.should == [3]
|
164
164
|
end
|
165
165
|
|
166
166
|
it "returns an clone of the real array" do
|
167
167
|
errors = Braintree::ValidationErrorCollection.new(
|
168
168
|
:errors => [
|
169
|
-
{
|
170
|
-
{
|
169
|
+
{:attribute => "one", :code => 1, :message => "bad juju"},
|
170
|
+
{:attribute => "two", :code => 2, :message => "bad juju"}],
|
171
171
|
)
|
172
172
|
errors.shallow_errors.pop
|
173
|
-
errors.shallow_errors.map {|e| e.code}.should == [1, 2]
|
173
|
+
errors.shallow_errors.map { |e| e.code }.should == [1, 2]
|
174
174
|
end
|
175
175
|
end
|
176
176
|
end
|
@@ -368,10 +368,10 @@ describe Braintree::ValidationErrorCollection do
|
|
368
368
|
}
|
369
369
|
}
|
370
370
|
errors = Braintree::ValidationErrorCollection.new(hash)
|
371
|
-
errors.shallow_errors.map {|e| e.code}.should == [1]
|
372
|
-
errors.for(:nested).shallow_errors.map {|e| e.code}.should == [2,3]
|
373
|
-
errors.for(:nested).for(:deeply_nested).shallow_errors.map {|e| e.code}.should == [4]
|
374
|
-
errors.for(:nested_again).shallow_errors.map {|e| e.code}.should == [5]
|
371
|
+
errors.shallow_errors.map { |e| e.code }.should == [1]
|
372
|
+
errors.for(:nested).shallow_errors.map { |e| e.code }.should == [2,3]
|
373
|
+
errors.for(:nested).for(:deeply_nested).shallow_errors.map { |e| e.code }.should == [4]
|
374
|
+
errors.for(:nested_again).shallow_errors.map { |e| e.code }.should == [5]
|
375
375
|
end
|
376
376
|
end
|
377
377
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::VenmoProfileData do
|
4
|
+
describe "self.new" do
|
5
|
+
it "is protected" do
|
6
|
+
expect do
|
7
|
+
Braintree::VenmoProfileData.new
|
8
|
+
end.to raise_error(NoMethodError, /protected method .new/)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "self._new" do
|
13
|
+
it "initializes the object with the appropriate attributes set" do
|
14
|
+
|
15
|
+
params = {
|
16
|
+
username: "a-username",
|
17
|
+
first_name: "a-first-name",
|
18
|
+
last_name: "a-last-name",
|
19
|
+
phone_number: "12312312343",
|
20
|
+
email: "a-email",
|
21
|
+
}
|
22
|
+
|
23
|
+
payment_method_customer_data_updated = Braintree::VenmoProfileData._new(params)
|
24
|
+
|
25
|
+
payment_method_customer_data_updated.username.should eq("a-username")
|
26
|
+
payment_method_customer_data_updated.first_name.should eq("a-first-name")
|
27
|
+
payment_method_customer_data_updated.last_name.should eq("a-last-name")
|
28
|
+
payment_method_customer_data_updated.phone_number.should eq("12312312343")
|
29
|
+
payment_method_customer_data_updated.email.should eq("a-email")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|