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
@@ -17,45 +17,38 @@ describe Braintree::Transaction do
17
17
  end
18
18
  end
19
19
 
20
- describe "self.create_from_transparent_redirect" do
21
- it "raises an exception if the query string is forged" do
22
- expect do
23
- Braintree::Transaction.create_from_transparent_redirect("http_status=200&forged=query_string")
24
- end.to raise_error(Braintree::ForgedQueryString)
25
- end
26
- end
27
-
28
20
  describe "self.find" do
29
21
  it "raises error if passed empty string" do
30
22
  expect do
31
23
  Braintree::Transaction.find("")
32
- end.to raise_error(ArgumentError)
24
+ end.to raise_error(ArgumentError, "id can not be empty")
33
25
  end
34
26
 
35
27
  it "raises error if passed empty string wth space" do
36
28
  expect do
37
29
  Braintree::Transaction.find(" ")
38
- end.to raise_error(ArgumentError)
30
+ end.to raise_error(ArgumentError, "id can not be empty")
39
31
  end
40
32
 
41
33
  it "raises error if passed nil" do
42
34
  expect do
43
35
  Braintree::Transaction.find(nil)
44
- end.to raise_error(ArgumentError)
36
+ end.to raise_error(ArgumentError, "id can not be empty")
45
37
  end
46
38
  end
47
39
 
48
- describe "self.create_transaction_url" do
49
- it "returns the url" do
50
- config = Braintree::Configuration.instantiate
51
- Braintree::Transaction.create_transaction_url.should == "http#{config.ssl? ? 's' : ''}://#{config.server}:#{config.port}/merchants/integration_merchant_id/transactions/all/create_via_transparent_redirect_request"
40
+ describe "self.submit_for_settlement" do
41
+ it "raises an ArgumentError if transaction_id is an invalid format" do
42
+ expect do
43
+ Braintree::Transaction.submit_for_settlement("invalid-transaction-id")
44
+ end.to raise_error(ArgumentError, "transaction_id is invalid")
52
45
  end
53
46
  end
54
47
 
55
- describe "self.submit_for_settlement" do
48
+ describe "self.adjust_authorization" do
56
49
  it "raises an ArgumentError if transaction_id is an invalid format" do
57
50
  expect do
58
- Braintree::Transaction.submit_for_settlement("invalid-transaction-id")
51
+ Braintree::Transaction.adjust_authorization("invalid-transaction-id", "10.00")
59
52
  end.to raise_error(ArgumentError, "transaction_id is invalid")
60
53
  end
61
54
  end
@@ -81,16 +74,16 @@ describe Braintree::Transaction do
81
74
  :website => "lednerllc.com",
82
75
  :phone => "1-999-652-4189 x56883",
83
76
  :fax => "012-161-8055"
84
- }
77
+ },
85
78
  )
86
- transaction.customer_details.id.should == "123"
87
- transaction.customer_details.first_name.should == "Adam"
88
- transaction.customer_details.last_name.should == "Taylor"
89
- transaction.customer_details.company.should == "Ledner LLC"
90
- transaction.customer_details.email.should == "adam.taylor@lednerllc.com"
91
- transaction.customer_details.website.should == "lednerllc.com"
92
- transaction.customer_details.phone.should == "1-999-652-4189 x56883"
93
- transaction.customer_details.fax.should == "012-161-8055"
79
+ expect(transaction.customer_details.id).to eq("123")
80
+ expect(transaction.customer_details.first_name).to eq("Adam")
81
+ expect(transaction.customer_details.last_name).to eq("Taylor")
82
+ expect(transaction.customer_details.company).to eq("Ledner LLC")
83
+ expect(transaction.customer_details.email).to eq("adam.taylor@lednerllc.com")
84
+ expect(transaction.customer_details.website).to eq("lednerllc.com")
85
+ expect(transaction.customer_details.phone).to eq("1-999-652-4189 x56883")
86
+ expect(transaction.customer_details.fax).to eq("012-161-8055")
94
87
  end
95
88
 
96
89
  it "sets up disbursement attributes in disbursement_details" do
@@ -103,15 +96,15 @@ describe Braintree::Transaction do
103
96
  :settlement_currency_exchange_rate => "1",
104
97
  :funds_held => false,
