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
@@ -1,4 +1,4 @@
1
- require 'stringio'
1
+ require "stringio"
2
2
 
3
3
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
4
4
 
@@ -22,26 +22,26 @@ describe Braintree::Configuration do
22
22
  describe "initialize" do
23
23
  it "accepts merchant credentials" do
24
24
  config = Braintree::Configuration.new(
25
- :merchant_id => 'merchant_id',
26
- :public_key => 'public_key',
27
- :private_key => 'private_key'
25
+ :merchant_id => "merchant_id",
26
+ :public_key => "public_key",
27
+ :private_key => "private_key",
28
28
  )
29
29
 
30
- config.merchant_id.should == 'merchant_id'
31
- config.public_key.should == 'public_key'
32
- config.private_key.should == 'private_key'
30
+ config.merchant_id.should == "merchant_id"
31
+ config.public_key.should == "public_key"
32
+ config.private_key.should == "private_key"
33
33
  end
34
34
 
35
35
  it "accepts partner credentials" do
36
36
  config = Braintree::Configuration.new(
37
- :partner_id => 'partner_id',
38
- :public_key => 'public_key',
39
- :private_key => 'private_key'
37
+ :partner_id => "partner_id",
38
+ :public_key => "public_key",
39
+ :private_key => "private_key",
40
40
  )
41
41
 
42
- config.merchant_id.should == 'partner_id'
43
- config.public_key.should == 'public_key'
44
- config.private_key.should == 'private_key'
42
+ config.merchant_id.should == "partner_id"
43
+ config.public_key.should == "public_key"
44
+ config.private_key.should == "private_key"
45
45
  end
46
46
 
47
47
  it "raises if combining client_id/secret with access_token" do
@@ -49,7 +49,7 @@ describe Braintree::Configuration do
49
49
  Braintree::Configuration.new(
50
50
  :client_id => "client_id$development$integration_client_id",
51
51
  :client_secret => "client_secret$development$integration_client_secret",
52
- :access_token => "access_token$development$integration_merchant_id$fb27c79dd"
52
+ :access_token => "access_token$development$integration_merchant_id$fb27c79dd",
53
53
  )
54
54
  end.to raise_error(Braintree::ConfigurationError, /mixed credential types/)
55
55
  end
@@ -62,7 +62,7 @@ describe Braintree::Configuration do
62
62
  :merchant_id => "merchant_id",
63
63
  :public_key => "public_key",
64
64
  :private_key => "private_key",
65
- :environment => "development"
65
+ :environment => "development",
66
66
  )
67
67
  end.to raise_error(Braintree::ConfigurationError, /mixed credential types/)
68
68
  end
@@ -96,21 +96,21 @@ describe Braintree::Configuration do
96
96
 
97
97
  it "accepts proxy params" do
98
98
  config = Braintree::Configuration.new(
99
- :proxy_address => 'localhost',
99
+ :proxy_address => "localhost",
100
100
  :proxy_port => 8080,
101
- :proxy_user => 'user',
102
- :proxy_pass => 'test'
101
+ :proxy_user => "user",
102
+ :proxy_pass => "test",
103
103
  )
104
104
 
105
- config.proxy_address.should == 'localhost'
105
+ config.proxy_address.should == "localhost"
106
106
  config.proxy_port.should == 8080
107
- config.proxy_user.should == 'user'
108
- config.proxy_pass.should == 'test'
107
+ config.proxy_user.should == "user"
108
+ config.proxy_pass.should == "test"
109
109
  end
110
110
 
111
111
  it "accepts ssl version" do
112
112
  config = Braintree::Configuration.new(
113
- :ssl_version => :TLSv1_2
113
+ :ssl_version => :TLSv1_2,
114
114
  )
115
115
 
116
116
  config.ssl_version.should == :TLSv1_2
@@ -146,14 +146,14 @@ describe Braintree::Configuration do
146
146
  Braintree::Configuration.environment = :sandbox
147
147
  ca_file = Braintree::Configuration.instantiate.ca_file
148
148
  ca_file.should match(/api_braintreegateway_com\.ca\.crt$/)
149
- File.exists?(ca_file).should == true
149
+ File.exist?(ca_file).should == true
150
150
  end
151
151
 
