braintree 4.13.0 → 4.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/braintree/credit_card.rb +13 -0
- data/lib/braintree/credit_card_gateway.rb +15 -3
- data/lib/braintree/payment_method_gateway.rb +15 -3
- data/lib/braintree/test/nonce.rb +1 -0
- data/lib/braintree/test/venmo_sdk.rb +2 -0
- data/lib/braintree/transaction/credit_card_details.rb +3 -0
- data/lib/braintree/transaction/local_payment_details.rb +2 -0
- data/lib/braintree/transaction/payment_receipt/card_present_data.rb +36 -0
- data/lib/braintree/transaction/payment_receipt/merchant_address.rb +19 -0
- data/lib/braintree/transaction/payment_receipt.rb +31 -0
- data/lib/braintree/transaction/us_bank_account_details.rb +1 -0
- data/lib/braintree/transaction.rb +7 -4
- data/lib/braintree/transaction_gateway.rb +15 -3
- data/lib/braintree/transaction_search.rb +6 -5
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/webhook_notification.rb +1 -0
- data/lib/braintree/webhook_testing_gateway.rb +17 -0
- data/lib/braintree.rb +3 -0
- data/spec/integration/braintree/add_on_spec.rb +9 -9
- data/spec/integration/braintree/address_spec.rb +69 -69
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +8 -8
- data/spec/integration/braintree/client_api/client_token_spec.rb +15 -15
- data/spec/integration/braintree/credit_card_spec.rb +223 -223
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
- data/spec/integration/braintree/credit_card_verification_spec.rb +52 -52
- data/spec/integration/braintree/customer_search_spec.rb +20 -20
- data/spec/integration/braintree/customer_spec.rb +313 -313
- data/spec/integration/braintree/disbursement_spec.rb +2 -2
- data/spec/integration/braintree/discount_spec.rb +9 -9
- data/spec/integration/braintree/dispute_spec.rb +87 -87
- data/spec/integration/braintree/document_upload_spec.rb +17 -17
- data/spec/integration/braintree/error_codes_spec.rb +2 -2
- data/spec/integration/braintree/http_spec.rb +28 -28
- data/spec/integration/braintree/merchant_account_spec.rb +127 -127
- data/spec/integration/braintree/merchant_spec.rb +103 -103
- data/spec/integration/braintree/oauth_spec.rb +61 -61
- data/spec/integration/braintree/payment_method_nonce_spec.rb +73 -73
- data/spec/integration/braintree/payment_method_spec.rb +389 -389
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +78 -78
- data/spec/integration/braintree/paypal_account_spec.rb +38 -38
- data/spec/integration/braintree/plan_spec.rb +15 -15
- data/spec/integration/braintree/samsung_pay_card_spec.rb +65 -65
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +51 -51
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +11 -11
- data/spec/integration/braintree/subscription_spec.rb +364 -364
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +19 -19
- data/spec/integration/braintree/transaction_line_item_spec.rb +6 -6
- data/spec/integration/braintree/transaction_search_spec.rb +198 -165
- data/spec/integration/braintree/transaction_spec.rb +1319 -1151
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -32
- data/spec/integration/braintree/us_bank_account_spec.rb +30 -30
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +18 -18
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +33 -33
- data/spec/integration/braintree/visa_checkout_card_spec.rb +57 -57
- data/spec/spec_helper.rb +9 -8
- data/spec/unit/braintree/address_spec.rb +8 -8
- data/spec/unit/braintree/base_module_spec.rb +4 -4
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +57 -57
- data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
- data/spec/unit/braintree/credit_card_spec.rb +31 -29
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +28 -28
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +9 -9
- data/spec/unit/braintree/credit_card_verification_spec.rb +17 -17
- data/spec/unit/braintree/customer_spec.rb +41 -40
- data/spec/unit/braintree/digest_spec.rb +5 -5
- data/spec/unit/braintree/disbursement_spec.rb +11 -11
- data/spec/unit/braintree/dispute_search_spec.rb +2 -2
- data/spec/unit/braintree/dispute_spec.rb +56 -56
- data/spec/unit/braintree/document_upload_spec.rb +8 -8
- data/spec/unit/braintree/enriched_customer_data_spec.rb +2 -2
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +9 -9
- data/spec/unit/braintree/http_spec.rb +8 -8
- data/spec/unit/braintree/local_payment_completed_spec.rb +11 -11
- data/spec/unit/braintree/local_payment_expired_spec.rb +2 -2
- data/spec/unit/braintree/local_payment_funded_spec.rb +6 -6
- data/spec/unit/braintree/merchant_account_spec.rb +4 -4
- data/spec/unit/braintree/modification_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +6 -6
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +7 -7
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +14 -14
- data/spec/unit/braintree/payment_method_spec.rb +19 -19
- data/spec/unit/braintree/paypal_account_spec.rb +4 -4
- data/spec/unit/braintree/resource_collection_spec.rb +7 -7
- data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +1 -1
- data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
- data/spec/unit/braintree/signature_service_spec.rb +2 -2
- data/spec/unit/braintree/subscription_search_spec.rb +17 -17
- data/spec/unit/braintree/subscription_spec.rb +8 -8
- data/spec/unit/braintree/successful_result_spec.rb +5 -5
- data/spec/unit/braintree/three_d_secure_info_spec.rb +20 -20
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -5
- data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
- data/spec/unit/braintree/transaction/local_payment_details_spec.rb +30 -0
- data/spec/unit/braintree/transaction/payment_receipt_spec.rb +73 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +9 -6
- data/spec/unit/braintree/transaction_search_spec.rb +2 -2
- data/spec/unit/braintree/transaction_spec.rb +101 -93
- data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
- data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
- data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +7 -7
- data/spec/unit/braintree/util_spec.rb +27 -27
- data/spec/unit/braintree/validation_error_collection_spec.rb +34 -34
- data/spec/unit/braintree/validation_error_spec.rb +4 -4
- data/spec/unit/braintree/venmo_profile_data_spec.rb +5 -5
- data/spec/unit/braintree/webhook_notification_spec.rb +206 -191
- data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
- data/spec/unit/braintree/xml/parser_spec.rb +8 -8
- data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
- data/spec/unit/braintree/xml_spec.rb +17 -17
- data/spec/unit/braintree_spec.rb +2 -2
- metadata +7 -2
@@ -18,21 +18,21 @@ describe Braintree::Address do
|
|
18
18
|
:postal_code => "60622",
|
19
19
|
:country_name => "United States of America",
|
20
20
|
)
|
21
|
-
result.success
|
22
|
-
result.address.customer_id.
|
23
|
-
result.address.first_name.
|
24
|
-
result.address.last_name.
|
25
|
-
result.address.company.
|
26
|
-
result.address.street_address.
|
27
|
-
result.address.extended_address.
|
28
|
-
result.address.locality.
|
29
|
-
result.address.region.
|
30
|
-
result.address.phone_number.
|
31
|
-
result.address.postal_code.
|
32
|
-
result.address.country_name.
|
33
|
-
result.address.country_code_alpha2.
|
34
|
-
result.address.country_code_alpha3.
|
35
|
-
result.address.country_code_numeric.
|
21
|
+
expect(result.success?).to eq(true)
|
22
|
+
expect(result.address.customer_id).to eq(customer.id)
|
23
|
+
expect(result.address.first_name).to eq("Ben")
|
24
|
+
expect(result.address.last_name).to eq("Moore")
|
25
|
+
expect(result.address.company).to eq("Moore Co.")
|
26
|
+
expect(result.address.street_address).to eq("1811 E Main St")
|
27
|
+
expect(result.address.extended_address).to eq("Suite 200")
|
28
|
+
expect(result.address.locality).to eq("Chicago")
|
29
|
+
expect(result.address.region).to eq("Illinois")
|
30
|
+
expect(result.address.phone_number).to eq("5551231234")
|
31
|
+
expect(result.address.postal_code).to eq("60622")
|
32
|
+
expect(result.address.country_name).to eq("United States of America")
|
33
|
+
expect(result.address.country_code_alpha2).to eq("US")
|
34
|
+
expect(result.address.country_code_alpha3).to eq("USA")
|
35
|
+
expect(result.address.country_code_numeric).to eq("840")
|
36
36
|
end
|
37
37
|
|
38
38
|
it "accepts country_codes" do
|
@@ -43,11 +43,11 @@ describe Braintree::Address do
|
|
43
43
|
:country_code_alpha3 => "ASM",
|
44
44
|
:country_code_numeric => "16",
|
45
45
|
)
|
46
|
-
result.success
|
47
|
-
result.address.country_name.
|
48
|
-
result.address.country_code_alpha2.
|
49
|
-
result.address.country_code_alpha3.
|
50
|
-
result.address.country_code_numeric.
|
46
|
+
expect(result.success?).to eq(true)
|
47
|
+
expect(result.address.country_name).to eq("American Samoa")
|
48
|
+
expect(result.address.country_code_alpha2).to eq("AS")
|
49
|
+
expect(result.address.country_code_alpha3).to eq("ASM")
|
50
|
+
expect(result.address.country_code_numeric).to eq("016")
|
51
51
|
end
|
52
52
|
|
53
53
|
it "accepts utf-8 country names" do
|
@@ -56,8 +56,8 @@ describe Braintree::Address do
|
|
56
56
|
:customer_id => customer.id,
|
57
57
|
:country_name => "Åland",
|
58
58
|
)
|
59
|
-
result.success
|
60
|
-
result.address.country_name.
|
59
|
+
expect(result.success?).to eq(true)
|
60
|
+
expect(result.address.country_name).to eq("Åland")
|
61
61
|
end
|
62
62
|
|
63
63
|
it "returns an error response given inconsistent country codes" do
|
@@ -67,8 +67,8 @@ describe Braintree::Address do
|
|
67
67
|
:country_code_alpha2 => "AS",
|
68
68
|
:country_code_alpha3 => "USA",
|
69
69
|
)
|
70
|
-
result.success
|
71
|
-
result.errors.for(:address).on(:base).map { |e| e.code }.
|
70
|
+
expect(result.success?).to eq(false)
|
71
|
+
expect(result.errors.for(:address).on(:base).map { |e| e.code }).to include(Braintree::ErrorCodes::Address::InconsistentCountry)
|
72
72
|
end
|
73
73
|
|
74
74
|
it "returns an error response given an invalid country_code_alpha2" do
|
@@ -77,8 +77,8 @@ describe Braintree::Address do
|
|
77
77
|
:customer_id => customer.id,
|
78
78
|
:country_code_alpha2 => "zz",
|
79
79
|
)
|
80
|
-
result.success
|
81
|
-
result.errors.for(:address).on(:country_code_alpha2).map { |e| e.code }.
|
80
|
+
expect(result.success?).to eq(false)
|
81
|
+
expect(result.errors.for(:address).on(:country_code_alpha2).map { |e| e.code }).to include(Braintree::ErrorCodes::Address::CountryCodeAlpha2IsNotAccepted)
|
82
82
|
end
|
83
83
|
|
84
84
|
it "returns an error response given an invalid country_code_alpha3" do
|
@@ -87,8 +87,8 @@ describe Braintree::Address do
|
|
87
87
|
:customer_id => customer.id,
|
88
88
|
:country_code_alpha3 => "zzz",
|
89
89
|
)
|
90
|
-
result.success
|
91
|
-
result.errors.for(:address).on(:country_code_alpha3).map { |e| e.code }.
|
90
|
+
expect(result.success?).to eq(false)
|
91
|
+
expect(result.errors.for(:address).on(:country_code_alpha3).map { |e| e.code }).to include(Braintree::ErrorCodes::Address::CountryCodeAlpha3IsNotAccepted)
|
92
92
|
end
|
93
93
|
|
94
94
|
it "returns an error response given an invalid country_code_numeric" do
|
@@ -97,8 +97,8 @@ describe Braintree::Address do
|
|
97
97
|
:customer_id => customer.id,
|
98
98
|
:country_code_numeric => "zz",
|
99
99
|
)
|
100
|
-
result.success
|
101
|
-
result.errors.for(:address).on(:country_code_numeric).map { |e| e.code }.
|
100
|
+
expect(result.success?).to eq(false)
|
101
|
+
expect(result.errors.for(:address).on(:country_code_numeric).map { |e| e.code }).to include(Braintree::ErrorCodes::Address::CountryCodeNumericIsNotAccepted)
|
102
102
|
end
|
103
103
|
|
104
104
|
it "returns an error response if invalid" do
|
@@ -107,8 +107,8 @@ describe Braintree::Address do
|
|
107
107
|
:customer_id => customer.id,
|
108
108
|
:country_name => "United States of Invalid",
|
109
109
|
)
|
110
|
-
result.success
|
111
|
-
result.errors.for(:address).on(:country_name)[0].message.
|
110
|
+
expect(result.success?).to eq(false)
|
111
|
+
expect(result.errors.for(:address).on(:country_name)[0].message).to eq("Country name is not an accepted country.")
|
112
112
|
end
|
113
113
|
|
114
114
|
it "allows -, _, A-Z, a-z, and 0-9 in customer_id without raising an ArgumentError" do
|
@@ -137,14 +137,14 @@ describe Braintree::Address do
|
|
137
137
|
:postal_code => "60623",
|
138
138
|
:country_name => "United States of America",
|
139
139
|
)
|
140
|
-
address.customer_id.
|
141
|
-
address.street_address.
|
142
|
-
address.extended_address.
|
143
|
-
address.locality.
|
144
|
-
address.region.
|
145
|
-
address.phone_number.
|
146
|
-
address.postal_code.
|
147
|
-
address.country_name.
|
140
|
+
expect(address.customer_id).to eq(customer.id)
|
141
|
+
expect(address.street_address).to eq("1812 E Main St")
|
142
|
+
expect(address.extended_address).to eq("Suite 201")
|
143
|
+
expect(address.locality).to eq("Bartlett")
|
144
|
+
expect(address.region).to eq("IL")
|
145
|
+
expect(address.phone_number).to eq("5551231234")
|
146
|
+
expect(address.postal_code).to eq("60623")
|
147
|
+
expect(address.country_name).to eq("United States of America")
|
148
148
|
end
|
149
149
|
|
150
150
|
it "raises a ValidationsFailed if invalid" do
|
@@ -162,7 +162,7 @@ describe Braintree::Address do
|
|
162
162
|
it "deletes the address given a customer id and an address id" do
|
163
163
|
customer = Braintree::Customer.create!(:last_name => "Wilson")
|
164
164
|
address = Braintree::Address.create!(:customer_id => customer.id, :street_address => "123 E Main St")
|
165
|
-
Braintree::Address.delete(customer.id, address.id).success
|
165
|
+
expect(Braintree::Address.delete(customer.id, address.id).success?).to eq(true)
|
166
166
|
expect do
|
167
167
|
Braintree::Address.find(customer.id, address.id)
|
168
168
|
end.to raise_error(Braintree::NotFoundError)
|
@@ -171,7 +171,7 @@ describe Braintree::Address do
|
|
171
171
|
it "deletes the address given a customer and an address id" do
|
172
172
|
customer = Braintree::Customer.create!(:last_name => "Wilson")
|
173
173
|
address = Braintree::Address.create!(:customer_id => customer.id, :street_address => "123 E Main St")
|
174
|
-
Braintree::Address.delete(customer, address.id).success
|
174
|
+
expect(Braintree::Address.delete(customer, address.id).success?).to eq(true)
|
175
175
|
expect do
|
176
176
|
Braintree::Address.find(customer.id, address.id)
|
177
177
|
end.to raise_error(Braintree::NotFoundError)
|
@@ -182,13 +182,13 @@ describe Braintree::Address do
|
|
182
182
|
it "finds the address given a customer and an address id" do
|
183
183
|
customer = Braintree::Customer.create!(:last_name => "Wilson")
|
184
184
|
address = Braintree::Address.create!(:customer_id => customer.id, :street_address => "123 E Main St")
|
185
|
-
Braintree::Address.find(customer, address.id).
|
185
|
+
expect(Braintree::Address.find(customer, address.id)).to eq(address)
|
186
186
|
end
|
187
187
|
|
188
188
|
it "finds the address given a customer id and an address id" do
|
189
189
|
customer = Braintree::Customer.create!(:last_name => "Wilson")
|
190
190
|
address = Braintree::Address.create!(:customer_id => customer.id, :street_address => "123 E Main St")
|
191
|
-
Braintree::Address.find(customer.id, address.id).
|
191
|
+
expect(Braintree::Address.find(customer.id, address.id)).to eq(address)
|
192
192
|
end
|
193
193
|
|
194
194
|
it "raises a NotFoundError if it cannot be found because of customer id" do
|
@@ -242,16 +242,16 @@ describe Braintree::Address do
|
|
242
242
|
:postal_code => "60621",
|
243
243
|
:country_name => "United States of America",
|
244
244
|
)
|
245
|
-
result.success
|
246
|
-
result.address.street_address.
|
247
|
-
result.address.extended_address.
|
248
|
-
result.address.locality.
|
249
|
-
result.address.region.
|
250
|
-
result.address.postal_code.
|
251
|
-
result.address.country_name.
|
252
|
-
result.address.country_code_alpha2.
|
253
|
-
result.address.country_code_alpha3.
|
254
|
-
result.address.country_code_numeric.
|
245
|
+
expect(result.success?).to eq(true)
|
246
|
+
expect(result.address.street_address).to eq("123 E New St")
|
247
|
+
expect(result.address.extended_address).to eq("New Suite 3")
|
248
|
+
expect(result.address.locality).to eq("Chicago")
|
249
|
+
expect(result.address.region).to eq("Illinois")
|
250
|
+
expect(result.address.postal_code).to eq("60621")
|
251
|
+
expect(result.address.country_name).to eq("United States of America")
|
252
|
+
expect(result.address.country_code_alpha2).to eq("US")
|
253
|
+
expect(result.address.country_code_alpha3).to eq("USA")
|
254
|
+
expect(result.address.country_code_numeric).to eq("840")
|
255
255
|
end
|
256
256
|
|
257
257
|
it "accepts country_codes" do
|
@@ -266,11 +266,11 @@ describe Braintree::Address do
|
|
266
266
|
:country_name => "Azerbaijan",
|
267
267
|
)
|
268
268
|
|
269
|
-
result.success
|
270
|
-
result.address.country_name.
|
271
|
-
result.address.country_code_alpha2.
|
272
|
-
result.address.country_code_alpha3.
|
273
|
-
result.address.country_code_numeric.
|
269
|
+
expect(result.success?).to eq(true)
|
270
|
+
expect(result.address.country_name).to eq("Azerbaijan")
|
271
|
+
expect(result.address.country_code_alpha2).to eq("AZ")
|
272
|
+
expect(result.address.country_code_alpha3).to eq("AZE")
|
273
|
+
expect(result.address.country_code_numeric).to eq("031")
|
274
274
|
end
|
275
275
|
|
276
276
|
it "returns an error response if invalid" do
|
@@ -285,8 +285,8 @@ describe Braintree::Address do
|
|
285
285
|
:street_address => "123 E New St",
|
286
286
|
:country_name => "United States of Invalid",
|
287
287
|
)
|
288
|
-
result.success
|
289
|
-
result.errors.for(:address).on(:country_name)[0].message.
|
288
|
+
expect(result.success?).to eq(false)
|
289
|
+
expect(result.errors.for(:address).on(:country_name)[0].message).to eq("Country name is not an accepted country.")
|
290
290
|
end
|
291
291
|
end
|
292
292
|
|
@@ -320,13 +320,13 @@ describe Braintree::Address do
|
|
320
320
|
:postal_code => "60621",
|
321
321
|
:country_name => "United States of America",
|
322
322
|
)
|
323
|
-
updated_address.
|
324
|
-
updated_address.street_address.
|
325
|
-
updated_address.extended_address.
|
326
|
-
updated_address.locality.
|
327
|
-
updated_address.region.
|
328
|
-
updated_address.postal_code.
|
329
|
-
updated_address.country_name.
|
323
|
+
expect(updated_address).to eq(address)
|
324
|
+
expect(updated_address.street_address).to eq("123 E New St")
|
325
|
+
expect(updated_address.extended_address).to eq("New Suite 3")
|
326
|
+
expect(updated_address.locality).to eq("Chicago")
|
327
|
+
expect(updated_address.region).to eq("Illinois")
|
328
|
+
expect(updated_address.postal_code).to eq("60621")
|
329
|
+
expect(updated_address.country_name).to eq("United States of America")
|
330
330
|
end
|
331
331
|
|
332
332
|
it "raises a ValidationsFailed invalid" do
|
@@ -352,7 +352,7 @@ describe Braintree::Address do
|
|
352
352
|
customer = Braintree::Customer.create!(:last_name => "Wilson")
|
353
353
|
address = Braintree::Address.create!(:customer_id => customer.id, :street_address => "123 E Main St")
|
354
354
|
result = Braintree::Address.delete(customer.id, address.id)
|
355
|
-
result.success
|
355
|
+
expect(result.success?).to eq(true)
|
356
356
|
expect do
|
357
357
|
Braintree::Address.find(customer.id, address.id)
|
358
358
|
end.to raise_error(Braintree::NotFoundError)
|
@@ -29,8 +29,8 @@ describe Braintree::AdvancedSearch do
|
|
29
29
|
search.id.is "subscription1_#{id}"
|
30
30
|
end
|
31
31
|
|
32
|
-
collection.
|
33
|
-
collection.
|
32
|
+
expect(collection).to include(subscription1)
|
33
|
+
expect(collection).not_to include(subscription2)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "is_not" do
|
@@ -54,8 +54,8 @@ describe Braintree::AdvancedSearch do
|
|
54
54
|
search.price.is "11"
|
55
55
|
end
|
56
56
|
|
57
|
-
collection.
|
58
|
-
collection.
|
57
|
+
expect(collection).not_to include(subscription1)
|
58
|
+
expect(collection).to include(subscription2)
|
59
59
|
end
|
60
60
|
|
61
61
|
it "starts_with" do
|
@@ -76,8 +76,8 @@ describe Braintree::AdvancedSearch do
|
|
76
76
|
search.id.starts_with "subscription1_"
|
77
77
|
end
|
78
78
|
|
79
|
-
collection.
|
80
|
-
collection.
|
79
|
+
expect(collection).to include(subscription1)
|
80
|
+
expect(collection).not_to include(subscription2)
|
81
81
|
end
|
82
82
|
|
83
83
|
it "ends_with" do
|
@@ -98,8 +98,8 @@ describe Braintree::AdvancedSearch do
|
|
98
98
|
search.id.ends_with "1_#{id}"
|
99
99
|
end
|
100
100
|
|
101
|
-
collection.
|
102
|
-
collection.
|
101
|
+
expect(collection).to include(subscription1)
|
102
|
+
expect(collection).not_to include(subscription2)
|
103
103
|
end
|
104
104
|
|
105
105
|
it "contains" do
|
@@ -120,8 +120,8 @@ describe Braintree::AdvancedSearch do
|
|
120
120
|
search.id.contains "scription1_"
|
121
121
|
end
|
122
122
|
|
123
|
-
collection.
|
124
|
-
collection.
|
123
|
+
expect(collection).to include(subscription1)
|
124
|
+
expect(collection).not_to include(subscription2)
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
@@ -147,8 +147,8 @@ describe Braintree::AdvancedSearch do
|
|
147
147
|
search.price.is "12"
|
148
148
|
end
|
149
149
|
|
150
|
-
collection.
|
151
|
-
collection.
|
150
|
+
expect(collection).to include(subscription1)
|
151
|
+
expect(collection).to include(subscription2)
|
152
152
|
end
|
153
153
|
|
154
154
|
it "returns only matching results" do
|
@@ -171,8 +171,8 @@ describe Braintree::AdvancedSearch do
|
|
171
171
|
search.price.is "13"
|
172
172
|
end
|
173
173
|
|
174
|
-
collection.
|
175
|
-
collection.
|
174
|
+
expect(collection).to include(subscription1)
|
175
|
+
expect(collection).not_to include(subscription2)
|
176
176
|
end
|
177
177
|
|
178
178
|
it "returns only matching results given an argument list" do
|
@@ -195,8 +195,8 @@ describe Braintree::AdvancedSearch do
|
|
195
195
|
search.price.is "14"
|
196
196
|
end
|
197
197
|
|
198
|
-
collection.
|
199
|
-
collection.
|
198
|
+
expect(collection).to include(subscription1)
|
199
|
+
expect(collection).to include(subscription2)
|
200
200
|
end
|
201
201
|
|
202
202
|
describe "is" do
|
@@ -220,8 +220,8 @@ describe Braintree::AdvancedSearch do
|
|
220
220
|
search.price.is "15"
|
221
221
|
end
|
222
222
|
|
223
|
-
collection.
|
224
|
-
collection.
|
223
|
+
expect(collection).to include(subscription1)
|
224
|
+
expect(collection).not_to include(subscription2)
|
225
225
|
end
|
226
226
|
end
|
227
227
|
|
@@ -245,8 +245,8 @@ describe Braintree::AdvancedSearch do
|
|
245
245
|
search.price.is "16"
|
246
246
|
end
|
247
247
|
|
248
|
-
collection.
|
249
|
-
collection.
|
248
|
+
expect(collection).to include(subscription1)
|
249
|
+
expect(collection).to include(subscription2)
|
250
250
|
end
|
251
251
|
|
252
252
|
it "returns expired subscriptions" do
|
@@ -254,8 +254,8 @@ describe Braintree::AdvancedSearch do
|
|
254
254
|
search.status.in [Braintree::Subscription::Status::Expired]
|
255
255
|
end
|
256
256
|
|
257
|
-
collection.maximum_size.
|
258
|
-
collection.all? { |subscription| subscription.status.
|
257
|
+
expect(collection.maximum_size).to be > 0
|
258
|
+
collection.all? { |subscription| expect(subscription.status).to eq(Braintree::Subscription::Status::Expired) }
|
259
259
|
end
|
260
260
|
end
|
261
261
|
end
|
@@ -287,7 +287,7 @@ describe Braintree::AdvancedSearch do
|
|
287
287
|
search.price.is "17"
|
288
288
|
end
|
289
289
|
|
290
|
-
collection.maximum_size.
|
290
|
+
expect(collection.maximum_size).to be > 0
|
291
291
|
collection.all? { |subscription| plan_ids.include?(subscription.plan_id) }
|
292
292
|
end
|
293
293
|
end
|
@@ -298,7 +298,7 @@ describe Braintree::AdvancedSearch do
|
|
298
298
|
search.plan_id.is "not_a_real_plan_id"
|
299
299
|
end
|
300
300
|
|
301
|
-
collection.maximum_size.
|
301
|
+
expect(collection.maximum_size).to eq(0)
|
302
302
|
end
|
303
303
|
end
|
304
304
|
|
@@ -321,8 +321,8 @@ describe Braintree::AdvancedSearch do
|
|
321
321
|
search.price.is "18"
|
322
322
|
end
|
323
323
|
|
324
|
-
collection.
|
325
|
-
collection.
|
324
|
+
expect(collection).to include(trialless_subscription)
|
325
|
+
expect(collection).not_to include(trial_subscription)
|
326
326
|
end
|
327
327
|
end
|
328
328
|
|
@@ -345,8 +345,8 @@ describe Braintree::AdvancedSearch do
|
|
345
345
|
search.price.is "19"
|
346
346
|
end
|
347
347
|
|
348
|
-
collection.
|
349
|
-
collection.
|
348
|
+
expect(collection).not_to include(trialless_subscription)
|
349
|
+
expect(collection).to include(trial_subscription)
|
350
350
|
end
|
351
351
|
end
|
352
352
|
|
@@ -369,8 +369,8 @@ describe Braintree::AdvancedSearch do
|
|
369
369
|
search.price.is "20"
|
370
370
|
end
|
371
371
|
|
372
|
-
collection.
|
373
|
-
collection.
|
372
|
+
expect(collection).to include(trial_subscription)
|
373
|
+
expect(collection).not_to include(trialless_subscription)
|
374
374
|
end
|
375
375
|
end
|
376
376
|
|
@@ -393,8 +393,8 @@ describe Braintree::AdvancedSearch do
|
|
393
393
|
search.price.is "21"
|
394
394
|
end
|
395
395
|
|
396
|
-
collection.
|
397
|
-
collection.
|
396
|
+
expect(collection).to include(trial_subscription)
|
397
|
+
expect(collection).not_to include(trialless_subscription)
|
398
398
|
end
|
399
399
|
end
|
400
400
|
|
@@ -417,8 +417,8 @@ describe Braintree::AdvancedSearch do
|
|
417
417
|
search.price.is "22"
|
418
418
|
end
|
419
419
|
|
420
|
-
collection.
|
421
|
-
collection.
|
420
|
+
expect(collection).to include(trial_subscription)
|
421
|
+
expect(collection).not_to include(trialless_subscription)
|
422
422
|
end
|
423
423
|
end
|
424
424
|
end
|
@@ -441,8 +441,8 @@ describe Braintree::AdvancedSearch do
|
|
441
441
|
search.price.is "5.00"
|
442
442
|
end
|
443
443
|
|
444
|
-
collection.
|
445
|
-
collection.
|
444
|
+
expect(collection).to include(subscription_500)
|
445
|
+
expect(collection).not_to include(subscription_501)
|
446
446
|
end
|
447
447
|
|
448
448
|
it "<=" do
|
@@ -468,9 +468,9 @@ describe Braintree::AdvancedSearch do
|
|
468
468
|
search.price <= "5.00"
|
469
469
|
end
|
470
470
|
|
471
|
-
collection.
|
472
|
-
collection.
|
473
|
-
collection.
|
471
|
+
expect(collection).to include(subscription_499)
|
472
|
+
expect(collection).to include(subscription_500)
|
473
|
+
expect(collection).not_to include(subscription_501)
|
474
474
|
end
|
475
475
|
|
476
476
|
it ">=" do
|
@@ -496,9 +496,9 @@ describe Braintree::AdvancedSearch do
|
|
496
496
|
search.price >= "1000.00"
|
497
497
|
end
|
498
498
|
|
499
|
-
collection.
|
500
|
-
collection.
|
501
|
-
collection.
|
499
|
+
expect(collection).not_to include(subscription_499)
|
500
|
+
expect(collection).to include(subscription_500)
|
501
|
+
expect(collection).to include(subscription_501)
|
502
502
|
end
|
503
503
|
|
504
504
|
it "between" do
|
@@ -524,9 +524,9 @@ describe Braintree::AdvancedSearch do
|
|
524
524
|
search.price.between "4.99", "5.01"
|
525
525
|
end
|
526
526
|
|
527
|
-
collection.
|
528
|
-
collection.
|
529
|
-
collection.
|
527
|
+
expect(collection).to include(subscription_499)
|
528
|
+
expect(collection).to include(subscription_500)
|
529
|
+
expect(collection).not_to include(subscription_502)
|
530
530
|
end
|
531
531
|
end
|
532
532
|
end
|
@@ -23,13 +23,13 @@ describe Braintree::ApplePayGateway do
|
|
23
23
|
describe "register_domain" do
|
24
24
|
it "registers an apple pay domain" do
|
25
25
|
result = @gateway.apple_pay.register_domain("www.example.com")
|
26
|
-
result.
|
26
|
+
expect(result).to be_success
|
27
27
|
end
|
28
28
|
|
29
29
|
it "gets a validation error when attempting to register no domains" do
|
30
30
|
result = @gateway.apple_pay.register_domain("")
|
31
|
-
result.
|
32
|
-
result.errors.for(:apple_pay)[0].message.
|
31
|
+
expect(result).not_to be_success
|
32
|
+
expect(result.errors.for(:apple_pay)[0].message).to eq("Domain name is required.")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -37,27 +37,27 @@ describe Braintree::ApplePayGateway do
|
|
37
37
|
it "unregisters an apple pay domain" do
|
38
38
|
domain = "example.org"
|
39
39
|
result = @gateway.apple_pay.unregister_domain(domain)
|
40
|
-
result.
|
40
|
+
expect(result).to be_success
|
41
41
|
end
|
42
42
|
|
43
43
|
it "unregisters an apple pay domain with scheme in url" do
|
44
44
|
domain = "http://example.org"
|
45
45
|
result = @gateway.apple_pay.unregister_domain(domain)
|
46
|
-
result.
|
46
|
+
expect(result).to be_success
|
47
47
|
end
|
48
48
|
|
49
49
|
it "escapes the unregistered domain query parameter" do
|
50
50
|
domain = "ex&mple.org"
|
51
51
|
result = @gateway.apple_pay.unregister_domain(domain)
|
52
|
-
result.
|
52
|
+
expect(result).to be_success
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
describe "registered_domains" do
|
57
57
|
it "returns stubbed registered domains" do
|
58
58
|
result = @gateway.apple_pay.registered_domains
|
59
|
-
result.
|
60
|
-
result.apple_pay_options.domains.
|
59
|
+
expect(result).to be_success
|
60
|
+
expect(result.apple_pay_options.domains).to eq(["www.example.com"])
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -17,7 +17,7 @@ describe Braintree::ClientToken do
|
|
17
17
|
|
18
18
|
response = http.get_payment_methods
|
19
19
|
|
20
|
-
response.code.
|
20
|
+
expect(response.code).to eq("200")
|
21
21
|
end
|
22
22
|
|
23
23
|
it "raises ArgumentError on invalid parameters (422)" do
|
@@ -31,14 +31,14 @@ describe Braintree::ClientToken do
|
|
31
31
|
config = Braintree::Configuration.instantiate
|
32
32
|
client_token_string = Braintree::ClientToken.generate(:version => 1)
|
33
33
|
client_token = JSON.parse(client_token_string)
|
34
|
-
client_token["version"].
|
34
|
+
expect(client_token["version"]).to eq(1)
|
35
35
|
end
|
36
36
|
|
37
37
|
it "defaults to 2" do
|
38
38
|
config = Braintree::Configuration.instantiate
|
39
39
|
client_token_string = Braintree::ClientToken.generate
|
40
40
|
client_token = decode_client_token(client_token_string)
|
41
|
-
client_token["version"].
|
41
|
+
expect(client_token["version"]).to eq(2)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -68,7 +68,7 @@ describe Braintree::ClientToken do
|
|
68
68
|
},
|
69
69
|
)
|
70
70
|
|
71
|
-
response.code.
|
71
|
+
expect(response.code).to eq("422")
|
72
72
|
end
|
73
73
|
|
74
74
|
it "can pass make_default" do
|
@@ -98,7 +98,7 @@ describe Braintree::ClientToken do
|
|
98
98
|
},
|
99
99
|
)
|
100
100
|
|
101
|
-
response.code.
|
101
|
+
expect(response.code).to eq("201")
|
102
102
|
|
103
103
|
response = http.add_payment_method(
|
104
104
|
:credit_card => {
|
@@ -108,10 +108,10 @@ describe Braintree::ClientToken do
|
|
108
108
|
},
|
109
109
|
)
|
110
110
|
|
111
|
-
response.code.
|
111
|
+
expect(response.code).to eq("201")
|
112
112
|
|
113
113
|
customer = Braintree::Customer.find(customer_id)
|
114
|
-
customer.credit_cards.select { |c| c.bin == "400551" }[0].
|
114
|
+
expect(customer.credit_cards.select { |c| c.bin == "400551" }[0]).to be_default
|
115
115
|
end
|
116
116
|
|
117
117
|
it "can pass fail_on_duplicate_payment_method" do
|
@@ -138,7 +138,7 @@ describe Braintree::ClientToken do
|
|
138
138
|
},
|
139
139
|
)
|
140
140
|
|
141
|
-
response.code.
|
141
|
+
expect(response.code).to eq("201")
|
142
142
|
|
143
143
|
second_raw_client_token = Braintree::ClientToken.generate(
|
144
144
|
:customer_id => customer_id,
|
@@ -158,7 +158,7 @@ describe Braintree::ClientToken do
|
|
158
158
|
},
|
159
159
|
)
|
160
160
|
|
161
|
-
response.code.
|
161
|
+
expect(response.code).to eq("422")
|
162
162
|
end
|
163
163
|
|
164
164
|
it "can pass merchant_account_id" do
|
@@ -169,7 +169,7 @@ describe Braintree::ClientToken do
|
|
169
169
|
)
|
170
170
|
client_token = decode_client_token(raw_client_token)
|
171
171
|
|
172
|
-
client_token["merchantAccountId"].
|
172
|
+
expect(client_token["merchantAccountId"]).to eq(merchant_account_id)
|
173
173
|
end
|
174
174
|
|
175
175
|
context "paypal" do
|
@@ -178,11 +178,11 @@ describe Braintree::ClientToken do
|
|
178
178
|
raw_client_token = Braintree::ClientToken.generate
|
179
179
|
client_token = decode_client_token(raw_client_token)
|
180
180
|
|
181
|
-
client_token["paypal"]["displayName"].
|
182
|
-
client_token["paypal"]["clientId"].
|
183
|
-
client_token["paypal"]["privacyUrl"].
|
184
|
-
client_token["paypal"]["userAgreementUrl"].
|
185
|
-
client_token["paypal"]["baseUrl"].
|
181
|
+
expect(client_token["paypal"]["displayName"]).to eq("merchant who has paypal and sepa enabled")
|
182
|
+
expect(client_token["paypal"]["clientId"]).to match(/.+/)
|
183
|
+
expect(client_token["paypal"]["privacyUrl"]).to match("http://www.example.com/privacy_policy")
|
184
|
+
expect(client_token["paypal"]["userAgreementUrl"]).to match("http://www.example.com/user_agreement")
|
185
|
+
expect(client_token["paypal"]["baseUrl"]).not_to be_nil
|
186
186
|
end
|
187
187
|
end
|
188
188
|
end
|