braintree 2.104.0 → 4.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/braintree.gemspec +7 -4
  4. data/lib/braintree/account_updater_daily_report.rb +1 -1
  5. data/lib/braintree/address.rb +2 -23
  6. data/lib/braintree/apple_pay.rb +1 -1
  7. data/lib/braintree/apple_pay_card.rb +11 -1
  8. data/lib/braintree/apple_pay_options.rb +1 -1
  9. data/lib/braintree/authorization_adjustment.rb +1 -1
  10. data/lib/braintree/base_module.rb +6 -0
  11. data/lib/braintree/bin_data.rb +9 -2
  12. data/lib/braintree/client_token.rb +1 -1
  13. data/lib/braintree/configuration.rb +12 -12
  14. data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
  15. data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
  16. data/lib/braintree/credit_card.rb +2 -77
  17. data/lib/braintree/credit_card_gateway.rb +17 -36
  18. data/lib/braintree/credit_card_verification.rb +18 -5
  19. data/lib/braintree/credit_card_verification_search.rb +1 -1
  20. data/lib/braintree/customer.rb +9 -78
  21. data/lib/braintree/customer_gateway.rb +2 -23
  22. data/lib/braintree/customer_search.rb +1 -1
  23. data/lib/braintree/disbursement.rb +1 -1
  24. data/lib/braintree/{transaction/coinbase_details.rb → dispute/paypal_message.rb} +5 -6
  25. data/lib/braintree/dispute/{history_event.rb → status_history.rb} +3 -1
  26. data/lib/braintree/dispute.rb +32 -8
  27. data/lib/braintree/dispute_gateway.rb +4 -9
  28. data/lib/braintree/dispute_search.rb +6 -3
  29. data/lib/braintree/document_upload.rb +1 -1
  30. data/lib/braintree/enriched_customer_data.rb +21 -0
  31. data/lib/braintree/error_codes.rb +150 -171
  32. data/lib/braintree/exceptions.rb +5 -3
  33. data/lib/braintree/exchange_rate.rb +13 -0
  34. data/lib/braintree/exchange_rate_quote.rb +24 -0
  35. data/lib/braintree/exchange_rate_quote_gateway.rb +35 -0
  36. data/lib/braintree/exchange_rate_quote_input.rb +21 -0
  37. data/lib/braintree/exchange_rate_quote_request.rb +18 -0
  38. data/lib/braintree/exchange_rate_quote_response.rb +18 -0
  39. data/lib/braintree/gateway.rb +4 -14
  40. data/lib/braintree/{android_pay_card.rb → google_pay_card.rb} +11 -3
  41. data/lib/braintree/granted_payment_instrument_update.rb +1 -1
  42. data/lib/braintree/graphql_client.rb +7 -7
  43. data/lib/braintree/http.rb +4 -3
  44. data/lib/braintree/local_payment_completed.rb +2 -2
  45. data/lib/braintree/local_payment_expired.rb +21 -0
  46. data/lib/braintree/local_payment_funded.rb +22 -0
  47. data/lib/braintree/local_payment_reversed.rb +19 -0
  48. data/lib/braintree/merchant.rb +1 -1
  49. data/lib/braintree/merchant_account.rb +1 -1
  50. data/lib/braintree/merchant_account_gateway.rb +3 -1
  51. data/lib/braintree/merchant_gateway.rb +1 -1
  52. data/lib/braintree/modification.rb +1 -1
  53. data/lib/braintree/oauth_credentials.rb +1 -1
  54. data/lib/braintree/oauth_gateway.rb +5 -5
  55. data/lib/braintree/payment_instrument_type.rb +10 -14
  56. data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
  57. data/lib/braintree/payment_method_gateway.rb +15 -17
  58. data/lib/braintree/payment_method_nonce.rb +7 -4
  59. data/lib/braintree/payment_method_nonce_details.rb +37 -0
  60. data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
  61. data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
  62. data/lib/braintree/payment_method_parser.rb +1 -8
  63. data/lib/braintree/plan.rb +21 -1
  64. data/lib/braintree/plan_gateway.rb +100 -0
  65. data/lib/braintree/processor_response_types.rb +3 -3
  66. data/lib/braintree/resource_collection.rb +8 -3
  67. data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
  68. data/lib/braintree/risk_data/liability_shift.rb +22 -0
  69. data/lib/braintree/risk_data.rb +5 -1
  70. data/lib/braintree/samsung_pay_card.rb +1 -1
  71. data/lib/braintree/settlement_batch_summary.rb +2 -2
  72. data/lib/braintree/subscription.rb +11 -11
  73. data/lib/braintree/successful_result.rb +3 -2
  74. data/lib/braintree/test/credit_card.rb +1 -0
  75. data/lib/braintree/test/nonce.rb +4 -23
  76. data/lib/braintree/three_d_secure_info.rb +22 -12
  77. data/lib/braintree/transaction/disbursement_details.rb +1 -0
  78. data/lib/braintree/transaction/{android_pay_details.rb → google_pay_details.rb} +1 -1
  79. data/lib/braintree/transaction/installment/adjustment.rb +33 -0
  80. data/lib/braintree/transaction/installment.rb +28 -0
  81. data/lib/braintree/transaction/paypal_details.rb +3 -0
  82. data/lib/braintree/transaction/subscription_details.rb +2 -0
  83. data/lib/braintree/transaction.rb +65 -120
  84. data/lib/braintree/transaction_gateway.rb +39 -27
  85. data/lib/braintree/transaction_line_item.rb +1 -1
  86. data/lib/braintree/transaction_review.rb +18 -0
  87. data/lib/braintree/transaction_search.rb +5 -3
  88. data/lib/braintree/unknown_payment_method.rb +1 -1
  89. data/lib/braintree/us_bank_account.rb +3 -3
  90. data/lib/braintree/us_bank_account_verification.rb +1 -1
  91. data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
  92. data/lib/braintree/util.rb +21 -6
  93. data/lib/braintree/venmo_account.rb +1 -1
  94. data/lib/braintree/venmo_profile_data.rb +23 -0
  95. data/lib/braintree/version.rb +2 -2
  96. data/lib/braintree/visa_checkout_card.rb +2 -2
  97. data/lib/braintree/webhook_notification.rb +44 -30
  98. data/lib/braintree/webhook_notification_gateway.rb +5 -5
  99. data/lib/braintree/webhook_testing_gateway.rb +104 -43
  100. data/lib/braintree/xml/generator.rb +5 -4
  101. data/lib/braintree/xml/parser.rb +22 -35
  102. data/lib/braintree/xml/rexml.rb +4 -5
  103. data/lib/braintree.rb +28 -23
  104. data/spec/integration/braintree/add_on_spec.rb +1 -1
  105. data/spec/integration/braintree/address_spec.rb +30 -113
  106. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  107. data/spec/integration/braintree/apple_pay_spec.rb +3 -3
  108. data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
  109. data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
  110. data/spec/integration/braintree/client_api/spec_helper.rb +5 -31
  111. data/spec/integration/braintree/credit_card_spec.rb +219 -593
  112. data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
  113. data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
  114. data/spec/integration/braintree/customer_search_spec.rb +8 -8
  115. data/spec/integration/braintree/customer_spec.rb +484 -513
  116. data/spec/integration/braintree/dispute_search_spec.rb +35 -6
  117. data/spec/integration/braintree/dispute_spec.rb +6 -7
  118. data/spec/integration/braintree/error_codes_spec.rb +1 -1
  119. data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
  120. data/spec/integration/braintree/graphql_client_spec.rb +0 -2
  121. data/spec/integration/braintree/http_spec.rb +2 -2
  122. data/spec/integration/braintree/merchant_account_spec.rb +28 -29
  123. data/spec/integration/braintree/merchant_spec.rb +14 -14
  124. data/spec/integration/braintree/oauth_spec.rb +11 -11
  125. data/spec/integration/braintree/payment_method_nonce_spec.rb +29 -35
  126. data/spec/integration/braintree/payment_method_spec.rb +535 -270
  127. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +17 -13
  128. data/spec/integration/braintree/paypal_account_spec.rb +28 -28
  129. data/spec/integration/braintree/plan_spec.rb +82 -0
  130. data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
  131. data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
  132. data/spec/integration/braintree/subscription_spec.rb +144 -149
  133. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  134. data/spec/integration/braintree/test_transaction_spec.rb +10 -10
  135. data/spec/integration/braintree/transaction_search_spec.rb +175 -70
  136. data/spec/integration/braintree/transaction_spec.rb +955 -894
  137. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -26
  138. data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
  139. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
  140. data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
  141. data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
  142. data/spec/integration/spec_helper.rb +16 -7
  143. data/spec/oauth_test_helper.rb +1 -1
  144. data/spec/script/httpsd.rb +6 -6
  145. data/spec/spec_helper.rb +8 -14
  146. data/spec/unit/braintree/address_spec.rb +1 -9
  147. data/spec/unit/braintree/apple_pay_card_spec.rb +7 -1
  148. data/spec/unit/braintree/client_token_spec.rb +2 -2
  149. data/spec/unit/braintree/configuration_spec.rb +42 -42
  150. data/spec/unit/braintree/credit_card_spec.rb +13 -32
  151. data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
  152. data/spec/unit/braintree/credit_card_verification_spec.rb +8 -4
  153. data/spec/unit/braintree/customer_spec.rb +21 -22
  154. data/spec/unit/braintree/disbursement_spec.rb +7 -7
  155. data/spec/unit/braintree/dispute_search_spec.rb +3 -0
  156. data/spec/unit/braintree/dispute_spec.rb +75 -21
  157. data/spec/unit/braintree/enriched_customer_data_spec.rb +32 -0
  158. data/spec/unit/braintree/error_result_spec.rb +5 -5
  159. data/spec/unit/braintree/errors_spec.rb +8 -8
  160. data/spec/unit/braintree/exchange_rate_quote_input_spec.rb +42 -0
  161. data/spec/unit/braintree/exchange_rate_quote_request_spec.rb +82 -0
  162. data/spec/unit/braintree/exchange_rate_quote_response_spec.rb +52 -0
  163. data/spec/unit/braintree/exchange_rate_quote_spec.rb +42 -0
  164. data/spec/unit/braintree/exchange_rate_spec.rb +23 -0
  165. data/spec/unit/braintree/http_spec.rb +10 -8
  166. data/spec/unit/braintree/local_payment_completed_spec.rb +14 -0
  167. data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
  168. data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
  169. data/spec/unit/braintree/merchant_account_spec.rb +1 -1
  170. data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +45 -0
  171. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
  172. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +43 -0
  173. data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
  174. data/spec/unit/braintree/payment_method_spec.rb +1 -1
  175. data/spec/unit/braintree/paypal_account_spec.rb +2 -2
  176. data/spec/unit/braintree/resource_collection_spec.rb +30 -1
  177. data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
  178. data/spec/unit/braintree/risk_data_spec.rb +38 -8
  179. data/spec/unit/braintree/subscription_search_spec.rb +1 -1
  180. data/spec/unit/braintree/successful_result_spec.rb +1 -1
  181. data/spec/unit/braintree/three_d_secure_info_spec.rb +32 -14
  182. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +3 -3
  183. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  184. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  185. data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
  186. data/spec/unit/braintree/transaction/paypal_details_spec.rb +7 -1
  187. data/spec/unit/braintree/transaction_search_spec.rb +12 -12
  188. data/spec/unit/braintree/transaction_spec.rb +36 -54
  189. data/spec/unit/braintree/util_spec.rb +55 -21
  190. data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
  191. data/spec/unit/braintree/venmo_profile_data_spec.rb +32 -0
  192. data/spec/unit/braintree/webhook_notification_spec.rb +166 -57
  193. data/spec/unit/braintree/xml/parser_spec.rb +21 -16
  194. data/spec/unit/braintree/xml_spec.rb +31 -31
  195. metadata +62 -30
  196. data/lib/braintree/amex_express_checkout_card.rb +0 -40
  197. data/lib/braintree/coinbase_account.rb +0 -34
  198. data/lib/braintree/europe_bank_account.rb +0 -36
  199. data/lib/braintree/europe_bank_account_gateway.rb +0 -17
  200. data/lib/braintree/ideal_payment.rb +0 -61
  201. data/lib/braintree/ideal_payment_gateway.rb +0 -19
  202. data/lib/braintree/masterpass_card.rb +0 -83
  203. data/lib/braintree/settlement_batch.rb +0 -0
  204. data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -21
  205. data/lib/braintree/transaction/ideal_payment_details.rb +0 -19
  206. data/lib/braintree/transaction/masterpass_card_details.rb +0 -49
  207. data/lib/braintree/transparent_redirect.rb +0 -40
  208. data/lib/braintree/transparent_redirect_gateway.rb +0 -105
  209. data/spec/hacks/tcp_socket.rb +0 -18
  210. data/spec/integration/braintree/coinbase_spec.rb +0 -34
  211. data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
  212. data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
  213. data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
