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
@@ -10,39 +10,35 @@ describe Braintree::PaymentMethod do
10
10
  Braintree::Configuration.private_key = "integration2_private_key"
11
11
  end
12
12
 
13
- context "plaid verified nonce" do
14
- let(:nonce) { generate_valid_plaid_us_bank_account_nonce }
13
+ context "non plaid verified nonce" do
14
+ let(:nonce) { generate_non_plaid_us_bank_account_nonce }
15
15
 
16
- it "succeeds" do
16
+ it "succeeds and does not verify when no method provided" do
17
17
  customer = Braintree::Customer.create.customer
18
18
  result = Braintree::PaymentMethod.create(
19
19
  :payment_method_nonce => nonce,
20
20
  :customer_id => customer.id,
21
21
  :options => {
22
22
  :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
23
- }
23
+ },
24
24
  )
25
25
 
26
- result.should be_success
26
+ expect(result).to be_success
27
27
  us_bank_account = result.payment_method
28
- us_bank_account.should be_a(Braintree::UsBankAccount)
29
- us_bank_account.routing_number.should == "011000015"
30
- us_bank_account.last_4.should == "0000"
31
- us_bank_account.account_type.should == "checking"
32
- us_bank_account.account_holder_name.should == "PayPal, Inc."
33
- us_bank_account.bank_name.should == "FEDERAL RESERVE BANK"
34
- us_bank_account.default.should == true
35
- us_bank_account.ach_mandate.text.should == "cl mandate text"
36
- us_bank_account.ach_mandate.accepted_at.should be_a Time
37
-
38
- us_bank_account.verifications.count.should == 1
39
- us_bank_account.verifications.first.status.should == Braintree::UsBankAccountVerification::Status::Verified
40
- us_bank_account.verifications.first.verification_method.should == Braintree::UsBankAccountVerification::VerificationMethod::TokenizedCheck
41
- us_bank_account.verifications.first.id.should_not be_empty
42
- us_bank_account.verifications.first.verification_determined_at.should be_a Time
43
- us_bank_account.verified.should == true
44
-
45
- Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
28
+ expect(us_bank_account).to be_a(Braintree::UsBankAccount)
29
+ expect(us_bank_account.routing_number).to eq("021000021")
30
+ expect(us_bank_account.last_4).to eq("0000")
31
+ expect(us_bank_account.account_type).to eq("checking")
32
+ expect(us_bank_account.account_holder_name).to eq("John Doe")
33
+ expect(us_bank_account.bank_name).to match(/CHASE/)
34
+ expect(us_bank_account.default).to eq(true)
35
+ expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
36
+ expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
37
+
38
+ expect(us_bank_account.verifications.count).to eq(0)
39
+ expect(us_bank_account.verified).to eq(false)
40
+
41
+ expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
46
42
  end
47
43
 
48
44
  [
@@ -57,107 +53,102 @@ describe Braintree::PaymentMethod do
57
53
  :options => {
58
54
  :us_bank_account_verification_method => method,
59
55
  :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
60
- }
56
+ },
61
57
  )
62
58
 
63
- result.should be_success
59
+ expect(result).to be_success
64
60
  us_bank_account = result.payment_method