105
98
  :success => true
106
- }
99
+ },
107
100
  )
108
101
  disbursement = transaction.disbursement_details
109
- disbursement.disbursement_date.should == "2013-04-03"
110
- disbursement.settlement_amount.should == "120.00"
111
- disbursement.settlement_currency_iso_code.should == "USD"
112
- disbursement.settlement_currency_exchange_rate.should == "1"
113
- disbursement.funds_held?.should be(false)
114
- disbursement.success?.should be(true)
102
+ expect(disbursement.disbursement_date).to eq(Date.parse("2013-04-03"))
103
+ expect(disbursement.settlement_amount).to eq("120.00")
104
+ expect(disbursement.settlement_currency_iso_code).to eq("USD")
105
+ expect(disbursement.settlement_currency_exchange_rate).to eq("1")
106
+ expect(disbursement.funds_held?).to be(false)
107
+ expect(disbursement.success?).to be(true)
115
108
  end
116
109
 
117
110
  it "sets up credit card attributes in credit_card_details" do
@@ -134,24 +127,66 @@ describe Braintree::Transaction do
134
127
  :product_id => "Unknown",
135
128
  :country_of_issuance => "Narnia",
136
129
  :issuing_bank => "Mr Tumnus"
137
- }
130
+ },
138
131
  )
139
- transaction.credit_card_details.token.should == "mzg2"
140
- transaction.credit_card_details.bin.should == "411111"
141
- transaction.credit_card_details.last_4.should == "1111"
142
- transaction.credit_card_details.card_type.should == "Visa"
143
- transaction.credit_card_details.expiration_month.should == "08"
144
- transaction.credit_card_details.expiration_year.should == "2009"
145
- transaction.credit_card_details.customer_location.should == "US"
146
- transaction.credit_card_details.prepaid.should == Braintree::CreditCard::Prepaid::Yes
147
- transaction.credit_card_details.healthcare.should == Braintree::CreditCard::Healthcare::Yes
148
- transaction.credit_card_details.durbin_regulated.should == Braintree::CreditCard::DurbinRegulated::Yes
149
- transaction.credit_card_details.debit.should == Braintree::CreditCard::Debit::Yes
150
- transaction.credit_card_details.commercial.should == Braintree::CreditCard::Commercial::No
151
- transaction.credit_card_details.payroll.should == Braintree::CreditCard::Payroll::Unknown
152
- transaction.credit_card_details.product_id.should == Braintree::CreditCard::ProductId::Unknown
153
- transaction.credit_card_details.country_of_issuance.should == "Narnia"
154
- transaction.credit_card_details.issuing_bank.should == "Mr Tumnus"
132
+ expect(transaction.credit_card_details.token).to eq("mzg2")
133
+ expect(transaction.credit_card_details.bin).to eq("411111")
134
+ expect(transaction.credit_card_details.last_4).to eq("1111")
135
+ expect(transaction.credit_card_details.card_type).to eq("Visa")
136
+ expect(transaction.credit_card_details.expiration_month).to eq("08")
137
+ expect(transaction.credit_card_details.expiration_year).to eq("2009")
138
+ expect(transaction.credit_card_details.customer_location).to eq("US")
139
+ expect(transaction.credit_card_details.prepaid).to eq(Braintree::CreditCard::Prepaid::Yes)
140
+ expect(transaction.credit_card_details.healthcare).to eq(Braintree::CreditCard::Healthcare::Yes)
141
+ expect(transaction.credit_card_details.durbin_regulated).to eq(Braintree::CreditCard::DurbinRegulated::Yes)
142
+ expect(transaction.credit_card_details.debit).to eq(Braintree::CreditCard::Debit::Yes)
143
+ expect(transaction.credit_card_details.commercial).to eq(Braintree::CreditCard::Commercial::No)
144
+ expect(transaction.credit_card_details.payroll).to eq(Braintree::CreditCard::Payroll::Unknown)
145
+ expect(transaction.credit_card_details.product_id).to eq(Braintree::CreditCard::ProductId::Unknown)
146
+ expect(transaction.credit_card_details.country_of_issuance).to eq("Narnia")
147
+ expect(transaction.credit_card_details.issuing_bank).to eq("Mr Tumnus")
148
+ end
149
+
150
+ it "sets up network token attributes in network_token_details" do
151
+ transaction = Braintree::Transaction._new(
152
+ :gateway,
153
+ :network_token => {
154
+ :token => "mzg2",
155
+ :bin => "411111",
156
+ :last_4 => "1111",
157
+ :card_type => "Visa",
158
+ :expiration_month => "08",
159
+ :expiration_year => "2009",
160
+ :customer_location => "US",
161
+ :prepaid => "Yes",
162
+ :healthcare => "Yes",
163
+ :durbin_regulated => "Yes",
164
+ :debit => "Yes",
165
+ :commercial => "No",
166
+ :payroll => "Unknown",
167
+ :product_id => "Unknown",
168
+ :country_of_issuance => "Narnia",
169
+ :issuing_bank => "Mr Tumnus",
170
+ :is_network_tokenized => true
171
+ },
172
+ )
173
+ expect(transaction.network_token_details.token).to eq("mzg2")
174
+ expect(transaction.network_token_details.bin).to eq("411111")
175
+ expect(transaction.network_token_details.last_4).to eq("1111")
176
+ expect(transaction.network_token_details.card_type).to eq("Visa")
177
+ expect(transaction.network_token_details.expiration_month).to eq("08")
178
+ expect(transaction.network_token_details.expiration_year).to eq("2009")
179
+ expect(transaction.network_token_details.customer_location).to eq("US")
180
+ expect(transaction.network_token_details.prepaid).to eq(Braintree::CreditCard::Prepaid::Yes)
181
+ expect(transaction.network_token_details.healthcare).to eq(Braintree::CreditCard::Healthcare::Yes)
182
+ expect(transaction.network_token_details.durbin_regulated).to eq(Braintree::CreditCard::DurbinRegulated::Yes)
183
+ expect(transaction.network_token_details.debit).to eq(Braintree::CreditCard::Debit::Yes)
184
+ expect(transaction.network_token_details.commercial).to eq(Braintree::CreditCard::Commercial::No)
185
+ expect(transaction.network_token_details.payroll).to eq(Braintree::CreditCard::Payroll::Unknown)
186
+ expect(transaction.network_token_details.product_id).to eq(Braintree::CreditCard::ProductId::Unknown)
187
+ expect(transaction.network_token_details.country_of_issuance).to eq("Narnia")
188
+ expect(transaction.network_token_details.issuing_bank).to eq("Mr Tumnus")
189
+ expect(transaction.network_token_details.is_network_tokenized?).to eq(true)
155
190
  end
