braintree 2.104.1 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/braintree.gemspec +7 -4
  4. data/lib/braintree.rb +7 -18
  5. data/lib/braintree/account_updater_daily_report.rb +1 -1
  6. data/lib/braintree/address.rb +1 -23
  7. data/lib/braintree/apple_pay.rb +1 -1
  8. data/lib/braintree/apple_pay_card.rb +1 -1
  9. data/lib/braintree/apple_pay_options.rb +1 -1
  10. data/lib/braintree/authorization_adjustment.rb +1 -1
  11. data/lib/braintree/base_module.rb +6 -0
  12. data/lib/braintree/bin_data.rb +9 -2
  13. data/lib/braintree/client_token.rb +1 -1
  14. data/lib/braintree/configuration.rb +12 -12
  15. data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
  16. data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
  17. data/lib/braintree/credit_card.rb +2 -77
  18. data/lib/braintree/credit_card_gateway.rb +7 -36
  19. data/lib/braintree/credit_card_verification.rb +18 -5
  20. data/lib/braintree/credit_card_verification_search.rb +1 -1
  21. data/lib/braintree/customer.rb +5 -76
  22. data/lib/braintree/customer_gateway.rb +0 -23
  23. data/lib/braintree/customer_search.rb +1 -1
  24. data/lib/braintree/disbursement.rb +1 -1
  25. data/lib/braintree/dispute.rb +2 -8
  26. data/lib/braintree/dispute/{history_event.rb → status_history.rb} +3 -1
  27. data/lib/braintree/dispute_gateway.rb +4 -9
  28. data/lib/braintree/dispute_search.rb +2 -2
  29. data/lib/braintree/document_upload.rb +1 -1
  30. data/lib/braintree/error_codes.rb +151 -170
  31. data/lib/braintree/exceptions.rb +5 -3
  32. data/lib/braintree/gateway.rb +0 -14
  33. data/lib/braintree/{android_pay_card.rb → google_pay_card.rb} +2 -3
  34. data/lib/braintree/granted_payment_instrument_update.rb +1 -1
  35. data/lib/braintree/graphql_client.rb +7 -7
  36. data/lib/braintree/http.rb +3 -3
  37. data/lib/braintree/local_payment_completed.rb +1 -1
  38. data/lib/braintree/local_payment_reversed.rb +19 -0
  39. data/lib/braintree/merchant.rb +1 -1
  40. data/lib/braintree/merchant_account.rb +1 -1
  41. data/lib/braintree/merchant_account_gateway.rb +3 -1
  42. data/lib/braintree/merchant_gateway.rb +1 -1
  43. data/lib/braintree/modification.rb +1 -1
  44. data/lib/braintree/oauth_credentials.rb +1 -1
  45. data/lib/braintree/oauth_gateway.rb +5 -5
  46. data/lib/braintree/payment_instrument_type.rb +10 -14
  47. data/lib/braintree/payment_method_gateway.rb +8 -13
  48. data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
  49. data/lib/braintree/payment_method_parser.rb +1 -8
  50. data/lib/braintree/plan.rb +1 -1
  51. data/lib/braintree/processor_response_types.rb +3 -3
  52. data/lib/braintree/resource_collection.rb +8 -3
  53. data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
  54. data/lib/braintree/risk_data.rb +3 -1
  55. data/lib/braintree/samsung_pay_card.rb +1 -1
  56. data/lib/braintree/settlement_batch_summary.rb +2 -2
  57. data/lib/braintree/subscription.rb +11 -11
  58. data/lib/braintree/successful_result.rb +0 -1
  59. data/lib/braintree/test/credit_card.rb +1 -0
  60. data/lib/braintree/test/nonce.rb +4 -23
  61. data/lib/braintree/three_d_secure_info.rb +22 -12
  62. data/lib/braintree/transaction.rb +44 -104
  63. data/lib/braintree/transaction/disbursement_details.rb +1 -0
  64. data/lib/braintree/transaction/{android_pay_details.rb → google_pay_details.rb} +1 -1
  65. data/lib/braintree/transaction/installment.rb +28 -0
  66. data/lib/braintree/transaction/installment/adjustment.rb +33 -0
  67. data/lib/braintree/transaction/paypal_details.rb +1 -0
  68. data/lib/braintree/transaction/subscription_details.rb +2 -0
  69. data/lib/braintree/transaction_gateway.rb +37 -25
  70. data/lib/braintree/transaction_line_item.rb +1 -1
  71. data/lib/braintree/transaction_search.rb +3 -2
  72. data/lib/braintree/unknown_payment_method.rb +1 -1
  73. data/lib/braintree/us_bank_account.rb +3 -3
  74. data/lib/braintree/us_bank_account_verification.rb +1 -1
  75. data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
  76. data/lib/braintree/util.rb +21 -6
  77. data/lib/braintree/venmo_account.rb +1 -1
  78. data/lib/braintree/version.rb +3 -3
  79. data/lib/braintree/visa_checkout_card.rb +2 -2
  80. data/lib/braintree/webhook_notification.rb +28 -29
  81. data/lib/braintree/webhook_notification_gateway.rb +5 -5
  82. data/lib/braintree/webhook_testing_gateway.rb +10 -43
  83. data/lib/braintree/xml/generator.rb +5 -4
  84. data/lib/braintree/xml/libxml.rb +1 -0
  85. data/lib/braintree/xml/parser.rb +21 -44
  86. data/spec/integration/braintree/add_on_spec.rb +1 -1
  87. data/spec/integration/braintree/address_spec.rb +26 -113
  88. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  89. data/spec/integration/braintree/apple_pay_spec.rb +3 -3
  90. data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
  91. data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
  92. data/spec/integration/braintree/client_api/spec_helper.rb +5 -31
  93. data/spec/integration/braintree/credit_card_spec.rb +130 -593
  94. data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
  95. data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
  96. data/spec/integration/braintree/customer_search_spec.rb +8 -8
  97. data/spec/integration/braintree/customer_spec.rb +336 -509
  98. data/spec/integration/braintree/dispute_search_spec.rb +6 -6
  99. data/spec/integration/braintree/dispute_spec.rb +6 -7
  100. data/spec/integration/braintree/error_codes_spec.rb +1 -1
  101. data/spec/integration/braintree/http_spec.rb +2 -2
  102. data/spec/integration/braintree/merchant_account_spec.rb +25 -26
  103. data/spec/integration/braintree/merchant_spec.rb +14 -14
  104. data/spec/integration/braintree/oauth_spec.rb +11 -11
  105. data/spec/integration/braintree/payment_method_nonce_spec.rb +12 -12
  106. data/spec/integration/braintree/payment_method_spec.rb +403 -269
  107. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +17 -13
  108. data/spec/integration/braintree/paypal_account_spec.rb +28 -28
  109. data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
  110. data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
  111. data/spec/integration/braintree/subscription_spec.rb +144 -149
  112. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  113. data/spec/integration/braintree/test_transaction_spec.rb +10 -10
  114. data/spec/integration/braintree/transaction_search_spec.rb +96 -70
  115. data/spec/integration/braintree/transaction_spec.rb +832 -904
  116. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -26
  117. data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
  118. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
  119. data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
  120. data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
  121. data/spec/integration/spec_helper.rb +10 -7
  122. data/spec/oauth_test_helper.rb +1 -1
  123. data/spec/script/httpsd.rb +6 -6
  124. data/spec/spec_helper.rb +6 -14
  125. data/spec/unit/braintree/address_spec.rb +1 -9
  126. data/spec/unit/braintree/apple_pay_card_spec.rb +1 -1
  127. data/spec/unit/braintree/client_token_spec.rb +2 -2
  128. data/spec/unit/braintree/configuration_spec.rb +42 -42
  129. data/spec/unit/braintree/credit_card_spec.rb +9 -28
  130. data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
  131. data/spec/unit/braintree/credit_card_verification_spec.rb +8 -4
  132. data/spec/unit/braintree/customer_spec.rb +5 -16
  133. data/spec/unit/braintree/disbursement_spec.rb +7 -7
  134. data/spec/unit/braintree/dispute_spec.rb +9 -20
  135. data/spec/unit/braintree/error_result_spec.rb +5 -5
  136. data/spec/unit/braintree/errors_spec.rb +8 -8
  137. data/spec/unit/braintree/http_spec.rb +8 -8
  138. data/spec/unit/braintree/merchant_account_spec.rb +1 -1
  139. data/spec/unit/braintree/payment_method_spec.rb +1 -1
  140. data/spec/unit/braintree/paypal_account_spec.rb +2 -2
  141. data/spec/unit/braintree/resource_collection_spec.rb +30 -1
  142. data/spec/unit/braintree/risk_data_spec.rb +9 -5
  143. data/spec/unit/braintree/subscription_search_spec.rb +1 -1
  144. data/spec/unit/braintree/successful_result_spec.rb +1 -1
  145. data/spec/unit/braintree/three_d_secure_info_spec.rb +32 -14
  146. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +3 -3
  147. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  148. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  149. data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
  150. data/spec/unit/braintree/transaction/paypal_details_spec.rb +3 -1
  151. data/spec/unit/braintree/transaction_search_spec.rb +12 -12
  152. data/spec/unit/braintree/transaction_spec.rb +25 -51
  153. data/spec/unit/braintree/util_spec.rb +55 -21
  154. data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
  155. data/spec/unit/braintree/webhook_notification_spec.rb +73 -57
  156. data/spec/unit/braintree/xml/parser_spec.rb +21 -16
  157. data/spec/unit/braintree/xml_spec.rb +31 -31
  158. metadata +30 -31
  159. data/lib/braintree/amex_express_checkout_card.rb +0 -40
  160. data/lib/braintree/coinbase_account.rb +0 -34
  161. data/lib/braintree/europe_bank_account.rb +0 -36
  162. data/lib/braintree/europe_bank_account_gateway.rb +0 -17
  163. data/lib/braintree/ideal_payment.rb +0 -61
  164. data/lib/braintree/ideal_payment_gateway.rb +0 -19
  165. data/lib/braintree/masterpass_card.rb +0 -83
  166. data/lib/braintree/settlement_batch.rb +0 -0
  167. data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -21
  168. data/lib/braintree/transaction/coinbase_details.rb +0 -16
  169. data/lib/braintree/transaction/ideal_payment_details.rb +0 -19
  170. data/lib/braintree/transaction/masterpass_card_details.rb +0 -49
  171. data/lib/braintree/transparent_redirect.rb +0 -40
  172. data/lib/braintree/transparent_redirect_gateway.rb +0 -105
  173. data/lib/braintree/xml/rexml.rb +0 -71
  174. data/spec/hacks/tcp_socket.rb +0 -18
  175. data/spec/integration/braintree/coinbase_spec.rb +0 -34
  176. data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
  177. data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
  178. data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
  179. data/spec/unit/braintree/xml/rexml_spec.rb +0 -51
