braintree 2.98.0 → 4.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) 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 +4 -4
  5. data/lib/braintree/ach_mandate.rb +1 -1
  6. data/lib/braintree/add_on_gateway.rb +1 -1
  7. data/lib/braintree/address.rb +7 -27
  8. data/lib/braintree/address_gateway.rb +8 -7
  9. data/lib/braintree/advanced_search.rb +11 -12
  10. data/lib/braintree/apple_pay.rb +4 -4
  11. data/lib/braintree/apple_pay_card.rb +18 -4
  12. data/lib/braintree/apple_pay_options.rb +4 -4
  13. data/lib/braintree/authorization_adjustment.rb +4 -4
  14. data/lib/braintree/base_module.rb +11 -1
  15. data/lib/braintree/bin_data.rb +10 -3
  16. data/lib/braintree/client_token.rb +1 -1
  17. data/lib/braintree/client_token_gateway.rb +4 -3
  18. data/lib/braintree/configuration.rb +35 -35
  19. data/lib/braintree/connected_merchant_paypal_status_changed.rb +2 -2
  20. data/lib/braintree/connected_merchant_status_transitioned.rb +2 -2
  21. data/lib/braintree/credit_card.rb +40 -86
  22. data/lib/braintree/credit_card_gateway.rb +58 -44
  23. data/lib/braintree/credit_card_verification.rb +39 -20
  24. data/lib/braintree/credit_card_verification_gateway.rb +35 -5
  25. data/lib/braintree/credit_card_verification_search.rb +2 -2
  26. data/lib/braintree/customer.rb +23 -88
  27. data/lib/braintree/customer_gateway.rb +17 -32
  28. data/lib/braintree/customer_search.rb +2 -2
  29. data/lib/braintree/descriptor.rb +1 -1
  30. data/lib/braintree/digest.rb +1 -1
  31. data/lib/braintree/disbursement.rb +7 -7
  32. data/lib/braintree/discount_gateway.rb +1 -1
  33. data/lib/braintree/dispute/evidence.rb +1 -1
  34. data/lib/braintree/{transaction/coinbase_details.rb → dispute/paypal_message.rb} +5 -6
  35. data/lib/braintree/dispute/{history_event.rb → status_history.rb} +3 -1
  36. data/lib/braintree/dispute/transaction.rb +3 -1
  37. data/lib/braintree/dispute/transaction_details.rb +1 -1
  38. data/lib/braintree/dispute.rb +47 -6
  39. data/lib/braintree/dispute_gateway.rb +5 -10
  40. data/lib/braintree/dispute_search.rb +8 -4
  41. data/lib/braintree/document_upload.rb +3 -3
  42. data/lib/braintree/document_upload_gateway.rb +3 -3
  43. data/lib/braintree/enriched_customer_data.rb +21 -0
  44. data/lib/braintree/error_codes.rb +217 -175
  45. data/lib/braintree/error_result.rb +2 -3
  46. data/lib/braintree/errors.rb +3 -3
  47. data/lib/braintree/exceptions.rb +6 -5
  48. data/lib/braintree/exchange_rate.rb +13 -0
  49. data/lib/braintree/exchange_rate_quote.rb +24 -0
  50. data/lib/braintree/exchange_rate_quote_gateway.rb +35 -0
  51. data/lib/braintree/exchange_rate_quote_input.rb +21 -0
  52. data/lib/braintree/exchange_rate_quote_request.rb +18 -0
  53. data/lib/braintree/exchange_rate_quote_response.rb +18 -0
  54. data/lib/braintree/facilitated_details.rb +1 -1
  55. data/lib/braintree/facilitator_details.rb +1 -1
  56. data/lib/braintree/gateway.rb +6 -12
  57. data/lib/braintree/{android_pay_card.rb → google_pay_card.rb} +18 -5
  58. data/lib/braintree/granted_payment_instrument_update.rb +2 -2
  59. data/lib/braintree/graphql_client.rb +14 -8
  60. data/lib/braintree/http.rb +9 -10
  61. data/lib/braintree/local_payment_completed/blik_alias.rb +23 -0
  62. data/lib/braintree/local_payment_completed.rb +10 -5
  63. data/lib/braintree/local_payment_expired.rb +21 -0
  64. data/lib/braintree/local_payment_funded.rb +22 -0
  65. data/lib/braintree/local_payment_reversed.rb +19 -0
  66. data/lib/braintree/merchant.rb +4 -4
  67. data/lib/braintree/merchant_account.rb +3 -3
  68. data/lib/braintree/merchant_account_gateway.rb +10 -8
  69. data/lib/braintree/merchant_gateway.rb +1 -1
  70. data/lib/braintree/meta_checkout_card.rb +89 -0
  71. data/lib/braintree/meta_checkout_token.rb +88 -0
  72. data/lib/braintree/modification.rb +4 -4
  73. data/lib/braintree/oauth_credentials.rb +4 -4
  74. data/lib/braintree/oauth_gateway.rb +5 -5
  75. data/lib/braintree/paginated_collection.rb +2 -2
  76. data/lib/braintree/paginated_result.rb +1 -1
  77. data/lib/braintree/payment_instrument_type.rb +14 -13
  78. data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
  79. data/lib/braintree/payment_method_gateway.rb +52 -22
  80. data/lib/braintree/payment_method_nonce.rb +12 -7
  81. data/lib/braintree/payment_method_nonce_details.rb +40 -0
  82. data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
  83. data/lib/braintree/payment_method_nonce_gateway.rb +14 -3
  84. data/lib/braintree/payment_method_parser.rb +4 -7
  85. data/lib/braintree/paypal_account.rb +3 -2
  86. data/lib/braintree/paypal_account_gateway.rb +5 -5
  87. data/lib/braintree/plan.rb +22 -2
  88. data/lib/braintree/plan_gateway.rb +101 -1
  89. data/lib/braintree/processor_response_types.rb +3 -3
  90. data/lib/braintree/resource_collection.rb +10 -5
  91. data/lib/braintree/revoked_payment_method_metadata.rb +2 -2
  92. data/lib/braintree/risk_data/liability_shift.rb +22 -0
  93. data/lib/braintree/risk_data.rb +10 -3
  94. data/lib/braintree/samsung_pay_card.rb +8 -6
  95. data/lib/braintree/sepa_direct_debit_account.rb +60 -0
  96. data/lib/braintree/sepa_direct_debit_account_gateway.rb +25 -0
  97. data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +28 -0
  98. data/lib/braintree/settlement_batch_summary.rb +2 -2
  99. data/lib/braintree/settlement_batch_summary_gateway.rb +1 -1
  100. data/lib/braintree/sha256_digest.rb +1 -1
  101. data/lib/braintree/subscription/status_details.rb +1 -1
  102. data/lib/braintree/subscription.rb +13 -13
  103. data/lib/braintree/subscription_gateway.rb +6 -6
  104. data/lib/braintree/subscription_search.rb +1 -1
  105. data/lib/braintree/successful_result.rb +5 -4
  106. data/lib/braintree/test/authentication_id.rb +21 -0
  107. data/lib/braintree/test/credit_card.rb +9 -10
  108. data/lib/braintree/test/merchant_account.rb +1 -1
  109. data/lib/braintree/test/nonce.rb +27 -20
  110. data/lib/braintree/test/transaction_amounts.rb +2 -3
  111. data/lib/braintree/test/venmo_sdk.rb +2 -0
  112. data/lib/braintree/testing_gateway.rb +1 -1
  113. data/lib/braintree/three_d_secure_info.rb +23 -11
  114. data/lib/braintree/transaction/address_details.rb +14 -1
  115. data/lib/braintree/transaction/apple_pay_details.rb +13 -10
  116. data/lib/braintree/transaction/credit_card_details.rb +8 -1
  117. data/lib/braintree/transaction/customer_details.rb +3 -2
  118. data/lib/braintree/transaction/disbursement_details.rb +2 -1
  119. data/lib/braintree/transaction/{android_pay_details.rb → google_pay_details.rb} +6 -1
  120. data/lib/braintree/transaction/installment/adjustment.rb +33 -0
  121. data/lib/braintree/transaction/installment.rb +28 -0
  122. data/lib/braintree/transaction/local_payment_details.rb +3 -0
  123. data/lib/braintree/transaction/meta_checkout_card_details.rb +52 -0
  124. data/lib/braintree/transaction/meta_checkout_token_details.rb +54 -0
  125. data/lib/braintree/transaction/package_details.rb +19 -0
  126. data/lib/braintree/transaction/payment_receipt/card_present_data.rb +36 -0
  127. data/lib/braintree/transaction/payment_receipt/merchant_address.rb +19 -0
  128. data/lib/braintree/transaction/payment_receipt.rb +31 -0
  129. data/lib/braintree/transaction/paypal_details.rb +5 -0
  130. data/lib/braintree/transaction/samsung_pay_card_details.rb +3 -1
  131. data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +27 -0
  132. data/lib/braintree/transaction/status_details.rb +1 -1
  133. data/lib/braintree/transaction/subscription_details.rb +3 -1
  134. data/lib/braintree/transaction/us_bank_account_details.rb +2 -1
  135. data/lib/braintree/transaction/visa_checkout_card_details.rb +1 -1
  136. data/lib/braintree/transaction.rb +119 -128
  137. data/lib/braintree/transaction_gateway.rb +138 -64
  138. data/lib/braintree/transaction_line_item.rb +14 -11
  139. data/lib/braintree/transaction_line_item_gateway.rb +1 -1
  140. data/lib/braintree/transaction_review.rb +18 -0
  141. data/lib/braintree/transaction_search.rb +11 -7
  142. data/lib/braintree/unknown_payment_method.rb +2 -2
  143. data/lib/braintree/us_bank_account.rb +5 -5
  144. data/lib/braintree/us_bank_account_verification.rb +24 -16
  145. data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
  146. data/lib/braintree/us_bank_account_verification_search.rb +1 -1
  147. data/lib/braintree/util.rb +25 -10
  148. data/lib/braintree/validation_error.rb +1 -1
  149. data/lib/braintree/validation_error_collection.rb +3 -3
  150. data/lib/braintree/venmo_account.rb +4 -4
  151. data/lib/braintree/venmo_profile_data.rb +25 -0
  152. data/lib/braintree/version.rb +2 -2
  153. data/lib/braintree/visa_checkout_card.rb +8 -8
  154. data/lib/braintree/webhook_notification.rb +55 -33
  155. data/lib/braintree/webhook_notification_gateway.rb +9 -9
  156. data/lib/braintree/webhook_testing.rb +1 -1
  157. data/lib/braintree/webhook_testing_gateway.rb +569 -46
  158. data/lib/braintree/xml/generator.rb +6 -5
  159. data/lib/braintree/xml/libxml.rb +1 -1
  160. data/lib/braintree/xml/parser.rb +24 -37
  161. data/lib/braintree/xml/rexml.rb +6 -7
  162. data/lib/braintree/xml.rb +1 -1
  163. data/lib/braintree.rb +41 -24
  164. data/lib/ssl/api_braintreegateway_com.ca.crt +401 -168
  165. data/spec/integration/braintree/add_on_spec.rb +10 -10
  166. data/spec/integration/braintree/address_spec.rb +101 -178
  167. data/spec/integration/braintree/advanced_search_spec.rb +93 -93
  168. data/spec/integration/braintree/apple_pay_spec.rb +12 -12
  169. data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
  170. data/spec/integration/braintree/client_api/client_token_spec.rb +279 -62
  171. data/spec/integration/braintree/client_api/spec_helper.rb +99 -73
  172. data/spec/integration/braintree/credit_card_spec.rb +522 -821
  173. data/spec/integration/braintree/credit_card_verification_search_spec.rb +18 -18
  174. data/spec/integration/braintree/credit_card_verification_spec.rb +219 -30
  175. data/spec/integration/braintree/customer_search_spec.rb +28 -28
  176. data/spec/integration/braintree/customer_spec.rb +840 -757
  177. data/spec/integration/braintree/disbursement_spec.rb +2 -2
  178. data/spec/integration/braintree/discount_spec.rb +9 -9
  179. data/spec/integration/braintree/dispute_search_spec.rb +45 -9
  180. data/spec/integration/braintree/dispute_spec.rb +109 -82
  181. data/spec/integration/braintree/document_upload_spec.rb +29 -17
  182. data/spec/integration/braintree/error_codes_spec.rb +3 -3
  183. data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
  184. data/spec/integration/braintree/graphql_client_spec.rb +0 -2
  185. data/spec/integration/braintree/http_spec.rb +31 -33
  186. data/spec/integration/braintree/merchant_account_spec.rb +155 -156
  187. data/spec/integration/braintree/merchant_spec.rb +71 -192
  188. data/spec/integration/braintree/oauth_spec.rb +72 -72
  189. data/spec/integration/braintree/package_tracking_spec.rb +130 -0
  190. data/spec/integration/braintree/payment_method_nonce_spec.rb +173 -78
  191. data/spec/integration/braintree/payment_method_spec.rb +953 -501
  192. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +147 -234
  193. data/spec/integration/braintree/paypal_account_spec.rb +74 -72
  194. data/spec/integration/braintree/plan_spec.rb +96 -15
  195. data/spec/integration/braintree/samsung_pay_card_spec.rb +75 -73
  196. data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +194 -0
  197. data/spec/integration/braintree/settlement_batch_summary_spec.rb +18 -18
  198. data/spec/integration/braintree/subscription_spec.rb +507 -513
  199. data/spec/integration/braintree/test/transaction_amounts_spec.rb +4 -4
  200. data/spec/integration/braintree/test_transaction_spec.rb +29 -29
  201. data/spec/integration/braintree/transaction_line_item_spec.rb +12 -6
  202. data/spec/integration/braintree/transaction_search_spec.rb +410 -217
  203. data/spec/integration/braintree/transaction_spec.rb +3252 -2102
  204. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +42 -278
  205. data/spec/integration/braintree/us_bank_account_spec.rb +36 -36
  206. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +25 -25
  207. data/spec/integration/braintree/us_bank_account_verification_spec.rb +41 -41
  208. data/spec/integration/braintree/visa_checkout_card_spec.rb +62 -62
  209. data/spec/integration/spec_helper.rb +22 -7
  210. data/spec/oauth_test_helper.rb +1 -1
  211. data/spec/script/httpsd.rb +6 -6
  212. data/spec/spec_helper.rb +15 -20
  213. data/spec/unit/braintree/address_spec.rb +9 -17
  214. data/spec/unit/braintree/apple_pay_card_spec.rb +110 -7
  215. data/spec/unit/braintree/base_module_spec.rb +4 -4
  216. data/spec/unit/braintree/client_token_spec.rb +6 -6
  217. data/spec/unit/braintree/configuration_spec.rb +84 -84
  218. data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
  219. data/spec/unit/braintree/credit_card_spec.rb +91 -58
  220. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +56 -0
  221. data/spec/unit/braintree/credit_card_verification_search_spec.rb +10 -10
  222. data/spec/unit/braintree/credit_card_verification_spec.rb +40 -18
  223. data/spec/unit/braintree/customer_spec.rb +102 -57
  224. data/spec/unit/braintree/digest_spec.rb +5 -6
  225. data/spec/unit/braintree/disbursement_spec.rb +14 -14
  226. data/spec/unit/braintree/dispute_search_spec.rb +6 -2
  227. data/spec/unit/braintree/dispute_spec.rb +144 -66
  228. data/spec/unit/braintree/document_upload_spec.rb +8 -8
  229. data/spec/unit/braintree/enriched_customer_data_spec.rb +41 -0
  230. data/spec/unit/braintree/error_result_spec.rb +11 -11
  231. data/spec/unit/braintree/errors_spec.rb +17 -17
  232. data/spec/unit/braintree/exchange_rate_quote_input_spec.rb +42 -0
  233. data/spec/unit/braintree/exchange_rate_quote_request_spec.rb +82 -0
  234. data/spec/unit/braintree/exchange_rate_quote_response_spec.rb +52 -0
  235. data/spec/unit/braintree/exchange_rate_quote_spec.rb +42 -0
  236. data/spec/unit/braintree/exchange_rate_spec.rb +23 -0
  237. data/spec/unit/braintree/http_spec.rb +19 -17
  238. data/spec/unit/braintree/local_payment_completed_spec.rb +62 -8
  239. data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
  240. data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
  241. data/spec/unit/braintree/merchant_account_spec.rb +5 -5
  242. data/spec/unit/braintree/meta_checkout_card_details_spec.rb +60 -0
  243. data/spec/unit/braintree/meta_checkout_card_spec.rb +60 -0
  244. data/spec/unit/braintree/meta_checkout_token_details_spec.rb +63 -0
  245. data/spec/unit/braintree/meta_checkout_token_spec.rb +63 -0
  246. data/spec/unit/braintree/modification_spec.rb +1 -1
  247. data/spec/unit/braintree/package_tracking_spec.rb +77 -0
  248. data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +45 -0
  249. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
  250. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +51 -0
  251. data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
  252. data/spec/unit/braintree/payment_method_spec.rb +20 -20
  253. data/spec/unit/braintree/paypal_account_spec.rb +16 -7
  254. data/spec/unit/braintree/resource_collection_spec.rb +34 -5
  255. data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
  256. data/spec/unit/braintree/risk_data_spec.rb +38 -8
  257. data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +29 -0
  258. data/spec/unit/braintree/sepa_debit_account_spec.rb +86 -0
  259. data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
  260. data/spec/unit/braintree/signature_service_spec.rb +2 -2
  261. data/spec/unit/braintree/subscription_search_spec.rb +18 -18
  262. data/spec/unit/braintree/subscription_spec.rb +8 -8
  263. data/spec/unit/braintree/successful_result_spec.rb +6 -6
  264. data/spec/unit/braintree/three_d_secure_info_spec.rb +37 -17
  265. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +22 -6
  266. data/spec/unit/braintree/transaction/customer_details_spec.rb +3 -2
  267. data/spec/unit/braintree/transaction/deposit_details_spec.rb +4 -4
  268. data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
  269. data/spec/unit/braintree/transaction/local_payment_details_spec.rb +36 -0
  270. data/spec/unit/braintree/transaction/payment_receipt_spec.rb +73 -0
  271. data/spec/unit/braintree/transaction/paypal_details_spec.rb +63 -0
  272. data/spec/unit/braintree/transaction/sepa_direct_debit_account_details_spec.rb +33 -0
  273. data/spec/unit/braintree/transaction_gateway_spec.rb +150 -0
  274. data/spec/unit/braintree/transaction_search_spec.rb +12 -12
  275. data/spec/unit/braintree/transaction_spec.rb +221 -124
  276. data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
  277. data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
  278. data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
  279. data/spec/unit/braintree/us_bank_account_verification_spec.rb +12 -7
  280. data/spec/unit/braintree/util_spec.rb +78 -44
  281. data/spec/unit/braintree/validation_error_collection_spec.rb +62 -62
  282. data/spec/unit/braintree/validation_error_spec.rb +4 -4
  283. data/spec/unit/braintree/venmo_profile_data_spec.rb +43 -0
  284. data/spec/unit/braintree/webhook_notification_spec.rb +434 -197
  285. data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
  286. data/spec/unit/braintree/xml/parser_spec.rb +27 -22
  287. data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
  288. data/spec/unit/braintree/xml_spec.rb +38 -38
  289. data/spec/unit/braintree_spec.rb +2 -2
  290. metadata +91 -30
  291. data/lib/braintree/amex_express_checkout_card.rb +0 -38
  292. data/lib/braintree/coinbase_account.rb +0 -34
  293. data/lib/braintree/europe_bank_account.rb +0 -36
  294. data/lib/braintree/europe_bank_account_gateway.rb +0 -17
  295. data/lib/braintree/ideal_payment.rb +0 -61
  296. data/lib/braintree/ideal_payment_gateway.rb +0 -19
  297. data/lib/braintree/masterpass_card.rb +0 -81
  298. data/lib/braintree/settlement_batch.rb +0 -0
  299. data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -21
  300. data/lib/braintree/transaction/ideal_payment_details.rb +0 -19
  301. data/lib/braintree/transaction/masterpass_card_details.rb +0 -47
  302. data/lib/braintree/transparent_redirect.rb +0 -40
  303. data/lib/braintree/transparent_redirect_gateway.rb +0 -105
  304. data/spec/hacks/tcp_socket.rb +0 -18
  305. data/spec/integration/braintree/coinbase_spec.rb +0 -34
  306. data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
  307. data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
  308. data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