156
191
 
157
192
  it "sets up three_d_secure_info" do
@@ -162,32 +197,13 @@ describe Braintree::Transaction do
162
197
  :liability_shifted => true,
163
198
  :liability_shift_possible => true,
164
199
  :status => "authenticate_successful",
165
- }
166
- )
167
-
168
- transaction.three_d_secure_info.enrolled.should == "Y"
169
- transaction.three_d_secure_info.status.should == "authenticate_successful"
170
- transaction.three_d_secure_info.liability_shifted.should == true
171
- transaction.three_d_secure_info.liability_shift_possible.should == true
172
- end
173
-
174
- it "sets up ideal_payment_details" do
175
- transaction = Braintree::Transaction._new(
176
- :gateway,
177
- :ideal_payment => {
178
- :ideal_payment_id => "idealpayment_abc_123",
179
- :ideal_transaction_id => "1150000008857321",
180
- :masked_iban => "12************7890",
181
- :bic => "RABONL2U",
182
- :image_url => "http://www.example.com/ideal.png"
183
- }
200
+ },
184
201
  )
185
202
 
186
- transaction.ideal_payment_details.ideal_payment_id.should == "idealpayment_abc_123"
187
- transaction.ideal_payment_details.ideal_transaction_id.should == "1150000008857321"
188
- transaction.ideal_payment_details.masked_iban.should == "12************7890"
189
- transaction.ideal_payment_details.bic.should == "RABONL2U"
190
- transaction.ideal_payment_details.image_url.should == "http://www.example.com/ideal.png"
203
+ expect(transaction.three_d_secure_info.status).to eq("authenticate_successful")
204
+ expect(transaction.three_d_secure_info.enrolled).to eq("Y")
205
+ expect(transaction.three_d_secure_info.liability_shifted).to eq(true)
206
+ expect(transaction.three_d_secure_info.liability_shift_possible).to eq(true)
191
207
  end
