braintree 4.14.0 → 4.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (241) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/account_updater_daily_report.rb +3 -3
  3. data/lib/braintree/ach_mandate.rb +1 -1
  4. data/lib/braintree/add_on_gateway.rb +1 -1
  5. data/lib/braintree/address.rb +4 -4
  6. data/lib/braintree/address_gateway.rb +5 -5
  7. data/lib/braintree/advanced_search.rb +10 -10
  8. data/lib/braintree/apple_pay.rb +3 -3
  9. data/lib/braintree/apple_pay_card.rb +3 -3
  10. data/lib/braintree/apple_pay_options.rb +3 -3
  11. data/lib/braintree/authorization_adjustment.rb +3 -3
  12. data/lib/braintree/base_module.rb +1 -1
  13. data/lib/braintree/bin_data.rb +2 -2
  14. data/lib/braintree/client_token_gateway.rb +1 -1
  15. data/lib/braintree/configuration.rb +22 -22
  16. data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
  17. data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
  18. data/lib/braintree/credit_card.rb +22 -9
  19. data/lib/braintree/credit_card_gateway.rb +23 -11
  20. data/lib/braintree/credit_card_verification.rb +3 -3
  21. data/lib/braintree/credit_card_verification_search.rb +1 -1
  22. data/lib/braintree/customer.rb +5 -9
  23. data/lib/braintree/customer_gateway.rb +7 -7
  24. data/lib/braintree/customer_search.rb +1 -1
  25. data/lib/braintree/descriptor.rb +1 -1
  26. data/lib/braintree/digest.rb +1 -1
  27. data/lib/braintree/disbursement.rb +5 -5
  28. data/lib/braintree/discount_gateway.rb +1 -1
  29. data/lib/braintree/dispute/evidence.rb +1 -1
  30. data/lib/braintree/dispute/paypal_message.rb +1 -1
  31. data/lib/braintree/dispute/status_history.rb +1 -1
  32. data/lib/braintree/dispute/transaction.rb +1 -1
  33. data/lib/braintree/dispute/transaction_details.rb +1 -1
  34. data/lib/braintree/dispute.rb +3 -3
  35. data/lib/braintree/dispute_gateway.rb +1 -1
  36. data/lib/braintree/dispute_search.rb +1 -1
  37. data/lib/braintree/document_upload.rb +2 -2
  38. data/lib/braintree/document_upload_gateway.rb +3 -3
  39. data/lib/braintree/enriched_customer_data.rb +2 -2
  40. data/lib/braintree/error_result.rb +2 -3
  41. data/lib/braintree/errors.rb +3 -3
  42. data/lib/braintree/exceptions.rb +1 -2
  43. data/lib/braintree/exchange_rate.rb +2 -2
  44. data/lib/braintree/exchange_rate_quote.rb +3 -3
  45. data/lib/braintree/exchange_rate_quote_gateway.rb +1 -1
  46. data/lib/braintree/exchange_rate_quote_input.rb +3 -3
  47. data/lib/braintree/exchange_rate_quote_request.rb +3 -3
  48. data/lib/braintree/exchange_rate_quote_response.rb +3 -3
  49. data/lib/braintree/facilitated_details.rb +1 -1
  50. data/lib/braintree/facilitator_details.rb +1 -1
  51. data/lib/braintree/google_pay_card.rb +3 -3
  52. data/lib/braintree/granted_payment_instrument_update.rb +1 -1
  53. data/lib/braintree/graphql_client.rb +1 -1
  54. data/lib/braintree/http.rb +1 -1
  55. data/lib/braintree/local_payment_completed.rb +2 -2
  56. data/lib/braintree/local_payment_expired.rb +2 -2
  57. data/lib/braintree/local_payment_funded.rb +2 -2
  58. data/lib/braintree/local_payment_reversed.rb +2 -2
  59. data/lib/braintree/merchant.rb +3 -3
  60. data/lib/braintree/merchant_account.rb +2 -2
  61. data/lib/braintree/merchant_account_gateway.rb +9 -9
  62. data/lib/braintree/meta_checkout_card.rb +89 -0
  63. data/lib/braintree/meta_checkout_token.rb +88 -0
  64. data/lib/braintree/modification.rb +3 -3
  65. data/lib/braintree/oauth_credentials.rb +3 -3
  66. data/lib/braintree/paginated_collection.rb +2 -2
  67. data/lib/braintree/paginated_result.rb +1 -1
  68. data/lib/braintree/payment_instrument_type.rb +2 -0
  69. data/lib/braintree/payment_method_customer_data_updated_metadata.rb +2 -2
  70. data/lib/braintree/payment_method_gateway.rb +23 -10
  71. data/lib/braintree/payment_method_nonce.rb +4 -4
  72. data/lib/braintree/payment_method_nonce_details.rb +1 -1
  73. data/lib/braintree/payment_method_nonce_details_payer_info.rb +1 -1
  74. data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
  75. data/lib/braintree/paypal_account.rb +1 -2
  76. data/lib/braintree/paypal_account_gateway.rb +5 -5
  77. data/lib/braintree/plan.rb +1 -1
  78. data/lib/braintree/plan_gateway.rb +2 -2
  79. data/lib/braintree/resource_collection.rb +2 -2
  80. data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
  81. data/lib/braintree/risk_data.rb +1 -1
  82. data/lib/braintree/samsung_pay_card.rb +5 -5
  83. data/lib/braintree/sepa_direct_debit_account.rb +2 -2
  84. data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +1 -1
  85. data/lib/braintree/settlement_batch_summary_gateway.rb +1 -1
  86. data/lib/braintree/sha256_digest.rb +1 -1
  87. data/lib/braintree/subscription/status_details.rb +1 -1
  88. data/lib/braintree/subscription.rb +2 -2
  89. data/lib/braintree/subscription_gateway.rb +6 -6
  90. data/lib/braintree/subscription_search.rb +1 -1
  91. data/lib/braintree/successful_result.rb +2 -2
  92. data/lib/braintree/test/credit_card.rb +7 -10
  93. data/lib/braintree/test/merchant_account.rb +1 -1
  94. data/lib/braintree/test/nonce.rb +4 -0
  95. data/lib/braintree/test/transaction_amounts.rb +2 -3
  96. data/lib/braintree/test/venmo_sdk.rb +2 -0
  97. data/lib/braintree/testing_gateway.rb +1 -1
  98. data/lib/braintree/three_d_secure_info.rb +1 -1
  99. data/lib/braintree/transaction/address_details.rb +1 -1
  100. data/lib/braintree/transaction/credit_card_details.rb +4 -1
  101. data/lib/braintree/transaction/customer_details.rb +1 -1
  102. data/lib/braintree/transaction/disbursement_details.rb +1 -1
  103. data/lib/braintree/transaction/local_payment_details.rb +2 -0
  104. data/lib/braintree/transaction/meta_checkout_card_details.rb +52 -0
  105. data/lib/braintree/transaction/meta_checkout_token_details.rb +54 -0
  106. data/lib/braintree/transaction/samsung_pay_card_details.rb +1 -1
  107. data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +1 -1
  108. data/lib/braintree/transaction/status_details.rb +1 -1
  109. data/lib/braintree/transaction/subscription_details.rb +1 -1
  110. data/lib/braintree/transaction/us_bank_account_details.rb +1 -1
  111. data/lib/braintree/transaction/visa_checkout_card_details.rb +1 -1
  112. data/lib/braintree/transaction.rb +27 -20
  113. data/lib/braintree/transaction_gateway.rb +23 -12
  114. data/lib/braintree/transaction_line_item.rb +2 -2
  115. data/lib/braintree/transaction_line_item_gateway.rb +1 -1
  116. data/lib/braintree/transaction_review.rb +1 -1
  117. data/lib/braintree/transaction_search.rb +7 -6
  118. data/lib/braintree/unknown_payment_method.rb +1 -1
  119. data/lib/braintree/us_bank_account.rb +2 -2
  120. data/lib/braintree/us_bank_account_verification.rb +23 -15
  121. data/lib/braintree/us_bank_account_verification_search.rb +1 -1
  122. data/lib/braintree/util.rb +3 -3
  123. data/lib/braintree/validation_error.rb +1 -1
  124. data/lib/braintree/validation_error_collection.rb +3 -3
  125. data/lib/braintree/venmo_account.rb +3 -3
  126. data/lib/braintree/venmo_profile_data.rb +6 -4
  127. data/lib/braintree/version.rb +1 -1
  128. data/lib/braintree/visa_checkout_card.rb +7 -7
  129. data/lib/braintree/webhook_notification.rb +3 -2
  130. data/lib/braintree/webhook_notification_gateway.rb +3 -3
  131. data/lib/braintree/webhook_testing.rb +1 -1
  132. data/lib/braintree/webhook_testing_gateway.rb +18 -1
  133. data/lib/braintree/xml/generator.rb +1 -1
  134. data/lib/braintree/xml/libxml.rb +1 -1
  135. data/lib/braintree/xml/parser.rb +2 -2
  136. data/lib/braintree/xml/rexml.rb +2 -2
  137. data/lib/braintree/xml.rb +1 -1
  138. data/lib/braintree.rb +4 -1
  139. data/spec/integration/braintree/add_on_spec.rb +9 -9
  140. data/spec/integration/braintree/address_spec.rb +69 -69
  141. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  142. data/spec/integration/braintree/apple_pay_spec.rb +8 -8
  143. data/spec/integration/braintree/client_api/client_token_spec.rb +15 -15
  144. data/spec/integration/braintree/credit_card_spec.rb +223 -223
  145. data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
  146. data/spec/integration/braintree/credit_card_verification_spec.rb +52 -52
  147. data/spec/integration/braintree/customer_search_spec.rb +20 -20
  148. data/spec/integration/braintree/customer_spec.rb +313 -313
  149. data/spec/integration/braintree/disbursement_spec.rb +2 -2
  150. data/spec/integration/braintree/discount_spec.rb +9 -9
  151. data/spec/integration/braintree/dispute_search_spec.rb +0 -1
  152. data/spec/integration/braintree/dispute_spec.rb +87 -87
  153. data/spec/integration/braintree/document_upload_spec.rb +17 -17
  154. data/spec/integration/braintree/error_codes_spec.rb +2 -2
  155. data/spec/integration/braintree/http_spec.rb +28 -28
  156. data/spec/integration/braintree/merchant_account_spec.rb +127 -127
  157. data/spec/integration/braintree/merchant_spec.rb +103 -103
  158. data/spec/integration/braintree/oauth_spec.rb +61 -61
  159. data/spec/integration/braintree/payment_method_nonce_spec.rb +89 -69
  160. data/spec/integration/braintree/payment_method_spec.rb +389 -389
  161. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +150 -78
  162. data/spec/integration/braintree/paypal_account_spec.rb +38 -38
  163. data/spec/integration/braintree/plan_spec.rb +15 -15
  164. data/spec/integration/braintree/samsung_pay_card_spec.rb +65 -65
  165. data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +51 -51
  166. data/spec/integration/braintree/settlement_batch_summary_spec.rb +11 -11
  167. data/spec/integration/braintree/subscription_spec.rb +364 -364
  168. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  169. data/spec/integration/braintree/test_transaction_spec.rb +19 -19
  170. data/spec/integration/braintree/transaction_line_item_spec.rb +6 -6
  171. data/spec/integration/braintree/transaction_search_spec.rb +225 -165
  172. data/spec/integration/braintree/transaction_spec.rb +1502 -1210
  173. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -32
  174. data/spec/integration/braintree/us_bank_account_spec.rb +30 -30
  175. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +18 -18
  176. data/spec/integration/braintree/us_bank_account_verification_spec.rb +33 -33
  177. data/spec/integration/braintree/visa_checkout_card_spec.rb +57 -57
  178. data/spec/spec_helper.rb +9 -8
  179. data/spec/unit/braintree/address_spec.rb +8 -8
  180. data/spec/unit/braintree/base_module_spec.rb +4 -4
  181. data/spec/unit/braintree/client_token_spec.rb +2 -2
  182. data/spec/unit/braintree/configuration_spec.rb +57 -57
  183. data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
  184. data/spec/unit/braintree/credit_card_spec.rb +31 -29
  185. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +28 -28
  186. data/spec/unit/braintree/credit_card_verification_search_spec.rb +9 -9
  187. data/spec/unit/braintree/credit_card_verification_spec.rb +17 -17
  188. data/spec/unit/braintree/customer_spec.rb +41 -40
  189. data/spec/unit/braintree/digest_spec.rb +5 -5
  190. data/spec/unit/braintree/disbursement_spec.rb +11 -11
  191. data/spec/unit/braintree/dispute_search_spec.rb +2 -2
  192. data/spec/unit/braintree/dispute_spec.rb +56 -56
  193. data/spec/unit/braintree/document_upload_spec.rb +8 -8
  194. data/spec/unit/braintree/enriched_customer_data_spec.rb +11 -2
  195. data/spec/unit/braintree/error_result_spec.rb +5 -5
  196. data/spec/unit/braintree/errors_spec.rb +9 -9
  197. data/spec/unit/braintree/http_spec.rb +9 -9
  198. data/spec/unit/braintree/local_payment_completed_spec.rb +11 -11
  199. data/spec/unit/braintree/local_payment_expired_spec.rb +2 -2
  200. data/spec/unit/braintree/local_payment_funded_spec.rb +6 -6
  201. data/spec/unit/braintree/merchant_account_spec.rb +4 -4
  202. data/spec/unit/braintree/meta_checkout_card_details_spec.rb +60 -0
  203. data/spec/unit/braintree/meta_checkout_card_spec.rb +60 -0
  204. data/spec/unit/braintree/meta_checkout_token_details_spec.rb +63 -0
  205. data/spec/unit/braintree/meta_checkout_token_spec.rb +63 -0
  206. data/spec/unit/braintree/modification_spec.rb +1 -1
  207. data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +6 -6
  208. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +7 -7
  209. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +14 -14
  210. data/spec/unit/braintree/payment_method_spec.rb +19 -19
  211. data/spec/unit/braintree/paypal_account_spec.rb +4 -4
  212. data/spec/unit/braintree/resource_collection_spec.rb +7 -7
  213. data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +1 -1
  214. data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
  215. data/spec/unit/braintree/signature_service_spec.rb +2 -2
  216. data/spec/unit/braintree/subscription_search_spec.rb +17 -17
  217. data/spec/unit/braintree/subscription_spec.rb +8 -8
  218. data/spec/unit/braintree/successful_result_spec.rb +5 -5
  219. data/spec/unit/braintree/three_d_secure_info_spec.rb +20 -20
  220. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -5
  221. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  222. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  223. data/spec/unit/braintree/transaction/local_payment_details_spec.rb +30 -0
  224. data/spec/unit/braintree/transaction_gateway_spec.rb +39 -7
  225. data/spec/unit/braintree/transaction_search_spec.rb +2 -2
  226. data/spec/unit/braintree/transaction_spec.rb +101 -93
  227. data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
  228. data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
  229. data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
  230. data/spec/unit/braintree/us_bank_account_verification_spec.rb +12 -7
  231. data/spec/unit/braintree/util_spec.rb +27 -27
  232. data/spec/unit/braintree/validation_error_collection_spec.rb +34 -34
  233. data/spec/unit/braintree/validation_error_spec.rb +4 -4
  234. data/spec/unit/braintree/venmo_profile_data_spec.rb +16 -5
  235. data/spec/unit/braintree/webhook_notification_spec.rb +206 -191
  236. data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
  237. data/spec/unit/braintree/xml/parser_spec.rb +8 -8
  238. data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
  239. data/spec/unit/braintree/xml_spec.rb +17 -17
  240. data/spec/unit/braintree_spec.rb +2 -2
  241. metadata +11 -2