65
- us_bank_account.should be_a(Braintree::UsBankAccount)
66
- us_bank_account.routing_number.should == "011000015"
67
- us_bank_account.last_4.should == "0000"
68
- us_bank_account.account_type.should == "checking"
69
- us_bank_account.account_holder_name.should == "PayPal, Inc."
70
- us_bank_account.bank_name.should == "FEDERAL RESERVE BANK"
71
- us_bank_account.default.should == true
72
- us_bank_account.ach_mandate.text.should == "cl mandate text"
73
- us_bank_account.ach_mandate.accepted_at.should be_a Time
74
- us_bank_account.verified.should == true
75
-
76
- us_bank_account.verifications.count.should == 2
77
-
78
- us_bank_account.verifications.map(&:verification_method).should contain_exactly(
79
- Braintree::UsBankAccountVerification::VerificationMethod::TokenizedCheck,
80
- method,
81
- )
82
-
83
- us_bank_account.verifications.each do |verification|
84
- verification.status.should == Braintree::UsBankAccountVerification::Status::Verified
85
- verification.id.should_not be_empty
86
- verification.verification_determined_at.should be_a Time
87
- end
88
-
89
- Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
61
+ expect(us_bank_account).to be_a(Braintree::UsBankAccount)
62
+ expect(us_bank_account.routing_number).to eq("021000021")
63
+ expect(us_bank_account.last_4).to eq("0000")
64
+ expect(us_bank_account.account_type).to eq("checking")
65
+ expect(us_bank_account.account_holder_name).to eq("John Doe")
66
+ expect(us_bank_account.bank_name).to match(/CHASE/)
67
+ expect(us_bank_account.default).to eq(true)
68
+ expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
69
+ expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
70
+
71
+ expect(us_bank_account.verifications.count).to eq(1)
72
+ expect(us_bank_account.verifications.first.status).to eq(Braintree::UsBankAccountVerification::Status::Verified)
73
+ expect(us_bank_account.verifications.first.verification_method).to eq(method)
74
+ expect(us_bank_account.verifications.first.id).not_to be_empty
75
+ expect(us_bank_account.verifications.first.verification_determined_at).to be_a Time
76
+ expect(us_bank_account.verified).to eq(true)
77
+
78
+ expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
90
79
  end
91
80
  end
92
- end
93
81
 
94
- context "non plaid verified nonce" do
95
- let(:nonce) { generate_non_plaid_us_bank_account_nonce }
96
-
97
- it "succeeds and does not verify when no method provided" do
82
+ it "succeeds and verifies with verification_add_ons for NetworkCheck with fake nonce" do
98
83
  customer = Braintree::Customer.create.customer
99
84
  result = Braintree::PaymentMethod.create(
100
- :payment_method_nonce => nonce,
85
+ :payment_method_nonce => Braintree::Test::Nonce::UsBankAccount,
101
86
  :customer_id => customer.id,
102
87
  :options => {
88
+ :us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
89
+ :verification_add_ons => Braintree::UsBankAccountVerification::VerificationAddOns::CustomerVerification,
103
90
  :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
104
- }
91
+ },
105
92
  )
106
93
 
107
- result.should be_success
94
+ expect(result).to be_success
108
95
  us_bank_account = result.payment_method
109
- us_bank_account.should be_a(Braintree::UsBankAccount)
110
- us_bank_account.routing_number.should == "021000021"
111
- us_bank_account.last_4.should == "0000"
112
- us_bank_account.account_type.should == "checking"
113
- us_bank_account.account_holder_name.should == "John Doe"
114
- us_bank_account.bank_name.should =~ /CHASE/
115
- us_bank_account.default.should == true
116
- us_bank_account.ach_mandate.text.should == "cl mandate text"
117
- us_bank_account.ach_mandate.accepted_at.should be_a Time
118
-
119
- us_bank_account.verifications.count.should == 0
120
- us_bank_account.verified.should == false
121
-
122
- Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
96
+ expect(us_bank_account).to be_a(Braintree::UsBankAccount)
97
+ expect(us_bank_account.routing_number).to eq("123456789")
98
+ expect(us_bank_account.last_4).to eq("0000")
99
+ expect(us_bank_account.account_type).to eq("checking")
100
+ expect(us_bank_account.account_holder_name).to eq("Dan Schulman")
101
+ expect(us_bank_account.bank_name).to match(/Wells Fargo/)
102
+ expect(us_bank_account.default).to eq(true)
103
+ expect(us_bank_account.ach_mandate.text).to eq("example mandate text")
104
+ expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
105
+
106
+ expect(us_bank_account.verifications.count).to eq(1)
107
+ expect(us_bank_account.verifications.first.status).to eq(Braintree::UsBankAccountVerification::Status::Verified)
108
+ expect(us_bank_account.verifications.first.verification_method).to eq(Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck)
109
+ expect(us_bank_account.verifications.first.id).not_to be_empty
110
+ expect(us_bank_account.verifications.first.verification_determined_at).to be_a Time
111
+ expect(us_bank_account.verifications.first.processor_response_code).to eq("1000")
112
+ expect(us_bank_account.verified).to eq(true)
113
+
114
+ expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
123
115
  end