@@ -13,14 +13,15 @@ describe Braintree::PaymentMethod do
13
13
  context "plaid verified nonce" do
14
14
  let(:nonce) { generate_valid_plaid_us_bank_account_nonce }
15
15
 
16
- it "succeeds" do
16
+ # we are temporarily skipping this test until we have a more stable CI env
17
+ xit "succeeds" do
17
18
  customer = Braintree::Customer.create.customer
18
19
  result = Braintree::PaymentMethod.create(
19
20
  :payment_method_nonce => nonce,
20
21
  :customer_id => customer.id,
21
22
  :options => {
22
23
  :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
23
- }
24
+ },
24
25
  )
25
26
 
26
27
  result.should be_success
@@ -49,7 +50,8 @@ describe Braintree::PaymentMethod do
49
50
  Braintree::UsBankAccountVerification::VerificationMethod::IndependentCheck,
50
51
  Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
51
52
  ].each do |method|
52
- it "succeeds and verifies via #{method}" do
53
+ # we are temporarily skipping this test until we have a more stable CI env
54
+ xit "succeeds and verifies via #{method}" do
53
55
  customer = Braintree::Customer.create.customer
54
56
  result = Braintree::PaymentMethod.create(
55
57
  :payment_method_nonce => nonce,
@@ -57,7 +59,7 @@ describe Braintree::PaymentMethod do
57
59
  :options => {
58
60
  :us_bank_account_verification_method => method,
59
61
  :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
60
- }
62
+ },
61
63
  )
62
64
 
63
65
  result.should be_success
@@ -101,7 +103,7 @@ describe Braintree::PaymentMethod do
101
103
  :customer_id => customer.id,
102
104
  :options => {
103
105
  :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
104
- }
106
+ },
105
107
  )
106
108
 
107
109
  result.should be_success
@@ -134,7 +136,7 @@ describe Braintree::PaymentMethod do
134
136
  :options => {
135
137
  :us_bank_account_verification_method => method,
136
138
  :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
137
- }
139
+ },
138
140
  )
139
141
 
140
142
  result.should be_success
@@ -165,7 +167,7 @@ describe Braintree::PaymentMethod do
165
167
  customer = Braintree::Customer.create.customer
166
168
  result = Braintree::PaymentMethod.create(
167
169
  :payment_method_nonce => generate_invalid_us_bank_account_nonce,
168
- :customer_id => customer.id
170
+ :customer_id => customer.id,
169
171
  )
170
172
 
171
173
  result.should_not be_success
@@ -183,14 +185,15 @@ describe Braintree::PaymentMethod do
183
185
 
184
186
  let(:nonce) { generate_valid_plaid_us_bank_account_nonce }
185
187
 
186
- it "succeeds and verifies via independent check" do
188
+ # we are temporarily skipping this test until we have a more stable CI env
189
+ xit "succeeds and verifies via independent check" do
187
190
  customer = Braintree::Customer.create.customer
188
191
  result = Braintree::PaymentMethod.create(
189
192
  :payment_method_nonce => nonce,
190
193
  :customer_id => customer.id,
191
194
  :options => {
192
195
  :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
193
- }
196
+ },
194
197
  )
195
198
 
196
199
  result.should be_success
@@ -219,14 +222,15 @@ describe Braintree::PaymentMethod do
219
222
  context "non plaid verified nonce" do
220
223
  let(:nonce) { generate_non_plaid_us_bank_account_nonce }
221
224
 
222
- it "succeeds and verifies via independent check" do
225
+ # we are temporarily skipping this test until we have a more stable CI env
226
+ xit "succeeds and verifies via independent check" do
223
227
  customer = Braintree::Customer.create.customer
224
228
  result = Braintree::PaymentMethod.create(
225
229
  :payment_method_nonce => nonce,
226
230
  :customer_id => customer.id,
227
231
  :options => {
228
232
  :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
229
- }
233
+ },
230
234
  )
231
235
 
232
236
  result.should be_success
@@ -256,7 +260,7 @@ describe Braintree::PaymentMethod do
256
260
  customer = Braintree::Customer.create.customer
257
261
  result = Braintree::PaymentMethod.create(
258
262
  :payment_method_nonce => generate_invalid_us_bank_account_nonce,
259
- :customer_id => customer.id
263
+ :customer_id => customer.id,
260
264
  )
261
265
 
262
266
  result.should_not be_success
@@ -352,7 +356,7 @@ describe Braintree::PaymentMethod do
352
356
  :customer_id => customer.id,
353
357
  :options => {
354
358
  :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
355
- }
359
+ },
356
360
  ).payment_method
357
361
  end
358
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 => 'Jenny Block',
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 => 'Jenny Block',
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 == 'Jenny Block'
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 => '47.00',
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 => '47.00',
118
- :options => { :store_in_vault => true },
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 == '3333'
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 => { :submit_for_settlement => true }
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('_').first
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 => { :submit_for_settlement => true }
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('_').first
53
- result = Braintree::SettlementBatchSummary.generate(settlement_date, 'store_me')
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,26 +16,24 @@ 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
- date_format = /^\d{4}\D\d{1,2}\D\d{1,2}$/
23
22
  result.success?.should == true
24
23
  result.subscription.id.should =~ /^\w{6}$/
25
24
  result.subscription.status.should == Braintree::Subscription::Status::Active
26
25
  result.subscription.plan_id.should == "integration_trialless_plan"
27
26
 
28
- result.subscription.first_billing_date.should match(date_format)
29
- result.subscription.next_billing_date.should match(date_format)
30
- result.subscription.billing_period_start_date.should match(date_format)
31
- result.subscription.billing_period_end_date.should match(date_format)
32
- result.subscription.paid_through_date.should match(date_format)
27
+ expect(result.subscription.first_billing_date).to be_a Date
28
+ expect(result.subscription.next_billing_date).to be_a Date
29
+ expect(result.subscription.billing_period_start_date).to be_a Date
30
+ expect(result.subscription.billing_period_end_date).to be_a Date
31
+ expect(result.subscription.paid_through_date).to be_a Date
33
32
 
34
33
  result.subscription.created_at.between?(Time.now - 60, Time.now).should == true
