braintree 3.2.0 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/braintree.gemspec +3 -3
- data/lib/braintree.rb +6 -1
- data/lib/braintree/account_updater_daily_report.rb +1 -1
- data/lib/braintree/address.rb +2 -1
- data/lib/braintree/apple_pay.rb +1 -1
- data/lib/braintree/apple_pay_card.rb +1 -1
- data/lib/braintree/apple_pay_options.rb +1 -1
- data/lib/braintree/authorization_adjustment.rb +1 -1
- data/lib/braintree/client_token.rb +1 -1
- data/lib/braintree/configuration.rb +11 -11
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
- data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
- data/lib/braintree/credit_card.rb +2 -2
- data/lib/braintree/credit_card_gateway.rb +14 -4
- data/lib/braintree/credit_card_verification.rb +5 -5
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +6 -4
- data/lib/braintree/customer_gateway.rb +2 -0
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/disbursement.rb +1 -1
- data/lib/braintree/dispute.rb +15 -1
- data/lib/braintree/dispute/paypal_message.rb +15 -0
- data/lib/braintree/dispute_gateway.rb +2 -2
- data/lib/braintree/dispute_search.rb +3 -2
- data/lib/braintree/document_upload.rb +1 -1
- data/lib/braintree/error_codes.rb +10 -6
- data/lib/braintree/google_pay_card.rb +1 -1
- data/lib/braintree/granted_payment_instrument_update.rb +1 -1
- data/lib/braintree/graphql_client.rb +7 -7
- data/lib/braintree/http.rb +3 -3
- data/lib/braintree/local_payment_completed.rb +1 -1
- data/lib/braintree/local_payment_reversed.rb +19 -0
- data/lib/braintree/merchant.rb +1 -1
- data/lib/braintree/merchant_account.rb +1 -1
- data/lib/braintree/merchant_account_gateway.rb +1 -1
- data/lib/braintree/merchant_gateway.rb +1 -1
- data/lib/braintree/modification.rb +1 -1
- data/lib/braintree/oauth_credentials.rb +1 -1
- data/lib/braintree/oauth_gateway.rb +5 -5
- data/lib/braintree/payment_instrument_type.rb +10 -10
- data/lib/braintree/payment_method_gateway.rb +10 -7
- 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/plan.rb +1 -1
- data/lib/braintree/processor_response_types.rb +3 -3
- data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
- data/lib/braintree/risk_data.rb +3 -1
- data/lib/braintree/samsung_pay_card.rb +1 -1
- data/lib/braintree/settlement_batch_summary.rb +2 -2
- data/lib/braintree/subscription.rb +6 -6
- data/lib/braintree/three_d_secure_info.rb +22 -12
- data/lib/braintree/transaction.rb +32 -24
- data/lib/braintree/transaction_gateway.rb +24 -5
- data/lib/braintree/transaction_line_item.rb +1 -1
- data/lib/braintree/transaction_search.rb +3 -1
- data/lib/braintree/unknown_payment_method.rb +1 -1
- data/lib/braintree/us_bank_account.rb +3 -3
- data/lib/braintree/us_bank_account_verification.rb +1 -1
- data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
- data/lib/braintree/util.rb +4 -4
- data/lib/braintree/venmo_account.rb +1 -1
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +2 -2
- data/lib/braintree/webhook_notification.rb +30 -20
- data/lib/braintree/webhook_notification_gateway.rb +5 -5
- data/lib/braintree/webhook_testing_gateway.rb +30 -0
- data/lib/braintree/xml/generator.rb +5 -4
- data/lib/braintree/xml/libxml.rb +0 -1
- data/lib/braintree/xml/parser.rb +22 -12
- data/lib/braintree/xml/rexml.rb +70 -0
- data/spec/integration/braintree/add_on_spec.rb +1 -1
- data/spec/integration/braintree/address_spec.rb +28 -24
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +3 -3
- data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
- data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
- data/spec/integration/braintree/client_api/spec_helper.rb +5 -5
- data/spec/integration/braintree/credit_card_spec.rb +213 -122
- 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 +282 -165
- data/spec/integration/braintree/dispute_search_spec.rb +28 -3
- data/spec/integration/braintree/dispute_spec.rb +6 -6
- data/spec/integration/braintree/error_codes_spec.rb +1 -1
- data/spec/integration/braintree/http_spec.rb +2 -2
- data/spec/integration/braintree/merchant_account_spec.rb +25 -26
- data/spec/integration/braintree/merchant_spec.rb +14 -14
- data/spec/integration/braintree/oauth_spec.rb +11 -11
- data/spec/integration/braintree/payment_method_nonce_spec.rb +28 -35
- data/spec/integration/braintree/payment_method_spec.rb +269 -165
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +9 -9
- data/spec/integration/braintree/paypal_account_spec.rb +28 -28
- data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
- data/spec/integration/braintree/subscription_spec.rb +133 -133
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +10 -10
- data/spec/integration/braintree/transaction_search_spec.rb +93 -67
- data/spec/integration/braintree/transaction_spec.rb +574 -360
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +20 -20
- data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
- data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
- data/spec/integration/spec_helper.rb +9 -3
- data/spec/oauth_test_helper.rb +1 -1
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec_helper.rb +6 -3
- data/spec/unit/braintree/address_spec.rb +1 -1
- data/spec/unit/braintree/apple_pay_card_spec.rb +1 -1
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +42 -42
- data/spec/unit/braintree/credit_card_spec.rb +13 -13
- 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 +20 -10
- data/spec/unit/braintree/disbursement_spec.rb +7 -7
- data/spec/unit/braintree/dispute_search_spec.rb +1 -0
- data/spec/unit/braintree/dispute_spec.rb +34 -9
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +8 -8
- data/spec/unit/braintree/http_spec.rb +5 -5
- data/spec/unit/braintree/merchant_account_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_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 +9 -9
- data/spec/unit/braintree/risk_data_spec.rb +9 -5
- 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/paypal_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction_search_spec.rb +12 -12
- data/spec/unit/braintree/transaction_spec.rb +25 -17
- data/spec/unit/braintree/util_spec.rb +18 -18
- data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
- data/spec/unit/braintree/webhook_notification_spec.rb +88 -56
- data/spec/unit/braintree/xml/rexml_spec.rb +51 -0
- data/spec/unit/braintree/xml_spec.rb +31 -31
- metadata +16 -8
- data/lib/braintree/settlement_batch.rb +0 -0
@@ -21,7 +21,7 @@ describe Braintree::PaymentMethod do
|
|
21
21
|
:customer_id => customer.id,
|
22
22
|
:options => {
|
23
23
|
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
24
|
-
}
|
24
|
+
},
|
25
25
|
)
|
26
26
|
|
27
27
|
result.should be_success
|
@@ -59,7 +59,7 @@ describe Braintree::PaymentMethod do
|
|
59
59
|
:options => {
|
60
60
|
:us_bank_account_verification_method => method,
|
61
61
|
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
62
|
-
}
|
62
|
+
},
|
63
63
|
)
|
64
64
|
|
65
65
|
result.should be_success
|
@@ -103,7 +103,7 @@ describe Braintree::PaymentMethod do
|
|
103
103
|
:customer_id => customer.id,
|
104
104
|
:options => {
|
105
105
|
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
106
|
-
}
|
106
|
+
},
|
107
107
|
)
|
108
108
|
|
109
109
|
result.should be_success
|
@@ -136,7 +136,7 @@ describe Braintree::PaymentMethod do
|
|
136
136
|
:options => {
|
137
137
|
:us_bank_account_verification_method => method,
|
138
138
|
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
139
|
-
}
|
139
|
+
},
|
140
140
|
)
|
141
141
|
|
142
142
|
result.should be_success
|
@@ -167,7 +167,7 @@ describe Braintree::PaymentMethod do
|
|
167
167
|
customer = Braintree::Customer.create.customer
|
168
168
|
result = Braintree::PaymentMethod.create(
|
169
169
|
:payment_method_nonce => generate_invalid_us_bank_account_nonce,
|
170
|
-
:customer_id => customer.id
|
170
|
+
:customer_id => customer.id,
|
171
171
|
)
|
172
172
|
|
173
173
|
result.should_not be_success
|
@@ -193,7 +193,7 @@ describe Braintree::PaymentMethod do
|
|
193
193
|
:customer_id => customer.id,
|
194
194
|
:options => {
|
195
195
|
:verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
|
196
|
-
}
|
196
|
+
},
|
197
197
|
)
|
198
198
|
|
199
199
|
result.should be_success
|
@@ -230,7 +230,7 @@ describe Braintree::PaymentMethod do
|
|
230
230
|
:customer_id => customer.id,
|
231
231
|
:options => {
|
232
232
|
:verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
|
233
|
-
}
|
233
|
+
},
|
234
234
|
)
|
235
235
|
|
236
236
|
result.should be_success
|
@@ -260,7 +260,7 @@ describe Braintree::PaymentMethod do
|
|
260
260
|
customer = Braintree::Customer.create.customer
|
261
261
|
result = Braintree::PaymentMethod.create(
|
262
262
|
:payment_method_nonce => generate_invalid_us_bank_account_nonce,
|
263
|
-
:customer_id => customer.id
|
263
|
+
:customer_id => customer.id,
|
264
264
|
)
|
265
265
|
|
266
266
|
result.should_not be_success
|
@@ -356,7 +356,7 @@ describe Braintree::PaymentMethod do
|
|
356
356
|
:customer_id => customer.id,
|
357
357
|
:options => {
|
358
358
|
:verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
|
359
|
-
}
|
359
|
+
},
|
360
360
|
).payment_method
|
361
361
|
end
|
362
362
|
|
@@ -9,11 +9,11 @@ describe Braintree::PayPalAccount do
|
|
9
9
|
|
10
10
|
nonce = nonce_for_paypal_account(
|
11
11
|
:consent_code => "consent-code",
|
12
|
-
:token => payment_method_token
|
12
|
+
:token => payment_method_token,
|
13
13
|
)
|
14
14
|
result = Braintree::PaymentMethod.create(
|
15
15
|
:payment_method_nonce => nonce,
|
16
|
-
:customer_id => customer.id
|
16
|
+
:customer_id => customer.id,
|
17
17
|
)
|
18
18
|
result.should be_success
|
19
19
|
|
@@ -35,7 +35,7 @@ describe Braintree::PayPalAccount do
|
|
35
35
|
result = Braintree::PaymentMethod.create(
|
36
36
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
|
37
37
|
:customer_id => customer.id,
|
38
|
-
:token => payment_method_token
|
38
|
+
:token => payment_method_token,
|
39
39
|
)
|
40
40
|
result.should be_success
|
41
41
|
|
@@ -56,7 +56,7 @@ describe Braintree::PayPalAccount do
|
|
56
56
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
57
57
|
:expiration_date => "05/2009",
|
58
58
|
:cvv => "100",
|
59
|
-
:token => "CREDIT_CARD_TOKEN"
|
59
|
+
:token => "CREDIT_CARD_TOKEN",
|
60
60
|
)
|
61
61
|
|
62
62
|
expect do
|
@@ -70,11 +70,11 @@ describe Braintree::PayPalAccount do
|
|
70
70
|
|
71
71
|
nonce = nonce_for_paypal_account(
|
72
72
|
:consent_code => "consent-code",
|
73
|
-
:token => payment_method_token
|
73
|
+
:token => payment_method_token,
|
74
74
|
)
|
75
75
|
result = Braintree::PaymentMethod.create(
|
76
76
|
:payment_method_nonce => nonce,
|
77
|
-
:customer_id => customer.id
|
77
|
+
:customer_id => customer.id,
|
78
78
|
)
|
79
79
|
result.should be_success
|
80
80
|
|
@@ -82,12 +82,12 @@ describe Braintree::PayPalAccount do
|
|
82
82
|
|
83
83
|
subscription1 = Braintree::Subscription.create(
|
84
84
|
:payment_method_token => token,
|
85
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
85
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
86
86
|
).subscription
|
87
87
|
|
88
88
|
subscription2 = Braintree::Subscription.create(
|
89
89
|
:payment_method_token => token,
|
90
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
90
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
91
91
|
).subscription
|
92
92
|
|
93
93
|
paypal_account = Braintree::PayPalAccount.find(token)
|
@@ -105,7 +105,7 @@ describe Braintree::PayPalAccount do
|
|
105
105
|
:options => {
|
106
106
|
:make_default => true,
|
107
107
|
:fail_on_duplicate_payment_method => true,
|
108
|
-
}
|
108
|
+
},
|
109
109
|
)
|
110
110
|
|
111
111
|
result.should be_success
|
@@ -116,7 +116,7 @@ describe Braintree::PayPalAccount do
|
|
116
116
|
it "throws an error if customer id is not specified" do
|
117
117
|
result = Braintree::PayPalAccount.create(
|
118
118
|
:billing_agreement_id => "some_billing_agreement_id",
|
119
|
-
:email => "some@example.com"
|
119
|
+
:email => "some@example.com",
|
120
120
|
)
|
121
121
|
|
122
122
|
result.success?.should == false
|
@@ -127,7 +127,7 @@ describe Braintree::PayPalAccount do
|
|
127
127
|
customer = Braintree::Customer.create!
|
128
128
|
result = Braintree::PayPalAccount.create(
|
129
129
|
:customer_id => customer.id,
|
130
|
-
:email => "some@example.com"
|
130
|
+
:email => "some@example.com",
|
131
131
|
)
|
132
132
|
|
133
133
|
result.success?.should == false
|
@@ -141,14 +141,14 @@ describe Braintree::PayPalAccount do
|
|
141
141
|
create_result = Braintree::PayPalAccount.create(
|
142
142
|
:customer_id => customer.id,
|
143
143
|
:billing_agreement_id => "first_billing_agreement_id",
|
144
|
-
:email => "first@example.com"
|
144
|
+
:email => "first@example.com",
|
145
145
|
)
|
146
146
|
create_result.success?.should == true
|
147
147
|
|
148
148
|
update_result = Braintree::PayPalAccount.update(
|
149
149
|
create_result.paypal_account.token,
|
150
150
|
:billing_agreement_id => "second_billing_agreement_id",
|
151
|
-
:email => "second@example.com"
|
151
|
+
:email => "second@example.com",
|
152
152
|
)
|
153
153
|
|
154
154
|
update_result.success?.should == true
|
@@ -163,17 +163,17 @@ describe Braintree::PayPalAccount do
|
|
163
163
|
original_token = random_payment_method_token
|
164
164
|
nonce = nonce_for_paypal_account(
|
165
165
|
:consent_code => "consent-code",
|
166
|
-
:token => original_token
|
166
|
+
:token => original_token,
|
167
167
|
)
|
168
168
|
original_result = Braintree::PaymentMethod.create(
|
169
169
|
:payment_method_nonce => nonce,
|
170
|
-
:customer_id => customer.id
|
170
|
+
:customer_id => customer.id,
|
171
171
|
)
|
172
172
|
|
173
173
|
updated_token = "UPDATED_TOKEN-" + rand(36**3).to_s(36)
|
174
174
|
updated_result = Braintree::PayPalAccount.update(
|
175
175
|
original_token,
|
176
|
-
:token => updated_token
|
176
|
+
:token => updated_token,
|
177
177
|
)
|
178
178
|
|
179
179
|
updated_paypal_account = Braintree::PayPalAccount.find(updated_token)
|
@@ -190,19 +190,19 @@ describe Braintree::PayPalAccount do
|
|
190
190
|
:customer_id => customer.id,
|
191
191
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
192
192
|
:expiration_date => "05/2009",
|
193
|
-
:options => {:make_default => true}
|
193
|
+
:options => {:make_default => true},
|
194
194
|
)
|
195
195
|
result.should be_success
|
196
196
|
|
197
197
|
nonce = nonce_for_paypal_account(:consent_code => "consent-code")
|
198
198
|
original_token = Braintree::PaymentMethod.create(
|
199
199
|
:payment_method_nonce => nonce,
|
200
|
-
:customer_id => customer.id
|
200
|
+
:customer_id => customer.id,
|
201
201
|
).payment_method.token
|
202
202
|
|
203
203
|
updated_result = Braintree::PayPalAccount.update(
|
204
204
|
original_token,
|
205
|
-
:options => {:make_default => true}
|
205
|
+
:options => {:make_default => true},
|
206
206
|
)
|
207
207
|
|
208
208
|
updated_paypal_account = Braintree::PayPalAccount.find(original_token)
|
@@ -216,25 +216,25 @@ describe Braintree::PayPalAccount do
|
|
216
216
|
|
217
217
|
first_nonce = nonce_for_paypal_account(
|
218
218
|
:consent_code => "consent-code",
|
219
|
-
:token => first_token
|
219
|
+
:token => first_token,
|
220
220
|
)
|
221
221
|
first_result = Braintree::PaymentMethod.create(
|
222
222
|
:payment_method_nonce => first_nonce,
|
223
|
-
:customer_id => customer.id
|
223
|
+
:customer_id => customer.id,
|
224
224
|
)
|
225
225
|
|
226
226
|
second_nonce = nonce_for_paypal_account(
|
227
227
|
:consent_code => "consent-code",
|
228
|
-
:token => second_token
|
228
|
+
:token => second_token,
|
229
229
|
)
|
230
230
|
second_result = Braintree::PaymentMethod.create(
|
231
231
|
:payment_method_nonce => second_nonce,
|
232
|
-
:customer_id => customer.id
|
232
|
+
:customer_id => customer.id,
|
233
233
|
)
|
234
234
|
|
235
235
|
updated_result = Braintree::PayPalAccount.update(
|
236
236
|
first_token,
|
237
|
-
:token => second_token
|
237
|
+
:token => second_token,
|
238
238
|
)
|
239
239
|
|
240
240
|
updated_result.should_not be_success
|
@@ -249,11 +249,11 @@ describe Braintree::PayPalAccount do
|
|
249
249
|
|
250
250
|
nonce = nonce_for_paypal_account(
|
251
251
|
:consent_code => "consent-code",
|
252
|
-
:token => token
|
252
|
+
:token => token,
|
253
253
|
)
|
254
254
|
Braintree::PaymentMethod.create(
|
255
255
|
:payment_method_nonce => nonce,
|
256
|
-
:customer_id => customer.id
|
256
|
+
:customer_id => customer.id,
|
257
257
|
)
|
258
258
|
|
259
259
|
result = Braintree::PayPalAccount.delete(token)
|
@@ -267,7 +267,7 @@ describe Braintree::PayPalAccount do
|
|
267
267
|
context "self.sale" do
|
268
268
|
it "creates a transaction using a paypal account and returns a result object" do
|
269
269
|
customer = Braintree::Customer.create!(
|
270
|
-
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment
|
270
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
271
271
|
)
|
272
272
|
|
273
273
|
result = Braintree::PayPalAccount.sale(customer.paypal_accounts[0].token, :amount => "100.00")
|
@@ -283,7 +283,7 @@ describe Braintree::PayPalAccount do
|
|
283
283
|
context "self.sale!" do
|
284
284
|
it "creates a transaction using a paypal account and returns a transaction" do
|
285
285
|
customer = Braintree::Customer.create!(
|
286
|
-
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment
|
286
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
287
287
|
)
|
288
288
|
|
289
289
|
transaction = Braintree::PayPalAccount.sale!(customer.paypal_accounts[0].token, :amount => "100.00")
|
@@ -8,7 +8,7 @@ describe Braintree::SamsungPayCard do
|
|
8
8
|
result = Braintree::PaymentMethod.create(
|
9
9
|
:payment_method_nonce => Braintree::Test::Nonce::SamsungPayDiscover,
|
10
10
|
:customer_id => customer.id,
|
11
|
-
:cardholder_name =>
|
11
|
+
:cardholder_name => "Jenny Block",
|
12
12
|
:billing_address => {
|
13
13
|
:first_name => "New First Name",
|
14
14
|
:last_name => "New Last Name",
|
@@ -19,7 +19,7 @@ describe Braintree::SamsungPayCard do
|
|
19
19
|
:region => "New State",
|
20
20
|
:postal_code => "56789",
|
21
21
|
:country_name => "United States of America"
|
22
|
-
}
|
22
|
+
},
|
23
23
|
)
|
24
24
|
result.should be_success
|
25
25
|
|
@@ -65,7 +65,7 @@ describe Braintree::SamsungPayCard do
|
|
65
65
|
result = Braintree::PaymentMethod.create(
|
66
66
|
:payment_method_nonce => Braintree::Test::Nonce::SamsungPayDiscover,
|
67
67
|
:customer_id => customer.id,
|
68
|
-
:cardholder_name =>
|
68
|
+
:cardholder_name => "Jenny Block",
|
69
69
|
:billing_address => {
|
70
70
|
:first_name => "New First Name",
|
71
71
|
:last_name => "New Last Name",
|
@@ -76,11 +76,11 @@ describe Braintree::SamsungPayCard do
|
|
76
76
|
:region => "New State",
|
77
77
|
:postal_code => "56789",
|
78
78
|
:country_name => "United States of America"
|
79
|
-
}
|
79
|
+
},
|
80
80
|
)
|
81
81
|
|
82
82
|
result.should be_success
|
83
|
-
result.payment_method.cardholder_name.should ==
|
83
|
+
result.payment_method.cardholder_name.should == "Jenny Block"
|
84
84
|
|
85
85
|
address = result.payment_method.billing_address
|
86
86
|
address.first_name.should == "New First Name"
|
@@ -96,7 +96,7 @@ describe Braintree::SamsungPayCard do
|
|
96
96
|
it "can search for transactions" do
|
97
97
|
transaction_create_result = Braintree::Transaction.sale(
|
98
98
|
:payment_method_nonce => Braintree::Test::Nonce::SamsungPayDiscover,
|
99
|
-
:amount =>
|
99
|
+
:amount => "47.00",
|
100
100
|
)
|
101
101
|
transaction_create_result.should be_success
|
102
102
|
transaction_id = transaction_create_result.transaction.id
|
@@ -114,8 +114,8 @@ describe Braintree::SamsungPayCard do
|
|
114
114
|
result = Braintree::Transaction.sale(
|
115
115
|
:payment_method_nonce => Braintree::Test::Nonce::SamsungPayDiscover,
|
116
116
|
:customer_id => customer.id,
|
117
|
-
:amount =>
|
118
|
-
:options => {
|
117
|
+
:amount => "47.00",
|
118
|
+
:options => {:store_in_vault => true},
|
119
119
|
)
|
120
120
|
result.should be_success
|
121
121
|
|
@@ -138,7 +138,7 @@ describe Braintree::SamsungPayCard do
|
|
138
138
|
samsung_pay_card_details.prepaid.should_not be_nil
|
139
139
|
samsung_pay_card_details.product_id.should_not be_nil
|
140
140
|
samsung_pay_card_details.source_card_last_4.should_not be_nil
|
141
|
-
samsung_pay_card_details.source_card_last_4.should ==
|
141
|
+
samsung_pay_card_details.source_card_last_4.should == "3333"
|
142
142
|
samsung_pay_card_details.token.should_not be_nil
|
143
143
|
end
|
144
144
|
end
|
@@ -12,7 +12,7 @@ describe Braintree::SettlementBatchSummary do
|
|
12
12
|
it "returns an error response if the date cannot be parsed" do
|
13
13
|
result = Braintree::SettlementBatchSummary.generate("NOT A DATE :(")
|
14
14
|
result.should_not be_success
|
15
|
-
result.errors.for(:settlement_batch_summary).on(:settlement_date).map {|e| e.code}.should include(Braintree::ErrorCodes::SettlementBatchSummary::SettlementDateIsInvalid)
|
15
|
+
result.errors.for(:settlement_batch_summary).on(:settlement_date).map { |e| e.code }.should include(Braintree::ErrorCodes::SettlementBatchSummary::SettlementDateIsInvalid)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "returns transactions settled on a given day" do
|
@@ -23,14 +23,14 @@ describe Braintree::SettlementBatchSummary do
|
|
23
23
|
:expiration_date => "05/2012",
|
24
24
|
:cardholder_name => "Sergio Ramos"
|
25
25
|
},
|
26
|
-
:options => {
|
26
|
+
:options => {:submit_for_settlement => true},
|
27
27
|
)
|
28
28
|
result = SpecHelper.settle_transaction transaction.id
|
29
|
-
settlement_date = result[:transaction][:settlement_batch_id].split(
|
29
|
+
settlement_date = result[:transaction][:settlement_batch_id].split("_").first
|
30
30
|
result = Braintree::SettlementBatchSummary.generate(settlement_date)
|
31
31
|
|
32
32
|
result.should be_success
|
33
|
-
amex_records = result.settlement_batch_summary.records.select {|row| row[:card_type] == Braintree::CreditCard::CardType::AmEx }
|
33
|
+
amex_records = result.settlement_batch_summary.records.select { |row| row[:card_type] == Braintree::CreditCard::CardType::AmEx }
|
34
34
|
amex_records.first[:count].to_i.should >= 1
|
35
35
|
amex_records.first[:amount_settled].to_i.should >= Braintree::Test::TransactionAmounts::Authorize.to_i
|
36
36
|
end
|
@@ -46,14 +46,14 @@ describe Braintree::SettlementBatchSummary do
|
|
46
46
|
:custom_fields => {
|
47
47
|
:store_me => "1"
|
48
48
|
},
|
49
|
-
:options => {
|
49
|
+
:options => {:submit_for_settlement => true},
|
50
50
|
)
|
51
51
|
result = SpecHelper.settle_transaction transaction.id
|
52
|
-
settlement_date = result[:transaction][:settlement_batch_id].split(
|
53
|
-
result = Braintree::SettlementBatchSummary.generate(settlement_date,
|
52
|
+
settlement_date = result[:transaction][:settlement_batch_id].split("_").first
|
53
|
+
result = Braintree::SettlementBatchSummary.generate(settlement_date, "store_me")
|
54
54
|
|
55
55
|
result.should be_success
|
56
|
-
amex_records = result.settlement_batch_summary.records.select {|row| row[:store_me] == "1" }
|
56
|
+
amex_records = result.settlement_batch_summary.records.select { |row| row[:store_me] == "1" }
|
57
57
|
amex_records.should_not be_empty
|
58
58
|
amex_records.first[:count].to_i.should >= 1
|
59
59
|
amex_records.first[:amount_settled].to_i.should >= Braintree::Test::TransactionAmounts::Authorize.to_i
|
@@ -8,7 +8,7 @@ describe Braintree::Subscription do
|
|
8
8
|
:credit_card => {
|
9
9
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
10
10
|
:expiration_date => "05/2010"
|
11
|
-
}
|
11
|
+
},
|
12
12
|
).credit_cards[0]
|
13
13
|
end
|
14
14
|
|
@@ -16,7 +16,7 @@ describe Braintree::Subscription do
|
|
16
16
|
it "is successful with a minimum of params" do
|
17
17
|
result = Braintree::Subscription.create(
|
18
18
|
:payment_method_token => @credit_card.token,
|
19
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
19
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
20
20
|
)
|
21
21
|
|
22
22
|
result.success?.should == true
|
@@ -47,7 +47,7 @@ describe Braintree::Subscription do
|
|
47
47
|
it "returns a transaction with billing period populated" do
|
48
48
|
result = Braintree::Subscription.create(
|
49
49
|
:payment_method_token => @credit_card.token,
|
50
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
50
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
51
51
|
)
|
52
52
|
|
53
53
|
result.success?.should == true
|
@@ -63,7 +63,7 @@ describe Braintree::Subscription do
|
|
63
63
|
result = Braintree::Subscription.create(
|
64
64
|
:payment_method_token => @credit_card.token,
|
65
65
|
:plan_id => SpecHelper::TrialPlan[:id],
|
66
|
-
:id => new_id
|
66
|
+
:id => new_id,
|
67
67
|
)
|
68
68
|
|
69
69
|
result.success?.should == true
|
@@ -80,11 +80,11 @@ describe Braintree::Subscription do
|
|
80
80
|
},
|
81
81
|
:client_token_options => {
|
82
82
|
:customer_id => @credit_card.customer_id
|
83
|
-
}
|
83
|
+
},
|
84
84
|
)
|
85
85
|
result = Braintree::Subscription.create(
|
86
86
|
:payment_method_nonce => nonce,
|
87
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
87
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
88
88
|
)
|
89
89
|
|
90
90
|
result.success?.should == true
|
@@ -97,12 +97,12 @@ describe Braintree::Subscription do
|
|
97
97
|
customer = Braintree::Customer.create!
|
98
98
|
payment_method_result = Braintree::PaymentMethod.create(
|
99
99
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
100
|
-
:customer_id => customer.id
|
100
|
+
:customer_id => customer.id,
|
101
101
|
)
|
102
102
|
|
103
103
|
result = Braintree::Subscription.create(
|
104
104
|
:payment_method_token => payment_method_result.payment_method.token,
|
105
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
105
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
106
106
|
)
|
107
107
|
|
108
108
|
result.should be_success
|
@@ -114,7 +114,7 @@ describe Braintree::Subscription do
|
|
114
114
|
customer = Braintree::Customer.create!
|
115
115
|
payment_method_result = Braintree::PaymentMethod.create(
|
116
116
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
117
|
-
:customer_id => customer.id
|
117
|
+
:customer_id => customer.id,
|
118
118
|
)
|
119
119
|
|
120
120
|
result = Braintree::Subscription.create(
|
@@ -139,11 +139,11 @@ describe Braintree::Subscription do
|
|
139
139
|
customer = Braintree::Customer.create!
|
140
140
|
result = Braintree::Subscription.create(
|
141
141
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
142
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
142
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
143
143
|
)
|
144
144
|
|
145
145
|
result.should_not be_success
|
146
|
-
result.errors.for(:subscription).on(:payment_method_nonce).first.code.should ==
|
146
|
+
result.errors.for(:subscription).on(:payment_method_nonce).first.code.should == "91925"
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
@@ -151,7 +151,7 @@ describe Braintree::Subscription do
|
|
151
151
|
it "inherits from the plan if not provided" do
|
152
152
|
result = Braintree::Subscription.create(
|
153
153
|
:payment_method_token => @credit_card.token,
|
154
|
-
:plan_id => SpecHelper::BillingDayOfMonthPlan[:id]
|
154
|
+
:plan_id => SpecHelper::BillingDayOfMonthPlan[:id],
|
155
155
|
)
|
156
156
|
|
157
157
|
result.success?.should == true
|
@@ -162,7 +162,7 @@ describe Braintree::Subscription do
|
|
162
162
|
result = Braintree::Subscription.create(
|
163
163
|
:payment_method_token => @credit_card.token,
|
164
164
|
:plan_id => SpecHelper::BillingDayOfMonthPlan[:id],
|
165
|
-
:billing_day_of_month => 25
|
165
|
+
:billing_day_of_month => 25,
|
166
166
|
)
|
167
167
|
|
168
168
|
result.success?.should == true
|
@@ -175,7 +175,7 @@ describe Braintree::Subscription do
|
|
175
175
|
:plan_id => SpecHelper::BillingDayOfMonthPlan[:id],
|
176
176
|
:options => {
|
177
177
|
:start_immediately => true
|
178
|
-
}
|
178
|
+
},
|
179
179
|
)
|
180
180
|
|
181
181
|
result.success?.should == true
|
@@ -188,7 +188,7 @@ describe Braintree::Subscription do
|
|
188
188
|
result = Braintree::Subscription.create(
|
189
189
|
:payment_method_token => @credit_card.token,
|
190
190
|
:plan_id => SpecHelper::BillingDayOfMonthPlan[:id],
|
191
|
-
:first_billing_date => Date.today + 3
|
191
|
+
:first_billing_date => Date.today + 3,
|
192
192
|
)
|
193
193
|
|
194
194
|
result.success?.should == true
|
@@ -200,7 +200,7 @@ describe Braintree::Subscription do
|
|
200
200
|
result = Braintree::Subscription.create(
|
201
201
|
:payment_method_token => @credit_card.token,
|
202
202
|
:plan_id => SpecHelper::BillingDayOfMonthPlan[:id],
|
203
|
-
:first_billing_date => Date.today - 3
|
203
|
+
:first_billing_date => Date.today - 3,
|
204
204
|
)
|
205
205
|
|
206
206
|
result.success?.should == false
|
@@ -212,7 +212,7 @@ describe Braintree::Subscription do
|
|
212
212
|
it "defaults to the default merchant account if no merchant_account_id is provided" do
|
213
213
|
result = Braintree::Subscription.create(
|
214
214
|
:payment_method_token => @credit_card.token,
|
215
|
-
:plan_id => SpecHelper::TrialPlan[:id]
|
215
|
+
:plan_id => SpecHelper::TrialPlan[:id],
|
216
216
|
)
|
217
217
|
|
218
218
|
result.success?.should == true
|
@@ -223,7 +223,7 @@ describe Braintree::Subscription do
|
|
223
223
|
result = Braintree::Subscription.create(
|
224
224
|
:payment_method_token => @credit_card.token,
|
225
225
|
:plan_id => SpecHelper::TrialPlan[:id],
|
226
|
-
:merchant_account_id => SpecHelper::NonDefaultMerchantAccountId
|
226
|
+
:merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
227
227
|
)
|
228
228
|
|
229
229
|
result.success?.should == true
|
@@ -236,7 +236,7 @@ describe Braintree::Subscription do
|
|
236
236
|
result = Braintree::Subscription.create(
|
237
237
|
:payment_method_token => @credit_card.token,
|
238
238
|
:plan_id => SpecHelper::TrialPlan[:id],
|
239
|
-
:number_of_billing_cycles => 10
|
239
|
+
:number_of_billing_cycles => 10,
|
240
240
|
)
|
241
241
|
|
242
242
|
result.success?.should == true
|
@@ -247,7 +247,7 @@ describe Braintree::Subscription do
|
|
247
247
|
result = Braintree::Subscription.create(
|
248
248
|
:payment_method_token => @credit_card.token,
|
249
249
|
:plan_id => SpecHelper::TrialPlan[:id],
|
250
|
-
:never_expires => true
|
250
|
+
:never_expires => true,
|
251
251
|
)
|
252
252
|
|
253
253
|
result.success?.should == true
|
@@ -260,7 +260,7 @@ describe Braintree::Subscription do
|
|
260
260
|
it "with no trial" do
|
261
261
|
result = Braintree::Subscription.create(
|
262
262
|
:payment_method_token => @credit_card.token,
|
263
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
263
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
264
264
|
)
|
265
265
|
|
266
266
|
result.subscription.trial_period.should == false
|
@@ -271,7 +271,7 @@ describe Braintree::Subscription do
|
|
271
271
|
it "with a trial" do
|
272
272
|
result = Braintree::Subscription.create(
|
273
273
|
:payment_method_token => @credit_card.token,
|
274
|
-
:plan_id => SpecHelper::TrialPlan[:id]
|
274
|
+
:plan_id => SpecHelper::TrialPlan[:id],
|
275
275
|
)
|
276
276
|
|
277
277
|
result.subscription.trial_period.should == true
|
@@ -284,7 +284,7 @@ describe Braintree::Subscription do
|
|
284
284
|
:payment_method_token => @credit_card.token,
|
285
285
|
:plan_id => SpecHelper::TrialPlan[:id],
|
286
286
|
:trial_duration => 5,
|
287
|
-
:trial_duration_unit => Braintree::Subscription::TrialDurationUnit::Month
|
287
|
+
:trial_duration_unit => Braintree::Subscription::TrialDurationUnit::Month,
|
288
288
|
)
|
289
289
|
|
290
290
|
result.subscription.trial_period.should == true
|
@@ -296,7 +296,7 @@ describe Braintree::Subscription do
|
|
296
296
|
result = Braintree::Subscription.create(
|
297
297
|
:payment_method_token => @credit_card.token,
|
298
298
|
:plan_id => SpecHelper::TrialPlan[:id],
|
299
|
-
:trial_period => false
|
299
|
+
:trial_period => false,
|
300
300
|
)
|
301
301
|
|
302
302
|
result.subscription.trial_period.should == false
|
@@ -305,7 +305,7 @@ describe Braintree::Subscription do
|
|
305
305
|
it "doesn't create a transaction if there's a trial period" do
|
306
306
|
result = Braintree::Subscription.create(
|
307
307
|
:payment_method_token => @credit_card.token,
|
308
|
-
:plan_id => SpecHelper::TrialPlan[:id]
|
308
|
+
:plan_id => SpecHelper::TrialPlan[:id],
|
309
309
|
)
|
310
310
|
|
311
311
|
result.subscription.transactions.size.should == 0
|
@@ -316,7 +316,7 @@ describe Braintree::Subscription do
|
|
316
316
|
it "creates a transaction if no trial period" do
|
317
317
|
result = Braintree::Subscription.create(
|
318
318
|
:payment_method_token => @credit_card.token,
|
319
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
319
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
320
320
|
)
|
321
321
|
|
322
322
|
result.subscription.transactions.size.should == 1
|
@@ -330,7 +330,7 @@ describe Braintree::Subscription do
|
|
330
330
|
result = Braintree::Subscription.create(
|
331
331
|
:payment_method_token => @credit_card.token,
|
332
332
|
:plan_id => SpecHelper::TriallessPlan[:id],
|
333
|
-
:price => Braintree::Test::TransactionAmounts::Decline
|
333
|
+
:price => Braintree::Test::TransactionAmounts::Decline,
|
334
334
|
)
|
335
335
|
|
336
336
|
result.success?.should be(false)
|
@@ -343,7 +343,7 @@ describe Braintree::Subscription do
|
|
343
343
|
it "defaults to the plan's price" do
|
344
344
|
result = Braintree::Subscription.create(
|
345
345
|
:payment_method_token => @credit_card.token,
|
346
|
-
:plan_id => SpecHelper::TrialPlan[:id]
|
346
|
+
:plan_id => SpecHelper::TrialPlan[:id],
|
347
347
|
)
|
348
348
|
|
349
349
|
result.subscription.price.should == SpecHelper::TrialPlan[:price]
|
@@ -353,7 +353,7 @@ describe Braintree::Subscription do
|
|
353
353
|
result = Braintree::Subscription.create(
|
354
354
|
:payment_method_token => @credit_card.token,
|
355
355
|
:plan_id => SpecHelper::TrialPlan[:id],
|
356
|
-
:price => 98.76
|
356
|
+
:price => 98.76,
|
357
357
|
)
|
358
358
|
|
359
359
|
result.subscription.price.should == BigDecimal("98.76")
|
@@ -366,7 +366,7 @@ describe Braintree::Subscription do
|
|
366
366
|
result = Braintree::Subscription.create(
|
367
367
|
:payment_method_token => @credit_card.token,
|
368
368
|
:plan_id => SpecHelper::TrialPlan[:id],
|
369
|
-
:id => "invalid token"
|
369
|
+
:id => "invalid token",
|
370
370
|
)
|
371
371
|
result.success?.should == false
|
372
372
|
result.errors.for(:subscription).on(:id)[0].message.should == "ID is invalid (use only letters, numbers, '-', and '_')."
|
@@ -377,14 +377,14 @@ describe Braintree::Subscription do
|
|
377
377
|
result = Braintree::Subscription.create(
|
378
378
|
:payment_method_token => @credit_card.token,
|
379
379
|
:plan_id => SpecHelper::TrialPlan[:id],
|
380
|
-
:id => duplicate_token
|
380
|
+
:id => duplicate_token,
|
381
381
|
)
|
382
382
|
result.success?.should == true
|
383
383
|
|
384
384
|
result = Braintree::Subscription.create(
|
385
385
|
:payment_method_token => @credit_card.token,
|
386
386
|
:plan_id => SpecHelper::TrialPlan[:id],
|
387
|
-
:id => duplicate_token
|
387
|
+
:id => duplicate_token,
|
388
388
|
)
|
389
389
|
result.success?.should == false
|
390
390
|
result.errors.for(:subscription).on(:id)[0].message.should == "ID has already been taken."
|
@@ -395,7 +395,7 @@ describe Braintree::Subscription do
|
|
395
395
|
:payment_method_token => @credit_card.token,
|
396
396
|
:plan_id => SpecHelper::TrialPlan[:id],
|
397
397
|
:trial_period => true,
|
398
|
-
:trial_duration => nil
|
398
|
+
:trial_duration => nil,
|
399
399
|
)
|
400
400
|
result.success?.should == false
|
401
401
|
result.errors.for(:subscription).on(:trial_duration)[0].message.should == "Trial Duration is required."
|
@@ -407,7 +407,7 @@ describe Braintree::Subscription do
|
|
407
407
|
:plan_id => SpecHelper::TrialPlan[:id],
|
408
408
|
:trial_period => true,
|
409
409
|
:trial_duration => 2,
|
410
|
-
:trial_duration_unit => nil
|
410
|
+
:trial_duration_unit => nil,
|
411
411
|
)
|
412
412
|
result.success?.should == false
|
413
413
|
result.errors.for(:subscription).on(:trial_duration_unit)[0].message.should == "Trial Duration Unit is invalid."
|
@@ -419,7 +419,7 @@ describe Braintree::Subscription do
|
|
419
419
|
result = Braintree::Subscription.create(
|
420
420
|
:payment_method_token => @credit_card.token,
|
421
421
|
:plan_id => SpecHelper::AddOnDiscountPlan[:id],
|
422
|
-
:options => {:do_not_inherit_add_ons_or_discounts => true}
|
422
|
+
:options => {:do_not_inherit_add_ons_or_discounts => true},
|
423
423
|
)
|
424
424
|
result.success?.should == true
|
425
425
|
|
@@ -432,7 +432,7 @@ describe Braintree::Subscription do
|
|
432
432
|
it "inherits the add_ons and discounts from the plan when not specified" do
|
433
433
|
result = Braintree::Subscription.create(
|
434
434
|
:payment_method_token => @credit_card.token,
|
435
|
-
:plan_id => SpecHelper::AddOnDiscountPlan[:id]
|
435
|
+
:plan_id => SpecHelper::AddOnDiscountPlan[:id],
|
436
436
|
)
|
437
437
|
result.success?.should == true
|
438
438
|
|
@@ -496,7 +496,7 @@ describe Braintree::Subscription do
|
|
496
496
|
:never_expires => true
|
497
497
|
}
|
498
498
|
]
|
499
|
-
}
|
499
|
+
},
|
500
500
|
)
|
501
501
|
result.success?.should == true
|
502
502
|
|
@@ -542,7 +542,7 @@ describe Braintree::Subscription do
|
|
542
542
|
},
|
543
543
|
:discounts => {
|
544
544
|
:remove => [SpecHelper::Discount7]
|
545
|
-
}
|
545
|
+
},
|
546
546
|
)
|
547
547
|
result.success?.should == true
|
548
548
|
|
@@ -570,7 +570,7 @@ describe Braintree::Subscription do
|
|
570
570
|
},
|
571
571
|
:discounts => {
|
572
572
|
:add => [{:inherited_from_id => SpecHelper::Discount15}]
|
573
|
-
}
|
573
|
+
},
|
574
574
|
)
|
575
575
|
result.success?.should == true
|
576
576
|
subscription = result.subscription
|
@@ -621,7 +621,7 @@ describe Braintree::Subscription do
|
|
621
621
|
:quantity => -10,
|
622
622
|
}
|
623
623
|
]
|
624
|
-
}
|
624
|
+
},
|
625
625
|
)
|
626
626
|
result.success?.should == false
|
627
627
|
result.errors.for(:subscription).for(:add_ons).for(:update).for_index(0).on(:amount)[0].code.should == Braintree::ErrorCodes::Subscription::Modification::AmountIsInvalid
|
@@ -635,19 +635,19 @@ describe Braintree::Subscription do
|
|
635
635
|
:payment_method_token => @credit_card.token,
|
636
636
|
:plan_id => SpecHelper::TriallessPlan[:id],
|
637
637
|
:descriptor => {
|
638
|
-
:name =>
|
639
|
-
:phone =>
|
640
|
-
}
|
638
|
+
:name => "123*123456789012345678",
|
639
|
+
:phone => "3334445555"
|
640
|
+
},
|
641
641
|
)
|
642
642
|
|
643
643
|
result.success?.should == true
|
644
|
-
result.subscription.descriptor.name.should ==
|
645
|
-
result.subscription.descriptor.phone.should ==
|
644
|
+
result.subscription.descriptor.name.should == "123*123456789012345678"
|
645
|
+
result.subscription.descriptor.phone.should == "3334445555"
|
646
646
|
|
647
647
|
result.subscription.transactions.size.should == 1
|
648
648
|
transaction = result.subscription.transactions.first
|
649
|
-
transaction.descriptor.name.should ==
|
650
|
-
transaction.descriptor.phone.should ==
|
649
|
+
transaction.descriptor.name.should == "123*123456789012345678"
|
650
|
+
transaction.descriptor.phone.should == "3334445555"
|
651
651
|
end
|
652
652
|
|
653
653
|
it "has validation errors if format is invalid" do
|
@@ -655,10 +655,10 @@ describe Braintree::Subscription do
|
|
655
655
|
:payment_method_token => @credit_card.token,
|
656
656
|
:plan_id => SpecHelper::TriallessPlan[:id],
|
657
657
|
:descriptor => {
|
658
|
-
:name =>
|
659
|
-
:phone =>
|
658
|
+
:name => "badcompanyname12*badproduct12",
|
659
|
+
:phone => "%bad4445555",
|
660
660
|
:url => "12345678901234"
|
661
|
-
}
|
661
|
+
},
|
662
662
|
)
|
663
663
|
result.success?.should == false
|
664
664
|
result.errors.for(:subscription).for(:descriptor).on(:name)[0].code.should == Braintree::ErrorCodes::Descriptor::NameFormatIsInvalid
|
@@ -672,7 +672,7 @@ describe Braintree::Subscription do
|
|
672
672
|
it "returns the subscription if valid" do
|
673
673
|
subscription = Braintree::Subscription.create!(
|
674
674
|
:payment_method_token => @credit_card.token,
|
675
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
675
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
676
676
|
)
|
677
677
|
|
678
678
|
subscription.id.should =~ /^\w{6}$/
|
@@ -695,7 +695,7 @@ describe Braintree::Subscription do
|
|
695
695
|
expect do
|
696
696
|
Braintree::Subscription.create!(
|
697
697
|
:payment_method_token => @credit_card.token,
|
698
|
-
:plan_id =>
|
698
|
+
:plan_id => "not_a_plan_id",
|
699
699
|
)
|
700
700
|
end.to raise_error(Braintree::ValidationsFailed)
|
701
701
|
end
|
@@ -705,7 +705,7 @@ describe Braintree::Subscription do
|
|
705
705
|
it "finds a subscription" do
|
706
706
|
result = Braintree::Subscription.create(
|
707
707
|
:payment_method_token => @credit_card.token,
|
708
|
-
:plan_id => SpecHelper::TrialPlan[:id]
|
708
|
+
:plan_id => SpecHelper::TrialPlan[:id],
|
709
709
|
)
|
710
710
|
result.success?.should == true
|
711
711
|
|
@@ -714,7 +714,7 @@ describe Braintree::Subscription do
|
|
714
714
|
|
715
715
|
it "raises Braintree::NotFoundError if it cannot find" do
|
716
716
|
expect {
|
717
|
-
Braintree::Subscription.find(
|
717
|
+
Braintree::Subscription.find("noSuchSubscription")
|
718
718
|
}.to raise_error(Braintree::NotFoundError, 'subscription with id "noSuchSubscription" not found')
|
719
719
|
end
|
720
720
|
end
|
@@ -724,13 +724,13 @@ describe Braintree::Subscription do
|
|
724
724
|
@subscription = Braintree::Subscription.create(
|
725
725
|
:payment_method_token => @credit_card.token,
|
726
726
|
:price => 54.32,
|
727
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
727
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
728
728
|
).subscription
|
729
729
|
end
|
730
730
|
|
731
731
|
it "allows changing the merchant_account_id" do
|
732
732
|
result = Braintree::Subscription.update(@subscription.id,
|
733
|
-
:merchant_account_id => SpecHelper::NonDefaultMerchantAccountId
|
733
|
+
:merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
734
734
|
)
|
735
735
|
|
736
736
|
result.success?.should == true
|
@@ -741,11 +741,11 @@ describe Braintree::Subscription do
|
|
741
741
|
new_credit_card = Braintree::CreditCard.create!(
|
742
742
|
:customer_id => @credit_card.customer_id,
|
743
743
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
744
|
-
:expiration_date => "05/2010"
|
744
|
+
:expiration_date => "05/2010",
|
745
745
|
)
|
746
746
|
|
747
747
|
result = Braintree::Subscription.update(@subscription.id,
|
748
|
-
:payment_method_token => new_credit_card.token
|
748
|
+
:payment_method_token => new_credit_card.token,
|
749
749
|
)
|
750
750
|
|
751
751
|
result.subscription.payment_method_token.should == new_credit_card.token
|
@@ -759,7 +759,7 @@ describe Braintree::Subscription do
|
|
759
759
|
},
|
760
760
|
:client_token_options => {
|
761
761
|
:customer_id => @credit_card.customer_id,
|
762
|
-
}
|
762
|
+
},
|
763
763
|
)
|
764
764
|
|
765
765
|
result = Braintree::Subscription.update(@subscription.id, :payment_method_nonce => nonce)
|
@@ -770,41 +770,41 @@ describe Braintree::Subscription do
|
|
770
770
|
it "allows changing the descriptors" do
|
771
771
|
result = Braintree::Subscription.update(@subscription.id,
|
772
772
|
:descriptor => {
|
773
|
-
:name =>
|
774
|
-
:phone =>
|
773
|
+
:name => "aaa*1234",
|
774
|
+
:phone => "3334443333",
|
775
775
|
:url => "ebay.com"
|
776
|
-
}
|
776
|
+
},
|
777
777
|
)
|
778
778
|
|
779
779
|
result.success?.should == true
|
780
|
-
result.subscription.descriptor.name.should ==
|
781
|
-
result.subscription.descriptor.phone.should ==
|
782
|
-
result.subscription.descriptor.url.should ==
|
780
|
+
result.subscription.descriptor.name.should == "aaa*1234"
|
781
|
+
result.subscription.descriptor.phone.should == "3334443333"
|
782
|
+
result.subscription.descriptor.url.should == "ebay.com"
|
783
783
|
end
|
784
784
|
|
785
785
|
it "allows changing the paypal description" do
|
786
786
|
customer = Braintree::Customer.create!
|
787
787
|
payment_method = Braintree::PaymentMethod.create(
|
788
788
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
789
|
-
:customer_id => customer.id
|
789
|
+
:customer_id => customer.id,
|
790
790
|
).payment_method
|
791
791
|
|
792
792
|
subscription = Braintree::Subscription.create(
|
793
793
|
:payment_method_token => payment_method.token,
|
794
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
794
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
795
795
|
).subscription
|
796
796
|
|
797
797
|
result = Braintree::Subscription.update(
|
798
798
|
subscription.id,
|
799
799
|
:options => {
|
800
800
|
:paypal => {
|
801
|
-
:description =>
|
801
|
+
:description => "A great product",
|
802
802
|
},
|
803
803
|
},
|
804
804
|
)
|
805
805
|
|
806
806
|
result.success?.should == true
|
807
|
-
result.subscription.description.should ==
|
807
|
+
result.subscription.description.should == "A great product"
|
808
808
|
end
|
809
809
|
|
810
810
|
context "when successful" do
|
@@ -813,7 +813,7 @@ describe Braintree::Subscription do
|
|
813
813
|
result = Braintree::Subscription.update(@subscription.id,
|
814
814
|
:id => new_id,
|
815
815
|
:price => 9999.88,
|
816
|
-
:plan_id => SpecHelper::TrialPlan[:id]
|
816
|
+
:plan_id => SpecHelper::TrialPlan[:id],
|
817
817
|
)
|
818
818
|
|
819
819
|
result.success?.should == true
|
@@ -825,7 +825,7 @@ describe Braintree::Subscription do
|
|
825
825
|
context "proration" do
|
826
826
|
it "prorates if there is a charge (because merchant has proration option enabled in control panel)" do
|
827
827
|
result = Braintree::Subscription.update(@subscription.id,
|
828
|
-
:price => @subscription.price.to_f + 1
|
828
|
+
:price => @subscription.price.to_f + 1,
|
829
829
|
)
|
830
830
|
|
831
831
|
result.success?.should == true
|
@@ -836,7 +836,7 @@ describe Braintree::Subscription do
|
|
836
836
|
it "allows the user to force proration if there is a charge" do
|
837
837
|
result = Braintree::Subscription.update(@subscription.id,
|
838
838
|
:price => @subscription.price.to_f + 1,
|
839
|
-
:options => {
|
839
|
+
:options => {:prorate_charges => true},
|
840
840
|
)
|
841
841
|
|
842
842
|
result.success?.should == true
|
@@ -847,7 +847,7 @@ describe Braintree::Subscription do
|
|
847
847
|
it "allows the user to prevent proration if there is a charge" do
|
848
848
|
result = Braintree::Subscription.update(@subscription.id,
|
849
849
|
:price => @subscription.price.to_f + 1,
|
850
|
-
:options => {
|
850
|
+
:options => {:prorate_charges => false},
|
851
851
|
)
|
852
852
|
|
853
853
|
result.success?.should == true
|
@@ -857,7 +857,7 @@ describe Braintree::Subscription do
|
|
857
857
|
|
858
858
|
it "doesn't prorate if price decreases" do
|
859
859
|
result = Braintree::Subscription.update(@subscription.id,
|
860
|
-
:price => @subscription.price.to_f - 1
|
860
|
+
:price => @subscription.price.to_f - 1,
|
861
861
|
)
|
862
862
|
|
863
863
|
result.success?.should == true
|
@@ -870,7 +870,7 @@ describe Braintree::Subscription do
|
|
870
870
|
:price => @subscription.price.to_f + 2100,
|
871
871
|
:options => {
|
872
872
|
:revert_subscription_on_proration_failure => false
|
873
|
-
}
|
873
|
+
},
|
874
874
|
)
|
875
875
|
|
876
876
|
result.success?.should == true
|
@@ -887,7 +887,7 @@ describe Braintree::Subscription do
|
|
887
887
|
:price => @subscription.price.to_f + 2100,
|
888
888
|
:options => {
|
889
889
|
:revert_subscription_on_proration_failure => true
|
890
|
-
}
|
890
|
+
},
|
891
891
|
)
|
892
892
|
|
893
893
|
result.success?.should == false
|
@@ -905,14 +905,14 @@ describe Braintree::Subscription do
|
|
905
905
|
before(:each) do
|
906
906
|
@subscription = Braintree::Subscription.create(
|
907
907
|
:payment_method_token => @credit_card.token,
|
908
|
-
:plan_id => SpecHelper::TrialPlan[:id]
|
908
|
+
:plan_id => SpecHelper::TrialPlan[:id],
|
909
909
|
).subscription
|
910
910
|
end
|
911
911
|
|
912
912
|
it "raises NotFoundError if the subscription can't be found" do
|
913
913
|
expect {
|
914
914
|
Braintree::Subscription.update(rand(36**9).to_s(36),
|
915
|
-
:price => 58.20
|
915
|
+
:price => 58.20,
|
916
916
|
)
|
917
917
|
}.to raise_error(Braintree::NotFoundError)
|
918
918
|
end
|
@@ -940,11 +940,11 @@ describe Braintree::Subscription do
|
|
940
940
|
duplicate = Braintree::Subscription.create(
|
941
941
|
:payment_method_token => @credit_card.token,
|
942
942
|
:plan_id => SpecHelper::TrialPlan[:id],
|
943
|
-
:id => duplicate_id
|
943
|
+
:id => duplicate_id,
|
944
944
|
)
|
945
945
|
result = Braintree::Subscription.update(
|
946
946
|
@subscription.id,
|
947
|
-
:id => duplicate_id
|
947
|
+
:id => duplicate_id,
|
948
948
|
)
|
949
949
|
result.success?.should == false
|
950
950
|
result.errors.for(:subscription).on(:id)[0].code.should == Braintree::ErrorCodes::Subscription::IdIsInUse
|
@@ -954,14 +954,14 @@ describe Braintree::Subscription do
|
|
954
954
|
subscription = Braintree::Subscription.create(
|
955
955
|
:payment_method_token => @credit_card.token,
|
956
956
|
:price => 54.32,
|
957
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
957
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
958
958
|
).subscription
|
959
959
|
|
960
960
|
result = Braintree::Subscription.cancel(subscription.id)
|
961
961
|
result.success?.should == true
|
962
962
|
|
963
963
|
result = Braintree::Subscription.update(subscription.id,
|
964
|
-
:price => 123.45
|
964
|
+
:price => 123.45,
|
965
965
|
)
|
966
966
|
result.success?.should == false
|
967
967
|
result.errors.for(:subscription)[0].code.should == Braintree::ErrorCodes::Subscription::CannotEditCanceledSubscription
|
@@ -973,12 +973,12 @@ describe Braintree::Subscription do
|
|
973
973
|
subscription = Braintree::Subscription.create(
|
974
974
|
:payment_method_token => @credit_card.token,
|
975
975
|
:plan_id => SpecHelper::TriallessPlan[:id],
|
976
|
-
:number_of_billing_cycles => 10
|
976
|
+
:number_of_billing_cycles => 10,
|
977
977
|
).subscription
|
978
978
|
|
979
979
|
result = Braintree::Subscription.update(
|
980
980
|
subscription.id,
|
981
|
-
:number_of_billing_cycles => 5
|
981
|
+
:number_of_billing_cycles => 5,
|
982
982
|
)
|
983
983
|
|
984
984
|
result.subscription.number_of_billing_cycles.should == 5
|
@@ -988,12 +988,12 @@ describe Braintree::Subscription do
|
|
988
988
|
subscription = Braintree::Subscription.create(
|
989
989
|
:payment_method_token => @credit_card.token,
|
990
990
|
:plan_id => SpecHelper::TriallessPlan[:id],
|
991
|
-
:number_of_billing_cycles => 10
|
991
|
+
:number_of_billing_cycles => 10,
|
992
992
|
).subscription
|
993
993
|
|
994
994
|
result = Braintree::Subscription.update(
|
995
995
|
subscription.id,
|
996
|
-
:never_expires => true
|
996
|
+
:never_expires => true,
|
997
997
|
)
|
998
998
|
|
999
999
|
result.success?.should == true
|
@@ -1006,7 +1006,7 @@ describe Braintree::Subscription do
|
|
1006
1006
|
it "can update add_ons and discounts" do
|
1007
1007
|
result = Braintree::Subscription.create(
|
1008
1008
|
:payment_method_token => @credit_card.token,
|
1009
|
-
:plan_id => SpecHelper::AddOnDiscountPlan[:id]
|
1009
|
+
:plan_id => SpecHelper::AddOnDiscountPlan[:id],
|
1010
1010
|
)
|
1011
1011
|
result.success?.should == true
|
1012
1012
|
subscription = result.subscription
|
@@ -1030,7 +1030,7 @@ describe Braintree::Subscription do
|
|
1030
1030
|
:quantity => 9
|
1031
1031
|
}
|
1032
1032
|
]
|
1033
|
-
}
|
1033
|
+
},
|
1034
1034
|
)
|
1035
1035
|
|
1036
1036
|
subscription = result.subscription
|
@@ -1051,7 +1051,7 @@ describe Braintree::Subscription do
|
|
1051
1051
|
it "allows adding new add_ons and discounts" do
|
1052
1052
|
subscription = Braintree::Subscription.create(
|
1053
1053
|
:payment_method_token => @credit_card.token,
|
1054
|
-
:plan_id => SpecHelper::AddOnDiscountPlan[:id]
|
1054
|
+
:plan_id => SpecHelper::AddOnDiscountPlan[:id],
|
1055
1055
|
).subscription
|
1056
1056
|
|
1057
1057
|
result = Braintree::Subscription.update(subscription.id,
|
@@ -1060,7 +1060,7 @@ describe Braintree::Subscription do
|
|
1060
1060
|
},
|
1061
1061
|
:discounts => {
|
1062
1062
|
:add => [{:inherited_from_id => SpecHelper::Discount15}]
|
1063
|
-
}
|
1063
|
+
},
|
1064
1064
|
)
|
1065
1065
|
|
1066
1066
|
result.success?.should == true
|
@@ -1100,7 +1100,7 @@ describe Braintree::Subscription do
|
|
1100
1100
|
it "allows replacing entire set of add_ons and discounts" do
|
1101
1101
|
subscription = Braintree::Subscription.create(
|
1102
1102
|
:payment_method_token => @credit_card.token,
|
1103
|
-
:plan_id => SpecHelper::AddOnDiscountPlan[:id]
|
1103
|
+
:plan_id => SpecHelper::AddOnDiscountPlan[:id],
|
1104
1104
|
).subscription
|
1105
1105
|
|
1106
1106
|
result = Braintree::Subscription.update(subscription.id,
|
@@ -1110,7 +1110,7 @@ describe Braintree::Subscription do
|
|
1110
1110
|
:discounts => {
|
1111
1111
|
:add => [{:inherited_from_id => SpecHelper::Discount15}]
|
1112
1112
|
},
|
1113
|
-
:options => {:replace_all_add_ons_and_discounts => true}
|
1113
|
+
:options => {:replace_all_add_ons_and_discounts => true},
|
1114
1114
|
)
|
1115
1115
|
|
1116
1116
|
result.success?.should == true
|
@@ -1130,7 +1130,7 @@ describe Braintree::Subscription do
|
|
1130
1130
|
it "allows deleting of add_ons and discounts" do
|
1131
1131
|
subscription = Braintree::Subscription.create(
|
1132
1132
|
:payment_method_token => @credit_card.token,
|
1133
|
-
:plan_id => SpecHelper::AddOnDiscountPlan[:id]
|
1133
|
+
:plan_id => SpecHelper::AddOnDiscountPlan[:id],
|
1134
1134
|
).subscription
|
1135
1135
|
|
1136
1136
|
result = Braintree::Subscription.update(subscription.id,
|
@@ -1139,7 +1139,7 @@ describe Braintree::Subscription do
|
|
1139
1139
|
},
|
1140
1140
|
:discounts => {
|
1141
1141
|
:remove => [SpecHelper::Discount7]
|
1142
|
-
}
|
1142
|
+
},
|
1143
1143
|
)
|
1144
1144
|
result.success?.should == true
|
1145
1145
|
|
@@ -1161,7 +1161,7 @@ describe Braintree::Subscription do
|
|
1161
1161
|
@subscription = Braintree::Subscription.create(
|
1162
1162
|
:payment_method_token => @credit_card.token,
|
1163
1163
|
:price => 54.32,
|
1164
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
1164
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
1165
1165
|
).subscription
|
1166
1166
|
end
|
1167
1167
|
|
@@ -1170,7 +1170,7 @@ describe Braintree::Subscription do
|
|
1170
1170
|
subscription = Braintree::Subscription.update!(@subscription.id,
|
1171
1171
|
:id => new_id,
|
1172
1172
|
:price => 9999.88,
|
1173
|
-
:plan_id => SpecHelper::TrialPlan[:id]
|
1173
|
+
:plan_id => SpecHelper::TrialPlan[:id],
|
1174
1174
|
)
|
1175
1175
|
|
1176
1176
|
subscription.id.should =~ /#{new_id}/
|
@@ -1181,7 +1181,7 @@ describe Braintree::Subscription do
|
|
1181
1181
|
it "raises a ValidationsFailed if invalid" do
|
1182
1182
|
expect do
|
1183
1183
|
Braintree::Subscription.update!(@subscription.id,
|
1184
|
-
:plan_id =>
|
1184
|
+
:plan_id => "not_a_plan_id",
|
1185
1185
|
)
|
1186
1186
|
end.to raise_error(Braintree::ValidationsFailed)
|
1187
1187
|
end
|
@@ -1193,7 +1193,7 @@ describe Braintree::Subscription do
|
|
1193
1193
|
subscription = Braintree::Subscription.create(
|
1194
1194
|
:payment_method_token => @credit_card.token,
|
1195
1195
|
:price => 54.32,
|
1196
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
1196
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
1197
1197
|
).subscription
|
1198
1198
|
|
1199
1199
|
result = Braintree::Subscription.cancel(subscription.id)
|
@@ -1203,7 +1203,7 @@ describe Braintree::Subscription do
|
|
1203
1203
|
|
1204
1204
|
it "returns a validation error if record not found" do
|
1205
1205
|
expect {
|
1206
|
-
r = Braintree::Subscription.cancel(
|
1206
|
+
r = Braintree::Subscription.cancel("noSuchSubscription")
|
1207
1207
|
}.to raise_error(Braintree::NotFoundError, 'subscription with id "noSuchSubscription" not found')
|
1208
1208
|
end
|
1209
1209
|
|
@@ -1211,7 +1211,7 @@ describe Braintree::Subscription do
|
|
1211
1211
|
subscription = Braintree::Subscription.create(
|
1212
1212
|
:payment_method_token => @credit_card.token,
|
1213
1213
|
:price => 54.32,
|
1214
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
1214
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
1215
1215
|
).subscription
|
1216
1216
|
|
1217
1217
|
result = Braintree::Subscription.cancel(subscription.id)
|
@@ -1229,7 +1229,7 @@ describe Braintree::Subscription do
|
|
1229
1229
|
subscription = Braintree::Subscription.create!(
|
1230
1230
|
:payment_method_token => @credit_card.token,
|
1231
1231
|
:price => 54.32,
|
1232
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
1232
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
1233
1233
|
)
|
1234
1234
|
|
1235
1235
|
updated_subscription = Braintree::Subscription.cancel!(subscription.id)
|
@@ -1244,13 +1244,13 @@ describe Braintree::Subscription do
|
|
1244
1244
|
subscription_with_trial = Braintree::Subscription.create(
|
1245
1245
|
:payment_method_token => @credit_card.token,
|
1246
1246
|
:plan_id => SpecHelper::TrialPlan[:id],
|
1247
|
-
:id => "subscription1_#{id}"
|
1247
|
+
:id => "subscription1_#{id}",
|
1248
1248
|
).subscription
|
1249
1249
|
|
1250
1250
|
subscription_without_trial = Braintree::Subscription.create(
|
1251
1251
|
:payment_method_token => @credit_card.token,
|
1252
1252
|
:plan_id => SpecHelper::TriallessPlan[:id],
|
1253
|
-
:id => "subscription2_#{id}"
|
1253
|
+
:id => "subscription2_#{id}",
|
1254
1254
|
).subscription
|
1255
1255
|
|
1256
1256
|
subscriptions_in_trial_period = Braintree::Subscription.search do |search|
|
@@ -1276,7 +1276,7 @@ describe Braintree::Subscription do
|
|
1276
1276
|
:payment_method_token => @credit_card.token,
|
1277
1277
|
:plan_id => SpecHelper::TrialPlan[:id],
|
1278
1278
|
:id => "subscription1_#{id}",
|
1279
|
-
:price => "11.38"
|
1279
|
+
:price => "11.38",
|
1280
1280
|
).subscription
|
1281
1281
|
|
1282
1282
|
collection = Braintree::Subscription.search do |search|
|
@@ -1310,13 +1310,13 @@ describe Braintree::Subscription do
|
|
1310
1310
|
subscription1 = Braintree::Subscription.create(
|
1311
1311
|
:payment_method_token => @credit_card.token,
|
1312
1312
|
:plan_id => SpecHelper::TrialPlan[:id],
|
1313
|
-
:id => "subscription1_#{id}"
|
1313
|
+
:id => "subscription1_#{id}",
|
1314
1314
|
).subscription
|
1315
1315
|
|
1316
1316
|
subscription2 = Braintree::Subscription.create(
|
1317
1317
|
:payment_method_token => @credit_card.token,
|
1318
1318
|
:plan_id => SpecHelper::TrialPlan[:id],
|
1319
|
-
:id => "subscription2_#{id}"
|
1319
|
+
:id => "subscription2_#{id}",
|
1320
1320
|
).subscription
|
1321
1321
|
|
1322
1322
|
collection = Braintree::Subscription.search do |search|
|
@@ -1334,14 +1334,14 @@ describe Braintree::Subscription do
|
|
1334
1334
|
:payment_method_token => @credit_card.token,
|
1335
1335
|
:plan_id => SpecHelper::TrialPlan[:id],
|
1336
1336
|
:merchant_account_id => SpecHelper::DefaultMerchantAccountId,
|
1337
|
-
:price => "1"
|
1337
|
+
:price => "1",
|
1338
1338
|
).subscription
|
1339
1339
|
|
1340
1340
|
subscription2 = Braintree::Subscription.create(
|
1341
1341
|
:payment_method_token => @credit_card.token,
|
1342
1342
|
:plan_id => SpecHelper::TrialPlan[:id],
|
1343
1343
|
:merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
1344
|
-
:price => "1"
|
1344
|
+
:price => "1",
|
1345
1345
|
).subscription
|
1346
1346
|
|
1347
1347
|
collection = Braintree::Subscription.search do |search|
|
@@ -1367,13 +1367,13 @@ describe Braintree::Subscription do
|
|
1367
1367
|
trialless_subscription = Braintree::Subscription.create(
|
1368
1368
|
:payment_method_token => @credit_card.token,
|
1369
1369
|
:plan_id => SpecHelper::TriallessPlan[:id],
|
1370
|
-
:price => "2"
|
1370
|
+
:price => "2",
|
1371
1371
|
).subscription
|
1372
1372
|
|
1373
1373
|
trial_subscription = Braintree::Subscription.create(
|
1374
1374
|
:payment_method_token => @credit_card.token,
|
1375
1375
|
:plan_id => SpecHelper::TrialPlan[:id],
|
1376
|
-
:price => "2"
|
1376
|
+
:price => "2",
|
1377
1377
|
).subscription
|
1378
1378
|
|
1379
1379
|
collection = Braintree::Subscription.search do |search|
|
@@ -1391,13 +1391,13 @@ describe Braintree::Subscription do
|
|
1391
1391
|
subscription_500 = Braintree::Subscription.create(
|
1392
1392
|
:payment_method_token => @credit_card.token,
|
1393
1393
|
:plan_id => SpecHelper::TrialPlan[:id],
|
1394
|
-
:price => "5.00"
|
1394
|
+
:price => "5.00",
|
1395
1395
|
).subscription
|
1396
1396
|
|
1397
1397
|
subscription_501 = Braintree::Subscription.create(
|
1398
1398
|
:payment_method_token => @credit_card.token,
|
1399
1399
|
:plan_id => SpecHelper::TrialPlan[:id],
|
1400
|
-
:price => "5.01"
|
1400
|
+
:price => "5.01",
|
1401
1401
|
).subscription
|
1402
1402
|
|
1403
1403
|
collection = Braintree::Subscription.search do |search|
|
@@ -1414,13 +1414,13 @@ describe Braintree::Subscription do
|
|
1414
1414
|
active_subscription = Braintree::Subscription.create(
|
1415
1415
|
:payment_method_token => @credit_card.token,
|
1416
1416
|
:plan_id => SpecHelper::TrialPlan[:id],
|
1417
|
-
:price => "6"
|
1417
|
+
:price => "6",
|
1418
1418
|
).subscription
|
1419
1419
|
|
1420
1420
|
past_due_subscription = Braintree::Subscription.create(
|
1421
1421
|
:payment_method_token => @credit_card.token,
|
1422
1422
|
:plan_id => SpecHelper::TrialPlan[:id],
|
1423
|
-
:price => "6"
|
1423
|
+
:price => "6",
|
1424
1424
|
).subscription
|
1425
1425
|
|
1426
1426
|
SpecHelper.make_past_due(past_due_subscription, 5)
|
@@ -1441,7 +1441,7 @@ describe Braintree::Subscription do
|
|
1441
1441
|
it "passes a smoke test" do
|
1442
1442
|
subscription = Braintree::Subscription.create(
|
1443
1443
|
:payment_method_token => @credit_card.token,
|
1444
|
-
:plan_id => SpecHelper::TrialPlan[:id]
|
1444
|
+
:plan_id => SpecHelper::TrialPlan[:id],
|
1445
1445
|
).subscription
|
1446
1446
|
|
1447
1447
|
collection = Braintree::Subscription.search do |search|
|
@@ -1461,19 +1461,19 @@ describe Braintree::Subscription do
|
|
1461
1461
|
subscription_5 = Braintree::Subscription.create(
|
1462
1462
|
:payment_method_token => @credit_card.token,
|
1463
1463
|
:plan_id => SpecHelper::TrialPlan[:id],
|
1464
|
-
:number_of_billing_cycles => 5
|
1464
|
+
:number_of_billing_cycles => 5,
|
1465
1465
|
).subscription
|
1466
1466
|
|
1467
1467
|
subscription_9 = Braintree::Subscription.create(
|
1468
1468
|
:payment_method_token => @credit_card.token,
|
1469
1469
|
:plan_id => SpecHelper::TriallessPlan[:id],
|
1470
|
-
:number_of_billing_cycles => 10
|
1470
|
+
:number_of_billing_cycles => 10,
|
1471
1471
|
).subscription
|
1472
1472
|
|
1473
1473
|
subscription_15 = Braintree::Subscription.create(
|
1474
1474
|
:payment_method_token => @credit_card.token,
|
1475
1475
|
:plan_id => SpecHelper::TriallessPlan[:id],
|
1476
|
-
:number_of_billing_cycles => 15
|
1476
|
+
:number_of_billing_cycles => 15,
|
1477
1477
|
).subscription
|
1478
1478
|
|
1479
1479
|
collection = Braintree::Subscription.search do |search|
|
@@ -1490,12 +1490,12 @@ describe Braintree::Subscription do
|
|
1490
1490
|
it "returns matching results" do
|
1491
1491
|
matching_subscription = Braintree::Subscription.create(
|
1492
1492
|
:payment_method_token => @credit_card.token,
|
1493
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
1493
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
1494
1494
|
).subscription
|
1495
1495
|
|
1496
1496
|
non_matching_subscription = Braintree::Subscription.create(
|
1497
1497
|
:payment_method_token => @credit_card.token,
|
1498
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
1498
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
1499
1499
|
).subscription
|
1500
1500
|
|
1501
1501
|
collection = Braintree::Subscription.search do |search|
|
@@ -1511,12 +1511,12 @@ describe Braintree::Subscription do
|
|
1511
1511
|
it "returns matching results" do
|
1512
1512
|
matching_subscription = Braintree::Subscription.create(
|
1513
1513
|
:payment_method_token => @credit_card.token,
|
1514
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
1514
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
1515
1515
|
).subscription
|
1516
1516
|
|
1517
1517
|
non_matching_subscription = Braintree::Subscription.create(
|
1518
1518
|
:payment_method_token => @credit_card.token,
|
1519
|
-
:plan_id => SpecHelper::TrialPlan[:id]
|
1519
|
+
:plan_id => SpecHelper::TrialPlan[:id],
|
1520
1520
|
).subscription
|
1521
1521
|
|
1522
1522
|
five_days_from_now = Time.now + (5 * 24 * 60 * 60)
|
@@ -1533,7 +1533,7 @@ describe Braintree::Subscription do
|
|
1533
1533
|
before(:each) do
|
1534
1534
|
@subscription = Braintree::Subscription.create(
|
1535
1535
|
:payment_method_token => @credit_card.token,
|
1536
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
1536
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
1537
1537
|
).subscription
|
1538
1538
|
@created_at = @subscription.created_at
|
1539
1539
|
end
|
@@ -1545,7 +1545,7 @@ describe Braintree::Subscription do
|
|
1545
1545
|
search.id.is @subscription.id
|
1546
1546
|
search.created_at.between(
|
1547
1547
|
@created_at - 60,
|
1548
|
-
@created_at + 60
|
1548
|
+
@created_at + 60,
|
1549
1549
|
)
|
1550
1550
|
end
|
1551
1551
|
|
@@ -1578,7 +1578,7 @@ describe Braintree::Subscription do
|
|
1578
1578
|
search.id.is @subscription.id
|
1579
1579
|
search.created_at.between(
|
1580
1580
|
@created_at + 300,
|
1581
|
-
@created_at + 400
|
1581
|
+
@created_at + 400,
|
1582
1582
|
)
|
1583
1583
|
end
|
1584
1584
|
|
@@ -1602,7 +1602,7 @@ describe Braintree::Subscription do
|
|
1602
1602
|
search.id.is @subscription.id
|
1603
1603
|
search.created_at.between(
|
1604
1604
|
now - 60,
|
1605
|
-
now + 60
|
1605
|
+
now + 60,
|
1606
1606
|
)
|
1607
1607
|
end
|
1608
1608
|
|
@@ -1641,7 +1641,7 @@ describe Braintree::Subscription do
|
|
1641
1641
|
search.id.is @subscription.id
|
1642
1642
|
search.created_at.between(
|
1643
1643
|
now + 300,
|
1644
|
-
now + 400
|
1644
|
+
now + 400,
|
1645
1645
|
)
|
1646
1646
|
end
|
1647
1647
|
|
@@ -1653,7 +1653,7 @@ describe Braintree::Subscription do
|
|
1653
1653
|
search.id.is @subscription.id
|
1654
1654
|
search.created_at.between(
|
1655
1655
|
Date.today - 1,
|
1656
|
-
Date.today + 1
|
1656
|
+
Date.today + 1,
|
1657
1657
|
)
|
1658
1658
|
end
|
1659
1659
|
|
@@ -1670,7 +1670,7 @@ describe Braintree::Subscription do
|
|
1670
1670
|
collection = Braintree::Subscription.search
|
1671
1671
|
collection.maximum_size.should > 100
|
1672
1672
|
|
1673
|
-
subscriptions_ids = collection.map {|t| t.id }.uniq.compact
|
1673
|
+
subscriptions_ids = collection.map { |t| t.id }.uniq.compact
|
1674
1674
|
subscriptions_ids.size.should == collection.maximum_size
|
1675
1675
|
end
|
1676
1676
|
end
|
@@ -1679,7 +1679,7 @@ describe Braintree::Subscription do
|
|
1679
1679
|
it "is successful with only subscription id" do
|
1680
1680
|
subscription = Braintree::Subscription.create(
|
1681
1681
|
:payment_method_token => @credit_card.token,
|
1682
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
1682
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
1683
1683
|
).subscription
|
1684
1684
|
SpecHelper.make_past_due(subscription)
|
1685
1685
|
|
@@ -1697,7 +1697,7 @@ describe Braintree::Subscription do
|
|
1697
1697
|
it "is successful with subscription id and amount" do
|
1698
1698
|
subscription = Braintree::Subscription.create(
|
1699
1699
|
:payment_method_token => @credit_card.token,
|
1700
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
1700
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
1701
1701
|
).subscription
|
1702
1702
|
SpecHelper.make_past_due(subscription)
|
1703
1703
|
|
@@ -1715,7 +1715,7 @@ describe Braintree::Subscription do
|
|
1715
1715
|
it "is successful with subscription id and submit_for_settlement" do
|
1716
1716
|
subscription = Braintree::Subscription.create(
|
1717
1717
|
:payment_method_token => @credit_card.token,
|
1718
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
1718
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
1719
1719
|
).subscription
|
1720
1720
|
SpecHelper.make_past_due(subscription)
|
1721
1721
|
|
@@ -1733,7 +1733,7 @@ describe Braintree::Subscription do
|
|
1733
1733
|
it "is successful with subscription id, amount and submit_for_settlement" do
|
1734
1734
|
subscription = Braintree::Subscription.create(
|
1735
1735
|
:payment_method_token => @credit_card.token,
|
1736
|
-
:plan_id => SpecHelper::TriallessPlan[:id]
|
1736
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
1737
1737
|
).subscription
|
1738
1738
|
SpecHelper.make_past_due(subscription)
|
1739
1739
|
|