@@ -23,22 +23,22 @@ describe Braintree::PaymentMethod do
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 == "021000021"
30
- us_bank_account.last_4.should == "0000"
31
- us_bank_account.account_type.should == "checking"
32
- us_bank_account.account_holder_name.should == "John Doe"
33
- us_bank_account.bank_name.should =~ /CHASE/
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 == 0
39
- us_bank_account.verified.should == false
40
-
41
- 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)
42
42
  end
43
43
 
44
44
  [
@@ -56,28 +56,100 @@ describe Braintree::PaymentMethod do
56
56
  },
57
57
  )
58
58
 
59
- result.should be_success
59
+ expect(result).to be_success
60
60
  us_bank_account = result.payment_method
61
- us_bank_account.should be_a(Braintree::UsBankAccount)
62
- us_bank_account.routing_number.should == "021000021"
63
- us_bank_account.last_4.should == "0000"
64
- us_bank_account.account_type.should == "checking"
65
- us_bank_account.account_holder_name.should == "John Doe"
66
- us_bank_account.bank_name.should =~ /CHASE/
67
- us_bank_account.default.should == true
68
- us_bank_account.ach_mandate.text.should == "cl mandate text"
69
- us_bank_account.ach_mandate.accepted_at.should be_a Time
70
-
71
- us_bank_account.verifications.count.should == 1
72
- us_bank_account.verifications.first.status.should == Braintree::UsBankAccountVerification::Status::Verified
73
- us_bank_account.verifications.first.verification_method.should == method
74
- us_bank_account.verifications.first.id.should_not be_empty
75
- us_bank_account.verifications.first.verification_determined_at.should be_a Time
76
- us_bank_account.verified.should == true
77
-
78
- 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)
79
79
  end