35
34
  result.subscription.updated_at.between?(Time.now - 60, Time.now).should == true
36
35
 
37
36
  result.subscription.failure_count.should == 0
38
- result.subscription.next_bill_amount.should == "12.34"
39
37
  result.subscription.next_billing_period_amount.should == "12.34"
40
38
  result.subscription.payment_method_token.should == @credit_card.token
41
39
 
@@ -49,7 +47,7 @@ describe Braintree::Subscription do
49
47
  it "returns a transaction with billing period populated" do
50
48
  result = Braintree::Subscription.create(
51
49
  :payment_method_token => @credit_card.token,
52
- :plan_id => SpecHelper::TriallessPlan[:id]
50
+ :plan_id => SpecHelper::TriallessPlan[:id],
53
51
  )
54
52
 
55
53
  result.success?.should == true
@@ -65,10 +63,9 @@ describe Braintree::Subscription do
65
63
  result = Braintree::Subscription.create(
66
64
  :payment_method_token => @credit_card.token,
67
65
  :plan_id => SpecHelper::TrialPlan[:id],
68
- :id => new_id
66
+ :id => new_id,
69
67
  )
70
68
 
71
- date_format = /^\d{4}\D\d{1,2}\D\d{1,2}$/
72
69
  result.success?.should == true
73
70
  result.subscription.id.should == new_id
74
71
  end
@@ -83,11 +80,11 @@ describe Braintree::Subscription do
83
80
  },
84
81
  :client_token_options => {
85
82
  :customer_id => @credit_card.customer_id
86
- }
83
+ },
87
84
  )
88
85
  result = Braintree::Subscription.create(
89
86
  :payment_method_nonce => nonce,
90
- :plan_id => SpecHelper::TriallessPlan[:id]
87
+ :plan_id => SpecHelper::TriallessPlan[:id],
91
88
  )
92
89
 
93
90
  result.success?.should == true
@@ -100,12 +97,12 @@ describe Braintree::Subscription do
100
97
  customer = Braintree::Customer.create!
101
98
  payment_method_result = Braintree::PaymentMethod.create(
102
99
  :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
103
- :customer_id => customer.id
100
+ :customer_id => customer.id,
104
101
  )
105
102
 
106
103
  result = Braintree::Subscription.create(
107
104
  :payment_method_token => payment_method_result.payment_method.token,
108
- :plan_id => SpecHelper::TriallessPlan[:id]
105
+ :plan_id => SpecHelper::TriallessPlan[:id],
109
106
  )
110
107
 
111
108
  result.should be_success
@@ -117,7 +114,7 @@ describe Braintree::Subscription do
117
114
  customer = Braintree::Customer.create!
118
115
  payment_method_result = Braintree::PaymentMethod.create(
119
116
  :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
120
- :customer_id => customer.id
117
+ :customer_id => customer.id,
121
118
  )
122
119
 
123
120
  result = Braintree::Subscription.create(
@@ -142,11 +139,11 @@ describe Braintree::Subscription do
142
139
  customer = Braintree::Customer.create!
143
140
  result = Braintree::Subscription.create(
144
141
  :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
145
- :plan_id => SpecHelper::TriallessPlan[:id]
142
+ :plan_id => SpecHelper::TriallessPlan[:id],
146
143
  )
147
144
 
148
145
  result.should_not be_success
149
- result.errors.for(:subscription).on(:payment_method_nonce).first.code.should == '91925'
146
+ result.errors.for(:subscription).on(:payment_method_nonce).first.code.should == "91925"
150
147
  end
151
148
  end
152
149
 
@@ -154,7 +151,7 @@ describe Braintree::Subscription do
154
151
  it "inherits from the plan if not provided" do
155
152
  result = Braintree::Subscription.create(
156
153
  :payment_method_token => @credit_card.token,
157
- :plan_id => SpecHelper::BillingDayOfMonthPlan[:id]
154
+ :plan_id => SpecHelper::BillingDayOfMonthPlan[:id],
158
155
  )
159
156
 
160
157
  result.success?.should == true
@@ -165,7 +162,7 @@ describe Braintree::Subscription do
165
162
  result = Braintree::Subscription.create(
166
163
  :payment_method_token => @credit_card.token,
167
164
  :plan_id => SpecHelper::BillingDayOfMonthPlan[:id],
168
- :billing_day_of_month => 25
165
+ :billing_day_of_month => 25,
169
166
  )
170
167
 
171
168
  result.success?.should == true
@@ -178,7 +175,7 @@ describe Braintree::Subscription do
178
175
  :plan_id => SpecHelper::BillingDayOfMonthPlan[:id],
179
176
  :options => {
180
177
  :start_immediately => true
181
- }
178
+ },
182
179
  )
183
180
 
184
181
  result.success?.should == true
@@ -191,11 +188,11 @@ describe Braintree::Subscription do
191
188
  result = Braintree::Subscription.create(
192
189
  :payment_method_token => @credit_card.token,
193
190
  :plan_id => SpecHelper::BillingDayOfMonthPlan[:id],
194
- :first_billing_date => Date.today + 3
191
+ :first_billing_date => Date.today + 3,
195
192
  )
196
193
 
197
194
  result.success?.should == true
198
- result.subscription.first_billing_date.should == (Date.today + 3).to_s
195
+ result.subscription.first_billing_date.should == Date.today + 3
199
196
  result.subscription.status.should == Braintree::Subscription::Status::Pending
200
197
  end
201
198
 
@@ -203,7 +200,7 @@ describe Braintree::Subscription do
203
200
  result = Braintree::Subscription.create(
204
201
  :payment_method_token => @credit_card.token,
205
202
  :plan_id => SpecHelper::BillingDayOfMonthPlan[:id],
206
- :first_billing_date => Date.today - 3
203
+ :first_billing_date => Date.today - 3,
207
204
  )
208
205
 
209
206
  result.success?.should == false
@@ -215,7 +212,7 @@ describe Braintree::Subscription do
215
212
  it "defaults to the default merchant account if no merchant_account_id is provided" do
216
213
  result = Braintree::Subscription.create(
217
214
  :payment_method_token => @credit_card.token,
218
- :plan_id => SpecHelper::TrialPlan[:id]
215
+ :plan_id => SpecHelper::TrialPlan[:id],
219
216
  )
220
217
 
221
218
  result.success?.should == true
@@ -226,7 +223,7 @@ describe Braintree::Subscription do
226
223
  result = Braintree::Subscription.create(
227
224
  :payment_method_token => @credit_card.token,
228
225
  :plan_id => SpecHelper::TrialPlan[:id],
229
- :merchant_account_id => SpecHelper::NonDefaultMerchantAccountId
226
+ :merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
230
227
  )
231
228
 
232
229
  result.success?.should == true
@@ -239,7 +236,7 @@ describe Braintree::Subscription do
239
236
  result = Braintree::Subscription.create(
240
237
  :payment_method_token => @credit_card.token,
241
238
  :plan_id => SpecHelper::TrialPlan[:id],
242
- :number_of_billing_cycles => 10
239
+ :number_of_billing_cycles => 10,
243
240
  )
244
241
 
245
242
  result.success?.should == true
@@ -250,7 +247,7 @@ describe Braintree::Subscription do
250
247
  result = Braintree::Subscription.create(
251
248
  :payment_method_token => @credit_card.token,
252
249
  :plan_id => SpecHelper::TrialPlan[:id],
253
- :never_expires => true
250
+ :never_expires => true,
254
251
  )
255
252
 
256
253
  result.success?.should == true
@@ -263,7 +260,7 @@ describe Braintree::Subscription do
263
260
  it "with no trial" do
264
261
  result = Braintree::Subscription.create(
265
262
  :payment_method_token => @credit_card.token,
266
- :plan_id => SpecHelper::TriallessPlan[:id]
263
+ :plan_id => SpecHelper::TriallessPlan[:id],
267
264
  )
268
265
 
269
266
  result.subscription.trial_period.should == false
@@ -274,7 +271,7 @@ describe Braintree::Subscription do
274
271
  it "with a trial" do
275
272
  result = Braintree::Subscription.create(
276
273
  :payment_method_token => @credit_card.token,
277
- :plan_id => SpecHelper::TrialPlan[:id]
274
+ :plan_id => SpecHelper::TrialPlan[:id],
278
275
  )
279
276
 
280
277
  result.subscription.trial_period.should == true
@@ -287,7 +284,7 @@ describe Braintree::Subscription do
287
284
  :payment_method_token => @credit_card.token,
