braintree 2.74.0 → 4.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (286) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE +1 -1
  3. data/braintree.gemspec +13 -7
  4. data/lib/braintree/account_updater_daily_report.rb +2 -2
  5. data/lib/braintree/ach_mandate.rb +2 -1
  6. data/lib/braintree/address/country_names.rb +4 -1
  7. data/lib/braintree/address.rb +30 -38
  8. data/lib/braintree/address_gateway.rb +12 -2
  9. data/lib/braintree/advanced_search.rb +8 -0
  10. data/lib/braintree/apple_pay.rb +29 -0
  11. data/lib/braintree/apple_pay_card.rb +28 -4
  12. data/lib/braintree/apple_pay_gateway.rb +37 -0
  13. data/lib/braintree/apple_pay_options.rb +19 -0
  14. data/lib/braintree/authorization_adjustment.rb +23 -0
  15. data/lib/braintree/base_module.rb +10 -0
  16. data/lib/braintree/bin_data.rb +33 -0
  17. data/lib/braintree/client_token.rb +3 -3
  18. data/lib/braintree/client_token_gateway.rb +3 -1
  19. data/lib/braintree/configuration.rb +57 -10
  20. data/lib/braintree/connected_merchant_paypal_status_changed.rb +6 -2
  21. data/lib/braintree/connected_merchant_status_transitioned.rb +6 -2
  22. data/lib/braintree/credentials_parser.rb +5 -1
  23. data/lib/braintree/credit_card.rb +53 -107
  24. data/lib/braintree/credit_card_gateway.rb +43 -30
  25. data/lib/braintree/credit_card_verification.rb +61 -21
  26. data/lib/braintree/credit_card_verification_gateway.rb +19 -6
  27. data/lib/braintree/credit_card_verification_search.rb +1 -1
  28. data/lib/braintree/customer.rb +51 -98
  29. data/lib/braintree/customer_gateway.rb +30 -23
  30. data/lib/braintree/customer_search.rb +1 -1
  31. data/lib/braintree/descriptor.rb +3 -1
  32. data/lib/braintree/disbursement.rb +24 -2
  33. data/lib/braintree/dispute/evidence.rb +24 -0
  34. data/lib/braintree/{transaction/coinbase_details.rb → dispute/paypal_message.rb} +5 -3
  35. data/lib/braintree/dispute/status_history.rb +18 -0
  36. data/lib/braintree/dispute/transaction.rb +20 -0
  37. data/lib/braintree/dispute/transaction_details.rb +2 -1
  38. data/lib/braintree/dispute.rb +114 -10
  39. data/lib/braintree/dispute_gateway.rb +142 -0
  40. data/lib/braintree/dispute_search.rb +31 -0
  41. data/lib/braintree/document_upload.rb +37 -0
  42. data/lib/braintree/document_upload_gateway.rb +38 -0
  43. data/lib/braintree/enriched_customer_data.rb +21 -0
  44. data/lib/braintree/error_codes.rb +328 -109
  45. data/lib/braintree/error_result.rb +8 -1
  46. data/lib/braintree/exceptions.rb +5 -3
  47. data/lib/braintree/exchange_rate.rb +13 -0
  48. data/lib/braintree/exchange_rate_quote.rb +24 -0
  49. data/lib/braintree/exchange_rate_quote_gateway.rb +35 -0
  50. data/lib/braintree/exchange_rate_quote_input.rb +21 -0
  51. data/lib/braintree/exchange_rate_quote_request.rb +18 -0
  52. data/lib/braintree/exchange_rate_quote_response.rb +18 -0
  53. data/lib/braintree/facilitated_details.rb +21 -0
  54. data/lib/braintree/facilitator_details.rb +2 -1
  55. data/lib/braintree/gateway.rb +29 -11
  56. data/lib/braintree/google_pay_card.rb +61 -0
  57. data/lib/braintree/granted_payment_instrument_update.rb +23 -0
  58. data/lib/braintree/graphql_client.rb +34 -0
  59. data/lib/braintree/http.rb +81 -20
  60. data/lib/braintree/local_payment_completed.rb +23 -0
  61. data/lib/braintree/local_payment_expired.rb +21 -0
  62. data/lib/braintree/local_payment_funded.rb +22 -0
  63. data/lib/braintree/local_payment_reversed.rb +19 -0
  64. data/lib/braintree/merchant.rb +11 -4
  65. data/lib/braintree/merchant_account/address_details.rb +4 -1
  66. data/lib/braintree/merchant_account/business_details.rb +4 -1
  67. data/lib/braintree/merchant_account/funding_details.rb +6 -1
  68. data/lib/braintree/merchant_account/individual_details.rb +7 -2
  69. data/lib/braintree/merchant_account.rb +23 -10
  70. data/lib/braintree/merchant_account_gateway.rb +13 -1
  71. data/lib/braintree/merchant_gateway.rb +2 -2
  72. data/lib/braintree/modification.rb +1 -1
  73. data/lib/braintree/oauth_credentials.rb +5 -2
  74. data/lib/braintree/oauth_gateway.rb +8 -14
  75. data/lib/braintree/paginated_result.rb +3 -1
  76. data/lib/braintree/payment_instrument_type.rb +11 -11
  77. data/lib/braintree/payment_method.rb +20 -12
  78. data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
  79. data/lib/braintree/payment_method_gateway.rb +82 -54
  80. data/lib/braintree/payment_method_nonce.rb +22 -8
  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 +19 -2
  84. data/lib/braintree/payment_method_parser.rb +28 -0
  85. data/lib/braintree/paypal_account.rb +10 -1
  86. data/lib/braintree/plan.rb +25 -5
  87. data/lib/braintree/plan_gateway.rb +100 -0
  88. data/lib/braintree/processor_response_types.rb +7 -0
  89. data/lib/braintree/resource_collection.rb +8 -3
  90. data/lib/braintree/revoked_payment_method_metadata.rb +22 -0
  91. data/lib/braintree/risk_data/liability_shift.rb +22 -0
  92. data/lib/braintree/risk_data.rb +12 -2
  93. data/lib/braintree/samsung_pay_card.rb +83 -0
  94. data/lib/braintree/sepa_direct_debit_account.rb +60 -0
  95. data/lib/braintree/sepa_direct_debit_account_gateway.rb +25 -0
  96. data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +28 -0
  97. data/lib/braintree/settlement_batch_summary.rb +2 -1
  98. data/lib/braintree/settlement_batch_summary_gateway.rb +2 -0
  99. data/lib/braintree/subscription/status_details.rb +8 -1
  100. data/lib/braintree/subscription.rb +56 -41
  101. data/lib/braintree/subscription_gateway.rb +25 -2
  102. data/lib/braintree/successful_result.rb +23 -1
  103. data/lib/braintree/test/authentication_id.rb +21 -0
  104. data/lib/braintree/test/credit_card.rb +13 -0
  105. data/lib/braintree/test/nonce.rb +28 -20
  106. data/lib/braintree/test/transaction_amounts.rb +1 -0
  107. data/lib/braintree/three_d_secure_info.rb +34 -2
  108. data/lib/braintree/transaction/address_details.rb +24 -4
  109. data/lib/braintree/transaction/apple_pay_details.rb +20 -2
  110. data/lib/braintree/transaction/credit_card_details.rb +45 -6
  111. data/lib/braintree/transaction/customer_details.rb +8 -1
  112. data/lib/braintree/transaction/disbursement_details.rb +6 -1
  113. data/lib/braintree/transaction/google_pay_details.rb +41 -0
  114. data/lib/braintree/transaction/installment/adjustment.rb +33 -0
  115. data/lib/braintree/transaction/installment.rb +28 -0
  116. data/lib/braintree/transaction/local_payment_details.rb +24 -0
  117. data/lib/braintree/transaction/paypal_details.rb +26 -4
  118. data/lib/braintree/transaction/paypal_here_details.rb +23 -0
  119. data/lib/braintree/transaction/{masterpass_card_details.rb → samsung_pay_card_details.rb} +21 -6
  120. data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +27 -0
  121. data/lib/braintree/transaction/status_details.rb +5 -1
  122. data/lib/braintree/transaction/subscription_details.rb +4 -1
  123. data/lib/braintree/transaction/us_bank_account_details.rb +8 -1
  124. data/lib/braintree/transaction/venmo_account_details.rb +5 -1
  125. data/lib/braintree/transaction/visa_checkout_card_details.rb +19 -4
  126. data/lib/braintree/transaction.rb +201 -188
  127. data/lib/braintree/transaction_gateway.rb +124 -30
  128. data/lib/braintree/transaction_line_item.rb +40 -0
  129. data/lib/braintree/transaction_line_item_gateway.rb +19 -0
  130. data/lib/braintree/transaction_review.rb +18 -0
  131. data/lib/braintree/transaction_search.rb +6 -3
  132. data/lib/braintree/unknown_payment_method.rb +3 -2
  133. data/lib/braintree/us_bank_account.rb +24 -8
  134. data/lib/braintree/us_bank_account_gateway.rb +0 -1
  135. data/lib/braintree/us_bank_account_verification.rb +81 -0
  136. data/lib/braintree/us_bank_account_verification_gateway.rb +51 -0
  137. data/lib/braintree/us_bank_account_verification_search.rb +19 -0
  138. data/lib/braintree/util.rb +79 -9
  139. data/lib/braintree/validation_error.rb +13 -3
  140. data/lib/braintree/validation_error_collection.rb +2 -1
  141. data/lib/braintree/venmo_account.rb +11 -4
  142. data/lib/braintree/venmo_profile_data.rb +23 -0
  143. data/lib/braintree/version.rb +2 -2
  144. data/lib/braintree/visa_checkout_card.rb +29 -13
  145. data/lib/braintree/webhook_notification.rb +66 -26
  146. data/lib/braintree/webhook_notification_gateway.rb +5 -3
  147. data/lib/braintree/webhook_testing.rb +2 -2
  148. data/lib/braintree/webhook_testing_gateway.rb +721 -55
  149. data/lib/braintree/xml/generator.rb +6 -4
  150. data/lib/braintree/xml/parser.rb +22 -35
  151. data/lib/braintree/xml/rexml.rb +4 -5
  152. data/lib/braintree.rb +60 -22
  153. data/lib/ssl/api_braintreegateway_com.ca.crt +50 -0
  154. data/spec/fixtures/files/bt_logo.png +0 -0
  155. data/spec/fixtures/files/gif_extension_bt_logo.gif +0 -0
  156. data/spec/fixtures/files/malformed_pdf.pdf +1 -0
  157. data/spec/fixtures/files/too_long.pdf +0 -0
  158. data/spec/integration/braintree/add_on_spec.rb +3 -3
  159. data/spec/integration/braintree/address_spec.rb +30 -113
  160. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  161. data/spec/integration/braintree/apple_pay_spec.rb +63 -0
  162. data/spec/integration/braintree/braintree_gateway_spec.rb +72 -0
  163. data/spec/integration/braintree/client_api/client_token_spec.rb +14 -32
  164. data/spec/integration/braintree/client_api/spec_helper.rb +104 -65
  165. data/spec/integration/braintree/credit_card_spec.rb +460 -615
  166. data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
  167. data/spec/integration/braintree/credit_card_verification_spec.rb +222 -6
  168. data/spec/integration/braintree/customer_search_spec.rb +8 -8
  169. data/spec/integration/braintree/customer_spec.rb +810 -498
  170. data/spec/integration/braintree/discount_spec.rb +1 -1
  171. data/spec/integration/braintree/dispute_search_spec.rb +167 -0
  172. data/spec/integration/braintree/dispute_spec.rb +333 -0
  173. data/spec/integration/braintree/document_upload_spec.rb +87 -0
  174. data/spec/integration/braintree/error_codes_spec.rb +1 -1
  175. data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
  176. data/spec/integration/braintree/graphql_client_spec.rb +72 -0
  177. data/spec/integration/braintree/http_spec.rb +12 -4
  178. data/spec/integration/braintree/merchant_account_spec.rb +74 -26
  179. data/spec/integration/braintree/merchant_spec.rb +39 -13
  180. data/spec/integration/braintree/oauth_spec.rb +18 -25
  181. data/spec/integration/braintree/payment_method_nonce_spec.rb +239 -5
  182. data/spec/integration/braintree/payment_method_spec.rb +882 -300
  183. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +416 -0
  184. data/spec/integration/braintree/paypal_account_spec.rb +32 -31
  185. data/spec/integration/braintree/plan_spec.rb +82 -0
  186. data/spec/integration/braintree/samsung_pay_card_spec.rb +144 -0
  187. data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +196 -0
  188. data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
  189. data/spec/integration/braintree/subscription_spec.rb +274 -180
  190. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  191. data/spec/integration/braintree/test_transaction_spec.rb +18 -18
  192. data/spec/integration/braintree/transaction_line_item_spec.rb +38 -0
  193. data/spec/integration/braintree/transaction_search_spec.rb +280 -152
  194. data/spec/integration/braintree/transaction_spec.rb +3709 -1175
  195. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +438 -0
  196. data/spec/integration/braintree/us_bank_account_spec.rb +38 -17
  197. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +178 -0
  198. data/spec/integration/braintree/us_bank_account_verification_spec.rb +240 -0
  199. data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
  200. data/spec/integration/spec_helper.rb +27 -6
  201. data/spec/oauth_test_helper.rb +1 -1
  202. data/spec/script/httpsd.rb +6 -6
  203. data/spec/spec_helper.rb +26 -23
  204. data/spec/unit/braintree/address_spec.rb +1 -9
  205. data/spec/unit/braintree/apple_pay_card_spec.rb +104 -4
  206. data/spec/unit/braintree/client_token_spec.rb +2 -2
  207. data/spec/unit/braintree/configuration_spec.rb +108 -33
  208. data/spec/unit/braintree/credit_card_spec.rb +62 -33
  209. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +51 -0
  210. data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
  211. data/spec/unit/braintree/credit_card_verification_spec.rb +39 -6
  212. data/spec/unit/braintree/customer_spec.rb +107 -27
  213. data/spec/unit/braintree/disbursement_spec.rb +59 -7
  214. data/spec/unit/braintree/dispute_search_spec.rb +66 -0
  215. data/spec/unit/braintree/dispute_spec.rb +472 -8
  216. data/spec/unit/braintree/document_upload_spec.rb +35 -0
  217. data/spec/unit/braintree/enriched_customer_data_spec.rb +32 -0
  218. data/spec/unit/braintree/error_result_spec.rb +5 -5
  219. data/spec/unit/braintree/errors_spec.rb +8 -8
  220. data/spec/unit/braintree/exchange_rate_quote_input_spec.rb +42 -0
  221. data/spec/unit/braintree/exchange_rate_quote_request_spec.rb +82 -0
  222. data/spec/unit/braintree/exchange_rate_quote_response_spec.rb +52 -0
  223. data/spec/unit/braintree/exchange_rate_quote_spec.rb +42 -0
  224. data/spec/unit/braintree/exchange_rate_spec.rb +23 -0
  225. data/spec/unit/braintree/http_spec.rb +93 -5
  226. data/spec/unit/braintree/local_payment_completed_spec.rb +50 -0
  227. data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
  228. data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
  229. data/spec/unit/braintree/merchant_account_spec.rb +1 -1
  230. data/spec/unit/braintree/modification_spec.rb +1 -1
  231. data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +45 -0
  232. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
  233. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +51 -0
  234. data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
  235. data/spec/unit/braintree/payment_method_spec.rb +1 -1
  236. data/spec/unit/braintree/paypal_account_spec.rb +2 -2
  237. data/spec/unit/braintree/resource_collection_spec.rb +30 -1
  238. data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
  239. data/spec/unit/braintree/risk_data_spec.rb +40 -6
  240. data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +29 -0
  241. data/spec/unit/braintree/sepa_debit_account_spec.rb +86 -0
  242. data/spec/unit/braintree/subscription_search_spec.rb +1 -1
  243. data/spec/unit/braintree/subscription_spec.rb +2 -2
  244. data/spec/unit/braintree/successful_result_spec.rb +1 -1
  245. data/spec/unit/braintree/three_d_secure_info_spec.rb +34 -6
  246. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +19 -3
  247. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  248. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  249. data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
  250. data/spec/unit/braintree/transaction/paypal_details_spec.rb +63 -0
  251. data/spec/unit/braintree/transaction/sepa_direct_debit_account_details_spec.rb +33 -0
  252. data/spec/unit/braintree/transaction_gateway_spec.rb +111 -0
  253. data/spec/unit/braintree/transaction_search_spec.rb +12 -12
  254. data/spec/unit/braintree/transaction_spec.rb +171 -55
  255. data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +60 -0
  256. data/spec/unit/braintree/us_bank_account_verification_spec.rb +93 -0
  257. data/spec/unit/braintree/util_spec.rb +162 -19
  258. data/spec/unit/braintree/validation_error_collection_spec.rb +336 -133
  259. data/spec/unit/braintree/venmo_profile_data_spec.rb +32 -0
  260. data/spec/unit/braintree/webhook_notification_spec.rb +546 -114
  261. data/spec/unit/braintree/xml/parser_spec.rb +21 -16
  262. data/spec/unit/braintree/xml_spec.rb +31 -24
  263. data/spec/unit/braintree_spec.rb +1 -0
  264. metadata +290 -198
  265. data/README.rdoc +0 -93
  266. data/lib/braintree/amex_express_checkout_card.rb +0 -26
  267. data/lib/braintree/android_pay_card.rb +0 -35
  268. data/lib/braintree/coinbase_account.rb +0 -25
  269. data/lib/braintree/europe_bank_account.rb +0 -34
  270. data/lib/braintree/europe_bank_account_gateway.rb +0 -17
  271. data/lib/braintree/ideal_payment.rb +0 -46
  272. data/lib/braintree/ideal_payment_gateway.rb +0 -18
  273. data/lib/braintree/masterpass_card.rb +0 -66
  274. data/lib/braintree/settlement_batch.rb +0 -0
  275. data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -14
  276. data/lib/braintree/transaction/android_pay_details.rb +0 -17
  277. data/lib/braintree/transaction/ideal_payment_details.rb +0 -13
  278. data/lib/braintree/transparent_redirect.rb +0 -40
  279. data/lib/braintree/transparent_redirect_gateway.rb +0 -105
  280. data/spec/hacks/tcp_socket.rb +0 -18
  281. data/spec/httpsd.pid +0 -1
  282. data/spec/integration/braintree/coinbase_spec.rb +0 -31
  283. data/spec/integration/braintree/ideal_payment_spec.rb +0 -87
  284. data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
  285. data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
  286. data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