80
80
  end
81
+
82
+ it "succeeds and verifies with verification_add_ons for NetworkCheck with fake nonce" do
83
+ customer = Braintree::Customer.create.customer
84
+ result = Braintree::PaymentMethod.create(
85
+ :payment_method_nonce => Braintree::Test::Nonce::UsBankAccount,
86
+ :customer_id => customer.id,
87
+ :options => {
88
+ :us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
89
+ :verification_add_ons => Braintree::UsBankAccountVerification::VerificationAddOns::CustomerVerification,
90
+ :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
91
+ },
92
+ )
93
+
94
+ expect(result).to be_success
95
+ us_bank_account = result.payment_method
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)
115
+ end
116
+
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(account_number = "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
+ )
128
+
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)
152
+ end
81
153
  end
82
154
 
83
155
  it "fails with invalid nonce" do
@@ -87,8 +159,8 @@ describe Braintree::PaymentMethod do
87
159
  :customer_id => customer.id,
88
160
  )
89
161
 
90
- result.should_not be_success
91
- 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)
92
164
  end
93
165
  end
94
166
 
@@ -100,8 +172,8 @@ describe Braintree::PaymentMethod do
100
172
  :customer_id => customer.id,
101
173
  )
102
174
 
103
- result.should_not be_success
104
- 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)
105
177
  end