288
285
  :plan_id => SpecHelper::TrialPlan[:id],
289
286
  :trial_duration => 5,
290
- :trial_duration_unit => Braintree::Subscription::TrialDurationUnit::Month
287
+ :trial_duration_unit => Braintree::Subscription::TrialDurationUnit::Month,
291
288
  )
292
289
 
293
290
  result.subscription.trial_period.should == true
@@ -299,7 +296,7 @@ describe Braintree::Subscription do
299
296
  result = Braintree::Subscription.create(
300
297
  :payment_method_token => @credit_card.token,
301
298
  :plan_id => SpecHelper::TrialPlan[:id],
302
- :trial_period => false
299
+ :trial_period => false,
303
300
  )
304
301
 
305
302
  result.subscription.trial_period.should == false
@@ -308,7 +305,7 @@ describe Braintree::Subscription do
308
305
  it "doesn't create a transaction if there's a trial period" do
309
306
  result = Braintree::Subscription.create(
310
307
  :payment_method_token => @credit_card.token,
311
- :plan_id => SpecHelper::TrialPlan[:id]
308
+ :plan_id => SpecHelper::TrialPlan[:id],
312
309
  )
313
310
 
314
311
  result.subscription.transactions.size.should == 0
@@ -319,7 +316,7 @@ describe Braintree::Subscription do
319
316
  it "creates a transaction if no trial period" do
320
317
  result = Braintree::Subscription.create(
321
318
  :payment_method_token => @credit_card.token,
322
- :plan_id => SpecHelper::TriallessPlan[:id]
319
+ :plan_id => SpecHelper::TriallessPlan[:id],
323
320
  )
324
321
 
325
322
  result.subscription.transactions.size.should == 1
@@ -333,7 +330,7 @@ describe Braintree::Subscription do
333
330
  result = Braintree::Subscription.create(
334
331
  :payment_method_token => @credit_card.token,
335
332
  :plan_id => SpecHelper::TriallessPlan[:id],
336
- :price => Braintree::Test::TransactionAmounts::Decline
333
+ :price => Braintree::Test::TransactionAmounts::Decline,
337
334
  )
338
335
 
339
336
  result.success?.should be(false)
@@ -346,7 +343,7 @@ describe Braintree::Subscription do
346
343
  it "defaults to the plan's price" do
347
344
  result = Braintree::Subscription.create(
348
345
  :payment_method_token => @credit_card.token,
349
- :plan_id => SpecHelper::TrialPlan[:id]
346
+ :plan_id => SpecHelper::TrialPlan[:id],
350
347
  )
351
348
 
352
349
  result.subscription.price.should == SpecHelper::TrialPlan[:price]
@@ -356,7 +353,7 @@ describe Braintree::Subscription do
356
353
  result = Braintree::Subscription.create(
357
354
  :payment_method_token => @credit_card.token,
358
355
  :plan_id => SpecHelper::TrialPlan[:id],
359
- :price => 98.76
356
+ :price => 98.76,
360
357
  )
361
358
 
362
359
  result.subscription.price.should == BigDecimal("98.76")
@@ -369,7 +366,7 @@ describe Braintree::Subscription do
369
366
  result = Braintree::Subscription.create(
370
367
  :payment_method_token => @credit_card.token,
371
368
  :plan_id => SpecHelper::TrialPlan[:id],
372
- :id => "invalid token"
369
+ :id => "invalid token",
373
370
  )
374
371
  result.success?.should == false
375
372
  result.errors.for(:subscription).on(:id)[0].message.should == "ID is invalid (use only letters, numbers, '-', and '_')."
@@ -380,14 +377,14 @@ describe Braintree::Subscription do
380
377
  result = Braintree::Subscription.create(
381
378
  :payment_method_token => @credit_card.token,
382
379
  :plan_id => SpecHelper::TrialPlan[:id],
383
- :id => duplicate_token
380
+ :id => duplicate_token,
384
381
  )
385
382
  result.success?.should == true
386
383
 
387
384
  result = Braintree::Subscription.create(
388
385
  :payment_method_token => @credit_card.token,
389
386
  :plan_id => SpecHelper::TrialPlan[:id],
390
- :id => duplicate_token
387
+ :id => duplicate_token,
391
388
  )
392
389
  result.success?.should == false
393
390
  result.errors.for(:subscription).on(:id)[0].message.should == "ID has already been taken."
@@ -398,7 +395,7 @@ describe Braintree::Subscription do
398
395
  :payment_method_token => @credit_card.token,
399
396
  :plan_id => SpecHelper::TrialPlan[:id],
400
397
  :trial_period => true,
401
- :trial_duration => nil
398
+ :trial_duration => nil,
402
399
  )
403
400
  result.success?.should == false
404
401
  result.errors.for(:subscription).on(:trial_duration)[0].message.should == "Trial Duration is required."
@@ -410,7 +407,7 @@ describe Braintree::Subscription do
410
407
  :plan_id => SpecHelper::TrialPlan[:id],
411
408
  :trial_period => true,
412
409
  :trial_duration => 2,
413
- :trial_duration_unit => nil
410
+ :trial_duration_unit => nil,
414
411
  )
415
412
  result.success?.should == false
416
413
  result.errors.for(:subscription).on(:trial_duration_unit)[0].message.should == "Trial Duration Unit is invalid."
@@ -422,7 +419,7 @@ describe Braintree::Subscription do
422
419
  result = Braintree::Subscription.create(
423
420
  :payment_method_token => @credit_card.token,
424
421
  :plan_id => SpecHelper::AddOnDiscountPlan[:id],
425
- :options => {:do_not_inherit_add_ons_or_discounts => true}
422
+ :options => {:do_not_inherit_add_ons_or_discounts => true},
426
423
  )
427
424
  result.success?.should == true
428
425
 
@@ -435,7 +432,7 @@ describe Braintree::Subscription do
435
432
  it "inherits the add_ons and discounts from the plan when not specified" do
436
433
  result = Braintree::Subscription.create(
437
434
  :payment_method_token => @credit_card.token,
438
- :plan_id => SpecHelper::AddOnDiscountPlan[:id]
435
+ :plan_id => SpecHelper::AddOnDiscountPlan[:id],
439
436
  )
440
437
  result.success?.should == true
441
438
 
@@ -499,7 +496,7 @@ describe Braintree::Subscription do
499
496
  :never_expires => true
500
497
  }
501
498
  ]
502
- }
499
+ },
503
500
  )
504
501
  result.success?.should == true
505
502
 
@@ -545,7 +542,7 @@ describe Braintree::Subscription do
545
542
  },
546
543
  :discounts => {
547
544
  :remove => [SpecHelper::Discount7]
548
- }
545
+ },
549
546
  )
550
547
  result.success?.should == true
551
548
 
@@ -573,7 +570,7 @@ describe Braintree::Subscription do
573
570
  },
574
571
  :discounts => {
575
572
  :add => [{:inherited_from_id => SpecHelper::Discount15}]
576
- }
573
+ },
577
574
  )
578
575
  result.success?.should == true
579
576
  subscription = result.subscription
@@ -624,7 +621,7 @@ describe Braintree::Subscription do
624
621
  :quantity => -10,
625
622
  }
626
623
  ]
627
- }
624
+ },
628
625
  )
629
626
  result.success?.should == false
630
627
  result.errors.for(:subscription).for(:add_ons).for(:update).for_index(0).on(:amount)[0].code.should == Braintree::ErrorCodes::Subscription::Modification::AmountIsInvalid
@@ -638,19 +635,19 @@ describe Braintree::Subscription do
638
635
  :payment_method_token => @credit_card.token,
639
636
  :plan_id => SpecHelper::TriallessPlan[:id],
640
637
  :descriptor => {
641
- :name => '123*123456789012345678',
642
- :phone => '3334445555'
643
- }
638
+ :name => "123*123456789012345678",
639
+ :phone => "3334445555"
640
+ },
644
641
  )
645
642
 
646
643
  result.success?.should == true
647
- result.subscription.descriptor.name.should == '123*123456789012345678'
648
- result.subscription.descriptor.phone.should == '3334445555'
644
+ result.subscription.descriptor.name.should == "123*123456789012345678"
645
+ result.subscription.descriptor.phone.should == "3334445555"
649
646
 
650
647
  result.subscription.transactions.size.should == 1
651
648
  transaction = result.subscription.transactions.first
652
- transaction.descriptor.name.should == '123*123456789012345678'
653
- transaction.descriptor.phone.should == '3334445555'
649
+ transaction.descriptor.name.should == "123*123456789012345678"
650
+ transaction.descriptor.phone.should == "3334445555"
654
651
  end