@@ -0,0 +1,416 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+ require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
3
+
4
+ describe Braintree::PaymentMethod do
5
+ describe "self.create" do
6
+ context "compliant merchant" do
7
+ before do
8
+ Braintree::Configuration.merchant_id = "integration2_merchant_id"
9
+ Braintree::Configuration.public_key = "integration2_public_key"
10
+ Braintree::Configuration.private_key = "integration2_private_key"
11
+ end
12
+
13
+ context "plaid verified nonce" do
14
+ let(:nonce) { generate_valid_plaid_us_bank_account_nonce }
15
+
16
+ # we are temporarily skipping this test until we have a more stable CI env
17
+ xit "succeeds" do
18
+ customer = Braintree::Customer.create.customer
19
+ result = Braintree::PaymentMethod.create(
20
+ :payment_method_nonce => nonce,
21
+ :customer_id => customer.id,
22
+ :options => {
23
+ :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
24
+ },
25
+ )
26
+
27
+ result.should be_success
28
+ us_bank_account = result.payment_method
29
+ us_bank_account.should be_a(Braintree::UsBankAccount)
30
+ us_bank_account.routing_number.should == "011000015"
31
+ us_bank_account.last_4.should == "0000"
32
+ us_bank_account.account_type.should == "checking"
33
+ us_bank_account.account_holder_name.should == "PayPal, Inc."
34
+ us_bank_account.bank_name.should == "FEDERAL RESERVE BANK"
35
+ us_bank_account.default.should == true
36
+ us_bank_account.ach_mandate.text.should == "cl mandate text"
37
+ us_bank_account.ach_mandate.accepted_at.should be_a Time
38
+
39
+ us_bank_account.verifications.count.should == 1
40
+ us_bank_account.verifications.first.status.should == Braintree::UsBankAccountVerification::Status::Verified
41
+ us_bank_account.verifications.first.verification_method.should == Braintree::UsBankAccountVerification::VerificationMethod::TokenizedCheck
42
+ us_bank_account.verifications.first.id.should_not be_empty
43
+ us_bank_account.verifications.first.verification_determined_at.should be_a Time
44
+ us_bank_account.verified.should == true
45
+
46
+ Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
47
+ end
48
+
49
+ [
50
+ Braintree::UsBankAccountVerification::VerificationMethod::IndependentCheck,
51
+ Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
52
+ ].each do |method|
53
+ # we are temporarily skipping this test until we have a more stable CI env
54
+ xit "succeeds and verifies via #{method}" do
55
+ customer = Braintree::Customer.create.customer
56
+ result = Braintree::PaymentMethod.create(
57
+ :payment_method_nonce => nonce,
58
+ :customer_id => customer.id,
59
+ :options => {
60
+ :us_bank_account_verification_method => method,
61
+ :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
62
+ },
63
+ )
64
+
65
+ result.should be_success
66
+ us_bank_account = result.payment_method
67
+ us_bank_account.should be_a(Braintree::UsBankAccount)
68
+ us_bank_account.routing_number.should == "011000015"
69
+ us_bank_account.last_4.should == "0000"
70
+ us_bank_account.account_type.should == "checking"
71
+ us_bank_account.account_holder_name.should == "PayPal, Inc."
72
+ us_bank_account.bank_name.should == "FEDERAL RESERVE BANK"
73
+ us_bank_account.default.should == true
74
+ us_bank_account.ach_mandate.text.should == "cl mandate text"
75
+ us_bank_account.ach_mandate.accepted_at.should be_a Time
76
+ us_bank_account.verified.should == true
77
+
78
+ us_bank_account.verifications.count.should == 2
79
+
80
+ us_bank_account.verifications.map(&:verification_method).should contain_exactly(
81
+ Braintree::UsBankAccountVerification::VerificationMethod::TokenizedCheck,
82
+ method,
83
+ )
84
+
85
+ us_bank_account.verifications.each do |verification|
86
+ verification.status.should == Braintree::UsBankAccountVerification::Status::Verified
87
+ verification.id.should_not be_empty
88
+ verification.verification_determined_at.should be_a Time
89
+ end
90
+
91
+ Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
92
+ end
93
+ end
94
+ end
95
+
96
+ context "non plaid verified nonce" do
97
+ let(:nonce) { generate_non_plaid_us_bank_account_nonce }
98
+
99
+ it "succeeds and does not verify when no method provided" do
100
+ customer = Braintree::Customer.create.customer
101
+ result = Braintree::PaymentMethod.create(
102
+ :payment_method_nonce => nonce,
103
+ :customer_id => customer.id,
104
+ :options => {
105
+ :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
106
+ },
107
+ )
108
+
109
+ result.should be_success
110
+ us_bank_account = result.payment_method
111
+ us_bank_account.should be_a(Braintree::UsBankAccount)
112
+ us_bank_account.routing_number.should == "021000021"
113
+ us_bank_account.last_4.should == "0000"
114
+ us_bank_account.account_type.should == "checking"
115
+ us_bank_account.account_holder_name.should == "John Doe"
116
+ us_bank_account.bank_name.should =~ /CHASE/
117
+ us_bank_account.default.should == true
118
+ us_bank_account.ach_mandate.text.should == "cl mandate text"
119
+ us_bank_account.ach_mandate.accepted_at.should be_a Time
120
+
121
+ us_bank_account.verifications.count.should == 0
122
+ us_bank_account.verified.should == false
123
+
124
+ Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
125
+ end
126
+
127
+ [
128
+ Braintree::UsBankAccountVerification::VerificationMethod::IndependentCheck,
129
+ Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
130
+ ].each do |method|
131
+ it "succeeds and verifies via #{method}" do
132
+ customer = Braintree::Customer.create.customer
133
+ result = Braintree::PaymentMethod.create(
134
+ :payment_method_nonce => nonce,
135
+ :customer_id => customer.id,
136
+ :options => {
137
+ :us_bank_account_verification_method => method,
138
+ :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
139
+ },
140
+ )
141
+
142
+ result.should be_success
143
+ us_bank_account = result.payment_method
144
+ us_bank_account.should be_a(Braintree::UsBankAccount)
145
+ us_bank_account.routing_number.should == "021000021"
146
+ us_bank_account.last_4.should == "0000"
147
+ us_bank_account.account_type.should == "checking"
148
+ us_bank_account.account_holder_name.should == "John Doe"
149
+ us_bank_account.bank_name.should =~ /CHASE/
150
+ us_bank_account.default.should == true
151
+ us_bank_account.ach_mandate.text.should == "cl mandate text"
152
+ us_bank_account.ach_mandate.accepted_at.should be_a Time
153
+
154
+ us_bank_account.verifications.count.should == 1
155
+ us_bank_account.verifications.first.status.should == Braintree::UsBankAccountVerification::Status::Verified
156
+ us_bank_account.verifications.first.verification_method.should == method
157
+ us_bank_account.verifications.first.id.should_not be_empty
158
+ us_bank_account.verifications.first.verification_determined_at.should be_a Time
159
+ us_bank_account.verified.should == true
160
+
161
+ Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
162
+ end
163
+ end
164
+ end
165
+
166
+ it "fails with invalid nonce" do
167
+ customer = Braintree::Customer.create.customer
168
+ result = Braintree::PaymentMethod.create(
169
+ :payment_method_nonce => generate_invalid_us_bank_account_nonce,
170
+ :customer_id => customer.id,
171
+ )
172
+
173
+ result.should_not be_success
174
+ result.errors.for(:payment_method).on(:payment_method_nonce)[0].code.should == Braintree::ErrorCodes::PaymentMethod::PaymentMethodNonceUnknown
175
+ end
176
+ end
177
+
178
+ context "exempt merchant" do
179
+ context "plaid verified nonce" do
180
+ before do
181
+ Braintree::Configuration.merchant_id = "integration_merchant_id"
182
+ Braintree::Configuration.public_key = "integration_public_key"
183
+ Braintree::Configuration.private_key = "integration_private_key"
184
+ end
185
+
186
+ let(:nonce) { generate_valid_plaid_us_bank_account_nonce }
187
+
188
+ # we are temporarily skipping this test until we have a more stable CI env
189
+ xit "succeeds and verifies via independent check" do
190
+ customer = Braintree::Customer.create.customer
191
+ result = Braintree::PaymentMethod.create(
192
+ :payment_method_nonce => nonce,
193
+ :customer_id => customer.id,
194
+ :options => {
195
+ :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
196
+ },
197
+ )
198
+
199
+ result.should be_success
200
+ us_bank_account = result.payment_method
201
+ us_bank_account.should be_a(Braintree::UsBankAccount)
202
+ us_bank_account.routing_number.should == "011000015"
203
+ us_bank_account.last_4.should == "0000"
204
+ us_bank_account.account_type.should == "checking"
205
+ us_bank_account.account_holder_name.should == "PayPal, Inc."
206
+ us_bank_account.bank_name.should == "FEDERAL RESERVE BANK"
207
+ us_bank_account.default.should == true
208
+ us_bank_account.ach_mandate.text.should == "cl mandate text"
209
+ us_bank_account.ach_mandate.accepted_at.should be_a Time
210
+
211
+ us_bank_account.verifications.count.should == 1
212
+ us_bank_account.verifications.first.status.should == Braintree::UsBankAccountVerification::Status::Verified
213
+ us_bank_account.verifications.first.verification_method.should == Braintree::UsBankAccountVerification::VerificationMethod::TokenizedCheck
214
+ us_bank_account.verifications.first.id.should_not be_empty
215
+ us_bank_account.verifications.first.verification_determined_at.should be_a Time
216
+ us_bank_account.verified.should == true
217
+
218
+ Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
219
+ end
220
+ end
221
+
222
+ context "non plaid verified nonce" do
223
+ let(:nonce) { generate_non_plaid_us_bank_account_nonce }
224
+
225
+ # we are temporarily skipping this test until we have a more stable CI env
226
+ xit "succeeds and verifies via independent check" do
227
+ customer = Braintree::Customer.create.customer
228
+ result = Braintree::PaymentMethod.create(
229
+ :payment_method_nonce => nonce,
230
+ :customer_id => customer.id,
231
+ :options => {
232
+ :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
233
+ },
234
+ )
235
+
236
+ result.should be_success
237
+ us_bank_account = result.payment_method
238
+ us_bank_account.should be_a(Braintree::UsBankAccount)
239
+ us_bank_account.routing_number.should == "021000021"
240
+ us_bank_account.last_4.should == "0000"
241
+ us_bank_account.account_type.should == "checking"
242
+ us_bank_account.account_holder_name.should == "John Doe"
243
+ us_bank_account.bank_name.should =~ /CHASE/
244
+ us_bank_account.default.should == true
245
+ us_bank_account.ach_mandate.text.should == "cl mandate text"
246
+ us_bank_account.ach_mandate.accepted_at.should be_a Time
247
+
248
+ us_bank_account.verifications.count.should == 1
249
+ us_bank_account.verifications.first.status.should == Braintree::UsBankAccountVerification::Status::Verified
250
+ us_bank_account.verifications.first.verification_method.should == Braintree::UsBankAccountVerification::VerificationMethod::IndependentCheck
251
+ us_bank_account.verifications.first.id.should_not be_empty
252
+ us_bank_account.verifications.first.verification_determined_at.should be_a Time
253
+ us_bank_account.verified.should == true
254
+
255
+ Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
256
+ end
257
+ end
258
+
259
+ it "fails with invalid nonce" do
260
+ customer = Braintree::Customer.create.customer
261
+ result = Braintree::PaymentMethod.create(
262
+ :payment_method_nonce => generate_invalid_us_bank_account_nonce,
263
+ :customer_id => customer.id,
264
+ )
265
+
266
+ result.should_not be_success
267
+ result.errors.for(:payment_method).on(:payment_method_nonce)[0].code.should == Braintree::ErrorCodes::PaymentMethod::PaymentMethodNonceUnknown
268
+ end
269
+ end
270
+ end
271
+
272
+ context "self.update" do
273
+ context "compliant merchant" do
274
+ before do
275
+ Braintree::Configuration.merchant_id = "integration2_merchant_id"
276
+ Braintree::Configuration.public_key = "integration2_public_key"
277
+ Braintree::Configuration.private_key = "integration2_private_key"
278
+ end
279
+
280
+ context "unverified token" do
281
+ let(:payment_method) do
282
+ customer = Braintree::Customer.create.customer
283
+ result = Braintree::PaymentMethod.create(
284
+ :payment_method_nonce => generate_non_plaid_us_bank_account_nonce,
285
+ :customer_id => customer.id,
286
+ :options => {
287
+ :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
288
+ },
289
+ ).payment_method
290
+ end
291
+
292
+ [
293
+ Braintree::UsBankAccountVerification::VerificationMethod::IndependentCheck,
294
+ Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
295
+ ].each do |method|
296
+ it "succeeds and verifies via #{method}" do
297
+ result = Braintree::PaymentMethod.update(
298
+ payment_method.token,
299
+ :options => {
300
+ :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
301
+ :us_bank_account_verification_method => method,
302
+ },
303
+ )
304
+
305
+ result.should be_success
306
+
307
+ us_bank_account = result.payment_method
308
+ us_bank_account.should be_a(Braintree::UsBankAccount)
309
+ us_bank_account.routing_number.should == "021000021"
310
+ us_bank_account.last_4.should == "0000"
311
+ us_bank_account.account_type.should == "checking"
312
+ us_bank_account.account_holder_name.should == "John Doe"
313
+ us_bank_account.bank_name.should =~ /CHASE/
314
+ us_bank_account.default.should == true
315
+ us_bank_account.ach_mandate.text.should == "cl mandate text"
316
+ us_bank_account.ach_mandate.accepted_at.should be_a Time
317
+
318
+ us_bank_account.verifications.count.should == 1
319
+ us_bank_account.verifications.first.status.should == Braintree::UsBankAccountVerification::Status::Verified
320
+ us_bank_account.verifications.first.verification_method.should == method
321
+ us_bank_account.verifications.first.id.should_not be_empty
322
+ us_bank_account.verifications.first.verification_determined_at.should be_a Time
323
+ us_bank_account.verified.should == true
324
+
325
+ Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
326
+ end
327
+ end
328
+
329
+ it "fails with invalid verification method" do
330
+ result = Braintree::PaymentMethod.update(
331
+ payment_method.token,
332
+ :options => {
333
+ :verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
334
+ :us_bank_account_verification_method => "blahblah",
335
+ },
336
+ )
337
+
338
+ result.should_not be_success
339
+ result.errors.for(:options).first.code.should == Braintree::ErrorCodes::PaymentMethod::Options::UsBankAccountVerificationMethodIsInvalid
340
+ end
341
+ end
342
+ end
343
+
344
+ context "exempt merchant" do
345
+ before do
346
+ Braintree::Configuration.merchant_id = "integration_merchant_id"
347
+ Braintree::Configuration.public_key = "integration_public_key"
348
+ Braintree::Configuration.private_key = "integration_private_key"
349
+ end
350
+
351
+ context "unverified token" do
352
+ let(:payment_method) do
353
+ customer = Braintree::Customer.create.customer
354
+ result = Braintree::PaymentMethod.create(
355
+ :payment_method_nonce => generate_non_plaid_us_bank_account_nonce,
356
+ :customer_id => customer.id,
357
+ :options => {
358
+ :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
359
+ },
360
+ ).payment_method
361
+ end
362
+
363
+ [
364
+ Braintree::UsBankAccountVerification::VerificationMethod::IndependentCheck,
365
+ Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
366
+ ].each do |method|
367
+ it "succeeds and verifies via #{method}" do
368
+ result = Braintree::PaymentMethod.update(
369
+ payment_method.token,
370
+ :options => {
371
+ :verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
372
+ :us_bank_account_verification_method => method,
373
+ },
374
+ )
375
+
376
+ result.should be_success
377
+
378
+ us_bank_account = result.payment_method
379
+ us_bank_account.should be_a(Braintree::UsBankAccount)
380
+ us_bank_account.routing_number.should == "021000021"
381
+ us_bank_account.last_4.should == "0000"
382
+ us_bank_account.account_type.should == "checking"
383
+ us_bank_account.account_holder_name.should == "John Doe"
384
+ us_bank_account.bank_name.should =~ /CHASE/
385
+ us_bank_account.default.should == true
386
+ us_bank_account.ach_mandate.text.should == "cl mandate text"
387
+ us_bank_account.ach_mandate.accepted_at.should be_a Time
388
+
389
+ us_bank_account.verifications.count.should == 2
390
+ verification = us_bank_account.verifications.find do |verification|
391
+ verification.verification_method == method
392
+ end
393
+ verification.status.should == Braintree::UsBankAccountVerification::Status::Verified
394
+ verification.id.should_not be_empty
395
+ verification.verification_determined_at.should be_a Time
396
+ us_bank_account.verified.should == true
397
+
398
+ Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
399
+ end
400
+ end
401
+
402
+ it "fails with invalid verification method" do
403
+ result = Braintree::PaymentMethod.update(
404
+ payment_method.token,
405
+ :options => {
406
+ :us_bank_account_verification_method => "blahblah",
407
+ },
408
+ )
409
+
410
+ result.should_not be_success
411
+ result.errors.for(:options).first.code.should == Braintree::ErrorCodes::PaymentMethod::Options::UsBankAccountVerificationMethodIsInvalid
412
+ end
413
+ end
414
+ end
415
+ end
416
+ end
@@ -9,11 +9,11 @@ describe Braintree::PayPalAccount do
9
9
 