106
178
  end
107
179
  end
@@ -139,27 +211,27 @@ describe Braintree::PaymentMethod do
139
211
  },
140
212
  )
141
213
 
142
- result.should be_success
214
+ expect(result).to be_success
143
215
 
144
216
  us_bank_account = result.payment_method
145
- us_bank_account.should be_a(Braintree::UsBankAccount)
146
- us_bank_account.routing_number.should == "021000021"
147
- us_bank_account.last_4.should == "0000"
148
- us_bank_account.account_type.should == "checking"
149
- us_bank_account.account_holder_name.should == "John Doe"
150
- us_bank_account.bank_name.should =~ /CHASE/
151
- us_bank_account.default.should == true
152
- us_bank_account.ach_mandate.text.should == "cl mandate text"
153
- us_bank_account.ach_mandate.accepted_at.should be_a Time
154
-
155
- us_bank_account.verifications.count.should == 1
156
- us_bank_account.verifications.first.status.should == Braintree::UsBankAccountVerification::Status::Verified
157
- us_bank_account.verifications.first.verification_method.should == method
158
- us_bank_account.verifications.first.id.should_not be_empty
159
- us_bank_account.verifications.first.verification_determined_at.should be_a Time
160
- us_bank_account.verified.should == true
161
-
162
- 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)
163
235
  end