655
652
 
656
653
  it "has validation errors if format is invalid" do
@@ -658,10 +655,10 @@ describe Braintree::Subscription do
658
655
  :payment_method_token => @credit_card.token,
659
656
  :plan_id => SpecHelper::TriallessPlan[:id],
660
657
  :descriptor => {
661
- :name => 'badcompanyname12*badproduct12',
662
- :phone => '%bad4445555',
658
+ :name => "badcompanyname12*badproduct12",
659
+ :phone => "%bad4445555",
663
660
  :url => "12345678901234"
664
- }
661
+ },
665
662
  )
666
663
  result.success?.should == false
667
664
  result.errors.for(:subscription).for(:descriptor).on(:name)[0].code.should == Braintree::ErrorCodes::Descriptor::NameFormatIsInvalid
@@ -675,23 +672,21 @@ describe Braintree::Subscription do
675
672
  it "returns the subscription if valid" do
676
673
  subscription = Braintree::Subscription.create!(
677
674
  :payment_method_token => @credit_card.token,
678
- :plan_id => SpecHelper::TriallessPlan[:id]
675
+ :plan_id => SpecHelper::TriallessPlan[:id],
679
676
  )
680
677
 
681
- date_format = /^\d{4}\D\d{1,2}\D\d{1,2}$/
682
678
  subscription.id.should =~ /^\w{6}$/
683
679
  subscription.status.should == Braintree::Subscription::Status::Active
684
680
  subscription.plan_id.should == "integration_trialless_plan"
685
681
 
686
- subscription.first_billing_date.should match(date_format)
687
- subscription.next_billing_date.should match(date_format)
688
- subscription.billing_period_start_date.should match(date_format)
689
- subscription.billing_period_end_date.should match(date_format)
690
- subscription.paid_through_date.should match(date_format)
682
+ expect(subscription.first_billing_date).to be_a Date
683
+ expect(subscription.next_billing_date).to be_a Date
684
+ expect(subscription.billing_period_start_date).to be_a Date
685
+ expect(subscription.billing_period_end_date).to be_a Date
686
+ expect(subscription.paid_through_date).to be_a Date
691
687
 
692
688
  subscription.failure_count.should == 0
693
689
  subscription.current_billing_cycle.should == 1
694
- subscription.next_bill_amount.should == "12.34"
695
690
  subscription.next_billing_period_amount.should == "12.34"
696
691
  subscription.payment_method_token.should == @credit_card.token
697
692
  end
@@ -700,7 +695,7 @@ describe Braintree::Subscription do
700
695
  expect do
701
696
  Braintree::Subscription.create!(
702
697
  :payment_method_token => @credit_card.token,
703
- :plan_id => 'not_a_plan_id'
698
+ :plan_id => "not_a_plan_id",
704
699
  )
705
700
  end.to raise_error(Braintree::ValidationsFailed)
706
701
  end
@@ -710,7 +705,7 @@ describe Braintree::Subscription do
710
705
  it "finds a subscription" do
711
706
  result = Braintree::Subscription.create(
712
707
  :payment_method_token => @credit_card.token,
713
- :plan_id => SpecHelper::TrialPlan[:id]
708
+ :plan_id => SpecHelper::TrialPlan[:id],
714
709
  )
715
710
  result.success?.should == true
716
711
 
@@ -719,7 +714,7 @@ describe Braintree::Subscription do
719
714
 
720
715
  it "raises Braintree::NotFoundError if it cannot find" do
721
716
  expect {
722
- Braintree::Subscription.find('noSuchSubscription')
717
+ Braintree::Subscription.find("noSuchSubscription")
723
718
  }.to raise_error(Braintree::NotFoundError, 'subscription with id "noSuchSubscription" not found')
724
719
  end
725
720
  end
@@ -729,13 +724,13 @@ describe Braintree::Subscription do
729
724
  @subscription = Braintree::Subscription.create(
730
725
  :payment_method_token => @credit_card.token,
731
726
  :price => 54.32,
732
- :plan_id => SpecHelper::TriallessPlan[:id]
727
+ :plan_id => SpecHelper::TriallessPlan[:id],
733
728
  ).subscription
734
729
  end
735
730
 
736
731
  it "allows changing the merchant_account_id" do
737
732
  result = Braintree::Subscription.update(@subscription.id,
738
- :merchant_account_id => SpecHelper::NonDefaultMerchantAccountId
733
+ :merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
739
734
  )
740
735
 
741
736
  result.success?.should == true
@@ -746,11 +741,11 @@ describe Braintree::Subscription do
746
741
  new_credit_card = Braintree::CreditCard.create!(
747
742
  :customer_id => @credit_card.customer_id,
748
743
  :number => Braintree::Test::CreditCardNumbers::Visa,
749
- :expiration_date => "05/2010"
744
+ :expiration_date => "05/2010",
750
745
  )
751
746
 
752
747
  result = Braintree::Subscription.update(@subscription.id,
753
- :payment_method_token => new_credit_card.token
748
+ :payment_method_token => new_credit_card.token,
754
749
  )
755
750
 
756
751
  result.subscription.payment_method_token.should == new_credit_card.token
@@ -764,7 +759,7 @@ describe Braintree::Subscription do
764
759
  },
765
760
  :client_token_options => {
766
761
  :customer_id => @credit_card.customer_id,
767
- }
762
+ },
768
763
  )
769
764
 
770
765
  result = Braintree::Subscription.update(@subscription.id, :payment_method_nonce => nonce)
@@ -775,41 +770,41 @@ describe Braintree::Subscription do
775
770
  it "allows changing the descriptors" do
776
771
  result = Braintree::Subscription.update(@subscription.id,
777
772
  :descriptor => {
778
- :name => 'aaa*1234',
779
- :phone => '3334443333',
773
+ :name => "aaa*1234",
774
+ :phone => "3334443333",
780
775
  :url => "ebay.com"
781
- }
776
+ },
782
777
  )
783
778
 
784
779
  result.success?.should == true
785
- result.subscription.descriptor.name.should == 'aaa*1234'
786
- result.subscription.descriptor.phone.should == '3334443333'
787
- result.subscription.descriptor.url.should == 'ebay.com'
780
+ result.subscription.descriptor.name.should == "aaa*1234"
781
+ result.subscription.descriptor.phone.should == "3334443333"
782
+ result.subscription.descriptor.url.should == "ebay.com"
788
783
  end
789
784
 
790
785
  it "allows changing the paypal description" do
791
786
  customer = Braintree::Customer.create!
792
787
  payment_method = Braintree::PaymentMethod.create(
793
788
  :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
794
- :customer_id => customer.id
789
+ :customer_id => customer.id,
795
790
  ).payment_method
796
791
 
797
792
  subscription = Braintree::Subscription.create(
798
793
  :payment_method_token => payment_method.token,
799
- :plan_id => SpecHelper::TriallessPlan[:id]
794
+ :plan_id => SpecHelper::TriallessPlan[:id],
800
795
  ).subscription
801
796
 
802
797
  result = Braintree::Subscription.update(
803
798
  subscription.id,
804
799
  :options => {
805
800
  :paypal => {
806
- :description => 'A great product',
801
+ :description => "A great product",
807
802
  },
808
803
  },
809
804
  )
810
805
 
811
806
  result.success?.should == true
812
- result.subscription.description.should == 'A great product'
807
+ result.subscription.description.should == "A great product"
813
808
  end
814
809
 
815
810
  context "when successful" do
@@ -818,7 +813,7 @@ describe Braintree::Subscription do
818
813
  result = Braintree::Subscription.update(@subscription.id,
819
814
  :id => new_id,
820
815
  :price => 9999.88,
821
- :plan_id => SpecHelper::TrialPlan[:id]
816
+ :plan_id => SpecHelper::TrialPlan[:id],
822
817
  )
823
818
 
824
819
  result.success?.should == true
@@ -830,7 +825,7 @@ describe Braintree::Subscription do
830
825
  context "proration" do
831
826
  it "prorates if there is a charge (because merchant has proration option enabled in control panel)" do
832
827
  result = Braintree::Subscription.update(@subscription.id,
833
- :price => @subscription.price.to_f + 1
828
+ :price => @subscription.price.to_f + 1,
834
829
  )
835
830
 
836
831
  result.success?.should == true
@@ -841,7 +836,7 @@ describe Braintree::Subscription do
841
836
  it "allows the user to force proration if there is a charge" do