@@ -14,7 +14,8 @@ describe Braintree::Transaction do
14
14
  let(:plaid_nonce) { generate_valid_plaid_us_bank_account_nonce }
15
15
 
16
16
  context "nonce" do
17
- it "sale succeeds" do
17
+ # we are temporarily skipping this test until we have a more stable CI env
18
+ xit "sale succeeds" do
18
19
  result = Braintree::Transaction.create(
19
20
  :type => "sale",
20
21
  :amount => Braintree::Test::TransactionAmounts::Authorize,
@@ -22,7 +23,7 @@ describe Braintree::Transaction do
22
23
  :payment_method_nonce => plaid_nonce,
23
24
  :options => {
24
25
  :submit_for_settlement => true,
25
- }
26
+ },
26
27
  )
27
28
  result.success?.should == true
28
29
  result.transaction.id.should =~ /^\w{6,}$/
@@ -41,13 +42,14 @@ describe Braintree::Transaction do
41
42
  end
42
43
 
43
44
  context "token" do
44
- it "payment_method#create then sale succeeds" do
45
+ # we are temporarily skipping this test until we have a more stable CI env
46
+ xit "payment_method#create then sale succeeds" do
45
47
  payment_method = Braintree::PaymentMethod.create(
46
48
  :payment_method_nonce => plaid_nonce,
47
49
  :customer_id => Braintree::Customer.create.customer.id,
48
50
  :options => {
49
51
  :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
50
- }
52
+ },
51
53
  ).payment_method