10
10
  nonce = nonce_for_paypal_account(
11
11
  :consent_code => "consent-code",
12
- :token => payment_method_token
12
+ :token => payment_method_token,
13
13
  )
14
14
  result = Braintree::PaymentMethod.create(
15
15
  :payment_method_nonce => nonce,
16
- :customer_id => customer.id
16
+ :customer_id => customer.id,
17
17
  )
18
18
  result.should be_success
19
19
 
@@ -25,6 +25,7 @@ describe Braintree::PayPalAccount do
25
25
  paypal_account.created_at.should_not be_nil
26
26
  paypal_account.updated_at.should_not be_nil
27
27
  paypal_account.customer_id.should == customer.id
28
+ paypal_account.revoked_at.should be_nil
28
29
  end
29
30
 
30
31
  it "returns a PayPalAccount with a billing agreement id" do
@@ -34,7 +35,7 @@ describe Braintree::PayPalAccount do
34
35
  result = Braintree::PaymentMethod.create(
35
36
  :payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
36
37
  :customer_id => customer.id,
37
- :token => payment_method_token
38
+ :token => payment_method_token,
38
39
  )
39
40
  result.should be_success
40
41
 
@@ -55,7 +56,7 @@ describe Braintree::PayPalAccount do
55
56
  :number => Braintree::Test::CreditCardNumbers::Visa,