@@ -3,8 +3,8 @@ 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
7
- output.should include("#<Braintree::Customer id: \"1234\",")
6
+ output = Braintree::Customer._new(:gateway, {:first_name => "Dan", :id => "1234"}).inspect
7
+ expect(output).to include("#<Braintree::Customer id: \"1234\",")
8
8
  end
9
9
 
10
10
  it "includes all customer attributes" do
@@ -16,23 +16,26 @@ describe Braintree::Customer do
16
16
  :first_name => "Patrick",
17
17
  :last_name => "Smith",
18
18
  :phone => "802-483-5932",
19
+ :international_phone => {:country_code => "1", :national_number => "3121234567"},
19
20
  :website => "patrick.smith.com",
20
21
  :created_at => Time.now,
21
- :updated_at => Time.now
22
+ :updated_at => Time.now,
22
23
  )
23
24
  output = customer.inspect
24
- output.should include(%q(company: "Company"))
25
- output.should include(%q(email: "e@mail.com"))
26
- output.should include(%q(fax: "483-438-5821"))
27
- output.should include(%q(first_name: "Patrick"))
28
- output.should include(%q(last_name: "Smith"))
29
- output.should include(%q(phone: "802-483-5932"))
30
- output.should include(%q(website: "patrick.smith.com"))
31
- output.should include(%q(addresses: []))
32
- output.should include(%q(credit_cards: []))
33
- output.should include(%q(paypal_accounts: []))
34
- output.should include(%Q(created_at: #{customer.created_at.inspect}))
35
- output.should include(%Q(updated_at: #{customer.updated_at.inspect}))
25
+ expect(output).to include(%q(company: "Company"))
26
+ expect(output).to include(%q(email: "e@mail.com"))
27
+ expect(output).to include(%q(fax: "483-438-5821"))
28
+ expect(output).to include(%q(first_name: "Patrick"))
29
+ expect(output).to include(%q(last_name: "Smith"))
30
+ expect(output).to include(%q(phone: "802-483-5932"))
31
+ expect(output).to include(%q(international_phone: {:country_code=>"1", :national_number=>"3121234567"}))
32
+ expect(output).to include(%q(website: "patrick.smith.com"))
33
+ expect(output).to include(%q(addresses: []))
34
+ expect(output).to include(%q(credit_cards: []))
35
+ expect(output).to include(%q(paypal_accounts: []))
36
+ expect(output).to include(%q(tax_identifiers: []))
37
+ expect(output).to include(%Q(created_at: #{customer.created_at.inspect}))
38
+ expect(output).to include(%Q(updated_at: #{customer.updated_at.inspect}))
36
39
  end
37
40
  end
38
41
 
@@ -58,7 +61,7 @@ describe Braintree::Customer do
58
61
  end
59
62
 
60
63
  it "does not raise an exception if the id is a fixnum" do
61
- Braintree::Http.stub(:new).and_return double.as_null_object
64
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
62
65
  expect do
63
66
  Braintree::Customer.find(8675309)
64
67
  end.to_not raise_error
@@ -75,12 +78,13 @@ describe Braintree::Customer do
75
78
 
76
79
  describe "self.create_signature" do
77
80
  it "should be what we expect" do
78
- Braintree::CustomerGateway._create_signature.should == [
81
+ expect(Braintree::CustomerGateway._create_signature).to match([
79
82
  :company,
80
83
  :email,
81
84
  :fax,
82
85
  :first_name,
83
86
  :id,
87
+ {:international_phone=>[:country_code, :national_number]},
84
88
  :last_name,
85
89
  :phone,
86
90
  :website,
@@ -91,17 +95,17 @@ describe Braintree::Customer do
91
95
  :billing_address_id,
92
96
  :cardholder_name,
93
97
  :cvv,
94
- :device_session_id,
95
98
  :expiration_date,
96
99
  :expiration_month,
97
100
  :expiration_year,
98
101
  :number,
99
102
  :token,
100
- :venmo_sdk_payment_method_code,
103
+ :venmo_sdk_payment_method_code, # NEXT_MAJOR_VERSION Remove this attribute
101
104
  :device_data,
102
- :fraud_merchant_id,
103
105
  :payment_method_nonce,
104
- {:options => [:make_default, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, :fail_on_duplicate_payment_method, :verification_account_type]},
106
+ {:external_vault=>[:network_transaction_id]},
107
+ {:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
108
+ :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
105
109
  {:billing_address => [
106
110
  :company,
107
111
  :country_code_alpha2,
@@ -110,12 +114,24 @@ describe Braintree::Customer do
110
114
  :country_name,
111
115
  :extended_address,
112
116
  :first_name,
117
+ {:international_phone=>[:country_code, :national_number]},
113
118
  :last_name,
114
119
  :locality,
120
+ :phone_number,
115
121
  :postal_code,
116
122
  :region,
117
123
  :street_address
118
- ]}
124
+ ]},
125
+ {:three_d_secure_pass_thru => [
126
+ :eci_flag,
127
+ :cavv,
128
+ :xid,
129
+ :three_d_secure_version,
130
+ :authentication_response,
131
+ :directory_response,
132
+ :cavv_algorithm,
133
+ :ds_transaction_id,
134
+ ]},
119
135
  ]},
120
136
  {:paypal_account => [
121
137
  :email,
@@ -123,6 +139,10 @@ describe Braintree::Customer do
123
139
  :billing_agreement_id,
124
140
  {:options => [:make_default]},
125
141
  ]},
142
+ {:tax_identifiers => [
143
+ :country_code,
144
+ :identifier
145
+ ]},
126
146
  {:options =>
127
147
  [:paypal => [
128
148
  :payee_email,
@@ -138,8 +158,10 @@ describe Braintree::Customer do
138
158
  :country_name,
139
159
  :extended_address,
140
160
  :first_name,
161
+ {:international_phone=>[:country_code, :national_number]},
141
162
  :last_name,
142
163
  :locality,
164
+ :phone_number,
143
165
  :postal_code,
144
166
  :region,
145
167
  :street_address,
@@ -147,18 +169,19 @@ describe Braintree::Customer do
147
169
  ]]
148
170
  },
149
171
  {:custom_fields => :_any_key_}
150
- ]
172
+ ])
151
173
  end
152
174
  end
153
175
 
154
176
  describe "self.update_signature" do
155
177
  it "should be what we expect" do
156
- Braintree::CustomerGateway._update_signature.should == [
178
+ expect(Braintree::CustomerGateway._update_signature).to match([
157
179
  :company,
158
180
  :email,
159
181
  :fax,
160
182
  :first_name,
161
183
  :id,
184
+ {:international_phone=>[:country_code, :national_number]},
162
185
  :last_name,
163
186
  :phone,
164
187
  :website,
@@ -169,26 +192,28 @@ describe Braintree::Customer do
169
192
  :billing_address_id,
170
193
  :cardholder_name,
171
194
  :cvv,
172
- :device_session_id,
173
195
  :expiration_date,
174
196
  :expiration_month,
175
197
  :expiration_year,
176
198
  :number,
177
199
  :token,
178
- :venmo_sdk_payment_method_code,
200
+ :venmo_sdk_payment_method_code, # NEXT_MAJOR_VERSION Remove this attribute
179
201
  :device_data,
180
- :fraud_merchant_id,
181
202
  :payment_method_nonce,
182
- {:options => [
203
+ {:external_vault=>[:network_transaction_id]},
204
+ {:options => match_array([
183
205
  :make_default,
206
+ :skip_advanced_fraud_checking,
184
207
  :verification_merchant_account_id,
185
208
  :verify_card,
186
209
  :verification_amount,
187
- :venmo_sdk_session,
210
+ :venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
188
211
  :fail_on_duplicate_payment_method,
212
+ :fail_on_duplicate_payment_method_for_customer,
189
213
  :verification_account_type,
214
+ :verification_currency_iso_code,
190
215
  :update_existing_token
191
- ]},
216
+ ])},
192
217
  {:billing_address => [
193
218
  :company,
194
219
  :country_code_alpha2,
@@ -197,13 +222,29 @@ describe Braintree::Customer do
197
222
  :country_name,
198
223
  :extended_address,
199
224
  :first_name,
225
+ {:international_phone=>[:country_code, :national_number]},
200
226
  :last_name,
201
227
  :locality,
228
+ :phone_number,
202
229
  :postal_code,
203
230
  :region,
204
231
  :street_address,
205
232
  {:options => [:update_existing]}
206
- ]}
233
+ ]},
234
+ {:three_d_secure_pass_thru => [
235
+ :eci_flag,
236
+ :cavv,
237
+ :xid,
238
+ :three_d_secure_version,
239
+ :authentication_response,
240
+ :directory_response,
241
+ :cavv_algorithm,
242
+ :ds_transaction_id,
243
+ ]},
244
+ ]},
245
+ {:tax_identifiers => [
246
+ :country_code,
247
+ :identifier
207
248
  ]},
208
249
  {:options =>
209
250
  [:paypal => [
@@ -220,8 +261,10 @@ describe Braintree::Customer do
220
261
  :country_name,
221
262
  :extended_address,
222
263
  :first_name,
264
+ {:international_phone=>[:country_code, :national_number]},
223
265
  :last_name,
224
266
  :locality,
267
+ :phone_number,
225
268
  :postal_code,
226
269
  :region,
227
270
  :street_address,
@@ -229,15 +272,7 @@ describe Braintree::Customer do
229
272
  ]]
230
273
  },
231
274
  {:custom_fields => :_any_key_}
232
- ]
233
- end
234
- end
235
-
236
- describe "self.create_from_transparent_redirect" do
237
- it "raises an exception if the query string is forged" do
238
- expect do
239
- Braintree::Customer.create_from_transparent_redirect("http_status=200&forged=query_string")
240
- end.to raise_error(Braintree::ForgedQueryString)
275
+ ])
241
276
  end
242
277
  end
243
278
 
@@ -246,21 +281,21 @@ describe Braintree::Customer do
246
281
  first = Braintree::Customer._new(:gateway, :id => 123)
247
282
  second = Braintree::Customer._new(:gateway, :id => 123)
248
283
 
249
- first.should == second
250
- second.should == first
284
+ expect(first).to eq(second)
285
+ expect(second).to eq(first)
251
286
  end
252
287
 
253
288
  it "returns false when given a customer with a different id" do
254
289
  first = Braintree::Customer._new(:gateway, :id => 123)
255
290
  second = Braintree::Customer._new(:gateway, :id => 124)
256
291
 
257
- first.should_not == second
258
- second.should_not == first
292
+ expect(first).not_to eq(second)
293
+ expect(second).not_to eq(first)
259
294
  end
260
295
 
261
296
  it "returns false when not given a customer" do
262
297
  customer = Braintree::Customer._new(:gateway, :id => 123)
263
- customer.should_not == "not a customer"
298
+ expect(customer).not_to eq("not a customer")
264
299
  end
265
300
  end
266
301
 
@@ -275,22 +310,32 @@ describe Braintree::Customer do
275
310
  :paypal_accounts => [
276
311
  {:token => "paypal_1"},
277
312
  {:token => "paypal_2"}
278
- ]
313
+ ],
314
+ :sepa_debit_accounts => [
315
+ {:token => "sepa_debit_1"},
316
+ {:token => "sepa_debit_2"}
317
+ ],
279
318
  )