52
54
 
53
55
  payment_method.verifications.count.should == 1
@@ -64,7 +66,7 @@ describe Braintree::Transaction do
64
66
  :payment_method_token => payment_method.token,
65
67
  :options => {
66
68
  :submit_for_settlement => true,
67
- }
69
+ },
68
70
  )
69
71
 
70
72
  result.success?.should == true
@@ -84,7 +86,8 @@ describe Braintree::Transaction do
84
86
  transaction.us_bank_account_details.ach_mandate.accepted_at.should be_a Time
85
87
  end
86
88
 
87
- it "transaction#create store_in_vault then sale succeeds" do
89
+ # we are temporarily skipping this test until we have a more stable CI env
90
+ xit "transaction#create store_in_vault then sale succeeds" do
88
91
  result = Braintree::Transaction.create(
89
92
  :type => "sale",
90
93
  :amount => Braintree::Test::TransactionAmounts::Authorize,
@@ -93,7 +96,7 @@ describe Braintree::Transaction do
93
96
  :options => {
94
97
  :submit_for_settlement => true,
95
98
  :store_in_vault => true,
96
- }
99
+ },
97
100
  )
98
101
 
99
102
  result.success?.should == true
@@ -105,7 +108,7 @@ describe Braintree::Transaction do
105
108
  :payment_method_token => result.transaction.us_bank_account_details.token,