56
57
  :expiration_date => "05/2009",
57
58
  :cvv => "100",
58
- :token => "CREDIT_CARD_TOKEN"
59
+ :token => "CREDIT_CARD_TOKEN",
59
60
  )
60
61
 
61
62
  expect do
@@ -69,11 +70,11 @@ describe Braintree::PayPalAccount do
69
70
 
70
71
  nonce = nonce_for_paypal_account(
71
72
  :consent_code => "consent-code",
72
- :token => payment_method_token
73
+ :token => payment_method_token,
73
74
  )
74
75
  result = Braintree::PaymentMethod.create(
75
76
  :payment_method_nonce => nonce,
76
- :customer_id => customer.id
77
+ :customer_id => customer.id,
77
78
  )
78
79
  result.should be_success
79
80
 
@@ -81,12 +82,12 @@ describe Braintree::PayPalAccount do
81
82
 
82
83
  subscription1 = Braintree::Subscription.create(
83
84
  :payment_method_token => token,
84
- :plan_id => SpecHelper::TriallessPlan[:id]
85
+ :plan_id => SpecHelper::TriallessPlan[:id],
85
86
  ).subscription
86
87
 
87
88
  subscription2 = Braintree::Subscription.create(
88
89
  :payment_method_token => token,
89
- :plan_id => SpecHelper::TriallessPlan[:id]
90
+ :plan_id => SpecHelper::TriallessPlan[:id],
90
91
  ).subscription