124
116
 
125
- [
126
- Braintree::UsBankAccountVerification::VerificationMethod::IndependentCheck,
127
- Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
128
- ].each do |method|
129
- it "succeeds and verifies via #{method}" do
130
- customer = Braintree::Customer.create.customer
131
- result = Braintree::PaymentMethod.create(
132
- :payment_method_nonce => nonce,
133
- :customer_id => customer.id,
134
- :options => {
135
- :us_bank_account_verification_method => method,
136
- :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
137
- }
138
- )
117
+ it "returns additional processor response for failed NetworkCheck" do
118
+ customer = Braintree::Customer.create.customer
119
+ invalid_nonce = generate_non_plaid_us_bank_account_nonce("1000000005")
120
+ result = Braintree::PaymentMethod.create(
121
+ :payment_method_nonce => invalid_nonce,
122
+ :customer_id => customer.id,
123
+ :options => {
124
+ :us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
125
+ :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
126
+ },
127
+ )
139
128
 
140
- result.should be_success
141
- us_bank_account = result.payment_method
142
- us_bank_account.should be_a(Braintree::UsBankAccount)
143
- us_bank_account.routing_number.should == "021000021"
144
- us_bank_account.last_4.should == "0000"
145
- us_bank_account.account_type.should == "checking"
146
- us_bank_account.account_holder_name.should == "John Doe"
147
- us_bank_account.bank_name.should =~ /CHASE/
148
- us_bank_account.default.should == true
149
- us_bank_account.ach_mandate.text.should == "cl mandate text"
150
- us_bank_account.ach_mandate.accepted_at.should be_a Time
151
-
152
- us_bank_account.verifications.count.should == 1
153
- us_bank_account.verifications.first.status.should == Braintree::UsBankAccountVerification::Status::Verified
154
- us_bank_account.verifications.first.verification_method.should == method
155
- us_bank_account.verifications.first.id.should_not be_empty
156
- us_bank_account.verifications.first.verification_determined_at.should be_a Time
157
- us_bank_account.verified.should == true
158
-
159
- Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
160
- end
129
+ expect(result).to be_success
130
+ us_bank_account = result.payment_method
131
+ expect(us_bank_account).to be_a(Braintree::UsBankAccount)
132
+ expect(us_bank_account.routing_number).to eq("021000021")
133
+ expect(us_bank_account.last_4).to eq("0005")
134
+ expect(us_bank_account.account_type).to eq("checking")
135
+ expect(us_bank_account.account_holder_name).to eq("John Doe")
136
+ expect(us_bank_account.bank_name).to match(/CHASE/)
137
+ expect(us_bank_account.default).to eq(true)
138
+ expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
139
+ expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
140
+
141
+ expect(us_bank_account.verifications.count).to eq(1)
142
+ expect(us_bank_account.verifications.first.status).to eq(Braintree::UsBankAccountVerification::Status::ProcessorDeclined)
143
+ expect(us_bank_account.verifications.first.verification_method).to eq(Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck)
144
+ expect(us_bank_account.verifications.first.id).not_to be_empty
145
+ expect(us_bank_account.verifications.first.verification_determined_at).to be_a Time
146
+ expect(us_bank_account.verifications.first.processor_response_code).to eq("2061")
147
+ expect(us_bank_account.verifications.first.additional_processor_response).to eq("Invalid routing number")
148
+
149
+ expect(us_bank_account.verified).to eq(false)
150
+
151
+ expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
161
152
  end
162
153
  end
163
154
 
@@ -165,102 +156,24 @@ describe Braintree::PaymentMethod do
165
156
  customer = Braintree::Customer.create.customer