164
236
  end
165
237
 
@@ -172,8 +244,8 @@ describe Braintree::PaymentMethod do
172
244
  },
173
245
  )
174
246
 
175
- result.should_not be_success
176
- 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)
177
249
  end
178
250
  end
179
251
  end
@@ -210,29 +282,29 @@ describe Braintree::PaymentMethod do
210
282
  },
211
283
  )
212
284
 
213
- result.should be_success
285
+ expect(result).to be_success
214
286
 
215
287
  us_bank_account = result.payment_method
216
- us_bank_account.should be_a(Braintree::UsBankAccount)
217
- us_bank_account.routing_number.should == "021000021"
218
- us_bank_account.last_4.should == "0000"
219
- us_bank_account.account_type.should == "checking"
220
- us_bank_account.account_holder_name.should == "John Doe"
221
- us_bank_account.bank_name.should =~ /CHASE/
222
- us_bank_account.default.should == true
223
- us_bank_account.ach_mandate.text.should == "cl mandate text"
224
- us_bank_account.ach_mandate.accepted_at.should be_a Time
225
-
226
- 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)
227
299
  verification = us_bank_account.verifications.find do |verification|
228
300
  verification.verification_method == method
229
301
  end
230
- verification.status.should == Braintree::UsBankAccountVerification::Status::Verified
231
- verification.id.should_not be_empty
232
- verification.verification_determined_at.should be_a Time
233
- 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)
234
306
 