192
208
 
193
209
  it "sets up history attributes in status_history" do
@@ -195,18 +211,18 @@ describe Braintree::Transaction do
195
211
  transaction = Braintree::Transaction._new(
196
212
  :gateway,
197
213
  :status_history => [
198
- { :timestamp => time, :amount => "12.00", :transaction_source => "API",
199
- :user => "larry", :status => Braintree::Transaction::Status::Authorized },
200
- { :timestamp => Time.utc(2010,1,15), :amount => "12.00", :transaction_source => "API",
214
+ {:timestamp => time, :amount => "12.00", :transaction_source => "API",
215
+ :user => "larry", :status => Braintree::Transaction::Status::Authorized},
216
+ {:timestamp => Time.utc(2010,1,15), :amount => "12.00", :transaction_source => "API",
201
217
  :user => "curly", :status => "scheduled_for_settlement"}
202
218
  ])
203
- transaction.status_history.size.should == 2
204
- transaction.status_history[0].user.should == "larry"
205
- transaction.status_history[0].amount.should == "12.00"
206
- transaction.status_history[0].status.should == Braintree::Transaction::Status::Authorized
207
- transaction.status_history[0].transaction_source.should == "API"
208
- transaction.status_history[0].timestamp.should == time
209
- transaction.status_history[1].user.should == "curly"
219
+ expect(transaction.status_history.size).to eq(2)
220
+ expect(transaction.status_history[0].user).to eq("larry")
221
+ expect(transaction.status_history[0].amount).to eq("12.00")
222
+ expect(transaction.status_history[0].status).to eq(Braintree::Transaction::Status::Authorized)
223
+ expect(transaction.status_history[0].transaction_source).to eq("API")
224
+ expect(transaction.status_history[0].timestamp).to eq(time)
225
+ expect(transaction.status_history[1].user).to eq("curly")
210
226
  end
211
227
 
212
228
  it "sets up authorization_adjustments" do
@@ -214,32 +230,43 @@ describe Braintree::Transaction do
214
230
  transaction = Braintree::Transaction._new(
215
231
  :gateway,
216
232
  :authorization_adjustments => [
217
- { :timestamp => timestamp, :processor_response_code => "1000", :processor_response_text => "Approved", :amount => "12.00", :success => true },
218
- { :timestamp => timestamp, :processor_response_code => "3000", :processor_response_text => "Processor Network Unavailable - Try Again", :amount => "12.34", :success => false },
233
+ {:timestamp => timestamp, :processor_response_code => "1000", :processor_response_text => "Approved", :amount => "12.00", :success => true},
234
+ {:timestamp => timestamp, :processor_response_code => "3000", :processor_response_text => "Processor Network Unavailable - Try Again", :amount => "12.34", :success => false},
219
235
  ])
220
- transaction.authorization_adjustments.size.should == 2
221
- transaction.authorization_adjustments[0].amount.should == "12.00"
222
- transaction.authorization_adjustments[0].success.should == true
223
- transaction.authorization_adjustments[0].timestamp.should == timestamp
224
- transaction.authorization_adjustments[0].processor_response_code.should == "1000"
225
- transaction.authorization_adjustments[0].processor_response_text.should == "Approved"
226
- transaction.authorization_adjustments[1].amount.should == "12.34"
227
- transaction.authorization_adjustments[1].success.should == false
228
- transaction.authorization_adjustments[1].timestamp.should == timestamp
229
- transaction.authorization_adjustments[1].processor_response_code.should == "3000"
230
- transaction.authorization_adjustments[1].processor_response_text.should == "Processor Network Unavailable - Try Again"
236
+ expect(transaction.authorization_adjustments.size).to eq(2)
237
+ expect(transaction.authorization_adjustments[0].amount).to eq("12.00")
238
+ expect(transaction.authorization_adjustments[0].success).to eq(true)
239
+ expect(transaction.authorization_adjustments[0].timestamp).to eq(timestamp)
240
+ expect(transaction.authorization_adjustments[0].processor_response_code).to eq("1000")
241
+ expect(transaction.authorization_adjustments[0].processor_response_text).to eq("Approved")
242
+ expect(transaction.authorization_adjustments[1].amount).to eq("12.34")
243
+ expect(transaction.authorization_adjustments[1].success).to eq(false)
244
+ expect(transaction.authorization_adjustments[1].timestamp).to eq(timestamp)
245
+ expect(transaction.authorization_adjustments[1].processor_response_code).to eq("3000")
246
+ expect(transaction.authorization_adjustments[1].processor_response_text).to eq("Processor Network Unavailable - Try Again")
247
+ end
248
+
249
+ it "accepts retry_ids and retried_transaction_id attributes in a transactions" do
250
+ transaction = Braintree::Transaction._new(
251
+ :gateway,
252
+ :retry_ids => ["retry_id_1"],
253
+ :retried_transaction_id => "original_retried_tranction_id",
254
+ )
255
+ expect(transaction.retry_ids.count).to eq(1)
256
+ expect(transaction.retry_ids[0]).to eq("retry_id_1")
257
+ expect(transaction.retried_transaction_id).to eq("original_retried_tranction_id")
231
258
  end
232
259
 
233
260
  it "handles receiving custom as an empty string" do
234
- transaction = Braintree::Transaction._new(
261
+ Braintree::Transaction._new(
235
262
  :gateway,
236
- :custom => "\n "
263
+ :custom => "\n ",
237
264
  )
238
265
  end
239
266
 
240
267
  it "accepts amount as either a String or a BigDecimal" do
241
- Braintree::Transaction._new(:gateway, :amount => "12.34").amount.should == BigDecimal("12.34")
242
- Braintree::Transaction._new(:gateway, :amount => BigDecimal("12.34")).amount.should == BigDecimal("12.34")
268
+ expect(Braintree::Transaction._new(:gateway, :amount => "12.34").amount).to eq(BigDecimal("12.34"))
269
+ expect(Braintree::Transaction._new(:gateway, :amount => BigDecimal("12.34")).amount).to eq(BigDecimal("12.34"))
243
270
  end
244
271
 
245
272
  it "blows up if amount is not a string or BigDecimal" do
@@ -251,17 +278,25 @@ describe Braintree::Transaction do
251
278
  it "handles nil risk_data" do
252
279
  transaction = Braintree::Transaction._new(
253
280
  :gateway,
254
- :risk_data => nil
281
+ :risk_data => nil,
255
282
  )
256
- transaction.risk_data.should be_nil
283
+ expect(transaction.risk_data).to be_nil
257
284
  end
258
285
 
259
286
  it "accepts network_transaction_id" do
260
287
  transaction = Braintree::Transaction._new(
261
288
  :gateway,
262
- :network_transaction_id => "123456789012345"
289
+ :network_transaction_id => "123456789012345",
263
290
  )
264
- transaction.network_transaction_id.should == "123456789012345"
291
+ expect(transaction.network_transaction_id).to eq("123456789012345")
292
+ end
293
+
294
+ it "accepts ach_return_code" do
295
+ transaction = Braintree::Transaction._new(
296
+ :gateway,
297
+ :ach_return_code => "R01",
298
+ )
299
+ expect(transaction.ach_return_code).to eq("R01")
265
300
  end
266
301
 
267
302
  it "accepts network_response code and network_response_text" do
@@ -273,19 +308,62 @@ describe Braintree::Transaction do
273
308
  expect(transaction.network_response_code).to eq("00")
274
309
  expect(transaction.network_response_text).to eq("Successful approval/completion or V.I.P. PIN verification is successful")
275
310
  end
311
+
312
+ it "accepts merchant_advice_code and merchant_advice_text" do
313
+ transaction = Braintree::Transaction._new(
314
+ :gateway,
315
+ :merchant_advice_code => "01",
316
+ :merchant_advice_code_text => "New account information available",
317
+ )
318
+ expect(transaction.merchant_advice_code).to eq("01")
319
+ expect(transaction.merchant_advice_code_text).to eq("New account information available")
320
+ end
321
+
322
+ it "accepts sepa_direct_debit_return_code" do
323
+ transaction = Braintree::Transaction._new(
324
+ :gateway,
325
+ :sepa_direct_debit_return_code => "AM04",
326
+ )
327
+ expect(transaction.sepa_direct_debit_return_code).to eq("AM04")
328
+ end
329
+
330
+ it "accepts sepa_direct_debit_account_details" do
331
+ transaction = Braintree::Transaction._new(
332
+ :gateway,
333
+ :id => "123",
334
+ :type => "sale",
335
+ :amount => "12.34",
336
+ :status => "settled",
337
+ :sepa_debit_account_detail => {
338
+ :token => "1234",
339
+ },
340
+ )
341
+ details = transaction.sepa_direct_debit_account_details
342
+ expect(details.token).to eq("1234")
343
+ end
344
+
345
+ it "accepts debit_network" do
346
+ transaction = Braintree::Transaction._new(
347
+ :gateway,
348
+ :debit_network => "STAR",
349
+ )
350
+ expect(transaction.debit_network).to eq "STAR"
351
+ end
276
352
  end
277
353
 
278
354
  describe "inspect" do
279
- it "includes the id, type, amount, and status first" do
355
+ it "includes the id, type, amount, status, and processed_with_network_token?" do
280
356
  transaction = Braintree::Transaction._new(
281
357
  :gateway,
282
358
  :id => "1234",
283
359
  :type => "sale",
284
360
  :amount => "100.00",
285
- :status => Braintree::Transaction::Status::Authorized
361
+ :status => Braintree::Transaction::Status::Authorized,
362
+ :processed_with_network_token => false,
286
363
  )
287
364
  output = transaction.inspect
288
- output.should include(%Q(#<Braintree::Transaction id: "1234", type: "sale", amount: "100.0", status: "authorized"))
365
+ expect(output).to include(%Q(#<Braintree::Transaction id: "1234", type: "sale", amount: "100.0", status: "authorized"))
366
+ expect(output).to include(%Q(processed_with_network_token?: false))
289
367
  end
290
368
  end
291
369
 
@@ -294,27 +372,27 @@ describe Braintree::Transaction do
294
372
  first = Braintree::Transaction._new(:gateway, :id => 123)
295
373
  second = Braintree::Transaction._new(:gateway, :id => 123)
296
374
 
297
- first.should == second
298
- second.should == first
375
+ expect(first).to eq(second)
376
+ expect(second).to eq(first)
299
377
  end
300
378
 
301
379
  it "returns false for transactions with different ids" do
302
380
  first = Braintree::Transaction._new(:gateway, :id => 123)
303
381
  second = Braintree::Transaction._new(:gateway, :id => 124)
304
382
 
305
- first.should_not == second
306
- second.should_not == first
383
+ expect(first).not_to eq(second)
384
+ expect(second).not_to eq(first)
307
385
  end
308
386
 
309
387
  it "returns false when comparing to nil" do
310
- Braintree::Transaction._new(:gateway, {}).should_not == nil
388
+ expect(Braintree::Transaction._new(:gateway, {})).not_to eq(nil)
311
389
  end
312
390
 
313
391
  it "returns false when comparing to non-transactions" do
314
392
  same_id_different_object = Object.new
315
393
  def same_id_different_object.id; 123; end
316
394
  transaction = Braintree::Transaction._new(:gateway, :id => 123)
317
- transaction.should_not == same_id_different_object
395
+ expect(transaction).not_to eq(same_id_different_object)
318
396
  end
319
397
  end
320
398
 
@@ -329,25 +407,25 @@ describe Braintree::Transaction do
329
407
  describe "refunded?" do
330
408
  it "is true if the transaciton has been refunded" do
331
409
  transaction = Braintree::Transaction._new(:gateway, :refund_id => "123")
332
- transaction.refunded?.should == true
410
+ expect(transaction.refunded?).to eq(true)
333
411
  end
334
412
 
335
413
  it "is false if the transaciton has not been refunded" do
336
414
  transaction = Braintree::Transaction._new(:gateway, :refund_id => nil)
337
- transaction.refunded?.should == false
415
+ expect(transaction.refunded?).to eq(false)
338
416
  end
339
417
  end
340
418
 
341
419
  describe "sale" do
342
- let(:mock_response) { {:transaction => {}}}
343
- let(:http_stub) { double('http_stub').as_null_object }
420
+ let(:mock_response) { {:transaction => {}} }
421
+ let(:http_stub) { double("http_stub").as_null_object }
344
422
 
345
423
  RSpec::Matchers.define :skip_advanced_fraud_check_value_is do |value|
346
424
  match { |params| params[:transaction][:options][:skip_advanced_fraud_checking] == value }
347
425
  end
348
426
 
349
427
  it "accepts skip_advanced_fraud_checking options with value true" do
350
- Braintree::Http.stub(:new).and_return http_stub
428
+ allow(Braintree::Http).to receive(:new).and_return http_stub
351
429
  expect(http_stub).to receive(:post).with(anything, skip_advanced_fraud_check_value_is(true)).and_return(mock_response)
352
430
 
353
431
  Braintree::Transaction.sale(
@@ -358,12 +436,12 @@ describe Braintree::Transaction do
358
436
  },
359
437
  :options => {
360
438
  :skip_advanced_fraud_checking => true
361
- }
439
+ },
362
440
  )
363
441
  end
364
442
 
365
443
  it "accepts skip_advanced_fraud_checking options with value false" do
366
- Braintree::Http.stub(:new).and_return http_stub
444
+ allow(Braintree::Http).to receive(:new).and_return http_stub
367
445
  expect(http_stub).to receive(:post).with(anything, skip_advanced_fraud_check_value_is(false)).and_return(mock_response)
368
446
 
369
447
  Braintree::Transaction.sale(
@@ -374,12 +452,12 @@ describe Braintree::Transaction do
374
452
  },
375
453
  :options => {
376
454
  :skip_advanced_fraud_checking => false
377
- }
455
+ },
378
456
  )
379
457
  end
380
458
 
381
459
  it "doesn't include skip_advanced_fraud_checking in params if its not specified" do
382
- Braintree::Http.stub(:new).and_return http_stub
460
+ allow(Braintree::Http).to receive(:new).and_return http_stub
383
461
  expect(http_stub).to receive(:post).with(anything, skip_advanced_fraud_check_value_is(nil)).and_return(mock_response)
384
462
 
385
463
  Braintree::Transaction.sale(
@@ -390,8 +468,27 @@ describe Braintree::Transaction do
390
468
  },
391
469
  :options => {
392
470
  :submit_for_settlement => false
393
- }
471
+ },
394
472
  )