106
109
  :options => {
107
110
  :submit_for_settlement => true,
108
- }
111
+ },
109
112
  )
110
113
 
111
114
  result.success?.should == true
@@ -140,7 +143,7 @@ describe Braintree::Transaction do
140
143
  :payment_method_nonce => non_plaid_nonce,
141
144
  :options => {
142
145
  :submit_for_settlement => true,
143
- }
146
+ },
144
147
  )
145
148
  result.success?.should == false
146
149
  result.errors.for(:transaction).on(:payment_method_nonce)[0].code.should == Braintree::ErrorCodes::Transaction::UsBankAccountNonceMustBePlaidVerified
@@ -154,7 +157,7 @@ describe Braintree::Transaction do
154
157
  :payment_method_nonce => invalid_nonce,
155
158
  :options => {
156
159
  :submit_for_settlement => true,
157
- }
160
+ },
158
161
  )
159
162
  result.success?.should == false
160
163
  result.errors.for(:transaction).on(:payment_method_nonce)[0].code.should == Braintree::ErrorCodes::Transaction::PaymentMethodNonceUnknown
@@ -169,7 +172,7 @@ describe Braintree::Transaction do
169
172
  :options => {
170
173
  :us_bank_account_verification_method => "independent_check",
171
174
  :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
172
- }
175
+ },
173
176
  )
174
177
  payment_method = result.payment_method
175
178
 
@@ -187,7 +190,7 @@ describe Braintree::Transaction do
187
190
  :payment_method_token => payment_method.token,
188
191
  :options => {
189
192
  :submit_for_settlement => true,
190
- }
193
+ },
191
194
  )
192
195
 
193
196
  result.success?.should == true
@@ -199,7 +202,7 @@ describe Braintree::Transaction do
199
202
  :customer_id => Braintree::Customer.create.customer.id,
200
203
  :options => {
201
204
  :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
202
- }
205
+ },
203
206
  ).payment_method
204
207
 
205
208
  payment_method.verifications.count.should == 0
@@ -212,7 +215,7 @@ describe Braintree::Transaction do
212
215
  :payment_method_token => payment_method.token,
213
216
  :options => {
214
217
  :submit_for_settlement => true,
215
- }
218
+ },
216
219
  )
217
220
 
218
221
  result.success?.should == false
@@ -233,7 +236,8 @@ describe Braintree::Transaction do
233
236
  let(:plaid_nonce) { generate_valid_plaid_us_bank_account_nonce }
234
237
 
235
238
  context "nonce" do
236
- it "sale succeeds" do
239
+ # we are temporarily skipping this test until we have a more stable CI env
240
+ xit "sale succeeds" do
237
241
  result = Braintree::Transaction.create(
238
242
  :type => "sale",
239
243
  :amount => Braintree::Test::TransactionAmounts::Authorize,
@@ -241,7 +245,7 @@ describe Braintree::Transaction do
241
245
  :payment_method_nonce => plaid_nonce,
242
246
  :options => {
243
247
  :submit_for_settlement => true,
244
- }
248
+ },
245
249
  )
246
250
  result.success?.should == true
247
251
  result.transaction.id.should =~ /^\w{6,}$/
@@ -260,13 +264,14 @@ describe Braintree::Transaction do
260
264
  end
261
265
 
262
266
  context "token" do
263
- it "payment_method#create then sale succeeds" do
267
+ # we are temporarily skipping this test until we have a more stable CI env
268
+ xit "payment_method#create then sale succeeds" do
264
269
  result = Braintree::PaymentMethod.create(
265
270
  :payment_method_nonce => plaid_nonce,
266
271
  :customer_id => Braintree::Customer.create.customer.id,
267
272
  :options => {
268
273
  :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
269
- }
274
+ },
270
275
  )
271
276
 
272
277
  payment_method = result.payment_method
@@ -285,7 +290,7 @@ describe Braintree::Transaction do
285
290
  :payment_method_token => payment_method.token,
286
291
  :options => {
287
292
  :submit_for_settlement => true,
288
- }
293
+ },
289
294
  )
290
295
 
291
296
  result.success?.should == true
@@ -305,7 +310,8 @@ describe Braintree::Transaction do
305
310
  transaction.us_bank_account_details.ach_mandate.accepted_at.should be_a Time
306
311
  end
307
312
 
308
- it "transaction#create store_in_vault then sale succeeds" do
313
+ # we are temporarily skipping this test until we have a more stable CI env
314
+ xit "transaction#create store_in_vault then sale succeeds" do
309
315
  result = Braintree::Transaction.create(
310
316
  :type => "sale",
311
317
  :amount => Braintree::Test::TransactionAmounts::Authorize,
@@ -314,7 +320,7 @@ describe Braintree::Transaction do
314
320
  :options => {
315
321
  :submit_for_settlement => true,
316
322
  :store_in_vault => true,
317
- }
323
+ },
318
324
  )