166
157
  result = Braintree::PaymentMethod.create(
167
158
  :payment_method_nonce => generate_invalid_us_bank_account_nonce,
168
- :customer_id => customer.id
159
+ :customer_id => customer.id,
169
160
  )
170
161
 
171
- result.should_not be_success
172
- result.errors.for(:payment_method).on(:payment_method_nonce)[0].code.should == Braintree::ErrorCodes::PaymentMethod::PaymentMethodNonceUnknown
162
+ expect(result).not_to be_success
163
+ expect(result.errors.for(:payment_method).on(:payment_method_nonce)[0].code).to eq(Braintree::ErrorCodes::PaymentMethod::PaymentMethodNonceUnknown)
173
164
  end
174
165
  end
175
166
 
176
167
  context "exempt merchant" do
177
- context "plaid verified nonce" do
178
- before do
179
- Braintree::Configuration.merchant_id = "integration_merchant_id"
180
- Braintree::Configuration.public_key = "integration_public_key"
181
- Braintree::Configuration.private_key = "integration_private_key"
182
- end
183
-
184
- let(:nonce) { generate_valid_plaid_us_bank_account_nonce }
185
-
186
- it "succeeds and verifies via independent check" do
187
- customer = Braintree::Customer.create.customer
188
- result = Braintree::PaymentMethod.create(
189
- :payment_method_nonce => nonce,
190
- :customer_id => customer.id,
191
- :options => {
192
- :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
193
- }
194
- )
195
-
196
- result.should be_success
197
- us_bank_account = result.payment_method
198
- us_bank_account.should be_a(Braintree::UsBankAccount)
199
- us_bank_account.routing_number.should == "011000015"
200
- us_bank_account.last_4.should == "0000"
201
- us_bank_account.account_type.should == "checking"
202
- us_bank_account.account_holder_name.should == "PayPal, Inc."
203
- us_bank_account.bank_name.should == "FEDERAL RESERVE BANK"
204
- us_bank_account.default.should == true
205
- us_bank_account.ach_mandate.text.should == "cl mandate text"
206
- us_bank_account.ach_mandate.accepted_at.should be_a Time
207
-
208
- us_bank_account.verifications.count.should == 1
209
- us_bank_account.verifications.first.status.should == Braintree::UsBankAccountVerification::Status::Verified
210
- us_bank_account.verifications.first.verification_method.should == Braintree::UsBankAccountVerification::VerificationMethod::TokenizedCheck
211
- us_bank_account.verifications.first.id.should_not be_empty
212
- us_bank_account.verifications.first.verification_determined_at.should be_a Time
213
- us_bank_account.verified.should == true
214
-
215
- Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
216
- end
217
- end
218
-
219
- context "non plaid verified nonce" do
220
- let(:nonce) { generate_non_plaid_us_bank_account_nonce }
221
-
222
- it "succeeds and verifies via independent check" do
223
- customer = Braintree::Customer.create.customer
224
- result = Braintree::PaymentMethod.create(
225
- :payment_method_nonce => nonce,
226
- :customer_id => customer.id,
227
- :options => {
228
- :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
229
- }
230
- )
231
-
232
- result.should be_success
233
- us_bank_account = result.payment_method
234
- us_bank_account.should be_a(Braintree::UsBankAccount)
235
- us_bank_account.routing_number.should == "021000021"
236
- us_bank_account.last_4.should == "0000"
237
- us_bank_account.account_type.should == "checking"
238
- us_bank_account.account_holder_name.should == "John Doe"
239
- us_bank_account.bank_name.should =~ /CHASE/
240
- us_bank_account.default.should == true
241
- us_bank_account.ach_mandate.text.should == "cl mandate text"
242
- us_bank_account.ach_mandate.accepted_at.should be_a Time
243
-
244
- us_bank_account.verifications.count.should == 1
245
- us_bank_account.verifications.first.status.should == Braintree::UsBankAccountVerification::Status::Verified
246
- us_bank_account.verifications.first.verification_method.should == Braintree::UsBankAccountVerification::VerificationMethod::IndependentCheck
247
- us_bank_account.verifications.first.id.should_not be_empty
248
- us_bank_account.verifications.first.verification_determined_at.should be_a Time
249
- us_bank_account.verified.should == true
250
-
251
- Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
252
- end
253
- end
254
-
255
168
  it "fails with invalid nonce" do