842
837
  result = Braintree::Subscription.update(@subscription.id,
843
838
  :price => @subscription.price.to_f + 1,
844
- :options => { :prorate_charges => true }
839
+ :options => {:prorate_charges => true},
845
840
  )
846
841
 
847
842
  result.success?.should == true
@@ -852,7 +847,7 @@ describe Braintree::Subscription do
852
847
  it "allows the user to prevent proration if there is a charge" do
853
848
  result = Braintree::Subscription.update(@subscription.id,
854
849
  :price => @subscription.price.to_f + 1,
855
- :options => { :prorate_charges => false }
850
+ :options => {:prorate_charges => false},
856
851
  )
857
852
 
858
853
  result.success?.should == true
@@ -862,7 +857,7 @@ describe Braintree::Subscription do
862
857
 
863
858
  it "doesn't prorate if price decreases" do
864
859
  result = Braintree::Subscription.update(@subscription.id,
865
- :price => @subscription.price.to_f - 1
860
+ :price => @subscription.price.to_f - 1,
866
861
  )
867
862
 
868
863
  result.success?.should == true
@@ -875,7 +870,7 @@ describe Braintree::Subscription do
875
870
  :price => @subscription.price.to_f + 2100,
876
871
  :options => {
877
872
  :revert_subscription_on_proration_failure => false
878
- }
873
+ },
879
874
  )
880
875
 
881
876
  result.success?.should == true
@@ -892,7 +887,7 @@ describe Braintree::Subscription do
892
887
  :price => @subscription.price.to_f + 2100,
893
888
  :options => {
894
889
  :revert_subscription_on_proration_failure => true
895
- }
890
+ },
896
891
  )
897
892
 
898
893
  result.success?.should == false
@@ -910,14 +905,14 @@ describe Braintree::Subscription do
910
905
  before(:each) do
911
906
  @subscription = Braintree::Subscription.create(
912
907
  :payment_method_token => @credit_card.token,
913
- :plan_id => SpecHelper::TrialPlan[:id]
908
+ :plan_id => SpecHelper::TrialPlan[:id],
914
909
  ).subscription
915
910
  end
916
911
 
917
912
  it "raises NotFoundError if the subscription can't be found" do
918
913
  expect {
919
914
  Braintree::Subscription.update(rand(36**9).to_s(36),
920
- :price => 58.20
915
+ :price => 58.20,
921
916
  )
922
917
  }.to raise_error(Braintree::NotFoundError)
923
918
  end
@@ -945,11 +940,11 @@ describe Braintree::Subscription do
945
940
  duplicate = Braintree::Subscription.create(
946
941
  :payment_method_token => @credit_card.token,
947
942
  :plan_id => SpecHelper::TrialPlan[:id],
948
- :id => duplicate_id
943
+ :id => duplicate_id,
949
944
  )
950
945
  result = Braintree::Subscription.update(
951
946
  @subscription.id,
952
- :id => duplicate_id
947
+ :id => duplicate_id,
953
948
  )
954
949
  result.success?.should == false
955
950
  result.errors.for(:subscription).on(:id)[0].code.should == Braintree::ErrorCodes::Subscription::IdIsInUse
@@ -959,14 +954,14 @@ describe Braintree::Subscription do
959
954
  subscription = Braintree::Subscription.create(
960
955
  :payment_method_token => @credit_card.token,
961
956
  :price => 54.32,
962
- :plan_id => SpecHelper::TriallessPlan[:id]
957
+ :plan_id => SpecHelper::TriallessPlan[:id],
963
958
  ).subscription
964
959
 
965
960
  result = Braintree::Subscription.cancel(subscription.id)
966
961
  result.success?.should == true
967
962
 
968
963
  result = Braintree::Subscription.update(subscription.id,
969
- :price => 123.45
964
+ :price => 123.45,
970
965
  )
971
966
  result.success?.should == false
972
967
  result.errors.for(:subscription)[0].code.should == Braintree::ErrorCodes::Subscription::CannotEditCanceledSubscription
@@ -978,12 +973,12 @@ describe Braintree::Subscription do
978
973
  subscription = Braintree::Subscription.create(
979
974
  :payment_method_token => @credit_card.token,
980
975
  :plan_id => SpecHelper::TriallessPlan[:id],
981
- :number_of_billing_cycles => 10
976
+ :number_of_billing_cycles => 10,
982
977
  ).subscription
983
978
 
984
979
  result = Braintree::Subscription.update(
985
980
  subscription.id,
986
- :number_of_billing_cycles => 5
981
+ :number_of_billing_cycles => 5,
987
982
  )
988
983
 
989
984
  result.subscription.number_of_billing_cycles.should == 5
@@ -993,12 +988,12 @@ describe Braintree::Subscription do
993
988
  subscription = Braintree::Subscription.create(
994
989
  :payment_method_token => @credit_card.token,
995
990
  :plan_id => SpecHelper::TriallessPlan[:id],
996
- :number_of_billing_cycles => 10
991
+ :number_of_billing_cycles => 10,
997
992
  ).subscription
998
993
 
999
994
  result = Braintree::Subscription.update(
1000
995
  subscription.id,
1001
- :never_expires => true
996
+ :never_expires => true,
1002
997
  )
1003
998
 
1004
999
  result.success?.should == true
@@ -1011,7 +1006,7 @@ describe Braintree::Subscription do
1011
1006
  it "can update add_ons and discounts" do
1012
1007
  result = Braintree::Subscription.create(
1013
1008
  :payment_method_token => @credit_card.token,
1014
- :plan_id => SpecHelper::AddOnDiscountPlan[:id]
1009
+ :plan_id => SpecHelper::AddOnDiscountPlan[:id],
1015
1010
  )
1016
1011
  result.success?.should == true
1017
1012
  subscription = result.subscription
@@ -1035,7 +1030,7 @@ describe Braintree::Subscription do
1035
1030
  :quantity => 9
1036
1031
  }
1037
1032
  ]
1038
- }
1033
+ },
1039
1034
  )
1040
1035
 
1041
1036
  subscription = result.subscription
@@ -1056,7 +1051,7 @@ describe Braintree::Subscription do
1056
1051
  it "allows adding new add_ons and discounts" do
1057
1052
  subscription = Braintree::Subscription.create(
1058
1053
  :payment_method_token => @credit_card.token,
1059
- :plan_id => SpecHelper::AddOnDiscountPlan[:id]
1054
+ :plan_id => SpecHelper::AddOnDiscountPlan[:id],
1060
1055
  ).subscription
1061
1056
 
1062
1057
  result = Braintree::Subscription.update(subscription.id,
@@ -1065,7 +1060,7 @@ describe Braintree::Subscription do
1065
1060
  },
1066
1061
  :discounts => {
1067
1062
  :add => [{:inherited_from_id => SpecHelper::Discount15}]
1068
- }
1063
+ },
1069
1064
  )
1070
1065
 
1071
1066
  result.success?.should == true
@@ -1105,7 +1100,7 @@ describe Braintree::Subscription do
1105
1100
  it "allows replacing entire set of add_ons and discounts" do
1106
1101
  subscription = Braintree::Subscription.create(
1107
1102
  :payment_method_token => @credit_card.token,
1108
- :plan_id => SpecHelper::AddOnDiscountPlan[:id]
1103
+ :plan_id => SpecHelper::AddOnDiscountPlan[:id],
1109
1104
  ).subscription
1110
1105
 
1111
1106
  result = Braintree::Subscription.update(subscription.id,
@@ -1115,7 +1110,7 @@ describe Braintree::Subscription do
1115
1110
  :discounts => {
1116
1111
  :add => [{:inherited_from_id => SpecHelper::Discount15}]
1117
1112
  },
1118
- :options => {:replace_all_add_ons_and_discounts => true}
1113
+ :options => {:replace_all_add_ons_and_discounts => true},
1119
1114
  )
1120
1115
 
1121
1116
  result.success?.should == true
@@ -1135,7 +1130,7 @@ describe Braintree::Subscription do
1135
1130
  it "allows deleting of add_ons and discounts" do
1136
1131
  subscription = Braintree::Subscription.create(
1137
1132
  :payment_method_token => @credit_card.token,
1138
- :plan_id => SpecHelper::AddOnDiscountPlan[:id]
1133
+ :plan_id => SpecHelper::AddOnDiscountPlan[:id],
1139
1134
  ).subscription
1140
1135
 
1141
1136
  result = Braintree::Subscription.update(subscription.id,
@@ -1144,7 +1139,7 @@ describe Braintree::Subscription do
1144
1139
  },