280
319
 
281
- customer.credit_cards.size.should == 2
282
- customer.credit_cards[0].token.should == "credit_card_1"
283
- customer.credit_cards[1].token.should == "credit_card_2"
320
+ expect(customer.credit_cards.size).to eq(2)
321
+ expect(customer.credit_cards[0].token).to eq("credit_card_1")
322
+ expect(customer.credit_cards[1].token).to eq("credit_card_2")
323
+
324
+ expect(customer.paypal_accounts.size).to eq(2)
325
+ expect(customer.paypal_accounts[0].token).to eq("paypal_1")
326
+ expect(customer.paypal_accounts[1].token).to eq("paypal_2")
284
327
 
285
- customer.paypal_accounts.size.should == 2
286
- customer.paypal_accounts[0].token.should == "paypal_1"
287
- customer.paypal_accounts[1].token.should == "paypal_2"
328
+ expect(customer.sepa_direct_debit_accounts.size).to eq(2)
329
+ expect(customer.sepa_direct_debit_accounts[0].token).to eq("sepa_debit_1")
330
+ expect(customer.sepa_direct_debit_accounts[1].token).to eq("sepa_debit_2")
288
331
 
289
- customer.payment_methods.count.should == 4
290
- customer.payment_methods.map(&:token).should include("credit_card_1")
291
- customer.payment_methods.map(&:token).should include("credit_card_2")
292
- customer.payment_methods.map(&:token).should include("paypal_1")
293
- customer.payment_methods.map(&:token).should include("paypal_2")
332
+ expect(customer.payment_methods.count).to eq(6)
333
+ expect(customer.payment_methods.map(&:token)).to include("credit_card_1")
334
+ expect(customer.payment_methods.map(&:token)).to include("credit_card_2")
335
+ expect(customer.payment_methods.map(&:token)).to include("paypal_1")
336
+ expect(customer.payment_methods.map(&:token)).to include("paypal_2")
337
+ expect(customer.payment_methods.map(&:token)).to include("sepa_debit_1")
338
+ expect(customer.payment_methods.map(&:token)).to include("sepa_debit_2")
294
339
  end