319
325
 
320
326
  result.success?.should == true
@@ -326,7 +332,7 @@ describe Braintree::Transaction do
326
332
  :payment_method_token => result.transaction.us_bank_account_details.token,
327
333
  :options => {
328
334
  :submit_for_settlement => true,
329
- }
335
+ },
330
336
  )
331
337
 
332
338
  result.success?.should == true
@@ -361,7 +367,7 @@ describe Braintree::Transaction do
361
367
  :payment_method_nonce => non_plaid_nonce,
362
368
  :options => {
363
369
  :submit_for_settlement => true,
364
- }
370
+ },
365
371
  )
366
372
  result.success?.should == true
367
373
 
@@ -388,7 +394,7 @@ describe Braintree::Transaction do
388
394
  :payment_method_nonce => invalid_nonce,
389
395
  :options => {
390
396
  :submit_for_settlement => true,
391
- }
397
+ },
392
398
  )
393
399
  result.success?.should == false
394
400
  result.errors.for(:transaction).on(:payment_method_nonce)[0].code.should == Braintree::ErrorCodes::Transaction::PaymentMethodNonceUnknown
@@ -402,7 +408,7 @@ describe Braintree::Transaction do
402
408
  :customer_id => Braintree::Customer.create.customer.id,
403
409
  :options => {
404
410
  :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
405
- }
411
+ },
406
412
  )
407
413
  payment_method = result.payment_method
408
414
 
@@ -420,7 +426,7 @@ describe Braintree::Transaction do
420
426
  :payment_method_token => payment_method.token,
421
427
  :options => {
422
428
  :submit_for_settlement => true,
423
- }
429
+ },
424
430
  )
425
431
 
426
432
  result.success?.should == true
@@ -12,7 +12,7 @@ describe Braintree::UsBankAccount do
12
12
  :customer_id => customer.id,
13
13
  :options => {
14
14
  :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
15
- }
15
+ },
16
16
  )
17
17
  result.should be_success
18
18
 
@@ -44,14 +44,14 @@ describe Braintree::UsBankAccount do
44
44
  :customer_id => customer.id,
45
45
  :options => {
46
46
  :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
47
- }
47
+ },
48
48
  )
49
49
  result.should be_success
50
50
 
51
51
  result = Braintree::UsBankAccount.sale(
52
52
  result.payment_method.token,
53
53
  :merchant_account_id => SpecHelper::UsBankMerchantAccountId,
54
- :amount => "100.00"
54
+ :amount => "100.00",
55
55
  )
56
56
 
57
57
  result.success?.should == true
@@ -78,14 +78,14 @@ describe Braintree::UsBankAccount do
78
78
  :customer_id => customer.id,
79
79
  :options => {
80
80
  :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
81
- }
81
+ },
82
82
  )
83
83
  result.should be_success
84
84
 
85
85
  transaction = Braintree::UsBankAccount.sale!(
86
86
  result.payment_method.token,
87
87
  :merchant_account_id => SpecHelper::UsBankMerchantAccountId,
88
- :amount => "100.00"
88
+ :amount => "100.00",
89
89
  )
90
90
 
91
91
  transaction.amount.should == BigDecimal("100.00")
@@ -105,7 +105,7 @@ describe Braintree::UsBankAccount do
105
105
  Braintree::UsBankAccount.sale!(
106
106
  generate_invalid_us_bank_account_nonce,
107
107
  :merchant_account_id => SpecHelper::UsBankMerchantAccountId,
108
- :amount => "100.00"
108
+ :amount => "100.00",
109
109
  )
110
110
  end.to raise_error(Braintree::ValidationsFailed)
111
111
  end
@@ -21,7 +21,7 @@ describe Braintree::UsBankAccountVerification, "search" do
21
21
  :customer_id => customer.id,
22
22
  :options => {
23
23
  :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
24
- }
24
+ },
25
25
  ).payment_method
26
26
  verification = payment_method.verifications.first
27
27
 
@@ -70,7 +70,7 @@ describe Braintree::UsBankAccountVerification, "search" do
70
70
  :customer_id => customer.id,
71
71
  :options => {
72
72
  :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
73
- }
73
+ },
74
74
  ).payment_method
75
75
  verification1 = payment_method1.verifications.first
76
76
 
@@ -79,7 +79,7 @@ describe Braintree::UsBankAccountVerification, "search" do
79
79
  :customer_id => customer.id,
80
80
  :options => {
81
81
  :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
82
- }
82
+ },
83
83
  ).payment_method
84
84
  verification2 = payment_method2.verifications.first
85
85
 
@@ -100,7 +100,7 @@ describe Braintree::UsBankAccountVerification, "search" do
100
100
  :customer_id => customer.id,
101
101
  :options => {
102
102
  :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
103
- }
103
+ },
104
104
  ).payment_method
105
105
  verification = payment_method.verifications.first
106
106
 
@@ -110,7 +110,7 @@ describe Braintree::UsBankAccountVerification, "search" do
110
110
  search.id.is verification.id
111
111
  search.created_at.between(
112
112
  created_at - 60,
113
- created_at + 60
113
+ created_at + 60,
114
114
  )
115
115
  end
116
116
 