1145
1140
  :discounts => {
1146
1141
  :remove => [SpecHelper::Discount7]
1147
- }
1142
+ },
1148
1143
  )
1149
1144
  result.success?.should == true
1150
1145
 
@@ -1166,7 +1161,7 @@ describe Braintree::Subscription do
1166
1161
  @subscription = Braintree::Subscription.create(
1167
1162
  :payment_method_token => @credit_card.token,
1168
1163
  :price => 54.32,
1169
- :plan_id => SpecHelper::TriallessPlan[:id]
1164
+ :plan_id => SpecHelper::TriallessPlan[:id],
1170
1165
  ).subscription
1171
1166
  end
1172
1167
 
@@ -1175,7 +1170,7 @@ describe Braintree::Subscription do
1175
1170
  subscription = Braintree::Subscription.update!(@subscription.id,
1176
1171
  :id => new_id,
1177
1172
  :price => 9999.88,
1178
- :plan_id => SpecHelper::TrialPlan[:id]
1173
+ :plan_id => SpecHelper::TrialPlan[:id],
1179
1174
  )
1180
1175
 
1181
1176
  subscription.id.should =~ /#{new_id}/
@@ -1186,7 +1181,7 @@ describe Braintree::Subscription do
1186
1181
  it "raises a ValidationsFailed if invalid" do
1187
1182
  expect do
1188
1183
  Braintree::Subscription.update!(@subscription.id,
1189
- :plan_id => 'not_a_plan_id'
1184
+ :plan_id => "not_a_plan_id",
1190
1185
  )
1191
1186
  end.to raise_error(Braintree::ValidationsFailed)
1192
1187
  end
@@ -1198,7 +1193,7 @@ describe Braintree::Subscription do
1198
1193
  subscription = Braintree::Subscription.create(
1199
1194
  :payment_method_token => @credit_card.token,
1200
1195
  :price => 54.32,
1201
- :plan_id => SpecHelper::TriallessPlan[:id]
1196
+ :plan_id => SpecHelper::TriallessPlan[:id],
1202
1197
  ).subscription
1203
1198
 
1204
1199
  result = Braintree::Subscription.cancel(subscription.id)
@@ -1208,7 +1203,7 @@ describe Braintree::Subscription do
1208
1203
 
1209
1204
  it "returns a validation error if record not found" do
1210
1205
  expect {
1211
- r = Braintree::Subscription.cancel('noSuchSubscription')
1206
+ r = Braintree::Subscription.cancel("noSuchSubscription")
1212
1207
  }.to raise_error(Braintree::NotFoundError, 'subscription with id "noSuchSubscription" not found')
1213
1208
  end
1214
1209
 
@@ -1216,7 +1211,7 @@ describe Braintree::Subscription do
1216
1211
  subscription = Braintree::Subscription.create(
1217
1212
  :payment_method_token => @credit_card.token,
1218
1213
  :price => 54.32,
1219
- :plan_id => SpecHelper::TriallessPlan[:id]
1214
+ :plan_id => SpecHelper::TriallessPlan[:id],
1220
1215
  ).subscription
1221
1216
 
1222
1217
  result = Braintree::Subscription.cancel(subscription.id)
@@ -1234,7 +1229,7 @@ describe Braintree::Subscription do
1234
1229
  subscription = Braintree::Subscription.create!(
1235
1230
  :payment_method_token => @credit_card.token,
1236
1231
  :price => 54.32,
1237
- :plan_id => SpecHelper::TriallessPlan[:id]
1232
+ :plan_id => SpecHelper::TriallessPlan[:id],
1238
1233
  )
1239
1234
 
1240
1235
  updated_subscription = Braintree::Subscription.cancel!(subscription.id)
@@ -1249,13 +1244,13 @@ describe Braintree::Subscription do
1249
1244
  subscription_with_trial = Braintree::Subscription.create(
1250
1245
  :payment_method_token => @credit_card.token,
1251
1246
  :plan_id => SpecHelper::TrialPlan[:id],
1252
- :id => "subscription1_#{id}"
1247
+ :id => "subscription1_#{id}",
1253
1248
  ).subscription
1254
1249
 
1255
1250
  subscription_without_trial = Braintree::Subscription.create(
1256
1251
  :payment_method_token => @credit_card.token,
1257
1252
  :plan_id => SpecHelper::TriallessPlan[:id],
1258
- :id => "subscription2_#{id}"
1253
+ :id => "subscription2_#{id}",
1259
1254
  ).subscription
1260
1255
 
1261
1256
  subscriptions_in_trial_period = Braintree::Subscription.search do |search|
@@ -1281,7 +1276,7 @@ describe Braintree::Subscription do
1281
1276
  :payment_method_token => @credit_card.token,
1282
1277
  :plan_id => SpecHelper::TrialPlan[:id],
1283
1278
  :id => "subscription1_#{id}",
1284
- :price => "11.38"
1279
+ :price => "11.38",
1285
1280
  ).subscription
1286
1281
 
1287
1282
  collection = Braintree::Subscription.search do |search|
@@ -1315,13 +1310,13 @@ describe Braintree::Subscription do
1315
1310
  subscription1 = Braintree::Subscription.create(
1316
1311
  :payment_method_token => @credit_card.token,
1317
1312
  :plan_id => SpecHelper::TrialPlan[:id],
1318
- :id => "subscription1_#{id}"
1313
+ :id => "subscription1_#{id}",
1319
1314
  ).subscription
1320
1315
 
1321
1316
  subscription2 = Braintree::Subscription.create(
1322
1317
  :payment_method_token => @credit_card.token,
1323
1318
  :plan_id => SpecHelper::TrialPlan[:id],
1324
- :id => "subscription2_#{id}"
1319
+ :id => "subscription2_#{id}",
1325
1320
  ).subscription
1326
1321
 
1327
1322
  collection = Braintree::Subscription.search do |search|
@@ -1339,14 +1334,14 @@ describe Braintree::Subscription do
1339
1334
  :payment_method_token => @credit_card.token,
1340
1335
  :plan_id => SpecHelper::TrialPlan[:id],
1341
1336
  :merchant_account_id => SpecHelper::DefaultMerchantAccountId,
1342
- :price => "1"
1337
+ :price => "1",
1343
1338
  ).subscription
1344
1339
 
1345
1340
  subscription2 = Braintree::Subscription.create(
1346
1341
  :payment_method_token => @credit_card.token,
1347
1342
  :plan_id => SpecHelper::TrialPlan[:id],
1348
1343
  :merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
1349
- :price => "1"
1344
+ :price => "1",
1350
1345
  ).subscription
1351
1346
 
1352
1347
  collection = Braintree::Subscription.search do |search|
@@ -1372,13 +1367,13 @@ describe Braintree::Subscription do
1372
1367
  trialless_subscription = Braintree::Subscription.create(
1373
1368
  :payment_method_token => @credit_card.token,
1374
1369
  :plan_id => SpecHelper::TriallessPlan[:id],
1375
- :price => "2"
1370
+ :price => "2",
1376
1371
  ).subscription
1377
1372
 
1378
1373
  trial_subscription = Braintree::Subscription.create(
1379
1374
  :payment_method_token => @credit_card.token,
1380
1375
  :plan_id => SpecHelper::TrialPlan[:id],
1381
- :price => "2"
1376
+ :price => "2",
1382
1377
  ).subscription
1383
1378
 
1384
1379
  collection = Braintree::Subscription.search do |search|
@@ -1396,13 +1391,13 @@ describe Braintree::Subscription do
1396
1391
  subscription_500 = Braintree::Subscription.create(
1397
1392
  :payment_method_token => @credit_card.token,
1398
1393
  :plan_id => SpecHelper::TrialPlan[:id],
1399
- :price => "5.00"
1394
+ :price => "5.00",
1400
1395
  ).subscription
1401
1396
 
1402
1397
  subscription_501 = Braintree::Subscription.create(
1403
1398
  :payment_method_token => @credit_card.token,
1404
1399
  :plan_id => SpecHelper::TrialPlan[:id],
1405
- :price => "5.01"
1400
+ :price => "5.01",
1406
1401
  ).subscription
1407
1402
 
1408
1403
  collection = Braintree::Subscription.search do |search|
@@ -1419,13 +1414,13 @@ describe Braintree::Subscription do
1419
1414
  active_subscription = Braintree::Subscription.create(
1420
1415
  :payment_method_token => @credit_card.token,
1421
1416
  :plan_id => SpecHelper::TrialPlan[:id],
1422
- :price => "6"
1417
+ :price => "6",
1423
1418
  ).subscription