295
340
  end
296
341
 
@@ -3,16 +3,15 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
3
3
  describe Braintree::Digest do
4
4
  describe "self.hexdigest" do
5
5
  it "returns the sha1 hmac of the input string (test case 6 from RFC 2202)" do
6
- original_key = Braintree::Configuration.private_key
7
6
  private_key = "\xaa" * 80
8
7
  data = "Test Using Larger Than Block-Size Key - Hash Key First"
9
- Braintree::Digest.hexdigest(private_key, data).should == "aa4ae5e15272d00e95705637ce8a3b55ed402112"
8
+ expect(Braintree::Digest.hexdigest(private_key, data)).to eq("aa4ae5e15272d00e95705637ce8a3b55ed402112")
10
9
  end
11
10
 
12
11
  it "returns the sha1 hmac of the input string (test case 7 from RFC 2202)" do
13
12
  private_key = "\xaa" * 80
14
13
  data = "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data"
15
- Braintree::Digest.hexdigest(private_key, data).should == "e8e99d0f45237d786d6bbaa7965c7808bbff1a91"
14
+ expect(Braintree::Digest.hexdigest(private_key, data)).to eq("e8e99d0f45237d786d6bbaa7965c7808bbff1a91")
16
15
  end
17
16
 
18
17
  it "doesn't blow up if message is nil" do