395
473
  end
396
474
  end
475
+
476
+ describe "processed_with_network_token?" do
477
+ it "is true if the transaction was processed with a network token" do
478
+ transaction = Braintree::Transaction._new(:gateway, :processed_with_network_token => true)
479
+ expect(transaction.processed_with_network_token?).to eq(true)
480
+ end
481
+
482
+ it "is false if the transaction was not processed with a network token" do
483
+ transaction = Braintree::Transaction._new(:gateway, :processed_with_network_token => false)
484
+ expect(transaction.processed_with_network_token?).to eq(false)
485
+ end
486
+ end
487
+
488
+ describe "gateway rejection reason" do
489
+ it "verifies excessive_retry mapping" do
490
+ transaction = Braintree::Transaction._new(:gateway, :gateway_rejection_reason => "excessive_retry")
491
+ expect(transaction.gateway_rejection_reason).to eq(Braintree::Transaction::GatewayRejectionReason::ExcessiveRetry)
492
+ end
493
+ end
397
494
  end
@@ -8,26 +8,26 @@ describe Braintree::PayPalAccount do
8
8
  describe "token" do
9
9
  it "has a token identifier" do
10
10
  params = {:unknown_payment_method => {:token => 1234, :default => true}}
11
- Braintree::UnknownPaymentMethod.new(@gateway, params).token.should == 1234
11
+ expect(Braintree::UnknownPaymentMethod.new(@gateway, params).token).to eq(1234)
12
12
  end