235
- 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)
236
308
  end
237
309
  end
238
310
 
@@ -244,8 +316,8 @@ describe Braintree::PaymentMethod do
244
316
  },
245
317
  )
246
318
 
247
- result.should_not be_success
248
- 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)
249
321
  end
250
322
  end
251
323
  end
@@ -15,17 +15,17 @@ describe Braintree::PayPalAccount do
15
15
  :payment_method_nonce => nonce,
16
16
  :customer_id => customer.id,
17
17
  )
18
- result.should be_success
18
+ expect(result).to be_success
19
19
 
20
20
  paypal_account = Braintree::PayPalAccount.find(payment_method_token)
21
- paypal_account.should be_a(Braintree::PayPalAccount)
22
- paypal_account.token.should == payment_method_token
23
- paypal_account.email.should == "jane.doe@example.com"
24
- paypal_account.image_url.should_not be_nil
25
- paypal_account.created_at.should_not be_nil
26
- paypal_account.updated_at.should_not be_nil
27
- paypal_account.customer_id.should == customer.id
28
- paypal_account.revoked_at.should be_nil
21
+ expect(paypal_account).to be_a(Braintree::PayPalAccount)
22
+ expect(paypal_account.token).to eq(payment_method_token)
23
+ expect(paypal_account.email).to eq("jane.doe@example.com")
24
+ expect(paypal_account.image_url).not_to be_nil
25
+ expect(paypal_account.created_at).not_to be_nil
26
+ expect(paypal_account.updated_at).not_to be_nil
27
+ expect(paypal_account.customer_id).to eq(customer.id)
28
+ expect(paypal_account.revoked_at).to be_nil
29
29
  end
30
30
 
31
31
  it "returns a PayPalAccount with a billing agreement id" do
@@ -37,10 +37,10 @@ describe Braintree::PayPalAccount do
37
37
  :customer_id => customer.id,
38
38
  :token => payment_method_token,
39
39
  )
40
- result.should be_success
40
+ expect(result).to be_success
41
41
 
42
42
  paypal_account = Braintree::PayPalAccount.find(payment_method_token)
43
- paypal_account.billing_agreement_id.should_not be_nil
43
+ expect(paypal_account.billing_agreement_id).not_to be_nil
44
44
  end
45
45
 
46
46
  it "raises if the payment method token is not found" do
@@ -76,7 +76,7 @@ describe Braintree::PayPalAccount do
76
76
  :payment_method_nonce => nonce,
77
77
  :customer_id => customer.id,
78
78
  )
79
- result.should be_success
79
+ expect(result).to be_success
80
80
 
81
81
  token = result.payment_method.token
82
82
 
@@ -91,7 +91,7 @@ describe Braintree::PayPalAccount do
91
91
  ).subscription
92
92
 
93
93
  paypal_account = Braintree::PayPalAccount.find(token)
94
- paypal_account.subscriptions.map(&:id).sort.should == [subscription1.id, subscription2.id].sort
94
+ expect(paypal_account.subscriptions.map(&:id).sort).to eq([subscription1.id, subscription2.id].sort)
95
95
  end
96
96
  end
97
97
 