256
169
  customer = Braintree::Customer.create.customer
257
170
  result = Braintree::PaymentMethod.create(
258
171
  :payment_method_nonce => generate_invalid_us_bank_account_nonce,
259
- :customer_id => customer.id
172
+ :customer_id => customer.id,
260
173
  )
261
174
 
262
- result.should_not be_success
263
- result.errors.for(:payment_method).on(:payment_method_nonce)[0].code.should == Braintree::ErrorCodes::PaymentMethod::PaymentMethodNonceUnknown
175
+ expect(result).not_to be_success
176
+ expect(result.errors.for(:payment_method).on(:payment_method_nonce)[0].code).to eq(Braintree::ErrorCodes::PaymentMethod::PaymentMethodNonceUnknown)
264
177
  end
265
178
  end
266
179
  end
@@ -276,7 +189,7 @@ describe Braintree::PaymentMethod do
276
189
  context "unverified token" do
277
190
  let(:payment_method) do
278
191
  customer = Braintree::Customer.create.customer
279
- result = Braintree::PaymentMethod.create(
192
+ Braintree::PaymentMethod.create(
280
193
  :payment_method_nonce => generate_non_plaid_us_bank_account_nonce,
281
194
  :customer_id => customer.id,
282
195
  :options => {
@@ -298,27 +211,27 @@ describe Braintree::PaymentMethod do
298
211
  },
299
212
  )
300
213
 
301
- result.should be_success
214
+ expect(result).to be_success
302
215
 
303
216
  us_bank_account = result.payment_method
304
- us_bank_account.should be_a(Braintree::UsBankAccount)
305
- us_bank_account.routing_number.should == "021000021"
306
- us_bank_account.last_4.should == "0000"
307
- us_bank_account.account_type.should == "checking"
308
- us_bank_account.account_holder_name.should == "John Doe"
309
- us_bank_account.bank_name.should =~ /CHASE/
310
- us_bank_account.default.should == true
311
- us_bank_account.ach_mandate.text.should == "cl mandate text"
312
- us_bank_account.ach_mandate.accepted_at.should be_a Time
313
-
314
- us_bank_account.verifications.count.should == 1
315
- us_bank_account.verifications.first.status.should == Braintree::UsBankAccountVerification::Status::Verified
316
- us_bank_account.verifications.first.verification_method.should == method
317
- us_bank_account.verifications.first.id.should_not be_empty
318
- us_bank_account.verifications.first.verification_determined_at.should be_a Time
319
- us_bank_account.verified.should == true
320
-
321
- Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
217
+ expect(us_bank_account).to be_a(Braintree::UsBankAccount)
218
+ expect(us_bank_account.routing_number).to eq("021000021")
219
+ expect(us_bank_account.last_4).to eq("0000")
220
+ expect(us_bank_account.account_type).to eq("checking")
221
+ expect(us_bank_account.account_holder_name).to eq("John Doe")
222
+ expect(us_bank_account.bank_name).to match(/CHASE/)
223
+ expect(us_bank_account.default).to eq(true)
224
+ expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
225
+ expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
226
+
227
+ expect(us_bank_account.verifications.count).to eq(1)
228
+ expect(us_bank_account.verifications.first.status).to eq(Braintree::UsBankAccountVerification::Status::Verified)
229
+ expect(us_bank_account.verifications.first.verification_method).to eq(method)
230
+ expect(us_bank_account.verifications.first.id).not_to be_empty
231
+ expect(us_bank_account.verifications.first.verification_determined_at).to be_a Time
232
+ expect(us_bank_account.verified).to eq(true)
233
+
234
+ expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
322
235
  end
323
236
  end
324
237
 
@@ -331,8 +244,8 @@ describe Braintree::PaymentMethod do
331
244
  },