13
13
  end
14
14
 
15
15
  describe "image_url" do
16
16
  it "has a image_url" do
17
17
  params = {:unknown_payment_method => {:token => 1234, :default => true}}
18
- Braintree::UnknownPaymentMethod.new(@gateway, params).image_url.should == "https://assets.braintreegateway.com/payment_method_logo/unknown.png"
18
+ expect(Braintree::UnknownPaymentMethod.new(@gateway, params).image_url).to eq("https://assets.braintreegateway.com/payment_method_logo/unknown.png")
19
19
  end
20
20
  end
21
21
 
22
22
  describe "default?" do
23
23
  it "is true if the paypal account is the default payment method for the customer" do
24
24
  params = {:unknown_payment_method => {:token => 1234, :default => true}}
25
- Braintree::UnknownPaymentMethod.new(@gateway, params).should be_default
25
+ expect(Braintree::UnknownPaymentMethod.new(@gateway, params)).to be_default
26
26
  end
27
27
 
28
28
  it "is false if the paypal account is not the default payment methodfor the customer" do
29
29
  params = {:unknown_payment_method => {:token => 1234, :default => false}}
30
- Braintree::UnknownPaymentMethod.new(@gateway, params).should_not be_default
30
+ expect(Braintree::UnknownPaymentMethod.new(@gateway, params)).not_to be_default
31
31
  end