152
152
  it "production" do
153
153
  Braintree::Configuration.environment = :production
154
154
  ca_file = Braintree::Configuration.instantiate.ca_file
155
155
  ca_file.should match(/api_braintreegateway_com\.ca\.crt$/)
156
- File.exists?(ca_file).should == true
156
+ File.exist?(ca_file).should == true
157
157
  end
158
158
  end
159
159
 
@@ -238,12 +238,12 @@ describe Braintree::Configuration do
238
238
 
239
239
  it "allows the environment to be set with a string value" do
240
240
  expect do
241
- Braintree::Configuration.environment = 'sandbox'
241
+ Braintree::Configuration.environment = "sandbox"
242
242
  end.not_to raise_error
243
243
  end
244
244
 
245
245
  it "sets the environment as a symbol" do
246
- Braintree::Configuration.environment = 'sandbox'
246
+ Braintree::Configuration.environment = "sandbox"
247
247
  expect(Braintree::Configuration.environment).to eq :sandbox
248
248
  end
249
249
  end
@@ -326,15 +326,15 @@ describe Braintree::Configuration do
326
326
 
327
327
  it "is 3000 or GATEWAY_PORT environment variable for development" do
328
328
  Braintree::Configuration.environment = :development
329
- old_gateway_port = ENV['GATEWAY_PORT']
329
+ old_gateway_port = ENV["GATEWAY_PORT"]
330
330
  begin
331
- ENV['GATEWAY_PORT'] = nil
331
+ ENV["GATEWAY_PORT"] = nil
332
332
  Braintree::Configuration.instantiate.port.should == 3000
333
333
 
334
- ENV['GATEWAY_PORT'] = '1234'
335
- Braintree::Configuration.instantiate.port.should == '1234'
334
+ ENV["GATEWAY_PORT"] = "1234"
335
+ Braintree::Configuration.instantiate.port.should == "1234"
336
336
  ensure
337
- ENV['GATEWAY_PORT'] = old_gateway_port
337
+ ENV["GATEWAY_PORT"] = old_gateway_port
338
338
  end
339
339
  end
340
340
  end
@@ -359,15 +359,15 @@ describe Braintree::Configuration do
359
359
  describe "graphql_server" do
360
360
  it "is localhost or GRAPHQL_HOST environment variable for development" do
361
361
  Braintree::Configuration.environment = :development
362
- old_gateway_url = ENV['GRAPHQL_HOST']
362
+ old_gateway_url = ENV["GRAPHQL_HOST"]
363
363
  begin
364
- ENV['GRAPHQL_HOST'] = nil
364
+ ENV["GRAPHQL_HOST"] = nil
365
365
  Braintree::Configuration.instantiate.graphql_server.should == "graphql.bt.local"
366
366
 
367
- ENV['GRAPHQL_HOST'] = 'gateway'
368
- Braintree::Configuration.instantiate.graphql_server.should == 'gateway'
367
+ ENV["GRAPHQL_HOST"] = "gateway"
368
+ Braintree::Configuration.instantiate.graphql_server.should == "gateway"
369
369
  ensure
370
- ENV['GRAPHQL_HOST'] = old_gateway_url
370
+ ENV["GRAPHQL_HOST"] = old_gateway_url
371
371
  end
372
372
  end
373
373
  end
@@ -375,15 +375,15 @@ describe Braintree::Configuration do
375
375
  describe "server" do
376
376
  it "is localhost or GATEWAY_HOST environment variable for development" do
377
377
  Braintree::Configuration.environment = :development
378
- old_gateway_url = ENV['GATEWAY_HOST']
378
+ old_gateway_url = ENV["GATEWAY_HOST"]
379
379
  begin
380
- ENV['GATEWAY_HOST'] = nil
380
+ ENV["GATEWAY_HOST"] = nil
381
381
  Braintree::Configuration.instantiate.server.should == "localhost"
382
382
 
383
- ENV['GATEWAY_HOST'] = 'gateway'
384
- Braintree::Configuration.instantiate.server.should == 'gateway'
383
+ ENV["GATEWAY_HOST"] = "gateway"
384
+ Braintree::Configuration.instantiate.server.should == "gateway"
385
385
  ensure