@@ -137,7 +137,7 @@ describe Braintree::UsBankAccountVerification, "search" do
137
137
  search.id.is verification.id
138
138
  search.created_at.between(
139
139
  created_at - 300,
140
- created_at - 100
140
+ created_at - 100,
141
141
  )
142
142
  end
143
143
 
@@ -162,7 +162,7 @@ describe Braintree::UsBankAccountVerification, "search" do
162
162
  :customer_id => customer.id,
163
163
  :options => {
164
164
  :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
165
- }
165
+ },
166
166
  ).payment_method
167
167
  verification = payment_method.verifications.first
168
168
 
@@ -36,7 +36,7 @@ describe Braintree::UsBankAccountVerification do
36
36
  :options => {
37
37
  :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
38
38
  :us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers,
39
- }
39
+ },
40
40
  )
41
41
 
42
42
  result.should be_success
@@ -64,7 +64,7 @@ describe Braintree::UsBankAccountVerification do
64
64
  :options => {
65
65
  :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
66
66
  :us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers,
67
- }
67
+ },
68
68
  )
69
69
 
70
70
  result.should be_success
@@ -86,7 +86,7 @@ describe Braintree::UsBankAccountVerification do
86
86
  :options => {
87
87
  :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
88
88
  :us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers,
89
- }
89
+ },
90
90
  )
91
91
 
92
92
  result.should be_success
@@ -108,7 +108,7 @@ describe Braintree::UsBankAccountVerification do
108
108
  :options => {
109
109
  :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
110
110
  :us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers,
111
- }
111
+ },
112
112
  )
113
113
 
114
114
  result.should be_success
@@ -139,7 +139,7 @@ describe Braintree::UsBankAccountVerification do
139
139
  :options => {
140
140
  :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
141
141
  :us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::MicroTransfers,
142
- }
142
+ },
143
143
  )
144
144
 
145
145
  result.should be_success
@@ -160,7 +160,7 @@ describe Braintree::UsBankAccountVerification do
160
160
  :options => {
161
161
  :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
162
162
  :us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
163
- }
163
+ },
164
164
  )
165
165
 
166
166
  result.should be_success
@@ -182,7 +182,7 @@ describe Braintree::UsBankAccountVerification do
182
182
  :options => {
183
183
  :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
184
184
  :us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
185
- }
185
+ },
186
186
  )
187
187
 
188
188
  result.should be_success
@@ -208,7 +208,7 @@ describe Braintree::UsBankAccountVerification do
208
208
  :options => {
209
209
  :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
210
210
  :us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
211
- }
211
+ },
212
212
  ).payment_method
213
213
  end
214
214
 
@@ -7,7 +7,7 @@ describe Braintree::VisaCheckoutCard do
7
7
 
8
8
  result = Braintree::PaymentMethod.create(
9
9
  :payment_method_nonce => Braintree::Test::Nonce::VisaCheckoutDiscover,
10
- :customer_id => customer.id
10
+ :customer_id => customer.id,
11
11
  )
12
12
  result.should be_success
13
13
 
@@ -53,7 +53,7 @@ describe Braintree::VisaCheckoutCard do
53
53
  result = Braintree::PaymentMethod.create(
54
54
  :payment_method_nonce => Braintree::Test::Nonce::VisaCheckoutDiscover,
55
55
  :customer_id => customer.id,
56
- :options => { :verify_card => true }
56
+ :options => {:verify_card => true},
57
57
  )
58
58
  result.should be_success
59
59
  result.payment_method.verification.status.should == Braintree::CreditCardVerification::Status::Verified
@@ -62,7 +62,7 @@ describe Braintree::VisaCheckoutCard do
62
62
  it "can search for transactions" do
63
63
  transaction_create_result = Braintree::Transaction.sale(
64
64
  :payment_method_nonce => Braintree::Test::Nonce::VisaCheckoutDiscover,
65
- :amount => '47.00',
65
+ :amount => "47.00",
66
66
  )
67
67
  transaction_create_result.should be_success
68
68
  transaction_id = transaction_create_result.transaction.id
@@ -80,8 +80,8 @@ describe Braintree::VisaCheckoutCard do
80
80
  result = Braintree::Transaction.sale(
81
81
  :payment_method_nonce => Braintree::Test::Nonce::VisaCheckoutDiscover,
82
82
  :customer_id => customer.id,
83
- :amount => '47.00',
84
- :options => { :store_in_vault => true },
83
+ :amount => "47.00",
84
+ :options => {:store_in_vault => true},
85
85
  )
86
86
  result.should be_success
87
87
 
@@ -2,10 +2,9 @@ require "securerandom"
2
2
 
3
3
  unless defined?(INTEGRATION_SPEC_HELPER_LOADED)
4
4
  INTEGRATION_SPEC_HELPER_LOADED = true
5
- SSL_TEST_PORT = ENV['SSL_TEST_PORT'] || 8444
5
+ SSL_TEST_PORT = ENV["SSL_TEST_PORT"] || 8444
6
6
 
7
7
  require File.dirname(__FILE__) + "/../spec_helper"
8
- require File.dirname(__FILE__) + "/../hacks/tcp_socket"
9
8
 
10
9
  def start_ssl_server