91
92
 
92
93
  paypal_account = Braintree::PayPalAccount.find(token)
@@ -104,7 +105,7 @@ describe Braintree::PayPalAccount do
104
105
  :options => {
105
106
  :make_default => true,
106
107
  :fail_on_duplicate_payment_method => true,
107
- }
108
+ },
108
109
  )
109
110
 
110
111
  result.should be_success
@@ -115,7 +116,7 @@ describe Braintree::PayPalAccount do
115
116
  it "throws an error if customer id is not specified" do
116
117
  result = Braintree::PayPalAccount.create(
117
118
  :billing_agreement_id => "some_billing_agreement_id",
118
- :email => "some@example.com"
119
+ :email => "some@example.com",
119
120
  )
120
121
 
121
122
  result.success?.should == false
@@ -126,11 +127,11 @@ describe Braintree::PayPalAccount do
126
127
  customer = Braintree::Customer.create!
127
128
  result = Braintree::PayPalAccount.create(
128
129
  :customer_id => customer.id,
129
- :email => "some@example.com"
130
+ :email => "some@example.com",
130
131
  )
131
132
 
132
133
  result.success?.should == false
133
- result.errors.first.code.should == "82902"
134
+ result.errors.map(&:code).should include("82902")
134
135
  end
135
136
  end