386
- ENV['GATEWAY_HOST'] = old_gateway_url
386
+ ENV["GATEWAY_HOST"] = old_gateway_url
387
387
  end
388
388
  end
389
389
 
@@ -468,7 +468,7 @@ describe Braintree::Configuration do
468
468
  it "masks the private_key" do
469
469
  config = Braintree::Configuration.new(:private_key => "secret_key")
470
470
  config.inspect.should include('@private_key="[FILTERED]"')
471
- config.inspect.should_not include('secret_key')
471
+ config.inspect.should_not include("secret_key")
472
472
  end
473
473
  end
474
474
 
@@ -4,18 +4,17 @@ describe Braintree::CreditCard do
4
4
  describe "self.create" do
5
5
  it "raises an exception if attributes contain an invalid key" do
6
6
  expect do
7
- Braintree::CreditCard.create(:invalid_key => 'val')
7
+ Braintree::CreditCard.create(:invalid_key => "val")
8
8
  end.to raise_error(ArgumentError, "invalid keys: invalid_key")
9
9
  end
10
10
  end
11
11
 
12
12
  describe "self.create_signature" do
13
13
  it "should be what we expect" do
14
- Braintree::CreditCardGateway._create_signature.should == [
14
+ expect(Braintree::CreditCardGateway._create_signature).to match([
15
15
  :billing_address_id,
16
16
  :cardholder_name,
17
17
  :cvv,
18
- :device_session_id,
19
18
  :expiration_date,
20
19
  :expiration_month,
21
20
  :expiration_year,
@@ -23,10 +22,9 @@ describe Braintree::CreditCard do
23
22
  :token,
24
23
  :venmo_sdk_payment_method_code,
25
24
  :device_data,
26
- :fraud_merchant_id,
27
25
  :payment_method_nonce,
28
26
  {:external_vault=>[:network_transaction_id]},
29
- {:options => [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type]},
27
+ {:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
30
28
  {:billing_address => [
31
29
  :company,
32
30
  :country_code_alpha2,
@@ -53,17 +51,16 @@ describe Braintree::CreditCard do
53
51
  :ds_transaction_id,
54
52
  ]},
55
53
  :customer_id,
56
- ]
54
+ ])
57
55
  end
58
56
  end
59
57
 
60
58
  describe "self.update_signature" do
61
59
  it "should be what we expect" do
62
- Braintree::CreditCardGateway._update_signature.should == [
60
+ expect(Braintree::CreditCardGateway._update_signature).to match([
63
61
  :billing_address_id,
64
62
  :cardholder_name,
65
63
  :cvv,
66
- :device_session_id,
67
64
  :expiration_date,
68
65
  :expiration_month,
69
66
  :expiration_year,
@@ -71,10 +68,9 @@ describe Braintree::CreditCard do
71
68
  :token,
72
69
  :venmo_sdk_payment_method_code,
73
70
  :device_data,
74
- :fraud_merchant_id,
75
71
  :payment_method_nonce,
76
72
  {:external_vault=>[:network_transaction_id]},
77
- {:options => [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type]},
73
+ {:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
78
74
  {:billing_address => [
79
75
  :company,
80
76
  :country_code_alpha2,
@@ -101,22 +97,7 @@ describe Braintree::CreditCard do
101
97
  :cavv_algorithm,
102
98
  :ds_transaction_id,
103
99
  ]},
104
- ]
105
- end
106
- end
107
-
108
- describe "self.create_from_transparent_redirect" do
109
- it "raises an exception if the query string is forged" do
110
- expect do
111
- Braintree::CreditCard.create_from_transparent_redirect("http_status=200&forged=query_string")
112
- end.to raise_error(Braintree::ForgedQueryString)
113
- end
114
- end
115
-
116
- describe "self.create_credit_card_url" do
117
- it "returns the url" do
118
- config = Braintree::Configuration.instantiate
119
- Braintree::CreditCard.create_credit_card_url.should == "http#{config.ssl? ? 's' : ''}://#{config.server}:#{config.port}/merchants/integration_merchant_id/payment_methods/all/create_via_transparent_redirect_request"
100
+ ])
120
101
  end
121
102
  end
122
103
 
@@ -222,7 +203,7 @@ describe Braintree::CreditCard do
222
203
  credit_card = Braintree::CreditCard._new(
223
204
  :gateway,
224
205
  :bin => "510510",
225
- :last_4 => "5100"
206
+ :last_4 => "5100",
226
207
  )
227
208
  credit_card.masked_number.should == "510510******5100"
228
209
  end
@@ -234,7 +215,7 @@ describe Braintree::CreditCard do
234
215
  :gateway,
235
216
  :bin => "510510",
236
217
  :last_4 => "5100",
237
- :is_network_tokenized => true
218
+ :is_network_tokenized => true,
238
219
  )
239
220
  credit_card.is_network_tokenized?.should == true
240
221
  end
@@ -244,7 +225,7 @@ describe Braintree::CreditCard do
244
225
  :gateway,
245
226
  :bin => "510510",
246
227
  :last_4 => "5100",
247
- :is_network_tokenized => false
228
+ :is_network_tokenized => false,
248
229
  )