@@ -108,9 +108,9 @@ describe Braintree::PayPalAccount do
108
108
  },
109
109
  )
110
110
 
111
- result.should be_success
112
- result.paypal_account.billing_agreement_id.should == "some_billing_agreement_id"
113
- result.paypal_account.email.should == "some@example.com"
111
+ expect(result).to be_success
112
+ expect(result.paypal_account.billing_agreement_id).to eq("some_billing_agreement_id")
113
+ expect(result.paypal_account.email).to eq("some@example.com")
114
114
  end
115
115
 
116
116
  it "throws an error if customer id is not specified" do
@@ -119,8 +119,8 @@ describe Braintree::PayPalAccount do
119
119
  :email => "some@example.com",
120
120
  )
121
121
 
122
- result.success?.should == false
123
- result.errors.first.code.should == "82905"
122
+ expect(result.success?).to eq(false)
123
+ expect(result.errors.first.code).to eq("82905")
124
124
  end
125
125
 
126
126
  it "throws an error if billing agreement id is not specified" do
@@ -130,8 +130,8 @@ describe Braintree::PayPalAccount do
130
130
  :email => "some@example.com",
131
131
  )
132
132
 
133
- result.success?.should == false
134
- result.errors.map(&:code).should include("82902")
133
+ expect(result.success?).to eq(false)
134
+ expect(result.errors.map(&:code)).to include("82902")
135
135
  end
136
136
  end
137
137
 
@@ -143,7 +143,7 @@ describe Braintree::PayPalAccount do
143
143
  :billing_agreement_id => "first_billing_agreement_id",
144
144
  :email => "first@example.com",
145
145
  )
146
- create_result.success?.should == true
146
+ expect(create_result.success?).to eq(true)
147
147
 
148
148
  update_result = Braintree::PayPalAccount.update(
149
149
  create_result.paypal_account.token,
@@ -151,11 +151,11 @@ describe Braintree::PayPalAccount do
151
151
  :email => "second@example.com",
152
152
  )
153
153
 
154
- update_result.success?.should == true
154
+ expect(update_result.success?).to eq(true)
155
155
  paypal_account = update_result.paypal_account
156
156
 
157
- paypal_account.billing_agreement_id.should == "second_billing_agreement_id"
158
- paypal_account.email.should == "second@example.com"
157
+ expect(paypal_account.billing_agreement_id).to eq("second_billing_agreement_id")
158
+ expect(paypal_account.email).to eq("second@example.com")
159
159
  end
160
160
 
161
161
  it "updates a paypal account's token" do
@@ -177,7 +177,7 @@ describe Braintree::PayPalAccount do
177
177
  )
178
178
 
179
179
  updated_paypal_account = Braintree::PayPalAccount.find(updated_token)
180
- updated_paypal_account.email.should == original_result.payment_method.email
180
+ expect(updated_paypal_account.email).to eq(original_result.payment_method.email)
181
181
 
182
182
  expect do
183
183
  Braintree::PayPalAccount.find(original_token)
@@ -192,7 +192,7 @@ describe Braintree::PayPalAccount do
192
192
  :expiration_date => "05/2009",
193
193
  :options => {:make_default => true},
194
194
  )
195
- result.should be_success
195
+ expect(result).to be_success
196
196
 
197
197
  nonce = nonce_for_paypal_account(:consent_code => "consent-code")
198
198
  original_token = Braintree::PaymentMethod.create(
@@ -206,7 +206,7 @@ describe Braintree::PayPalAccount do
206
206
  )
207
207
 
208
208
  updated_paypal_account = Braintree::PayPalAccount.find(original_token)
209
- updated_paypal_account.should be_default
209
+ expect(updated_paypal_account).to be_default
210
210
  end
211
211
 
212
212
  it "returns an error if a token for account is used to attempt an update" do
@@ -237,8 +237,8 @@ describe Braintree::PayPalAccount do
237
237
  :token => second_token,
238
238
  )
239
239
 
240
- updated_result.should_not be_success
241
- updated_result.errors.first.code.should == "92906"
240
+ expect(updated_result).not_to be_success
241
+ expect(updated_result.errors.first.code).to eq("92906")
242
242
  end
243
243
  end