136
137
 
@@ -140,14 +141,14 @@ describe Braintree::PayPalAccount do
140
141
  create_result = Braintree::PayPalAccount.create(
141
142
  :customer_id => customer.id,
142
143
  :billing_agreement_id => "first_billing_agreement_id",
143
- :email => "first@example.com"
144
+ :email => "first@example.com",
144
145
  )
145
146
  create_result.success?.should == true
146
147
 
147
148
  update_result = Braintree::PayPalAccount.update(
148
149
  create_result.paypal_account.token,
149
150
  :billing_agreement_id => "second_billing_agreement_id",
150
- :email => "second@example.com"
151
+ :email => "second@example.com",
151
152
  )
152
153
 
153
154
  update_result.success?.should == true
@@ -162,17 +163,17 @@ describe Braintree::PayPalAccount do
162
163
  original_token = random_payment_method_token
163
164
  nonce = nonce_for_paypal_account(
164
165
  :consent_code => "consent-code",
165
- :token => original_token
166
+ :token => original_token,
166
167
  )
167
168
  original_result = Braintree::PaymentMethod.create(
168
169
  :payment_method_nonce => nonce,
169
- :customer_id => customer.id
170
+ :customer_id => customer.id,
170
171
  )
171
172
 
172
173
  updated_token = "UPDATED_TOKEN-" + rand(36**3).to_s(36)