249
230
  credit_card.is_network_tokenized?.should == false
250
231
  end
@@ -253,7 +234,7 @@ describe Braintree::CreditCard do
253
234
  describe "self.update" do
254
235
  it "raises an exception if attributes contain an invalid key" do
255
236
  expect do
256
- Braintree::CreditCard._new(Braintree::Configuration.gateway, {}).update(:invalid_key => 'val')
237
+ Braintree::CreditCard.update(:gateway, :invalid_key => "val")
257
238
  end.to raise_error(ArgumentError, "invalid keys: invalid_key")
258
239
  end
259
240
  end
@@ -269,8 +250,8 @@ describe Braintree::CreditCard do
269
250
  describe "self._new" do
270
251
  describe "initializing verification" do
271
252
  it "picks the youngest verification" do
272
- verification1 = { :created_at => Time.now, :id => 123 }
273
- verification2 = { :created_at => Time.now - 3600, :id => 456 }
253
+ verification1 = {:created_at => Time.now, :id => 123}
254
+ verification2 = {:created_at => Time.now - 3600, :id => 456}
274
255
  credit_card = Braintree::CreditCard._new(Braintree::Configuration.gateway, {:verifications => [verification1, verification2]})
275
256
  credit_card.verification.id.should == 123
276
257
  end
@@ -9,7 +9,7 @@ module Braintree
9
9
 
10
10
  lambda do
11
11
  search.credit_card_card_type.in(
12
- *Braintree::CreditCard::CardType::All
12
+ *Braintree::CreditCard::CardType::All,
13
13
  )
14
14
  end.should_not raise_error
15
15
  end
@@ -30,7 +30,7 @@ describe Braintree::CreditCardVerification do
30
30
  :cvv_response_code => "I",
31
31
  :processor_response_code => "2000",
32
32
  :processor_response_text => "Do Not Honor",
33
- :merchant_account_id => "some_id"
33
+ :merchant_account_id => "some_id",
34
34
  )
35
35
 
36
36
  verification.status.should == Braintree::CreditCardVerification::Status::Verified
@@ -44,7 +44,7 @@ describe Braintree::CreditCardVerification do
44
44
 
45
45
  it "accepts network_transaction_id" do
46
46
  verification = Braintree::CreditCardVerification._new(
47
- :network_transaction_id => "123456789012345"
47
+ :network_transaction_id => "123456789012345",
48
48
  )
49
49
  expect(verification.network_transaction_id).to eq "123456789012345"
50
50
  end
@@ -117,14 +117,18 @@ describe Braintree::CreditCardVerification do
117
117
  verification = Braintree::CreditCardVerification._new(:risk_data => {
118
118
  :id => "123",
119
119
  :decision => "WOO YOU WON $1000 dollars",
120
+ :decision_reasons => ["reason"],
120
121
  :device_data_captured => true,
121
- :fraud_service_provider => "kount"
122
+ :fraud_service_provider => "paypal_fraud_protection",
123
+ :transaction_risk_score => "12",
122
124
  })
123
125
 
124
126
  verification.risk_data.id.should == "123"
125
127
  verification.risk_data.decision.should == "WOO YOU WON $1000 dollars"
128
+ verification.risk_data.decision_reasons.should == ["reason"]
126
129
  verification.risk_data.device_data_captured.should == true