32
32
  end
33
33
  end
@@ -3,11 +3,11 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
3
3
  describe Braintree::UsBankAccount do
4
4
  describe "default?" do
5
5
  it "is true if the us bank account is the default us bank account for the customer" do
6
- Braintree::UsBankAccount._new(:gateway, :default => true).default?.should == true
6
+ expect(Braintree::UsBankAccount._new(:gateway, :default => true).default?).to eq(true)
7
7
  end
8
8
 
9
9
  it "is false if the us bank account is not the default us bank account for the customer" do
10
- Braintree::UsBankAccount._new(:gateway, :default => false).default?.should == false
10
+ expect(Braintree::UsBankAccount._new(:gateway, :default => false).default?).to eq(false)
11
11
  end
12
12
  end
13
13
  end
@@ -6,11 +6,11 @@ module Braintree
6
6
  it "allows All verification methods" do
7
7
  search = UsBankAccountVerificationSearch.new
8
8
 
9
- lambda do
9
+ expect do
10
10
  search.verification_method.in(
11
11
  *Braintree::UsBankAccountVerification::VerificationMethod::All,
12
12
  )
13
- end.should_not raise_error
13
+ end.not_to raise_error
14
14
  end
15
15
  end
16
16
 
@@ -19,7 +19,7 @@ module Braintree
19
19
  search = UsBankAccountVerificationSearch.new