173
174
  updated_result = Braintree::PayPalAccount.update(
174
175
  original_token,
175
- :token => updated_token
176
+ :token => updated_token,
176
177
  )
177
178
 
178
179
  updated_paypal_account = Braintree::PayPalAccount.find(updated_token)
@@ -189,19 +190,19 @@ describe Braintree::PayPalAccount do
189
190
  :customer_id => customer.id,
190
191
  :number => Braintree::Test::CreditCardNumbers::Visa,
191
192
  :expiration_date => "05/2009",
192
- :options => {:make_default => true}
193
+ :options => {:make_default => true},
193
194
  )
194
195
  result.should be_success
195
196
 
196
197
  nonce = nonce_for_paypal_account(:consent_code => "consent-code")
197
198
  original_token = Braintree::PaymentMethod.create(
198
199
  :payment_method_nonce => nonce,
199
- :customer_id => customer.id
200
+ :customer_id => customer.id,
200
201
  ).payment_method.token
201
202
 
202
203
  updated_result = Braintree::PayPalAccount.update(
203
204
  original_token,
204
- :options => {:make_default => true}
205
+ :options => {:make_default => true},
205
206
  )
206
207
 
207
208
  updated_paypal_account = Braintree::PayPalAccount.find(original_token)
@@ -215,25 +216,25 @@ describe Braintree::PayPalAccount do
215
216
 