127
- verification.risk_data.fraud_service_provider.should == "kount"
130
+ verification.risk_data.fraud_service_provider.should == "paypal_fraud_protection"
131
+ verification.risk_data.transaction_risk_score.should == "12"
128
132
  end
129
133
 
130
134
  it "handles a nil risk_data" do
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
3
3
  describe Braintree::Customer do
4
4
  describe "inspect" do
5
5
  it "includes the id first" do
6
- output = Braintree::Customer._new(:gateway, {:first_name => 'Dan', :id => '1234'}).inspect
6
+ output = Braintree::Customer._new(:gateway, {:first_name => "Dan", :id => "1234"}).inspect
7
7
  output.should include("#<Braintree::Customer id: \"1234\",")
8
8
  end
9
9
 
@@ -18,7 +18,7 @@ describe Braintree::Customer do
18
18
  :phone => "802-483-5932",
19
19
  :website => "patrick.smith.com",
20
20
  :created_at => Time.now,
21
- :updated_at => Time.now
21
+ :updated_at => Time.now,
22
22
  )
23
23
  output = customer.inspect
24
24
  output.should include(%q(company: "Company"))
@@ -31,6 +31,7 @@ describe Braintree::Customer do
31
31
  output.should include(%q(addresses: []))
32
32
  output.should include(%q(credit_cards: []))
33
33
  output.should include(%q(paypal_accounts: []))
34
+ output.should include(%q(tax_identifiers: []))
34
35
  output.should include(%Q(created_at: #{customer.created_at.inspect}))
35
36
  output.should include(%Q(updated_at: #{customer.updated_at.inspect}))
36
37
  end
@@ -75,7 +76,7 @@ describe Braintree::Customer do
75
76
 
76
77
  describe "self.create_signature" do
77
78
  it "should be what we expect" do
78
- Braintree::CustomerGateway._create_signature.should == [
79
+ expect(Braintree::CustomerGateway._create_signature).to match([
79
80
  :company,
80
81
  :email,
81
82
  :fax,
@@ -91,7 +92,6 @@ describe Braintree::Customer do
91
92
  :billing_address_id,
92
93
  :cardholder_name,
93
94
  :cvv,
94
- :device_session_id,
95
95
  :expiration_date,
96
96
  :expiration_month,
97
97
  :expiration_year,
@@ -99,10 +99,9 @@ describe Braintree::Customer do
99
99
  :token,
100
100
  :venmo_sdk_payment_method_code,
101
101
  :device_data,
102
- :fraud_merchant_id,
103
102
  :payment_method_nonce,
104
103
  {:external_vault=>[:network_transaction_id]},
105
- {:options => [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type]},
104
+ {:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
106
105
  {:billing_address => [
107
106
  :company,
108
107
  :country_code_alpha2,
@@ -135,6 +134,10 @@ describe Braintree::Customer do
135
134
  :billing_agreement_id,
136
135
  {:options => [:make_default]},
137
136
  ]},
137
+ {:tax_identifiers => [
138
+ :country_code,
139
+ :identifier
140
+ ]},
138
141
  {:options =>
139
142
  [:paypal => [
140
143
  :payee_email,
@@ -160,13 +163,13 @@ describe Braintree::Customer do
160
163
  ]]
161
164
  },
162
165
  {:custom_fields => :_any_key_}
163
- ]
166
+ ])
164
167
  end
165
168
  end
166
169
 
167
170
  describe "self.update_signature" do
168
171
  it "should be what we expect" do
169
- Braintree::CustomerGateway._update_signature.should == [
172
+ expect(Braintree::CustomerGateway._update_signature).to match([
170
173
  :company,
171
174
  :email,
172
175
  :fax,
@@ -182,7 +185,6 @@ describe Braintree::Customer do
182
185
  :billing_address_id,
183
186
  :cardholder_name,
184
187
  :cvv,
185
- :device_session_id,
186
188
  :expiration_date,
187
189
  :expiration_month,
188
190
  :expiration_year,
@@ -190,19 +192,20 @@ describe Braintree::Customer do
190
192
  :token,
191
193
  :venmo_sdk_payment_method_code,
192
194
  :device_data,
193
- :fraud_merchant_id,
194
195
  :payment_method_nonce,
195
196
  {:external_vault=>[:network_transaction_id]},
196
- {:options => [
197
+ {:options => match_array([
197
198
  :make_default,
199
+ :skip_advanced_fraud_checking,
198
200
  :verification_merchant_account_id,
199
201
  :verify_card,
200
202
  :verification_amount,
201
203
  :venmo_sdk_session,
202
204
  :fail_on_duplicate_payment_method,
203
205
  :verification_account_type,
206
+ :verification_currency_iso_code,
204
207
  :update_existing_token
205
- ]},
208
+ ])},
206
209
  {:billing_address => [
207
210
  :company,
208
211
  :country_code_alpha2,
@@ -230,6 +233,10 @@ describe Braintree::Customer do
230
233
  :ds_transaction_id,
231
234
  ]},
232
235
  ]},
236
+ {:tax_identifiers => [
237
+ :country_code,
238
+ :identifier
239
+ ]},
233
240
  {:options =>
234
241
  [:paypal => [
235
242
  :payee_email,
@@ -255,15 +262,7 @@ describe Braintree::Customer do
255
262
  ]]
256
263
  },
257
264
  {:custom_fields => :_any_key_}
258
- ]
259
- end
260
- end
261
-
262
- describe "self.create_from_transparent_redirect" do
263
- it "raises an exception if the query string is forged" do
264
- expect do
265
- Braintree::Customer.create_from_transparent_redirect("http_status=200&forged=query_string")
266
- end.to raise_error(Braintree::ForgedQueryString)
265
+ ])
267
266
  end
268
267
  end
269
268
 
@@ -301,7 +300,7 @@ describe Braintree::Customer do
301
300
  :paypal_accounts => [
302
301
  {:token => "paypal_1"},
303
302
  {:token => "paypal_2"}
304
- ]
303
+ ],
305
304
  )
306
305
 
307
306
  customer.credit_cards.size.should == 2
@@ -28,18 +28,18 @@ describe Braintree::Disbursement do
28
28
  :exception_message => "invalid_account_number",
29
29
  :follow_up_action => "update",
30
30
  :retry => false,
31
- :success => false
31
+ :success => false,
32
32
  )