244
244
 
@@ -272,11 +272,11 @@ describe Braintree::PayPalAccount do
272
272
 
273
273
  result = Braintree::PayPalAccount.sale(customer.paypal_accounts[0].token, :amount => "100.00")
274
274
 
275
- result.success?.should == true
276
- result.transaction.amount.should == BigDecimal("100.00")
277
- result.transaction.type.should == "sale"
278
- result.transaction.customer_details.id.should == customer.id
279
- result.transaction.paypal_details.token.should == customer.paypal_accounts[0].token
275
+ expect(result.success?).to eq(true)
276
+ expect(result.transaction.amount).to eq(BigDecimal("100.00"))
277
+ expect(result.transaction.type).to eq("sale")
278
+ expect(result.transaction.customer_details.id).to eq(customer.id)
279
+ expect(result.transaction.paypal_details.token).to eq(customer.paypal_accounts[0].token)
280
280
  end
281
281
  end
282
282
 
@@ -288,10 +288,10 @@ describe Braintree::PayPalAccount do
288
288
 
289
289
  transaction = Braintree::PayPalAccount.sale!(customer.paypal_accounts[0].token, :amount => "100.00")
290
290
 
291
- transaction.amount.should == BigDecimal("100.00")
292
- transaction.type.should == "sale"
293
- transaction.customer_details.id.should == customer.id
294
- transaction.paypal_details.token.should == customer.paypal_accounts[0].token
291
+ expect(transaction.amount).to eq(BigDecimal("100.00"))
292
+ expect(transaction.type).to eq("sale")
293
+ expect(transaction.customer_details.id).to eq(customer.id)
294
+ expect(transaction.paypal_details.token).to eq(customer.paypal_accounts[0].token)
295
295
  end
296
296
  end
297
297
  end
@@ -26,26 +26,26 @@ describe Braintree::Plan do
26
26
 
27
27
  plans = Braintree::Plan.all
28
28
  plan = plans.select { |plan| plan.id == plan_token }.first
29
- plan.should_not be_nil
30
- plan.id.should == attributes[:id]
31
- plan.billing_day_of_month.should == attributes[:billing_day_of_month]
32
- plan.billing_frequency.should == attributes[:billing_frequency]
33
- plan.currency_iso_code.should == attributes[:currency_iso_code]
34
- plan.description.should == attributes[:description]
35
- plan.name.should == attributes[:name]
36
- plan.number_of_billing_cycles.should == attributes[:number_of_billing_cycles]
37
- plan.price.should == Braintree::Util.to_big_decimal("1.00")
38
- plan.trial_period.should == attributes[:trial_period]
39
- plan.created_at.should_not be_nil
40
- plan.updated_at.should_not be_nil
41
- plan.add_ons.first.name.should == add_on_name
42
- plan.discounts.first.name.should == discount_name
29
+ expect(plan).not_to be_nil
30
+ expect(plan.id).to eq(attributes[:id])
31
+ expect(plan.billing_day_of_month).to eq(attributes[:billing_day_of_month])
32
+ expect(plan.billing_frequency).to eq(attributes[:billing_frequency])
33
+ expect(plan.currency_iso_code).to eq(attributes[:currency_iso_code])
34
+ expect(plan.description).to eq(attributes[:description])
35
+ expect(plan.name).to eq(attributes[:name])
36
+ expect(plan.number_of_billing_cycles).to eq(attributes[:number_of_billing_cycles])
37
+ expect(plan.price).to eq(Braintree::Util.to_big_decimal("1.00"))
38
+ expect(plan.trial_period).to eq(attributes[:trial_period])
39
+ expect(plan.created_at).not_to be_nil
40
+ expect(plan.updated_at).not_to be_nil
41
+ expect(plan.add_ons.first.name).to eq(add_on_name)
42
+ expect(plan.discounts.first.name).to eq(discount_name)
43
43
  end
44
44
 
45
45
  it "returns an empty array if there are no plans" do
46
46
  gateway = Braintree::Gateway.new(SpecHelper::TestMerchantConfig)
47
47
  plans = gateway.plan.all
48
- plans.should == []
48
+ expect(plans).to eq([])
49
49
  end
50
50
  end
51
51