332
245
  )
333
246
 
334
- result.should_not be_success
335
- result.errors.for(:options).first.code.should == Braintree::ErrorCodes::PaymentMethod::Options::UsBankAccountVerificationMethodIsInvalid
247
+ expect(result).not_to be_success
248
+ expect(result.errors.for(:options).first.code).to eq(Braintree::ErrorCodes::PaymentMethod::Options::UsBankAccountVerificationMethodIsInvalid)
336
249
  end
337
250
  end
338
251
  end
@@ -347,12 +260,12 @@ describe Braintree::PaymentMethod do
347
260
  context "unverified token" do
348
261
  let(:payment_method) do
349
262
  customer = Braintree::Customer.create.customer
350
- result = Braintree::PaymentMethod.create(
263
+ Braintree::PaymentMethod.create(
351
264
  :payment_method_nonce => generate_non_plaid_us_bank_account_nonce,
352
265
  :customer_id => customer.id,
353
266
  :options => {
354
267
  :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
355
- }
268
+ },
356
269
  ).payment_method
357
270
  end
358
271
 
@@ -369,29 +282,29 @@ describe Braintree::PaymentMethod do
369
282
  },
370
283
  )
371
284
 
372
- result.should be_success
285
+ expect(result).to be_success
373
286
 
374
287
  us_bank_account = result.payment_method
375
- us_bank_account.should be_a(Braintree::UsBankAccount)
376
- us_bank_account.routing_number.should == "021000021"
377
- us_bank_account.last_4.should == "0000"
378
- us_bank_account.account_type.should == "checking"
379
- us_bank_account.account_holder_name.should == "John Doe"
380
- us_bank_account.bank_name.should =~ /CHASE/
381
- us_bank_account.default.should == true
382
- us_bank_account.ach_mandate.text.should == "cl mandate text"
383
- us_bank_account.ach_mandate.accepted_at.should be_a Time
384
-
385
- us_bank_account.verifications.count.should == 2
288
+ expect(us_bank_account).to be_a(Braintree::UsBankAccount)
289
+ expect(us_bank_account.routing_number).to eq("021000021")
290
+ expect(us_bank_account.last_4).to eq("0000")
291
+ expect(us_bank_account.account_type).to eq("checking")
292
+ expect(us_bank_account.account_holder_name).to eq("John Doe")
293
+ expect(us_bank_account.bank_name).to match(/CHASE/)
294
+ expect(us_bank_account.default).to eq(true)
295
+ expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
296
+ expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
297
+
298
+ expect(us_bank_account.verifications.count).to eq(2)
386
299
  verification = us_bank_account.verifications.find do |verification|
387
300
  verification.verification_method == method
388
301
  end
389
- verification.status.should == Braintree::UsBankAccountVerification::Status::Verified
390
- verification.id.should_not be_empty
391
- verification.verification_determined_at.should be_a Time
392
- us_bank_account.verified.should == true
302
+ expect(verification.status).to eq(Braintree::UsBankAccountVerification::Status::Verified)
303
+ expect(verification.id).not_to be_empty
304
+ expect(verification.verification_determined_at).to be_a Time
305
+ expect(us_bank_account.verified).to eq(true)
393
306
 
394
- Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
307
+ expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
395
308
  end
396
309
  end
397
310
 
@@ -403,8 +316,8 @@ describe Braintree::PaymentMethod do
403
316
  },
404
317
  )
405
318
 
406
- result.should_not be_success
407
- result.errors.for(:options).first.code.should == Braintree::ErrorCodes::PaymentMethod::Options::UsBankAccountVerificationMethodIsInvalid
319
+ expect(result).not_to be_success
320
+ expect(result.errors.for(:options).first.code).to eq(Braintree::ErrorCodes::PaymentMethod::Options::UsBankAccountVerificationMethodIsInvalid)
408
321
  end
409
322
  end
410
323
  end