216
217
  first_nonce = nonce_for_paypal_account(
217
218
  :consent_code => "consent-code",
218
- :token => first_token
219
+ :token => first_token,
219
220
  )
220
221
  first_result = Braintree::PaymentMethod.create(
221
222
  :payment_method_nonce => first_nonce,
222
- :customer_id => customer.id
223
+ :customer_id => customer.id,
223
224
  )
224
225
 
225
226
  second_nonce = nonce_for_paypal_account(
226
227
  :consent_code => "consent-code",
227
- :token => second_token
228
+ :token => second_token,
228
229
  )
229
230
  second_result = Braintree::PaymentMethod.create(
230
231
  :payment_method_nonce => second_nonce,
231
- :customer_id => customer.id
232
+ :customer_id => customer.id,
232
233
  )
233
234
 
234
235
  updated_result = Braintree::PayPalAccount.update(
235
236
  first_token,
236
- :token => second_token
237
+ :token => second_token,
237
238
  )
238
239
 
239
240
  updated_result.should_not be_success
@@ -248,11 +249,11 @@ describe Braintree::PayPalAccount do
248
249
 
249
250
  nonce = nonce_for_paypal_account(
250
251
  :consent_code => "consent-code",
251
- :token => token
252
+ :token => token,
252
253
  )
253
254
  Braintree::PaymentMethod.create(
254
255
  :payment_method_nonce => nonce,
255
- :customer_id => customer.id
256
+ :customer_id => customer.id,
256
257
  )
257
258
 
258
259
  result = Braintree::PayPalAccount.delete(token)
@@ -266,13 +267,13 @@ describe Braintree::PayPalAccount do
266
267
  context "self.sale" do
267
268
  it "creates a transaction using a paypal account and returns a result object" do
268
269
  customer = Braintree::Customer.create!(
269
- :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment
270
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
270
271
  )
271
272
 
272
273
  result = Braintree::PayPalAccount.sale(customer.paypal_accounts[0].token, :amount => "100.00")
273
274
 
274
275
  result.success?.should == true
275
- result.transaction.amount.should == BigDecimal.new("100.00")
276
+ result.transaction.amount.should == BigDecimal("100.00")
276
277
  result.transaction.type.should == "sale"
277
278
  result.transaction.customer_details.id.should == customer.id
278
279
  result.transaction.paypal_details.token.should == customer.paypal_accounts[0].token
@@ -282,12 +283,12 @@ describe Braintree::PayPalAccount do
282
283
  context "self.sale!" do
283
284
  it "creates a transaction using a paypal account and returns a transaction" do
284
285
  customer = Braintree::Customer.create!(
285
- :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment
286
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
286
287
  )
287
288
 
288
289
  transaction = Braintree::PayPalAccount.sale!(customer.paypal_accounts[0].token, :amount => "100.00")
289
290
 
290
- transaction.amount.should == BigDecimal.new("100.00")
291
+ transaction.amount.should == BigDecimal("100.00")
291
292
  transaction.type.should == "sale"
292
293
  transaction.customer_details.id.should == customer.id
293
294
  transaction.paypal_details.token.should == customer.paypal_accounts[0].token