1424
1419
 
1425
1420
  past_due_subscription = Braintree::Subscription.create(
1426
1421
  :payment_method_token => @credit_card.token,
1427
1422
  :plan_id => SpecHelper::TrialPlan[:id],
1428
- :price => "6"
1423
+ :price => "6",
1429
1424
  ).subscription
1430
1425
 
1431
1426
  SpecHelper.make_past_due(past_due_subscription, 5)
@@ -1446,7 +1441,7 @@ describe Braintree::Subscription do
1446
1441
  it "passes a smoke test" do
1447
1442
  subscription = Braintree::Subscription.create(
1448
1443
  :payment_method_token => @credit_card.token,
1449
- :plan_id => SpecHelper::TrialPlan[:id]
1444
+ :plan_id => SpecHelper::TrialPlan[:id],
1450
1445
  ).subscription
1451
1446
 
1452
1447
  collection = Braintree::Subscription.search do |search|
@@ -1466,19 +1461,19 @@ describe Braintree::Subscription do
1466
1461
  subscription_5 = Braintree::Subscription.create(
1467
1462
  :payment_method_token => @credit_card.token,
1468
1463
  :plan_id => SpecHelper::TrialPlan[:id],
1469
- :number_of_billing_cycles => 5
1464
+ :number_of_billing_cycles => 5,
1470
1465
  ).subscription
1471
1466
 
1472
1467
  subscription_9 = Braintree::Subscription.create(
1473
1468
  :payment_method_token => @credit_card.token,
1474
1469
  :plan_id => SpecHelper::TriallessPlan[:id],
1475
- :number_of_billing_cycles => 10
1470
+ :number_of_billing_cycles => 10,
1476
1471
  ).subscription
1477
1472
 
1478
1473
  subscription_15 = Braintree::Subscription.create(
1479
1474
  :payment_method_token => @credit_card.token,
1480
1475
  :plan_id => SpecHelper::TriallessPlan[:id],
1481
- :number_of_billing_cycles => 15
1476
+ :number_of_billing_cycles => 15,
1482
1477
  ).subscription
1483
1478
 
1484
1479
  collection = Braintree::Subscription.search do |search|
@@ -1495,12 +1490,12 @@ describe Braintree::Subscription do
1495
1490
  it "returns matching results" do
1496
1491
  matching_subscription = Braintree::Subscription.create(
1497
1492
  :payment_method_token => @credit_card.token,
1498
- :plan_id => SpecHelper::TriallessPlan[:id]
1493
+ :plan_id => SpecHelper::TriallessPlan[:id],
1499
1494
  ).subscription
1500
1495
 
1501
1496
  non_matching_subscription = Braintree::Subscription.create(
1502
1497
  :payment_method_token => @credit_card.token,
1503
- :plan_id => SpecHelper::TriallessPlan[:id]
1498
+ :plan_id => SpecHelper::TriallessPlan[:id],
1504
1499
  ).subscription
1505
1500
 
1506
1501
  collection = Braintree::Subscription.search do |search|
@@ -1516,12 +1511,12 @@ describe Braintree::Subscription do
1516
1511
  it "returns matching results" do
1517
1512
  matching_subscription = Braintree::Subscription.create(
1518
1513
  :payment_method_token => @credit_card.token,
1519
- :plan_id => SpecHelper::TriallessPlan[:id]
1514
+ :plan_id => SpecHelper::TriallessPlan[:id],
1520
1515
  ).subscription
1521
1516
 
1522
1517
  non_matching_subscription = Braintree::Subscription.create(
1523
1518
  :payment_method_token => @credit_card.token,
1524
- :plan_id => SpecHelper::TrialPlan[:id]
1519
+ :plan_id => SpecHelper::TrialPlan[:id],
1525
1520
  ).subscription
1526
1521
 
1527
1522
  five_days_from_now = Time.now + (5 * 24 * 60 * 60)
@@ -1538,7 +1533,7 @@ describe Braintree::Subscription do
1538
1533
  before(:each) do
1539
1534
  @subscription = Braintree::Subscription.create(
1540
1535
  :payment_method_token => @credit_card.token,
1541
- :plan_id => SpecHelper::TriallessPlan[:id]
1536
+ :plan_id => SpecHelper::TriallessPlan[:id],
1542
1537
  ).subscription
1543
1538
  @created_at = @subscription.created_at
1544
1539
  end
@@ -1550,7 +1545,7 @@ describe Braintree::Subscription do
1550
1545
  search.id.is @subscription.id
1551
1546
  search.created_at.between(
1552
1547
  @created_at - 60,
1553
- @created_at + 60
1548
+ @created_at + 60,
1554
1549
  )
1555
1550
  end
1556
1551
 
@@ -1583,7 +1578,7 @@ describe Braintree::Subscription do
1583
1578
  search.id.is @subscription.id
1584
1579
  search.created_at.between(
1585
1580
  @created_at + 300,
1586
- @created_at + 400
1581
+ @created_at + 400,
1587
1582
  )
1588
1583
  end
1589
1584
 
@@ -1607,7 +1602,7 @@ describe Braintree::Subscription do
1607
1602
  search.id.is @subscription.id
1608
1603
  search.created_at.between(
1609
1604
  now - 60,
1610
- now + 60
1605
+ now + 60,
1611
1606
  )
1612
1607
  end
1613
1608
 
@@ -1646,7 +1641,7 @@ describe Braintree::Subscription do
1646
1641
  search.id.is @subscription.id
1647
1642
  search.created_at.between(
1648
1643
  now + 300,
1649
- now + 400
1644
+ now + 400,
1650
1645
  )
1651
1646
  end
1652
1647
 
@@ -1658,7 +1653,7 @@ describe Braintree::Subscription do
1658
1653
  search.id.is @subscription.id
1659
1654
  search.created_at.between(
1660
1655
  Date.today - 1,
1661
- Date.today + 1
1656
+ Date.today + 1,
1662
1657
  )
1663
1658
  end
1664
1659
 
@@ -1675,7 +1670,7 @@ describe Braintree::Subscription do
1675
1670
  collection = Braintree::Subscription.search
1676
1671
  collection.maximum_size.should > 100
1677
1672
 
1678
- subscriptions_ids = collection.map {|t| t.id }.uniq.compact
1673
+ subscriptions_ids = collection.map { |t| t.id }.uniq.compact
1679
1674
  subscriptions_ids.size.should == collection.maximum_size
1680
1675
  end
1681
1676
  end
@@ -1684,7 +1679,7 @@ describe Braintree::Subscription do
1684
1679
  it "is successful with only subscription id" do
1685
1680
  subscription = Braintree::Subscription.create(
1686
1681
  :payment_method_token => @credit_card.token,
1687
- :plan_id => SpecHelper::TriallessPlan[:id]
1682
+ :plan_id => SpecHelper::TriallessPlan[:id],
1688
1683
  ).subscription
1689
1684
  SpecHelper.make_past_due(subscription)
1690
1685
 
@@ -1702,7 +1697,7 @@ describe Braintree::Subscription do
1702
1697
  it "is successful with subscription id and amount" do
1703
1698
  subscription = Braintree::Subscription.create(
1704
1699
  :payment_method_token => @credit_card.token,
1705
- :plan_id => SpecHelper::TriallessPlan[:id]
1700
+ :plan_id => SpecHelper::TriallessPlan[:id],
1706
1701
  ).subscription
1707
1702
  SpecHelper.make_past_due(subscription)
1708
1703
 
@@ -1720,7 +1715,7 @@ describe Braintree::Subscription do
1720
1715
  it "is successful with subscription id and submit_for_settlement" do
1721
1716
  subscription = Braintree::Subscription.create(
1722
1717
  :payment_method_token => @credit_card.token,
1723
- :plan_id => SpecHelper::TriallessPlan[:id]
1718
+ :plan_id => SpecHelper::TriallessPlan[:id],
1724
1719
  ).subscription
1725
1720
  SpecHelper.make_past_due(subscription)
1726
1721
 
@@ -1738,7 +1733,7 @@ describe Braintree::Subscription do
1738
1733
  it "is successful with subscription id, amount and submit_for_settlement" do
1739
1734
  subscription = Braintree::Subscription.create(
1740
1735
  :payment_method_token => @credit_card.token,
1741
- :plan_id => SpecHelper::TriallessPlan[:id]
1736
+ :plan_id => SpecHelper::TriallessPlan[:id],
1742
1737
  ).subscription
1743
1738
  SpecHelper.make_past_due(subscription)
1744
1739