@@ -22,15 +21,15 @@ describe Braintree::Digest do
22
21
 
23
22
  describe "self.secure_compare" do
24
23
  it "returns true if two strings are equal" do
25
- Braintree::Digest.secure_compare("A_string", "A_string").should be(true)
24
+ expect(Braintree::Digest.secure_compare("A_string", "A_string")).to be(true)
26
25
  end
27
26
 
28
27
  it "returns false if two strings are different and the same length" do
29
- Braintree::Digest.secure_compare("A_string", "A_strong").should be(false)
28
+ expect(Braintree::Digest.secure_compare("A_string", "A_strong")).to be(false)
30
29
  end
31
30
 
32
31
  it "returns false if one is a prefix of the other" do
33
- Braintree::Digest.secure_compare("A_string", "A_string_that_is_longer").should be(false)
32
+ expect(Braintree::Digest.secure_compare("A_string", "A_string_that_is_longer")).to be(false)
34
33
  end
35
34
  end
36
35
  end
@@ -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
- disbursement.inspect.should include('id: "123456"')
35
- disbursement.inspect.should include('amount: "100.0"')
36
- disbursement.inspect.should include('exception_message: "invalid_account_number"')
37
- disbursement.inspect.should include('disbursement_date: 2013-04-10')
38
- disbursement.inspect.should include('follow_up_action: "update"')
39
- disbursement.inspect.should include('merchant_account: #<Braintree::MerchantAccount: ')
40
- disbursement.inspect.should include('transaction_ids: ["sub_merchant_transaction"]')
41
- disbursement.inspect.should include('retry: false')
42
- disbursement.inspect.should include('success: false')
34
+ expect(disbursement.inspect).to include('id: "123456"')
35
+ expect(disbursement.inspect).to include('amount: "100.0"')
36
+ expect(disbursement.inspect).to include('exception_message: "invalid_account_number"')
37
+ expect(disbursement.inspect).to include("disbursement_date: 2013-04-10")
38
+ expect(disbursement.inspect).to include('follow_up_action: "update"')
39
+ expect(disbursement.inspect).to include("merchant_account: #<Braintree::MerchantAccount: ")
40
+ expect(disbursement.inspect).to include('transaction_ids: ["sub_merchant_transaction"]')
41
+ expect(disbursement.inspect).to include("retry: false")
42
+ expect(disbursement.inspect).to include("success: false")
43
43
  end
