braintree 4.14.0 → 4.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/braintree/credit_card.rb +13 -0
- data/lib/braintree/credit_card_gateway.rb +15 -3
- data/lib/braintree/payment_method_gateway.rb +15 -3
- data/lib/braintree/test/nonce.rb +1 -0
- data/lib/braintree/test/venmo_sdk.rb +2 -0
- data/lib/braintree/transaction/credit_card_details.rb +3 -0
- data/lib/braintree/transaction/local_payment_details.rb +2 -0
- data/lib/braintree/transaction.rb +5 -4
- data/lib/braintree/transaction_gateway.rb +15 -3
- data/lib/braintree/transaction_search.rb +6 -5
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/webhook_notification.rb +1 -0
- data/lib/braintree/webhook_testing_gateway.rb +17 -0
- data/spec/integration/braintree/add_on_spec.rb +9 -9
- data/spec/integration/braintree/address_spec.rb +69 -69
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +8 -8
- data/spec/integration/braintree/client_api/client_token_spec.rb +15 -15
- data/spec/integration/braintree/credit_card_spec.rb +223 -223
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
- data/spec/integration/braintree/credit_card_verification_spec.rb +52 -52
- data/spec/integration/braintree/customer_search_spec.rb +20 -20
- data/spec/integration/braintree/customer_spec.rb +313 -313
- data/spec/integration/braintree/disbursement_spec.rb +2 -2
- data/spec/integration/braintree/discount_spec.rb +9 -9
- data/spec/integration/braintree/dispute_spec.rb +87 -87
- data/spec/integration/braintree/document_upload_spec.rb +17 -17
- data/spec/integration/braintree/error_codes_spec.rb +2 -2
- data/spec/integration/braintree/http_spec.rb +28 -28
- data/spec/integration/braintree/merchant_account_spec.rb +127 -127
- data/spec/integration/braintree/merchant_spec.rb +103 -103
- data/spec/integration/braintree/oauth_spec.rb +61 -61
- data/spec/integration/braintree/payment_method_nonce_spec.rb +73 -73
- data/spec/integration/braintree/payment_method_spec.rb +389 -389
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +78 -78
- data/spec/integration/braintree/paypal_account_spec.rb +38 -38
- data/spec/integration/braintree/plan_spec.rb +15 -15
- data/spec/integration/braintree/samsung_pay_card_spec.rb +65 -65
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +51 -51
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +11 -11
- data/spec/integration/braintree/subscription_spec.rb +364 -364
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +19 -19
- data/spec/integration/braintree/transaction_line_item_spec.rb +6 -6
- data/spec/integration/braintree/transaction_search_spec.rb +198 -165
- data/spec/integration/braintree/transaction_spec.rb +1315 -1149
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -32
- data/spec/integration/braintree/us_bank_account_spec.rb +30 -30
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +18 -18
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +33 -33
- data/spec/integration/braintree/visa_checkout_card_spec.rb +57 -57
- data/spec/spec_helper.rb +9 -8
- data/spec/unit/braintree/address_spec.rb +8 -8
- data/spec/unit/braintree/base_module_spec.rb +4 -4
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +57 -57
- data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
- data/spec/unit/braintree/credit_card_spec.rb +31 -29
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +28 -28
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +9 -9
- data/spec/unit/braintree/credit_card_verification_spec.rb +17 -17
- data/spec/unit/braintree/customer_spec.rb +41 -40
- data/spec/unit/braintree/digest_spec.rb +5 -5
- data/spec/unit/braintree/disbursement_spec.rb +11 -11
- data/spec/unit/braintree/dispute_search_spec.rb +2 -2
- data/spec/unit/braintree/dispute_spec.rb +56 -56
- data/spec/unit/braintree/document_upload_spec.rb +8 -8
- data/spec/unit/braintree/enriched_customer_data_spec.rb +2 -2
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +9 -9
- data/spec/unit/braintree/http_spec.rb +8 -8
- data/spec/unit/braintree/local_payment_completed_spec.rb +11 -11
- data/spec/unit/braintree/local_payment_expired_spec.rb +2 -2
- data/spec/unit/braintree/local_payment_funded_spec.rb +6 -6
- data/spec/unit/braintree/merchant_account_spec.rb +4 -4
- data/spec/unit/braintree/modification_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +6 -6
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +7 -7
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +14 -14
- data/spec/unit/braintree/payment_method_spec.rb +19 -19
- data/spec/unit/braintree/paypal_account_spec.rb +4 -4
- data/spec/unit/braintree/resource_collection_spec.rb +7 -7
- data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +1 -1
- data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
- data/spec/unit/braintree/signature_service_spec.rb +2 -2
- data/spec/unit/braintree/subscription_search_spec.rb +17 -17
- data/spec/unit/braintree/subscription_spec.rb +8 -8
- data/spec/unit/braintree/successful_result_spec.rb +5 -5
- data/spec/unit/braintree/three_d_secure_info_spec.rb +20 -20
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -5
- data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
- data/spec/unit/braintree/transaction/local_payment_details_spec.rb +30 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +9 -6
- data/spec/unit/braintree/transaction_search_spec.rb +2 -2
- data/spec/unit/braintree/transaction_spec.rb +101 -93
- data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
- data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
- data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +7 -7
- data/spec/unit/braintree/util_spec.rb +27 -27
- data/spec/unit/braintree/validation_error_collection_spec.rb +34 -34
- data/spec/unit/braintree/validation_error_spec.rb +4 -4
- data/spec/unit/braintree/venmo_profile_data_spec.rb +5 -5
- data/spec/unit/braintree/webhook_notification_spec.rb +206 -191
- data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
- data/spec/unit/braintree/xml/parser_spec.rb +8 -8
- data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
- data/spec/unit/braintree/xml_spec.rb +17 -17
- data/spec/unit/braintree_spec.rb +2 -2
- metadata +3 -2
@@ -20,11 +20,12 @@ describe Braintree::CreditCard do
|
|
20
20
|
:expiration_year,
|
21
21
|
:number,
|
22
22
|
:token,
|
23
|
-
:venmo_sdk_payment_method_code,
|
23
|
+
:venmo_sdk_payment_method_code, # NEXT_MAJOR_VERSION Remove this attribute
|
24
24
|
:device_data,
|
25
25
|
:payment_method_nonce,
|
26
26
|
{:external_vault=>[:network_transaction_id]},
|
27
|
-
{:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session,
|
27
|
+
{:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
|
28
|
+
:fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
|
28
29
|
{:billing_address => [
|
29
30
|
:company,
|
30
31
|
:country_code_alpha2,
|
@@ -66,11 +67,12 @@ describe Braintree::CreditCard do
|
|
66
67
|
:expiration_year,
|
67
68
|
:number,
|
68
69
|
:token,
|
69
|
-
:venmo_sdk_payment_method_code,
|
70
|
+
:venmo_sdk_payment_method_code, # NEXT_MAJOR_VERSION Remove this attribute
|
70
71
|
:device_data,
|
71
72
|
:payment_method_nonce,
|
72
73
|
{:external_vault=>[:network_transaction_id]},
|
73
|
-
{:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session,
|
74
|
+
{:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
|
75
|
+
:fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
|
74
76
|
{:billing_address => [
|
75
77
|
:company,
|
76
78
|
:country_code_alpha2,
|
@@ -106,31 +108,31 @@ describe Braintree::CreditCard do
|
|
106
108
|
first = Braintree::CreditCard._new(:gateway, :token => 123)
|
107
109
|
second = Braintree::CreditCard._new(:gateway, :token => 123)
|
108
110
|
|
109
|
-
first.
|
110
|
-
second.
|
111
|
+
expect(first).to eq(second)
|
112
|
+
expect(second).to eq(first)
|
111
113
|
end
|
112
114
|
|
113
115
|
it "returns false if given a credit card with a different token" do
|
114
116
|
first = Braintree::CreditCard._new(:gateway, :token => 123)
|
115
117
|
second = Braintree::CreditCard._new(:gateway, :token => 124)
|
116
118
|
|
117
|
-
first.
|
118
|
-
second.
|
119
|
+
expect(first).not_to eq(second)
|
120
|
+
expect(second).not_to eq(first)
|
119
121
|
end
|
120
122
|
|
121
123
|
it "returns false if not given a credit card" do
|
122
124
|
credit_card = Braintree::CreditCard._new(:gateway, :token => 123)
|
123
|
-
credit_card.
|
125
|
+
expect(credit_card).not_to eq("not a credit card")
|
124
126
|
end
|
125
127
|
end
|
126
128
|
|
127
129
|
describe "default?" do
|
128
130
|
it "is true if the credit card is the default credit card for the customer" do
|
129
|
-
Braintree::CreditCard._new(:gateway, :default => true).default
|
131
|
+
expect(Braintree::CreditCard._new(:gateway, :default => true).default?).to eq(true)
|
130
132
|
end
|
131
133
|
|
132
134
|
it "is false if the credit card is not the default credit card for the customer" do
|
133
|
-
Braintree::CreditCard._new(:gateway, :default => false).default
|
135
|
+
expect(Braintree::CreditCard._new(:gateway, :default => false).default?).to eq(false)
|
134
136
|
end
|
135
137
|
end
|
136
138
|
|
@@ -154,7 +156,7 @@ describe Braintree::CreditCard do
|
|
154
156
|
end
|
155
157
|
|
156
158
|
it "does not raise an error if address_id does not respond to strip" do
|
157
|
-
Braintree::Http.
|
159
|
+
allow(Braintree::Http).to receive(:new).and_return double.as_null_object
|
158
160
|
expect do
|
159
161
|
Braintree::CreditCard.find(8675309)
|
160
162
|
end.to_not raise_error
|
@@ -164,7 +166,7 @@ describe Braintree::CreditCard do
|
|
164
166
|
describe "inspect" do
|
165
167
|
it "includes the token first" do
|
166
168
|
output = Braintree::CreditCard._new(:gateway, :token => "cc123").inspect
|
167
|
-
output.
|
169
|
+
expect(output).to include("#<Braintree::CreditCard token: \"cc123\",")
|
168
170
|
end
|
169
171
|
|
170
172
|
it "includes all customer attributes" do
|
@@ -183,18 +185,18 @@ describe Braintree::CreditCard do
|
|
183
185
|
:is_network_tokenized => false,
|
184
186
|
)
|
185
187
|
output = credit_card.inspect
|
186
|
-
output.
|
187
|
-
output.
|
188
|
-
output.
|
188
|
+
expect(output).to include(%q(bin: "411111"))
|
189
|
+
expect(output).to include(%q(card_type: "Visa"))
|
190
|
+
expect(output).to include(%q(cardholder_name: "John Miller"))
|
189
191
|
|
190
|
-
output.
|
191
|
-
output.
|
192
|
-
output.
|
193
|
-
output.
|
194
|
-
output.
|
195
|
-
output.
|
196
|
-
output.
|
197
|
-
output.
|
192
|
+
expect(output).to include(%q(customer_id: "cid1"))
|
193
|
+
expect(output).to include(%q(expiration_month: "01"))
|
194
|
+
expect(output).to include(%q(expiration_year: "2020"))
|
195
|
+
expect(output).to include(%q(last_4: "1111"))
|
196
|
+
expect(output).to include(%q(token: "tok1"))
|
197
|
+
expect(output).to include(%Q(updated_at: #{credit_card.updated_at.inspect}))
|
198
|
+
expect(output).to include(%Q(created_at: #{credit_card.created_at.inspect}))
|
199
|
+
expect(output).to include(%q(is_network_tokenized?: false))
|
198
200
|
end
|
199
201
|
end
|
200
202
|
|
@@ -205,7 +207,7 @@ describe Braintree::CreditCard do
|
|
205
207
|
:bin => "510510",
|
206
208
|
:last_4 => "5100",
|
207
209
|
)
|
208
|
-
credit_card.masked_number.
|
210
|
+
expect(credit_card.masked_number).to eq("510510******5100")
|
209
211
|
end
|
210
212
|
end
|
211
213
|
|
@@ -217,7 +219,7 @@ describe Braintree::CreditCard do
|
|
217
219
|
:last_4 => "5100",
|
218
220
|
:is_network_tokenized => true,
|
219
221
|
)
|
220
|
-
credit_card.is_network_tokenized
|
222
|
+
expect(credit_card.is_network_tokenized?).to eq(true)
|
221
223
|
end
|
222
224
|
|
223
225
|
it "returns false" do
|
@@ -227,7 +229,7 @@ describe Braintree::CreditCard do
|
|
227
229
|
:last_4 => "5100",
|
228
230
|
:is_network_tokenized => false,
|
229
231
|
)
|
230
|
-
credit_card.is_network_tokenized
|
232
|
+
expect(credit_card.is_network_tokenized?).to eq(false)
|
231
233
|
end
|
232
234
|
end
|
233
235
|
|
@@ -253,12 +255,12 @@ describe Braintree::CreditCard do
|
|
253
255
|
verification1 = {:created_at => Time.now, :id => 123}
|
254
256
|
verification2 = {:created_at => Time.now - 3600, :id => 456}
|
255
257
|
credit_card = Braintree::CreditCard._new(Braintree::Configuration.gateway, {:verifications => [verification1, verification2]})
|
256
|
-
credit_card.verification.id.
|
258
|
+
expect(credit_card.verification.id).to eq(123)
|
257
259
|
end
|
258
260
|
|
259
261
|
it "picks nil if verifications are empty" do
|
260
262
|
credit_card = Braintree::CreditCard._new(Braintree::Configuration.gateway, {})
|
261
|
-
credit_card.verification.
|
263
|
+
expect(credit_card.verification).to be_nil
|
262
264
|
end
|
263
265
|
end
|
264
266
|
end
|
@@ -14,38 +14,38 @@ describe Braintree::CreditCardVerificationGateway do
|
|
14
14
|
it "creates a credit card verification gateway" do
|
15
15
|
result = Braintree::CreditCardVerificationGateway.new(gateway)
|
16
16
|
|
17
|
-
result.inspect.
|
18
|
-
result.inspect.
|
19
|
-
result.inspect.
|
17
|
+
expect(result.inspect).to include("merchant_id")
|
18
|
+
expect(result.inspect).to include("public_key")
|
19
|
+
expect(result.inspect).to include("private_key")
|
20
20
|
end
|
21
21
|
|
22
22
|
it "creates a credit card verification gateway signature" do
|
23
23
|
result = Braintree::CreditCardVerificationGateway._create_signature
|
24
|
-
result.inspect.
|
25
|
-
result.inspect.
|
26
|
-
result.inspect.
|
27
|
-
result.inspect.
|
28
|
-
result.inspect.
|
29
|
-
result.inspect.
|
30
|
-
result.inspect.
|
31
|
-
result.inspect.
|
32
|
-
result.inspect.
|
33
|
-
result.inspect.
|
34
|
-
result.inspect.
|
35
|
-
result.inspect.
|
36
|
-
result.inspect.
|
37
|
-
result.inspect.
|
38
|
-
result.inspect.
|
39
|
-
result.inspect.
|
40
|
-
result.inspect.
|
41
|
-
result.inspect.
|
42
|
-
result.inspect.
|
43
|
-
result.inspect.
|
44
|
-
result.inspect.
|
45
|
-
result.inspect.
|
46
|
-
result.inspect.
|
47
|
-
result.inspect.
|
48
|
-
result.inspect.
|
24
|
+
expect(result.inspect).to include("credit_card")
|
25
|
+
expect(result.inspect).to include("credit_card")
|
26
|
+
expect(result.inspect).to include("cardholder_name")
|
27
|
+
expect(result.inspect).to include("cvv")
|
28
|
+
expect(result.inspect).to include("expiration_date")
|
29
|
+
expect(result.inspect).to include("expiration_month")
|
30
|
+
expect(result.inspect).to include("expiration_year")
|
31
|
+
expect(result.inspect).to include("number")
|
32
|
+
expect(result.inspect).to include("billing_address")
|
33
|
+
expect(result.inspect).to include("intended_transaction_source")
|
34
|
+
expect(result.inspect).to include("options")
|
35
|
+
expect(result.inspect).to include("amount")
|
36
|
+
expect(result.inspect).to include("merchant_account_id")
|
37
|
+
expect(result.inspect).to include("account_type")
|
38
|
+
expect(result.inspect).to include("payment_method_nonce")
|
39
|
+
expect(result.inspect).to include("three_d_secure_authentication_id")
|
40
|
+
expect(result.inspect).to include("three_d_secure_pass_thru")
|
41
|
+
expect(result.inspect).to include("eci_flag")
|
42
|
+
expect(result.inspect).to include("cavv")
|
43
|
+
expect(result.inspect).to include("xid")
|
44
|
+
expect(result.inspect).to include("three_d_secure_version")
|
45
|
+
expect(result.inspect).to include("authentication_response")
|
46
|
+
expect(result.inspect).to include("directory_response")
|
47
|
+
expect(result.inspect).to include("cavv_algorithm")
|
48
|
+
expect(result.inspect).to include("ds_transaction_id")
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -7,11 +7,11 @@ module Braintree
|
|
7
7
|
it "allows All card types" do
|
8
8
|
search = CreditCardVerificationSearch.new
|
9
9
|
|
10
|
-
|
10
|
+
expect do
|
11
11
|
search.credit_card_card_type.in(
|
12
12
|
*Braintree::CreditCard::CardType::All,
|
13
13
|
)
|
14
|
-
end.
|
14
|
+
end.not_to raise_error
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -20,7 +20,7 @@ module Braintree
|
|
20
20
|
search = CreditCardVerificationSearch.new
|
21
21
|
search.id.is "v_id"
|
22
22
|
|
23
|
-
search.to_hash.
|
23
|
+
expect(search.to_hash).to eq({:id => {:is => "v_id"}})
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -29,7 +29,7 @@ module Braintree
|
|
29
29
|
search = CreditCardVerificationSearch.new
|
30
30
|
search.ids.in("id1","id2")
|
31
31
|
|
32
|
-
search.to_hash.
|
32
|
+
expect(search.to_hash).to eq({:ids => ["id1", "id2"]})
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -38,7 +38,7 @@ module Braintree
|
|
38
38
|
search = CreditCardVerificationSearch.new
|
39
39
|
search.credit_card_cardholder_name.is "v_cardholder_name"
|
40
40
|
|
41
|
-
search.to_hash.
|
41
|
+
expect(search.to_hash).to eq({:credit_card_cardholder_name => {:is => "v_cardholder_name"}})
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -47,7 +47,7 @@ module Braintree
|
|
47
47
|
search = CreditCardVerificationSearch.new
|
48
48
|
search.credit_card_expiration_date.is_not "v_credit_card_expiration_date"
|
49
49
|
|
50
|
-
search.to_hash.
|
50
|
+
expect(search.to_hash).to eq({:credit_card_expiration_date => {:is_not => "v_credit_card_expiration_date"}})
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -57,7 +57,7 @@ module Braintree
|
|
57
57
|
|
58
58
|
search.credit_card_number.starts_with "v_credit_card_bin"
|
59
59
|
|
60
|
-
search.to_hash.
|
60
|
+
expect(search.to_hash).to eq({:credit_card_number => {:starts_with => "v_credit_card_bin"}})
|
61
61
|
end
|
62
62
|
|
63
63
|
it "ends with" do
|
@@ -65,14 +65,14 @@ module Braintree
|
|
65
65
|
|
66
66
|
search.credit_card_number.ends_with "v_credit_card_last_4"
|
67
67
|
|
68
|
-
search.to_hash.
|
68
|
+
expect(search.to_hash).to eq({:credit_card_number => {:ends_with => "v_credit_card_last_4"}})
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
context "created_at" do
|
73
73
|
it "is a range node" do
|
74
74
|
search = CreditCardVerificationSearch.new
|
75
|
-
search.created_at.
|
75
|
+
expect(search.created_at).to be_kind_of(Braintree::AdvancedSearch::RangeNode)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -18,7 +18,7 @@ describe Braintree::CreditCardVerification do
|
|
18
18
|
:network_response_text => "Do not Honor",
|
19
19
|
)
|
20
20
|
|
21
|
-
verification.inspect.
|
21
|
+
expect(verification.inspect).to eq(%(#<Braintree::CreditCardVerification status: "verified", processor_response_code: "2000", processor_response_text: "Do Not Honor", amount: "12.45", currency_iso_code: "USD", cvv_response_code: "I", avs_error_response_code: "I", avs_postal_code_response_code: "I", avs_street_address_response_code: "I", network_response_code: "05", network_response_text: "Do not Honor", merchant_account_id: "some_id", gateway_rejection_reason: nil, id: nil, credit_card: nil, billing: nil, created_at: nil>))
|
22
22
|
end
|
23
23
|
|
24
24
|
it "has a status" do
|
@@ -33,13 +33,13 @@ describe Braintree::CreditCardVerification do
|
|
33
33
|
:merchant_account_id => "some_id",
|
34
34
|
)
|
35
35
|
|
36
|
-
verification.status.
|
36
|
+
expect(verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
it "accepts amount as either a String or BigDecimal" do
|
41
|
-
Braintree::CreditCardVerification._new(:amount => "12.34").amount.
|
42
|
-
Braintree::CreditCardVerification._new(:amount => BigDecimal("12.34")).amount.
|
41
|
+
expect(Braintree::CreditCardVerification._new(:amount => "12.34").amount).to eq(BigDecimal("12.34"))
|
42
|
+
expect(Braintree::CreditCardVerification._new(:amount => BigDecimal("12.34")).amount).to eq(BigDecimal("12.34"))
|
43
43
|
end
|
44
44
|
|
45
45
|
it "accepts network_transaction_id" do
|
@@ -88,27 +88,27 @@ describe Braintree::CreditCardVerification do
|
|
88
88
|
first = Braintree::CreditCardVerification._new(:id => 123)
|
89
89
|
second = Braintree::CreditCardVerification._new(:id => 123)
|
90
90
|
|
91
|
-
first.
|
92
|
-
second.
|
91
|
+
expect(first).to eq(second)
|
92
|
+
expect(second).to eq(first)
|
93
93
|
end
|
94
94
|
|
95
95
|
it "returns false for verifications with different ids" do
|
96
96
|
first = Braintree::CreditCardVerification._new(:id => 123)
|
97
97
|
second = Braintree::CreditCardVerification._new(:id => 124)
|
98
98
|
|
99
|
-
first.
|
100
|
-
second.
|
99
|
+
expect(first).not_to eq(second)
|
100
|
+
expect(second).not_to eq(first)
|
101
101
|
end
|
102
102
|
|
103
103
|
it "returns false when comparing to nil" do
|
104
|
-
Braintree::CreditCardVerification._new({}).
|
104
|
+
expect(Braintree::CreditCardVerification._new({})).not_to eq(nil)
|
105
105
|
end
|
106
106
|
|
107
107
|
it "returns false when comparing to non-verifications" do
|
108
108
|
same_id_different_object = Object.new
|
109
109
|
def same_id_different_object.id; 123; end
|
110
110
|
verification = Braintree::CreditCardVerification._new(:id => 123)
|
111
|
-
verification.
|
111
|
+
expect(verification).not_to eq(same_id_different_object)
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
@@ -123,17 +123,17 @@ describe Braintree::CreditCardVerification do
|
|
123
123
|
:transaction_risk_score => "12",
|
124
124
|
})
|
125
125
|
|
126
|
-
verification.risk_data.id.
|
127
|
-
verification.risk_data.decision.
|
128
|
-
verification.risk_data.decision_reasons.
|
129
|
-
verification.risk_data.device_data_captured.
|
130
|
-
verification.risk_data.fraud_service_provider.
|
131
|
-
verification.risk_data.transaction_risk_score.
|
126
|
+
expect(verification.risk_data.id).to eq("123")
|
127
|
+
expect(verification.risk_data.decision).to eq("WOO YOU WON $1000 dollars")
|
128
|
+
expect(verification.risk_data.decision_reasons).to eq(["reason"])
|
129
|
+
expect(verification.risk_data.device_data_captured).to eq(true)
|
130
|
+
expect(verification.risk_data.fraud_service_provider).to eq("paypal_fraud_protection")
|
131
|
+
expect(verification.risk_data.transaction_risk_score).to eq("12")
|
132
132
|
end
|
133
133
|
|
134
134
|
it "handles a nil risk_data" do
|
135
135
|
verification = Braintree::CreditCardVerification._new(:risk_data => nil)
|
136
|
-
verification.risk_data.
|
136
|
+
expect(verification.risk_data).to be_nil
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
@@ -4,7 +4,7 @@ describe Braintree::Customer do
|
|
4
4
|
describe "inspect" do
|
5
5
|
it "includes the id first" do
|
6
6
|
output = Braintree::Customer._new(:gateway, {:first_name => "Dan", :id => "1234"}).inspect
|
7
|
-
output.
|
7
|
+
expect(output).to include("#<Braintree::Customer id: \"1234\",")
|
8
8
|
end
|
9
9
|
|
10
10
|
it "includes all customer attributes" do
|
@@ -21,19 +21,19 @@ describe Braintree::Customer do
|
|
21
21
|
:updated_at => Time.now,
|
22
22
|
)
|
23
23
|
output = customer.inspect
|
24
|
-
output.
|
25
|
-
output.
|
26
|
-
output.
|
27
|
-
output.
|
28
|
-
output.
|
29
|
-
output.
|
30
|
-
output.
|
31
|
-
output.
|
32
|
-
output.
|
33
|
-
output.
|
34
|
-
output.
|
35
|
-
output.
|
36
|
-
output.
|
24
|
+
expect(output).to include(%q(company: "Company"))
|
25
|
+
expect(output).to include(%q(email: "e@mail.com"))
|
26
|
+
expect(output).to include(%q(fax: "483-438-5821"))
|
27
|
+
expect(output).to include(%q(first_name: "Patrick"))
|
28
|
+
expect(output).to include(%q(last_name: "Smith"))
|
29
|
+
expect(output).to include(%q(phone: "802-483-5932"))
|
30
|
+
expect(output).to include(%q(website: "patrick.smith.com"))
|
31
|
+
expect(output).to include(%q(addresses: []))
|
32
|
+
expect(output).to include(%q(credit_cards: []))
|
33
|
+
expect(output).to include(%q(paypal_accounts: []))
|
34
|
+
expect(output).to include(%q(tax_identifiers: []))
|
35
|
+
expect(output).to include(%Q(created_at: #{customer.created_at.inspect}))
|
36
|
+
expect(output).to include(%Q(updated_at: #{customer.updated_at.inspect}))
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -59,7 +59,7 @@ describe Braintree::Customer do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it "does not raise an exception if the id is a fixnum" do
|
62
|
-
Braintree::Http.
|
62
|
+
allow(Braintree::Http).to receive(:new).and_return double.as_null_object
|
63
63
|
expect do
|
64
64
|
Braintree::Customer.find(8675309)
|
65
65
|
end.to_not raise_error
|
@@ -97,11 +97,12 @@ describe Braintree::Customer do
|
|
97
97
|
:expiration_year,
|
98
98
|
:number,
|
99
99
|
:token,
|
100
|
-
:venmo_sdk_payment_method_code,
|
100
|
+
:venmo_sdk_payment_method_code, # NEXT_MAJOR_VERSION Remove this attribute
|
101
101
|
:device_data,
|
102
102
|
:payment_method_nonce,
|
103
103
|
{:external_vault=>[:network_transaction_id]},
|
104
|
-
{:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session,
|
104
|
+
{:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
|
105
|
+
:fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
|
105
106
|
{:billing_address => [
|
106
107
|
:company,
|
107
108
|
:country_code_alpha2,
|
@@ -190,7 +191,7 @@ describe Braintree::Customer do
|
|
190
191
|
:expiration_year,
|
191
192
|
:number,
|
192
193
|
:token,
|
193
|
-
:venmo_sdk_payment_method_code,
|
194
|
+
:venmo_sdk_payment_method_code, # NEXT_MAJOR_VERSION Remove this attribute
|
194
195
|
:device_data,
|
195
196
|
:payment_method_nonce,
|
196
197
|
{:external_vault=>[:network_transaction_id]},
|
@@ -200,7 +201,7 @@ describe Braintree::Customer do
|
|
200
201
|
:verification_merchant_account_id,
|
201
202
|
:verify_card,
|
202
203
|
:verification_amount,
|
203
|
-
:venmo_sdk_session,
|
204
|
+
:venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
|
204
205
|
:fail_on_duplicate_payment_method,
|
205
206
|
:verification_account_type,
|
206
207
|
:verification_currency_iso_code,
|
@@ -271,21 +272,21 @@ describe Braintree::Customer do
|
|
271
272
|
first = Braintree::Customer._new(:gateway, :id => 123)
|
272
273
|
second = Braintree::Customer._new(:gateway, :id => 123)
|
273
274
|
|
274
|
-
first.
|
275
|
-
second.
|
275
|
+
expect(first).to eq(second)
|
276
|
+
expect(second).to eq(first)
|
276
277
|
end
|
277
278
|
|
278
279
|
it "returns false when given a customer with a different id" do
|
279
280
|
first = Braintree::Customer._new(:gateway, :id => 123)
|
280
281
|
second = Braintree::Customer._new(:gateway, :id => 124)
|
281
282
|
|
282
|
-
first.
|
283
|
-
second.
|
283
|
+
expect(first).not_to eq(second)
|
284
|
+
expect(second).not_to eq(first)
|
284
285
|
end
|
285
286
|
|
286
287
|
it "returns false when not given a customer" do
|
287
288
|
customer = Braintree::Customer._new(:gateway, :id => 123)
|
288
|
-
customer.
|
289
|
+
expect(customer).not_to eq("not a customer")
|
289
290
|
end
|
290
291
|
end
|
291
292
|
|
@@ -307,25 +308,25 @@ describe Braintree::Customer do
|
|
307
308
|
],
|
308
309
|
)
|
309
310
|
|
310
|
-
customer.credit_cards.size.
|
311
|
-
customer.credit_cards[0].token.
|
312
|
-
customer.credit_cards[1].token.
|
311
|
+
expect(customer.credit_cards.size).to eq(2)
|
312
|
+
expect(customer.credit_cards[0].token).to eq("credit_card_1")
|
313
|
+
expect(customer.credit_cards[1].token).to eq("credit_card_2")
|
313
314
|
|
314
|
-
customer.paypal_accounts.size.
|
315
|
-
customer.paypal_accounts[0].token.
|
316
|
-
customer.paypal_accounts[1].token.
|
315
|
+
expect(customer.paypal_accounts.size).to eq(2)
|
316
|
+
expect(customer.paypal_accounts[0].token).to eq("paypal_1")
|
317
|
+
expect(customer.paypal_accounts[1].token).to eq("paypal_2")
|
317
318
|
|
318
|
-
customer.sepa_direct_debit_accounts.size.
|
319
|
-
customer.sepa_direct_debit_accounts[0].token.
|
320
|
-
customer.sepa_direct_debit_accounts[1].token.
|
319
|
+
expect(customer.sepa_direct_debit_accounts.size).to eq(2)
|
320
|
+
expect(customer.sepa_direct_debit_accounts[0].token).to eq("sepa_debit_1")
|
321
|
+
expect(customer.sepa_direct_debit_accounts[1].token).to eq("sepa_debit_2")
|
321
322
|
|
322
|
-
customer.payment_methods.count.
|
323
|
-
customer.payment_methods.map(&:token).
|
324
|
-
customer.payment_methods.map(&:token).
|
325
|
-
customer.payment_methods.map(&:token).
|
326
|
-
customer.payment_methods.map(&:token).
|
327
|
-
customer.payment_methods.map(&:token).
|
328
|
-
customer.payment_methods.map(&:token).
|
323
|
+
expect(customer.payment_methods.count).to eq(6)
|
324
|
+
expect(customer.payment_methods.map(&:token)).to include("credit_card_1")
|
325
|
+
expect(customer.payment_methods.map(&:token)).to include("credit_card_2")
|
326
|
+
expect(customer.payment_methods.map(&:token)).to include("paypal_1")
|
327
|
+
expect(customer.payment_methods.map(&:token)).to include("paypal_2")
|
328
|
+
expect(customer.payment_methods.map(&:token)).to include("sepa_debit_1")
|
329
|
+
expect(customer.payment_methods.map(&:token)).to include("sepa_debit_2")
|
329
330
|
end
|
330
331
|
end
|
331
332
|
|
@@ -6,13 +6,13 @@ describe Braintree::Digest do
|
|
6
6
|
original_key = Braintree::Configuration.private_key
|
7
7
|
private_key = "\xaa" * 80
|
8
8
|
data = "Test Using Larger Than Block-Size Key - Hash Key First"
|
9
|
-
Braintree::Digest.hexdigest(private_key, data).
|
9
|
+
expect(Braintree::Digest.hexdigest(private_key, data)).to eq("aa4ae5e15272d00e95705637ce8a3b55ed402112")
|
10
10
|
end
|
11
11
|
|
12
12
|
it "returns the sha1 hmac of the input string (test case 7 from RFC 2202)" do
|
13
13
|
private_key = "\xaa" * 80
|
14
14
|
data = "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data"
|
15
|
-
Braintree::Digest.hexdigest(private_key, data).
|
15
|
+
expect(Braintree::Digest.hexdigest(private_key, data)).to eq("e8e99d0f45237d786d6bbaa7965c7808bbff1a91")
|
16
16
|
end
|
17
17
|
|
18
18
|
it "doesn't blow up if message is nil" do
|
@@ -22,15 +22,15 @@ describe Braintree::Digest do
|
|
22
22
|
|
23
23
|
describe "self.secure_compare" do
|
24
24
|
it "returns true if two strings are equal" do
|
25
|
-
Braintree::Digest.secure_compare("A_string", "A_string").
|
25
|
+
expect(Braintree::Digest.secure_compare("A_string", "A_string")).to be(true)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "returns false if two strings are different and the same length" do
|
29
|
-
Braintree::Digest.secure_compare("A_string", "A_strong").
|
29
|
+
expect(Braintree::Digest.secure_compare("A_string", "A_strong")).to be(false)
|
30
30
|
end
|
31
31
|
|
32
32
|
it "returns false if one is a prefix of the other" do
|
33
|
-
Braintree::Digest.secure_compare("A_string", "A_string_that_is_longer").
|
33
|
+
expect(Braintree::Digest.secure_compare("A_string", "A_string_that_is_longer")).to be(false)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -31,15 +31,15 @@ describe Braintree::Disbursement do
|
|
31
31
|
:success => false,
|
32
32
|
)
|
33
33
|
|
34
|
-
disbursement.inspect.
|
35
|
-
disbursement.inspect.
|
36
|
-
disbursement.inspect.
|
37
|
-
disbursement.inspect.
|
38
|
-
disbursement.inspect.
|
39
|
-
disbursement.inspect.
|
40
|
-
disbursement.inspect.
|
41
|
-
disbursement.inspect.
|
42
|
-
disbursement.inspect.
|
34
|
+
expect(disbursement.inspect).to include('id: "123456"')
|
35
|
+
expect(disbursement.inspect).to include('amount: "100.0"')
|
36
|
+
expect(disbursement.inspect).to include('exception_message: "invalid_account_number"')
|
37
|
+
expect(disbursement.inspect).to include("disbursement_date: 2013-04-10")
|
38
|
+
expect(disbursement.inspect).to include('follow_up_action: "update"')
|
39
|
+
expect(disbursement.inspect).to include("merchant_account: #<Braintree::MerchantAccount: ")
|
40
|
+
expect(disbursement.inspect).to include('transaction_ids: ["sub_merchant_transaction"]')
|
41
|
+
expect(disbursement.inspect).to include("retry: false")
|
42
|
+
expect(disbursement.inspect).to include("success: false")
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -58,7 +58,7 @@ describe Braintree::Disbursement do
|
|
58
58
|
:success => false,
|
59
59
|
:disbursement_date => "2013-04-10",
|
60
60
|
)
|
61
|
-
disbursement.success
|
61
|
+
expect(disbursement.success?).to eq(false)
|
62
62
|
|
63
63
|
disbursement = Braintree::Disbursement._new(
|
64
64
|
:gateway,
|
@@ -73,7 +73,7 @@ describe Braintree::Disbursement do
|
|
73
73
|
:success => true,
|
74
74
|
:disbursement_date => "2013-04-10",
|
75
75
|
)
|
76
|
-
disbursement.success
|
76
|
+
expect(disbursement.success?).to eq(true)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -5,14 +5,14 @@ describe Braintree::DisputeSearch do
|
|
5
5
|
search = Braintree::DisputeSearch.new
|
6
6
|
search.id.is "dispute1"
|
7
7
|
search.id.is "dispute2"
|
8
|
-
search.to_hash.
|
8
|
+
expect(search.to_hash).to eq({:id => {:is => "dispute2"}})
|
9
9
|
end
|
10
10
|
|
11
11
|
it "overrides previous 'in' with new 'in' for the same field" do
|
12
12
|
search = Braintree::DisputeSearch.new
|
13
13
|
search.status.in Braintree::Dispute::Status::Open
|
14
14
|
search.status.in Braintree::Dispute::Status::Won
|
15
|
-
search.to_hash.
|
15
|
+
expect(search.to_hash).to eq({:status => [Braintree::Dispute::Status::Won]})
|
16
16
|
end
|
17
17
|
|
18
18
|
[
|