20
20
  search.id.is "v_id"
21
21
 
22
- search.to_hash.should == {:id => {:is => "v_id"}}
22
+ expect(search.to_hash).to eq({:id => {:is => "v_id"}})
23
23
  end
24
24
  end
25
25
 
@@ -28,7 +28,7 @@ module Braintree
28
28
  search = UsBankAccountVerificationSearch.new
29
29
  search.ids.in("id1", "id2")
30
30
 
31
- search.to_hash.should == {:ids => ["id1", "id2"]}
31
+ expect(search.to_hash).to eq({:ids => ["id1", "id2"]})
32
32
  end
33
33
  end
34
34
 
@@ -37,14 +37,14 @@ module Braintree
37
37
  search = UsBankAccountVerificationSearch.new
38
38
  search.account_holder_name.is "v_account_holder_name"
39
39
 
40
- search.to_hash.should == {:account_holder_name => {:is => "v_account_holder_name"}}
40
+ expect(search.to_hash).to eq({:account_holder_name => {:is => "v_account_holder_name"}})
41
41
  end
42
42
  end
43
43
 
44
44
  context "created_at" do
45
45
  it "is a range node" do
46
46
  search = UsBankAccountVerificationSearch.new
47
- search.created_at.should be_kind_of(Braintree::AdvancedSearch::RangeNode)
47
+ expect(search.created_at).to be_kind_of(Braintree::AdvancedSearch::RangeNode)
48
48
  end
49
49
  end
50
50
 
@@ -53,7 +53,7 @@ module Braintree
53
53
  search = UsBankAccountVerificationSearch.new
54
54
  search.account_number.ends_with "1234"
55
55
 
56
- search.to_hash.should == {:account_number => {:ends_with => "1234"}}
56
+ expect(search.to_hash).to eq({:account_number => {:ends_with => "1234"}})
57
57
  end
58
58
  end
59
59
  end