44
44
  end
45
45
 
@@ -56,9 +56,9 @@ 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
- disbursement.success?.should == false
61
+ expect(disbursement.success?).to eq(false)
62
62
 
63
63
  disbursement = Braintree::Disbursement._new(
64
64
  :gateway,
@@ -71,9 +71,9 @@ 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
- disbursement.success?.should == true
76
+ expect(disbursement.success?).to eq(true)
77
77
  end
78
78
  end
79
79
 
@@ -5,14 +5,14 @@ describe Braintree::DisputeSearch do
5
5
  search = Braintree::DisputeSearch.new
6
6
  search.id.is "dispute1"
7
7
  search.id.is "dispute2"
8
- search.to_hash.should == {:id => {:is => "dispute2"}}
8
+ expect(search.to_hash).to eq({:id => {:is => "dispute2"}})
9
9
  end
10
10
 
11
11
  it "overrides previous 'in' with new 'in' for the same field" do
12
12
  search = Braintree::DisputeSearch.new
13
13
  search.status.in Braintree::Dispute::Status::Open
14
14
  search.status.in Braintree::Dispute::Status::Won
15
- search.to_hash.should == {:status => [Braintree::Dispute::Status::Won]}
15
+ expect(search.to_hash).to eq({:status => [Braintree::Dispute::Status::Won]})
16
16
  end
17
17
 
18
18
  [
@@ -41,9 +41,13 @@ 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,
50
+ :pre_dispute_program,
47
51
  ].each do |field|
48
52
  it "raises if provided an unknown #{field} value" do
49
53
  search = Braintree::DisputeSearch.new