33
33
 
34
34
  disbursement.inspect.should include('id: "123456"')
35
35
  disbursement.inspect.should include('amount: "100.0"')
36
36
  disbursement.inspect.should include('exception_message: "invalid_account_number"')
37
- disbursement.inspect.should include('disbursement_date: 2013-04-10')
37
+ disbursement.inspect.should include("disbursement_date: 2013-04-10")
38
38
  disbursement.inspect.should include('follow_up_action: "update"')
39
- disbursement.inspect.should include('merchant_account: #<Braintree::MerchantAccount: ')
39
+ disbursement.inspect.should include("merchant_account: #<Braintree::MerchantAccount: ")
40
40
  disbursement.inspect.should include('transaction_ids: ["sub_merchant_transaction"]')
41
- disbursement.inspect.should include('retry: false')
42
- disbursement.inspect.should include('success: false')
41
+ disbursement.inspect.should include("retry: false")
42
+ disbursement.inspect.should include("success: false")
43
43
  end
44
44
  end
45
45
 
@@ -56,7 +56,7 @@ describe Braintree::Disbursement do
56
56
  :status => "active"
57
57
  },
58
58
  :success => false,
59
- :disbursement_date => "2013-04-10"
59
+ :disbursement_date => "2013-04-10",
60
60
  )
61
61
  disbursement.success?.should == false
62
62
 
@@ -71,7 +71,7 @@ describe Braintree::Disbursement do
71
71
  :status => "active"
72
72
  },
73
73
  :success => true,
74
- :disbursement_date => "2013-04-10"
74
+ :disbursement_date => "2013-04-10",
75
75
  )
76
76
  disbursement.success?.should == true
77
77
  end
@@ -41,6 +41,9 @@ describe Braintree::DisputeSearch do
41
41
  end
42
42
 
43
43
  [
44
+ # NEXT_MAJOR_VERSION Remove this assertion when chargeback_protection_level is removed from the SDK
45
+ :chargeback_protection_level,
46
+ :protection_level,
44
47
  :kind,
45
48
  :reason,
46
49
  :status,