11
10
  web_server_pid_file = File.expand_path(File.join(File.dirname(__FILE__), "..", "httpsd.pid"))
@@ -13,11 +12,9 @@ unless defined?(INTEGRATION_SPEC_HELPER_LOADED)
13
12
  FileUtils.rm(web_server_pid_file) if File.exist?(web_server_pid_file)
14
13
  command = File.expand_path(File.join(File.dirname(__FILE__), "..", "script", "httpsd.rb"))
15
14
  `#{command} #{web_server_pid_file}`
16
- TCPSocket.wait_for_service :host => "127.0.0.1", :port => SSL_TEST_PORT
15
+ TCPSocket.new("127.0.0.1",SSL_TEST_PORT)
17
16
 
18
- yield
19
-
20
- 10.times { unless File.exists?(web_server_pid_file); sleep 1; end }
17
+ 10.times { unless File.exist?(web_server_pid_file); sleep 1; end }
21
18
  ensure
22
19
  Process.kill "INT", File.read(web_server_pid_file).to_i
23
20
  end
@@ -45,12 +42,24 @@ unless defined?(INTEGRATION_SPEC_HELPER_LOADED)
45
42
  end
46
43
  end
47
44
 
48
- def with_advanced_fraud_integration_merchant(&block)
45
+ def with_advanced_fraud_kount_integration_merchant(&block)
49
46
  with_other_merchant("advanced_fraud_integration_merchant_id", "advanced_fraud_integration_public_key", "advanced_fraud_integration_private_key") do
50
47
  block.call
51
48
  end
52
49
  end
53
50
 
51
+ def with_fraud_protection_enterprise_merchant(&block)
52
+ with_other_merchant("fraud_protection_enterprise_integration_merchant_id", "fraud_protection_enterprise_integration_public_key", "fraud_protection_enterprise_integration_private_key") do
53
+ block.call
54
+ end
55
+ end
56
+
57
+ def with_chargeback_protection_merchant(&block)
58
+ with_other_merchant("fraud_protection_effortless_chargeback_protection_merchant_id", "effortless_chargeback_protection_public_key", "effortless_chargeback_protection_private_key") do
59
+ block.call
60
+ end
61
+ end
62
+
54
63
  def with_altpay_merchant(&block)
55
64
  with_other_merchant("altpay_merchant", "altpay_merchant_public_key", "altpay_merchant_private_key", &block)
56
65
  end
@@ -10,7 +10,7 @@ module Braintree
10
10
  def self.create_token(gateway, params)
11
11
  code = create_grant(gateway, params)
12
12
  gateway.oauth.create_token_from_code(
13
- :code => code
13
+ :code => code,
14
14
  )
15
15
  end
16
16
  end
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- require 'webrick'
3
- require 'webrick/https'
4
- require 'openssl'
2
+ require "webrick"
3
+ require "webrick/https"
4
+ require "openssl"
5
5
 
6
6
  private_key_file = File.expand_path(File.join(File.dirname(__FILE__), "..", "ssl", "privateKey.key"))
7
7
  cert_file = File.expand_path(File.join(File.dirname(__FILE__), "..", "ssl", "certificate.crt"))
@@ -12,7 +12,7 @@ cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
12
12
  pid_file = ARGV[0]
13
13
 
14
14
  s = WEBrick::HTTPServer.new(
15
- :Port => (ENV['SSL_TEST_PORT'] || 8444),
15
+ :Port => (ENV["SSL_TEST_PORT"] || 8444),
16
16
  :Logger => WEBrick::Log::new(nil, WEBrick::Log::ERROR),
17
17
  :DocumentRoot => File.join(File.dirname(__FILE__)),
18
18
  :ServerType => WEBrick::Daemon,
@@ -21,7 +21,7 @@ s = WEBrick::HTTPServer.new(
21
21
  :SSLCertificate => cert,
22
22
  :SSLPrivateKey => pkey,
23
23
  :SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ],
24
- :StartCallback => proc { File.open(pid_file, "w") { |f| f.write $$.to_s }}
24
+ :StartCallback => proc { File.open(pid_file, "w") { |f| f.write $$.to_s } },
25
25
  )
26
- trap("INT"){ s.shutdown }
26
+ trap("INT") { s.shutdown }
27
27
  s.start
data/spec/spec_helper.rb CHANGED
@@ -3,8 +3,8 @@ unless defined?(SPEC_HELPER_LOADED)
3
3
  project_root = File.expand_path(File.dirname(__FILE__) + "/..")
4
4
  require "rubygems"
5
5
  require "bundler/setup"
6
- require "rspec"
7
6
  require "libxml"
7
+ require "rspec"
8
8
  require "pry"
9
9
 
10
10
  braintree_lib = "#{project_root}/lib"
@@ -28,10 +28,6 @@ unless defined?(SPEC_HELPER_LOADED)
28
28
  end
29
29
  end
30
30
 
31
- def now_in_eastern
32
- (Time.now.utc - 5*60*60).strftime("%Y-%m-%d")
33
- end
34
-
35
31
  module SpecHelper
36
32
 
37
33
  DefaultMerchantAccountId = "sandbox_credit_card"
@@ -44,6 +40,9 @@ unless defined?(SPEC_HELPER_LOADED)
44
40
  AnotherUsBankMerchantAccountId = "another_us_bank_merchant_account"
45
41
  AdyenMerchantAccountId = "adyen_ma"
46
42
  HiperBRLMerchantAccountId = "hiper_brl"
43
+ CardProcessorBRLMerchantAccountId = "card_processor_brl"
44
+ FakeFirstDataMerchantAccountId = "fake_first_data_merchant_account"
45
+ AibSwedenMaMerchantAccountId = "aib_swe_ma"
47
46
 
48
47
  TrialPlan = {
49
48
  :description => "Plan for integration tests -- with trial",
@@ -92,13 +91,13 @@ unless defined?(SPEC_HELPER_LOADED)
92
91
  :environment => Braintree::Configuration.environment,
93
92
  :merchant_id => "test_merchant_id",
94
93
  :public_key => "test_public_key",
95
- :private_key => "test_private_key"
94
+ :private_key => "test_private_key",
96
95
  )
97
96
 
98
97
  def self.make_past_due(subscription, number_of_days_past_due = 1)
99
98
  config = Braintree::Configuration.instantiate
100
99
  config.http.put(
101
- "#{config.base_merchant_path}/subscriptions/#{subscription.id}/make_past_due?days_past_due=#{number_of_days_past_due}"
100
+ "#{config.base_merchant_path}/subscriptions/#{subscription.id}/make_past_due?days_past_due=#{number_of_days_past_due}",
102
101
  )
103
102
  end
104
103
 
@@ -117,7 +116,7 @@ unless defined?(SPEC_HELPER_LOADED)
117
116
  gateway = Braintree::Gateway.new(
118
117
  :client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
119
118
  :client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
120
- :logger => Logger.new("/dev/null")
119
+ :logger => Logger.new("/dev/null"),
121
120
  )
122
121
 
123
122
  gateway.merchant.create({
@@ -188,16 +187,11 @@ unless defined?(SPEC_HELPER_LOADED)
188
187
  end
189
188
 
190
189
  def matches?(xml_string)
191
- @libxml_parse = Braintree::Xml::Parser.hash_from_xml(xml_string, Braintree::Xml::Libxml)
192
- @rexml_parse = Braintree::Xml::Parser.hash_from_xml(xml_string, Braintree::Xml::Rexml)
190
+ @libxml_parse = Braintree::Xml::Parser.hash_from_xml(xml_string)
193
191
  if @libxml_parse != @expected_hash
194
192
  @results = @libxml_parse
195
193
  @failed_parser = "libxml"
196
194
  false
197
- elsif @rexml_parse != @expected_hash
198
- @results = @rexml_parse
199
- @failed_parser = "rexml"
200
- false
201
195
  else
202
196
  true
203
197
  end
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
3
3
  describe Braintree::Address do
4
4
  describe "==" do
5
5
  it "returns true if given an address with the same id and customer_id" do
6
- first = Braintree::Address._new(:gateway, :customer_id => "c1", :id => 'a1')
6
+ first = Braintree::Address._new(:gateway, :customer_id => "c1", :id => "a1")
7
7
  second = Braintree::Address._new(:gateway, :customer_id => "c1", :id => "a1")
8
8
 
9
9
  first.should == second
@@ -94,12 +94,4 @@ describe Braintree::Address do
94
94
  end.to raise_error(NoMethodError, /protected method .new/)
95
95
  end
96
96
  end
97
-
98
- describe "update" do
99
- it "raises an exception if hash includes an invalid key" do
100
- expect do
101
- Braintree::Address._new(Braintree::Configuration.gateway, {}).update(:street_address => "456 E Main", :invalid_key2 => "foo")
102
- end.to raise_error(ArgumentError, "invalid keys: invalid_key2")
103
- end
104
- end
105
97
  end
@@ -3,7 +3,13 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
3
3
  describe Braintree::ApplePayCard do
4
4
  describe "bin" do
5
5
  it "returns Apple pay card bin" do
6
- Braintree::ApplePayCard._new(:gateway, bin: '411111').bin.should == '411111'
6
+ Braintree::ApplePayCard._new(:gateway, bin: "411111").bin.should == "411111"
7
+ end
8
+ end
9
+
10
+ describe "cardholder_name" do
11
+ it "returns Apple pay card cardholder name" do
12
+ Braintree::ApplePayCard._new(:gateway, cardholder_name: "John Miller").cardholder_name.should == "John Miller"
7
13
  end
8
14
  end
9
15
 
@@ -16,7 +16,7 @@ module Braintree
16
16
  expect {
17
17
  client_token = Braintree::ClientToken.generate(
18
18
  :public_key => "bad_key",
19
- :created_at => "bad_time"
19
+ :created_at => "bad_time",
20
20
  )
21
21
  }.to raise_error(ArgumentError, /created_at, public_key/)
22
22
  end
@@ -27,7 +27,7 @@ module Braintree
27
27
  it "raises an ArgumentError if #{option_name} is present" do
28
28
  expect do
29
29
  Braintree::ClientToken.generate(
30
- option_name.to_sym => true
30
+ option_name.to_sym => true,
31
31
  )
32
32
  end.to raise_error(ArgumentError, /#{option_name}/)
33
33
  end