braintree 2.10.0 → 4.26.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 (353) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +1 -1
  3. data/braintree.gemspec +24 -0
  4. data/lib/braintree/account_updater_daily_report.rb +20 -0
  5. data/lib/braintree/ach_mandate.rb +14 -0
  6. data/lib/braintree/add_on.rb +4 -0
  7. data/lib/braintree/add_on_gateway.rb +17 -0
  8. data/lib/braintree/address/country_names.rb +4 -1
  9. data/lib/braintree/address.rb +35 -43
  10. data/lib/braintree/address_gateway.rb +24 -11
  11. data/lib/braintree/advanced_search.rb +26 -11
  12. data/lib/braintree/apple_pay.rb +29 -0
  13. data/lib/braintree/apple_pay_card.rb +66 -0
  14. data/lib/braintree/apple_pay_gateway.rb +37 -0
  15. data/lib/braintree/apple_pay_options.rb +19 -0
  16. data/lib/braintree/authorization_adjustment.rb +23 -0
  17. data/lib/braintree/base_module.rb +11 -1
  18. data/lib/braintree/bin_data.rb +34 -0
  19. data/lib/braintree/client_token.rb +11 -0
  20. data/lib/braintree/client_token_gateway.rb +45 -0
  21. data/lib/braintree/configuration.rb +231 -39
  22. data/lib/braintree/connected_merchant_paypal_status_changed.rb +22 -0
  23. data/lib/braintree/connected_merchant_status_transitioned.rb +22 -0
  24. data/lib/braintree/credentials_parser.rb +44 -0
  25. data/lib/braintree/credit_card.rb +107 -132
  26. data/lib/braintree/credit_card_gateway.rb +90 -41
  27. data/lib/braintree/credit_card_verification.rb +90 -17
  28. data/lib/braintree/credit_card_verification_gateway.rb +87 -0
  29. data/lib/braintree/credit_card_verification_search.rb +20 -0
  30. data/lib/braintree/customer.rb +80 -118
  31. data/lib/braintree/customer_gateway.rb +66 -39
  32. data/lib/braintree/customer_search.rb +5 -2
  33. data/lib/braintree/customer_session_gateway.rb +194 -0
  34. data/lib/braintree/descriptor.rb +4 -2
  35. data/lib/braintree/digest.rb +16 -3
  36. data/lib/braintree/disbursement.rb +63 -0
  37. data/lib/braintree/discount.rb +4 -0
  38. data/lib/braintree/discount_gateway.rb +17 -0
  39. data/lib/braintree/dispute/evidence.rb +24 -0
  40. data/lib/braintree/dispute/paypal_message.rb +15 -0
  41. data/lib/braintree/dispute/status_history.rb +18 -0
  42. data/lib/braintree/dispute/transaction.rb +20 -0
  43. data/lib/braintree/dispute/transaction_details.rb +15 -0
  44. data/lib/braintree/dispute.rb +165 -0
  45. data/lib/braintree/dispute_gateway.rb +142 -0
  46. data/lib/braintree/dispute_search.rb +31 -0
  47. data/lib/braintree/document_upload.rb +37 -0
  48. data/lib/braintree/document_upload_gateway.rb +38 -0
  49. data/lib/braintree/enriched_customer_data.rb +21 -0
  50. data/lib/braintree/error_codes.rb +680 -15
  51. data/lib/braintree/error_result.rb +13 -6
  52. data/lib/braintree/errors.rb +5 -5
  53. data/lib/braintree/exceptions.rb +14 -20
  54. data/lib/braintree/exchange_rate.rb +13 -0
  55. data/lib/braintree/exchange_rate_quote.rb +24 -0
  56. data/lib/braintree/exchange_rate_quote_gateway.rb +35 -0
  57. data/lib/braintree/exchange_rate_quote_input.rb +21 -0
  58. data/lib/braintree/exchange_rate_quote_request.rb +18 -0
  59. data/lib/braintree/exchange_rate_quote_response.rb +18 -0
  60. data/lib/braintree/facilitated_details.rb +21 -0
  61. data/lib/braintree/facilitator_details.rb +20 -0
  62. data/lib/braintree/gateway.rb +104 -6
  63. data/lib/braintree/google_pay_card.rb +62 -0
  64. data/lib/braintree/granted_payment_instrument_update.rb +23 -0
  65. data/lib/braintree/graphql/enums/recommendations.rb +7 -0
  66. data/lib/braintree/graphql/enums/recommended_payment_option.rb +8 -0
  67. data/lib/braintree/graphql/inputs/create_customer_session_input.rb +35 -0
  68. data/lib/braintree/graphql/inputs/customer_recommendations_input.rb +41 -0
  69. data/lib/braintree/graphql/inputs/customer_session_input.rb +39 -0
  70. data/lib/braintree/graphql/inputs/phone_input.rb +32 -0
  71. data/lib/braintree/graphql/inputs/update_customer_session_input.rb +37 -0
  72. data/lib/braintree/graphql/types/customer_recommendations_payload.rb +32 -0
  73. data/lib/braintree/graphql/types/payment_options.rb +33 -0
  74. data/lib/braintree/graphql/unions/customer_recommendations.rb +34 -0
  75. data/lib/braintree/graphql_client.rb +50 -0
  76. data/lib/braintree/http.rb +119 -25
  77. data/lib/braintree/local_payment_completed/blik_alias.rb +23 -0
  78. data/lib/braintree/local_payment_completed.rb +28 -0
  79. data/lib/braintree/local_payment_expired.rb +21 -0
  80. data/lib/braintree/local_payment_funded.rb +22 -0
  81. data/lib/braintree/local_payment_reversed.rb +19 -0
  82. data/lib/braintree/merchant.rb +34 -0
  83. data/lib/braintree/merchant_account/address_details.rb +16 -0
  84. data/lib/braintree/merchant_account/business_details.rb +17 -0
  85. data/lib/braintree/merchant_account/funding_details.rb +18 -0
  86. data/lib/braintree/merchant_account/individual_details.rb +20 -0
  87. data/lib/braintree/merchant_account.rb +76 -0
  88. data/lib/braintree/merchant_account_gateway.rb +130 -0
  89. data/lib/braintree/merchant_gateway.rb +38 -0
  90. data/lib/braintree/meta_checkout_card.rb +90 -0
  91. data/lib/braintree/meta_checkout_token.rb +89 -0
  92. data/lib/braintree/modification.rb +16 -5
  93. data/lib/braintree/oauth_credentials.rb +22 -0
  94. data/lib/braintree/oauth_gateway.rb +73 -0
  95. data/lib/braintree/paginated_collection.rb +25 -0
  96. data/lib/braintree/paginated_result.rb +15 -0
  97. data/lib/braintree/payment_instrument_type.rb +18 -0
  98. data/lib/braintree/payment_method.rb +37 -0
  99. data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
  100. data/lib/braintree/payment_method_gateway.rb +221 -0
  101. data/lib/braintree/payment_method_nonce.rb +49 -0
  102. data/lib/braintree/payment_method_nonce_details.rb +40 -0
  103. data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
  104. data/lib/braintree/payment_method_nonce_gateway.rb +38 -0
  105. data/lib/braintree/payment_method_parser.rb +29 -0
  106. data/lib/braintree/paypal_account.rb +60 -0
  107. data/lib/braintree/paypal_account_gateway.rb +73 -0
  108. data/lib/braintree/paypal_payment_resource.rb +22 -0
  109. data/lib/braintree/paypal_payment_resource_gateway.rb +36 -0
  110. data/lib/braintree/plan.rb +62 -0
  111. data/lib/braintree/plan_gateway.rb +117 -0
  112. data/lib/braintree/processor_response_types.rb +7 -0
  113. data/lib/braintree/resource_collection.rb +12 -5
  114. data/lib/braintree/revoked_payment_method_metadata.rb +22 -0
  115. data/lib/braintree/risk_data/liability_shift.rb +22 -0
  116. data/lib/braintree/risk_data.rb +29 -0
  117. data/lib/braintree/samsung_pay_card.rb +85 -0
  118. data/lib/braintree/sepa_direct_debit_account.rb +60 -0
  119. data/lib/braintree/sepa_direct_debit_account_gateway.rb +25 -0
  120. data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +28 -0
  121. data/lib/braintree/settlement_batch_summary.rb +25 -0
  122. data/lib/braintree/settlement_batch_summary_gateway.rb +27 -0
  123. data/lib/braintree/sha256_digest.rb +13 -0
  124. data/lib/braintree/signature_service.rb +19 -0
  125. data/lib/braintree/subscription/status_details.rb +20 -0
  126. data/lib/braintree/subscription.rb +67 -47
  127. data/lib/braintree/subscription_gateway.rb +43 -16
  128. data/lib/braintree/subscription_search.rb +2 -2
  129. data/lib/braintree/successful_result.rb +30 -10
  130. data/lib/braintree/test/authentication_id.rb +21 -0
  131. data/lib/braintree/test/credit_card.rb +76 -0
  132. data/lib/braintree/test/merchant_account.rb +12 -0
  133. data/lib/braintree/test/nonce.rb +81 -0
  134. data/lib/braintree/test/transaction_amounts.rb +3 -5
  135. data/lib/braintree/test/venmo_sdk.rb +21 -0
  136. data/lib/braintree/test_transaction.rb +19 -0
  137. data/lib/braintree/testing_gateway.rb +43 -0
  138. data/lib/braintree/three_d_secure_info.rb +53 -0
  139. data/lib/braintree/transaction/address_details.rb +27 -5
  140. data/lib/braintree/transaction/apple_pay_details.rb +35 -0
  141. data/lib/braintree/transaction/credit_card_details.rb +55 -4
  142. data/lib/braintree/transaction/customer_details.rb +11 -3
  143. data/lib/braintree/transaction/disbursement_details.rb +28 -0
  144. data/lib/braintree/transaction/google_pay_details.rb +42 -0
  145. data/lib/braintree/transaction/installment/adjustment.rb +33 -0
  146. data/lib/braintree/transaction/installment.rb +28 -0
  147. data/lib/braintree/transaction/local_payment_details.rb +27 -0
  148. data/lib/braintree/transaction/meta_checkout_card_details.rb +55 -0
  149. data/lib/braintree/transaction/meta_checkout_token_details.rb +58 -0
  150. data/lib/braintree/transaction/package_details.rb +19 -0
  151. data/lib/braintree/transaction/payment_receipt/card_present_data.rb +36 -0
  152. data/lib/braintree/transaction/payment_receipt/merchant_address.rb +19 -0
  153. data/lib/braintree/transaction/payment_receipt.rb +31 -0
  154. data/lib/braintree/transaction/paypal_details.rb +40 -0
  155. data/lib/braintree/transaction/paypal_here_details.rb +23 -0
  156. data/lib/braintree/transaction/samsung_pay_card_details.rb +50 -0
  157. data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +27 -0
  158. data/lib/braintree/transaction/status_details.rb +6 -2
  159. data/lib/braintree/transaction/subscription_details.rb +5 -2
  160. data/lib/braintree/transaction/us_bank_account_details.rb +22 -0
  161. data/lib/braintree/transaction/venmo_account_details.rb +17 -0
  162. data/lib/braintree/transaction/visa_checkout_card_details.rb +51 -0
  163. data/lib/braintree/transaction.rb +293 -150
  164. data/lib/braintree/transaction_gateway.rb +303 -59
  165. data/lib/braintree/transaction_line_item.rb +43 -0
  166. data/lib/braintree/transaction_line_item_gateway.rb +19 -0
  167. data/lib/braintree/transaction_review.rb +18 -0
  168. data/lib/braintree/transaction_search.rb +17 -9
  169. data/lib/braintree/unknown_payment_method.rb +26 -0
  170. data/lib/braintree/us_bank_account.rb +57 -0
  171. data/lib/braintree/us_bank_account_gateway.rb +17 -0
  172. data/lib/braintree/us_bank_account_verification.rb +89 -0
  173. data/lib/braintree/us_bank_account_verification_gateway.rb +51 -0
  174. data/lib/braintree/us_bank_account_verification_search.rb +19 -0
  175. data/lib/braintree/util.rb +91 -11
  176. data/lib/braintree/validation_error.rb +14 -5
  177. data/lib/braintree/validation_error_collection.rb +5 -5
  178. data/lib/braintree/venmo_account.rb +34 -0
  179. data/lib/braintree/venmo_profile_data.rb +25 -0
  180. data/lib/braintree/version.rb +2 -2
  181. data/lib/braintree/visa_checkout_card.rb +90 -0
  182. data/lib/braintree/webhook_notification.rb +146 -0
  183. data/lib/braintree/webhook_notification_gateway.rb +46 -0
  184. data/lib/braintree/webhook_testing.rb +7 -0
  185. data/lib/braintree/webhook_testing_gateway.rb +1239 -0
  186. data/lib/braintree/xml/generator.rb +18 -10
  187. data/lib/braintree/xml/libxml.rb +1 -1
  188. data/lib/braintree/xml/parser.rb +24 -36
  189. data/lib/braintree/xml/rexml.rb +6 -7
  190. data/lib/braintree/xml.rb +1 -2
  191. data/lib/braintree.rb +186 -52
  192. data/lib/ssl/api_braintreegateway_com.ca.crt +474 -0
  193. data/spec/fixtures/files/bt_logo.png +0 -0
  194. data/spec/fixtures/files/gif_extension_bt_logo.gif +0 -0
  195. data/spec/fixtures/files/malformed_pdf.pdf +1 -0
  196. data/spec/fixtures/files/too_long.pdf +0 -0
  197. data/spec/integration/braintree/add_on_spec.rb +46 -0
  198. data/spec/integration/braintree/address_spec.rb +101 -178
  199. data/spec/integration/braintree/advanced_search_spec.rb +100 -97
  200. data/spec/integration/braintree/apple_pay_spec.rb +63 -0
  201. data/spec/integration/braintree/braintree_gateway_spec.rb +72 -0
  202. data/spec/integration/braintree/client_api/client_token_spec.rb +407 -0
  203. data/spec/integration/braintree/client_api/spec_helper.rb +300 -0
  204. data/spec/integration/braintree/credit_card_spec.rb +885 -654
  205. data/spec/integration/braintree/credit_card_verification_search_spec.rb +193 -0
  206. data/spec/integration/braintree/credit_card_verification_spec.rb +473 -0
  207. data/spec/integration/braintree/customer_search_spec.rb +69 -21
  208. data/spec/integration/braintree/customer_session_spec.rb +143 -0
  209. data/spec/integration/braintree/customer_spec.rb +1437 -518
  210. data/spec/integration/braintree/disbursement_spec.rb +31 -0
  211. data/spec/integration/braintree/discount_spec.rb +34 -0
  212. data/spec/integration/braintree/dispute_search_spec.rb +165 -0
  213. data/spec/integration/braintree/dispute_spec.rb +333 -0
  214. data/spec/integration/braintree/document_upload_spec.rb +87 -0
  215. data/spec/integration/braintree/error_codes_spec.rb +3 -3
  216. data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
  217. data/spec/integration/braintree/graphql_client_spec.rb +72 -0
  218. data/spec/integration/braintree/http_spec.rb +106 -56
  219. data/spec/integration/braintree/merchant_account_spec.rb +603 -0
  220. data/spec/integration/braintree/merchant_spec.rb +227 -0
  221. data/spec/integration/braintree/oauth_spec.rb +225 -0
  222. data/spec/integration/braintree/package_tracking_spec.rb +130 -0
  223. data/spec/integration/braintree/payment_method_nonce_spec.rb +345 -0
  224. data/spec/integration/braintree/payment_method_spec.rb +2146 -0
  225. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +325 -0
  226. data/spec/integration/braintree/paypal_account_spec.rb +299 -0
  227. data/spec/integration/braintree/paypal_payment_resource_spec.rb +141 -0
  228. data/spec/integration/braintree/plan_spec.rb +136 -0
  229. data/spec/integration/braintree/samsung_pay_card_spec.rb +146 -0
  230. data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +194 -0
  231. data/spec/integration/braintree/settlement_batch_summary_spec.rb +62 -0
  232. data/spec/integration/braintree/subscription_spec.rb +785 -431
  233. data/spec/integration/braintree/test/transaction_amounts_spec.rb +4 -4
  234. data/spec/integration/braintree/test_transaction_spec.rb +145 -0
  235. data/spec/integration/braintree/transaction_line_item_spec.rb +44 -0
  236. data/spec/integration/braintree/transaction_search_spec.rb +745 -156
  237. data/spec/integration/braintree/transaction_spec.rb +7452 -1288
  238. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +196 -0
  239. data/spec/integration/braintree/us_bank_account_spec.rb +113 -0
  240. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +178 -0
  241. data/spec/integration/braintree/us_bank_account_verification_spec.rb +240 -0
  242. data/spec/integration/braintree/visa_checkout_card_spec.rb +110 -0
  243. data/spec/integration/spec_helper.rb +61 -5
  244. data/spec/oauth_test_helper.rb +17 -0
  245. data/spec/script/httpsd.rb +6 -6
  246. data/spec/spec.opts +4 -0
  247. data/spec/spec_helper.rb +77 -21
  248. data/spec/ssl/certificate.crt +17 -0
  249. data/spec/ssl/geotrust_global.crt +20 -0
  250. data/spec/ssl/privateKey.key +15 -0
  251. data/spec/unit/braintree/address_spec.rb +27 -16
  252. data/spec/unit/braintree/apple_pay_card_spec.rb +133 -0
  253. data/spec/unit/braintree/base_module_spec.rb +4 -4
  254. data/spec/unit/braintree/client_token_spec.rb +37 -0
  255. data/spec/unit/braintree/configuration_spec.rb +293 -43
  256. data/spec/unit/braintree/credentials_parser_spec.rb +81 -0
  257. data/spec/unit/braintree/credit_card_spec.rb +138 -47
  258. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +56 -0
  259. data/spec/unit/braintree/credit_card_verification_search_spec.rb +79 -0
  260. data/spec/unit/braintree/credit_card_verification_spec.rb +132 -6
  261. data/spec/unit/braintree/customer_session_gateway_spec.rb +120 -0
  262. data/spec/unit/braintree/customer_spec.rb +196 -40
  263. data/spec/unit/braintree/digest_spec.rb +16 -3
  264. data/spec/unit/braintree/disbursement_spec.rb +131 -0
  265. data/spec/unit/braintree/dispute_search_spec.rb +66 -0
  266. data/spec/unit/braintree/dispute_spec.rb +479 -0
  267. data/spec/unit/braintree/document_upload_spec.rb +35 -0
  268. data/spec/unit/braintree/enriched_customer_data_spec.rb +41 -0
  269. data/spec/unit/braintree/error_result_spec.rb +11 -11
  270. data/spec/unit/braintree/errors_spec.rb +17 -17
  271. data/spec/unit/braintree/exchange_rate_quote_input_spec.rb +42 -0
  272. data/spec/unit/braintree/exchange_rate_quote_request_spec.rb +82 -0
  273. data/spec/unit/braintree/exchange_rate_quote_response_spec.rb +52 -0
  274. data/spec/unit/braintree/exchange_rate_quote_spec.rb +42 -0
  275. data/spec/unit/braintree/exchange_rate_spec.rb +23 -0
  276. data/spec/unit/braintree/google_pay_card_spec.rb +8 -0
  277. data/spec/unit/braintree/graphql/create_customer_session_input_spec.rb +81 -0
  278. data/spec/unit/braintree/graphql/customer_recommendations_input_spec.rb +110 -0
  279. data/spec/unit/braintree/graphql/customer_session_input_spec.rb +81 -0
  280. data/spec/unit/braintree/graphql/phone_input_spec.rb +51 -0
  281. data/spec/unit/braintree/graphql/update_customer_session_input_spec.rb +93 -0
  282. data/spec/unit/braintree/graphql_client_spec.rb +37 -0
  283. data/spec/unit/braintree/http_spec.rb +164 -2
  284. data/spec/unit/braintree/local_payment_completed_spec.rb +90 -0
  285. data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
  286. data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
  287. data/spec/unit/braintree/merchant_account_spec.rb +33 -0
  288. data/spec/unit/braintree/meta_checkout_card_details_spec.rb +60 -0
  289. data/spec/unit/braintree/meta_checkout_card_spec.rb +62 -0
  290. data/spec/unit/braintree/meta_checkout_token_details_spec.rb +63 -0
  291. data/spec/unit/braintree/meta_checkout_token_spec.rb +65 -0
  292. data/spec/unit/braintree/modification_spec.rb +7 -0
  293. data/spec/unit/braintree/package_tracking_spec.rb +77 -0
  294. data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +45 -0
  295. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
  296. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +51 -0
  297. data/spec/unit/braintree/payment_method_nonce_spec.rb +43 -0
  298. data/spec/unit/braintree/payment_method_spec.rb +135 -0
  299. data/spec/unit/braintree/paypal_account_spec.rb +53 -0
  300. data/spec/unit/braintree/paypal_payment_resource_spec.rb +125 -0
  301. data/spec/unit/braintree/resource_collection_spec.rb +44 -3
  302. data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
  303. data/spec/unit/braintree/risk_data_spec.rb +55 -0
  304. data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +29 -0
  305. data/spec/unit/braintree/sepa_debit_account_spec.rb +86 -0
  306. data/spec/unit/braintree/sha256_digest_spec.rb +11 -0
  307. data/spec/unit/braintree/signature_service_spec.rb +23 -0
  308. data/spec/unit/braintree/subscription_search_spec.rb +25 -18
  309. data/spec/unit/braintree/subscription_spec.rb +34 -7
  310. data/spec/unit/braintree/successful_result_spec.rb +9 -9
  311. data/spec/unit/braintree/three_d_secure_info_spec.rb +69 -0
  312. data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +8 -0
  313. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +34 -6
  314. data/spec/unit/braintree/transaction/customer_details_spec.rb +3 -2
  315. data/spec/unit/braintree/transaction/deposit_details_spec.rb +18 -0
  316. data/spec/unit/braintree/transaction/google_pay_details_spec.rb +8 -0
  317. data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
  318. data/spec/unit/braintree/transaction/local_payment_details_spec.rb +36 -0
  319. data/spec/unit/braintree/transaction/meta_checkout_card_details_spec.rb +8 -0
  320. data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +8 -0
  321. data/spec/unit/braintree/transaction/payment_receipt_spec.rb +73 -0
  322. data/spec/unit/braintree/transaction/paypal_details_spec.rb +68 -0
  323. data/spec/unit/braintree/transaction/sepa_direct_debit_account_details_spec.rb +33 -0
  324. data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +8 -0
  325. data/spec/unit/braintree/transaction_gateway_spec.rb +150 -0
  326. data/spec/unit/braintree/transaction_search_spec.rb +12 -12
  327. data/spec/unit/braintree/transaction_spec.rb +366 -52
  328. data/spec/unit/braintree/unknown_payment_method_spec.rb +33 -0
  329. data/spec/unit/braintree/us_bank_account_spec.rb +13 -0
  330. data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +60 -0
  331. data/spec/unit/braintree/us_bank_account_verification_spec.rb +98 -0
  332. data/spec/unit/braintree/util_spec.rb +199 -39
  333. data/spec/unit/braintree/validation_error_collection_spec.rb +336 -133
  334. data/spec/unit/braintree/validation_error_spec.rb +4 -4
  335. data/spec/unit/braintree/venmo_profile_data_spec.rb +43 -0
  336. data/spec/unit/braintree/visa_checkout_card_spec.rb +8 -0
  337. data/spec/unit/braintree/webhook_notification_spec.rb +977 -0
  338. data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
  339. data/spec/unit/braintree/xml/parser_spec.rb +39 -5
  340. data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
  341. data/spec/unit/braintree/xml_spec.rb +39 -32
  342. data/spec/unit/braintree_spec.rb +3 -2
  343. data/spec/unit/credit_card_details_spec.rb +8 -0
  344. metadata +314 -73
  345. data/README.rdoc +0 -80
  346. data/lib/braintree/test/credit_card_numbers.rb +0 -52
  347. data/lib/braintree/transparent_redirect.rb +0 -51
  348. data/lib/braintree/transparent_redirect_gateway.rb +0 -105
  349. data/lib/ssl/sandbox_braintreegateway_com.ca.crt +0 -19
  350. data/lib/ssl/www_braintreegateway_com.ca.crt +0 -202
  351. data/spec/hacks/tcp_socket.rb +0 -18
  352. data/spec/integration/braintree/transparent_redirect_spec.rb +0 -236
  353. data/spec/unit/braintree/transparent_redirect_spec.rb +0 -160
@@ -0,0 +1,120 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::CustomerSessionGateway do
4
+ let(:gateway) { double(:gateway) }
5
+ let(:graphql_client) { double(:graphql_client) }
6
+ let(:customer_session_gateway) { Braintree::CustomerSessionGateway.new(gateway, graphql_client) }
7
+
8
+ describe "#create_customer_session" do
9
+ let(:input) do
10
+ {
11
+ :merchant_account_id => "merchant-account-id",
12
+ }
13
+ end
14
+
15
+ let(:response) do
16
+ {
17
+ data: {
18
+ createCustomerSession: {
19
+ sessionId: "session-id"
20
+ }
21
+ }
22
+ }
23
+ end
24
+
25
+
26
+ it "executes the createCustomerSession mutation" do
27
+ create_input = Braintree::CreateCustomerSessionInput.new(input)
28
+ expect(graphql_client).to receive(:query).with(Braintree::CustomerSessionGateway::CREATE_CUSTOMER_SESSION,
29
+ {
30
+ "input" => create_input.to_graphql_variables
31
+ }).and_return(response)
32
+
33
+ expect(Braintree::GraphQLClient).to receive(:get_validation_errors).with(response).and_return(nil)
34
+ result = customer_session_gateway.create_customer_session(create_input)
35
+ expect(result).to be_a(Braintree::SuccessfulResult)
36
+ expect(result.session_id).to eq("session-id")
37
+ end
38
+
39
+ it "returns an error result if there are validation errors" do
40
+ create_input = Braintree::CreateCustomerSessionInput.new(input)
41
+ errors = {:errors =>
42
+ [ {:attribute => "", :code => "123", :message => "error"} ]
43
+ }
44
+ expect(graphql_client).to receive(:query).and_return(response)
45
+ expect(Braintree::GraphQLClient).to receive(:get_validation_errors).with(response).and_return(errors)
46
+ result = customer_session_gateway.create_customer_session(create_input)
47
+ expect(result).to be_a(Braintree::ErrorResult)
48
+ expect(result.errors.first.message).to eq("error")
49
+ end
50
+
51
+ it "raises an UnexpectedError if there is a problem parsing the response" do
52
+ create_input = Braintree::CreateCustomerSessionInput.new(input)
53
+ badResonse = {:data => {}}
54
+ expect(graphql_client).to receive(:query).and_return(badResonse)
55
+ expect(Braintree::GraphQLClient).to receive(:get_validation_errors).with(badResonse).and_return(nil)
56
+ expect { customer_session_gateway.create_customer_session(create_input) }.to raise_error(Braintree::UnexpectedError)
57
+ end
58
+ end
59
+
60
+
61
+ describe "#update_customer_session" do
62
+ let(:input) do
63
+ {
64
+ :merchant_account_id => "merchant-account-id", :session_id => "session-id"
65
+ }
66
+ end
67
+ let(:response) do
68
+ {
69
+ data: {
70
+ updateCustomerSession: {
71
+ sessionId: "session-id"
72
+ }
73
+ }
74
+ }
75
+ end
76
+
77
+ it "executes the updateCustomerSession mutation" do
78
+ update_input = Braintree::UpdateCustomerSessionInput.new(input)
79
+ expect(graphql_client).to receive(:query).with(Braintree::CustomerSessionGateway::UPDATE_CUSTOMER_SESSION,
80
+ {
81
+ "input" => update_input.to_graphql_variables
82
+ }).and_return(response)
83
+ expect(Braintree::GraphQLClient).to receive(:get_validation_errors).with(response).and_return(nil)
84
+ result = customer_session_gateway.update_customer_session(update_input)
85
+ expect(result).to be_a(Braintree::SuccessfulResult)
86
+ expect(result.session_id).to eq("session-id")
87
+ end
88
+ end
89
+
90
+ describe "#get_customer_recommendations" do
91
+ let(:customer_recommendations_input) { double(:customer_recommendations_input, to_graphql_variables: {"sessionId" => "session_id", recommendations: ["PAYMENT_RECOMMENDATIONS"]}) }
92
+ let(:response) do
93
+ {
94
+ data: {
95
+ customerRecommendations: {
96
+ isInPayPalNetwork: true,
97
+ recommendations: {
98
+ paymentOptions: [
99
+ {paymentOption: "PAYPAL", recommendedPriority: 1}
100
+ ]
101
+ }
102
+ }
103
+ }
104
+ }
105
+ end
106
+
107
+ it "fetches customer recommendations" do
108
+ expected_variables = {"input" => {"sessionId" => "session_id", recommendations: ["PAYMENT_RECOMMENDATIONS"]}}
109
+ expect(graphql_client).to receive(:query).with(Braintree::CustomerSessionGateway::GET_CUSTOMER_RECOMMENDATIONS, expected_variables).and_return(response)
110
+ expect(Braintree::GraphQLClient).to receive(:get_validation_errors).with(response).and_return(nil)
111
+
112
+ result = customer_session_gateway.get_customer_recommendations(customer_recommendations_input)
113
+ expect(result).to be_a(Braintree::SuccessfulResult)
114
+ expect(result.customer_recommendations.is_in_paypal_network).to eq(true)
115
+ expect(result.customer_recommendations.recommendations.payment_options[0].payment_option).to eq("PAYPAL")
116
+ expect(result.customer_recommendations.recommendations.payment_options[0].recommended_priority).to eq(1)
117
+ end
118
+ end
119
+
120
+ end
@@ -3,8 +3,8 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
3
3
  describe Braintree::Customer do
4
4
  describe "inspect" do
5
5
  it "includes the id first" do
6
- output = Braintree::Customer._new(:gateway, {:first_name => 'Dan', :id => '1234'}).inspect
7
- output.should include("#<Braintree::Customer id: \"1234\",")
6
+ output = Braintree::Customer._new(:gateway, {:first_name => "Dan", :id => "1234"}).inspect
7
+ expect(output).to include("#<Braintree::Customer id: \"1234\",")
8
8
  end
9
9
 
10
10
  it "includes all customer attributes" do
@@ -16,20 +16,26 @@ describe Braintree::Customer do
16
16
  :first_name => "Patrick",
17
17
  :last_name => "Smith",
18
18
  :phone => "802-483-5932",
19
+ :international_phone => {:country_code => "1", :national_number => "3121234567"},
19
20
  :website => "patrick.smith.com",
20
21
  :created_at => Time.now,
21
- :updated_at => Time.now
22
+ :updated_at => Time.now,
22
23
  )
23
24
  output = customer.inspect
24
- output.should include(%q(company: "Company"))
25
- output.should include(%q(email: "e@mail.com"))
26
- output.should include(%q(fax: "483-438-5821"))
27
- output.should include(%q(first_name: "Patrick"))
28
- output.should include(%q(last_name: "Smith"))
29
- output.should include(%q(phone: "802-483-5932"))
30
- output.should include(%q(website: "patrick.smith.com"))
31
- output.should include(%Q(created_at: #{customer.created_at.inspect}))
32
- output.should include(%Q(updated_at: #{customer.updated_at.inspect}))
25
+ expect(output).to include(%q(company: "Company"))
26
+ expect(output).to include(%q(email: "e@mail.com"))
27
+ expect(output).to include(%q(fax: "483-438-5821"))
28
+ expect(output).to include(%q(first_name: "Patrick"))
29
+ expect(output).to include(%q(last_name: "Smith"))
30
+ expect(output).to include(%q(phone: "802-483-5932"))
31
+ expect(output).to include(%q(international_phone: {:country_code=>"1", :national_number=>"3121234567"}))
32
+ expect(output).to include(%q(website: "patrick.smith.com"))
33
+ expect(output).to include(%q(addresses: []))
34
+ expect(output).to include(%q(credit_cards: []))
35
+ expect(output).to include(%q(paypal_accounts: []))
36
+ expect(output).to include(%q(tax_identifiers: []))
37
+ expect(output).to include(%Q(created_at: #{customer.created_at.inspect}))
38
+ expect(output).to include(%Q(updated_at: #{customer.updated_at.inspect}))
33
39
  end
34
40
  end
35
41
 
@@ -41,6 +47,27 @@ describe Braintree::Customer do
41
47
  end
42
48
  end
43
49
 
50
+ describe "self.find" do
51
+ it "raises an exception if the id is blank" do
52
+ expect do
53
+ Braintree::Customer.find(" ")
54
+ end.to raise_error(ArgumentError)
55
+ end
56
+
57
+ it "raises an exception if the id is nil" do
58
+ expect do
59
+ Braintree::Customer.find(nil)
60
+ end.to raise_error(ArgumentError)
61
+ end
62
+
63
+ it "does not raise an exception if the id is a fixnum" do
64
+ allow(Braintree::Http).to receive(:new).and_return double.as_null_object
65
+ expect do
66
+ Braintree::Customer.find(8675309)
67
+ end.to_not raise_error
68
+ end
69
+ end
70
+
44
71
  describe "self.update" do
45
72
  it "raises an exception if hash includes an invalid key" do
46
73
  expect do
@@ -51,15 +78,19 @@ describe Braintree::Customer do
51
78
 
52
79
  describe "self.create_signature" do
53
80
  it "should be what we expect" do
54
- Braintree::CustomerGateway._create_signature.should == [
81
+ expect(Braintree::CustomerGateway._create_signature).to match([
55
82
  :company,
56
83
  :email,
57
84
  :fax,
58
85
  :first_name,
59
86
  :id,
87
+ {:international_phone=>[:country_code, :national_number]},
60
88
  :last_name,
61
89
  :phone,
62
90
  :website,
91
+ :device_data,
92
+ :payment_method_nonce,
93
+ {:risk_data => [:customer_browser, :customer_ip]},
63
94
  {:credit_card => [
64
95
  :billing_address_id,
65
96
  :cardholder_name,
@@ -69,7 +100,12 @@ describe Braintree::Customer do
69
100
  :expiration_year,
70
101
  :number,
71
102
  :token,
72
- {:options => [:make_default, :verification_merchant_account_id, :verify_card]},
103
+ :venmo_sdk_payment_method_code, # NEXT_MAJOR_VERSION Remove this attribute
104
+ :device_data,
105
+ :payment_method_nonce,
106
+ {:external_vault=>[:network_transaction_id]},
107
+ {:options => match_array([:make_default, :skip_advanced_fraud_checking, :verification_merchant_account_id, :verify_card, :verification_amount, :venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
108
+ :fail_on_duplicate_payment_method, :verification_account_type, :verification_currency_iso_code])},
73
109
  {:billing_address => [
74
110
  :company,
75
111
  :country_code_alpha2,
@@ -78,29 +114,80 @@ describe Braintree::Customer do
78
114
  :country_name,
79
115
  :extended_address,
80
116
  :first_name,
117
+ {:international_phone=>[:country_code, :national_number]},
81
118
  :last_name,
82
119
  :locality,
120
+ :phone_number,
83
121
  :postal_code,
84
122
  :region,
85
123
  :street_address
86
- ]}
124
+ ]},
125
+ {:three_d_secure_pass_thru => [
126
+ :eci_flag,
127
+ :cavv,
128
+ :xid,
129
+ :three_d_secure_version,
130
+ :authentication_response,
131
+ :directory_response,
132
+ :cavv_algorithm,
133
+ :ds_transaction_id,
134
+ ]},
135
+ ]},
136
+ {:paypal_account => [
137
+ :email,
138
+ :token,
139
+ :billing_agreement_id,
140
+ {:options => [:make_default]},
87
141
  ]},
142
+ {:tax_identifiers => [
143
+ :country_code,
144
+ :identifier
145
+ ]},
146
+ {:options =>
147
+ [:paypal => [
148
+ :payee_email,
149
+ :order_id,
150
+ :custom_field,
151
+ :description,
152
+ :amount,
153
+ {:shipping => [
154
+ :company,
155
+ :country_code_alpha2,
156
+ :country_code_alpha3,
157
+ :country_code_numeric,
158
+ :country_name,
159
+ :extended_address,
160
+ :first_name,
161
+ {:international_phone=>[:country_code, :national_number]},
162
+ :last_name,
163
+ :locality,
164
+ :phone_number,
165
+ :postal_code,
166
+ :region,
167
+ :street_address,
168
+ ]}
169
+ ]]
170
+ },
88
171
  {:custom_fields => :_any_key_}
89
- ]
172
+ ])
90
173
  end
91
174
  end
92
175
 
93
176
  describe "self.update_signature" do
94
177
  it "should be what we expect" do
95
- Braintree::CustomerGateway._update_signature.should == [
178
+ expect(Braintree::CustomerGateway._update_signature).to match([
96
179
  :company,
97
180
  :email,
98
181
  :fax,
99
182
  :first_name,
100
183
  :id,
184
+ {:international_phone=>[:country_code, :national_number]},
101
185
  :last_name,
102
186
  :phone,
103
187
  :website,
188
+ :device_data,
189
+ :payment_method_nonce,
190
+ :default_payment_method_token,
104
191
  {:credit_card => [
105
192
  :billing_address_id,
106
193
  :cardholder_name,
@@ -110,12 +197,23 @@ describe Braintree::Customer do
110
197
  :expiration_year,
111
198
  :number,
112
199
  :token,
113
- {:options => [
200
+ :venmo_sdk_payment_method_code, # NEXT_MAJOR_VERSION Remove this attribute
201
+ :device_data,
202
+ :payment_method_nonce,
203
+ {:external_vault=>[:network_transaction_id]},
204
+ {:options => match_array([
114
205
  :make_default,
206
+ :skip_advanced_fraud_checking,
115
207
  :verification_merchant_account_id,
116
208
  :verify_card,
209
+ :verification_amount,
210
+ :venmo_sdk_session, # NEXT_MAJOR_VERSION Remove this attribute
211
+ :fail_on_duplicate_payment_method,
212
+ :fail_on_duplicate_payment_method_for_customer,
213
+ :verification_account_type,
214
+ :verification_currency_iso_code,
117
215
  :update_existing_token
118
- ]},
216
+ ])},
119
217
  {:billing_address => [
120
218
  :company,
121
219
  :country_code_alpha2,
@@ -124,24 +222,57 @@ describe Braintree::Customer do
124
222
  :country_name,
125
223
  :extended_address,
126
224
  :first_name,
225
+ {:international_phone=>[:country_code, :national_number]},
127
226
  :last_name,
128
227
  :locality,
228
+ :phone_number,
129
229
  :postal_code,
130
230
  :region,
131
231
  :street_address,
132
232
  {:options => [:update_existing]}
133
- ]}
233
+ ]},
234
+ {:three_d_secure_pass_thru => [
235
+ :eci_flag,
236
+ :cavv,
237
+ :xid,
238
+ :three_d_secure_version,
239
+ :authentication_response,
240
+ :directory_response,
241
+ :cavv_algorithm,
242
+ :ds_transaction_id,
243
+ ]},
134
244
  ]},
245
+ {:tax_identifiers => [
246
+ :country_code,
247
+ :identifier
248
+ ]},
249
+ {:options =>
250
+ [:paypal => [
251
+ :payee_email,
252
+ :order_id,
253
+ :custom_field,
254
+ :description,
255
+ :amount,
256
+ {:shipping => [
257
+ :company,
258
+ :country_code_alpha2,
259
+ :country_code_alpha3,
260
+ :country_code_numeric,
261
+ :country_name,
262
+ :extended_address,
263
+ :first_name,
264
+ {:international_phone=>[:country_code, :national_number]},
265
+ :last_name,
266
+ :locality,
267
+ :phone_number,
268
+ :postal_code,
269
+ :region,
270
+ :street_address,
271
+ ]}
272
+ ]]
273
+ },
135
274
  {:custom_fields => :_any_key_}
136
- ]
137
- end
138
- end
139
-
140
- describe "self.create_from_transparent_redirect" do
141
- it "raises an exception if the query string is forged" do
142
- expect do
143
- Braintree::Customer.create_from_transparent_redirect("http_status=200&forged=query_string")
144
- end.to raise_error(Braintree::ForgedQueryString)
275
+ ])
145
276
  end
146
277
  end
147
278
 
@@ -150,21 +281,21 @@ describe Braintree::Customer do
150
281
  first = Braintree::Customer._new(:gateway, :id => 123)
151
282
  second = Braintree::Customer._new(:gateway, :id => 123)
152
283
 
153
- first.should == second
154
- second.should == first
284
+ expect(first).to eq(second)
285
+ expect(second).to eq(first)
155
286
  end
156
287
 
157
288
  it "returns false when given a customer with a different id" do
158
289
  first = Braintree::Customer._new(:gateway, :id => 123)
159
290
  second = Braintree::Customer._new(:gateway, :id => 124)
160
291
 
161
- first.should_not == second
162
- second.should_not == first
292
+ expect(first).not_to eq(second)
293
+ expect(second).not_to eq(first)
163
294
  end
164
295
 
165
296
  it "returns false when not given a customer" do
166
297
  customer = Braintree::Customer._new(:gateway, :id => 123)
167
- customer.should_not == "not a customer"
298
+ expect(customer).not_to eq("not a customer")
168
299
  end
169
300
  end
170
301
 
@@ -173,13 +304,38 @@ describe Braintree::Customer do
173
304
  customer = Braintree::Customer._new(
174
305
  :gateway,
175
306
  :credit_cards => [
176
- {:token => "pm1"},
177
- {:token => "pm2"}
178
- ]
307
+ {:token => "credit_card_1"},
308
+ {:token => "credit_card_2"}
309
+ ],
310
+ :paypal_accounts => [
311
+ {:token => "paypal_1"},
312
+ {:token => "paypal_2"}
313
+ ],
314
+ :sepa_debit_accounts => [
315
+ {:token => "sepa_debit_1"},
316
+ {:token => "sepa_debit_2"}
317
+ ],
179
318
  )
180
- customer.credit_cards.size.should == 2
181
- customer.credit_cards[0].token.should == "pm1"
182
- customer.credit_cards[1].token.should == "pm2"
319
+
320
+ expect(customer.credit_cards.size).to eq(2)
321
+ expect(customer.credit_cards[0].token).to eq("credit_card_1")
322
+ expect(customer.credit_cards[1].token).to eq("credit_card_2")
323
+
324
+ expect(customer.paypal_accounts.size).to eq(2)
325
+ expect(customer.paypal_accounts[0].token).to eq("paypal_1")
326
+ expect(customer.paypal_accounts[1].token).to eq("paypal_2")
327
+
328
+ expect(customer.sepa_direct_debit_accounts.size).to eq(2)
329
+ expect(customer.sepa_direct_debit_accounts[0].token).to eq("sepa_debit_1")
330
+ expect(customer.sepa_direct_debit_accounts[1].token).to eq("sepa_debit_2")
331
+
332
+ expect(customer.payment_methods.count).to eq(6)
333
+ expect(customer.payment_methods.map(&:token)).to include("credit_card_1")
334
+ expect(customer.payment_methods.map(&:token)).to include("credit_card_2")
335
+ expect(customer.payment_methods.map(&:token)).to include("paypal_1")
336
+ expect(customer.payment_methods.map(&:token)).to include("paypal_2")
337
+ expect(customer.payment_methods.map(&:token)).to include("sepa_debit_1")
338
+ expect(customer.payment_methods.map(&:token)).to include("sepa_debit_2")
183
339
  end
184
340
  end
185
341
 
@@ -3,21 +3,34 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
3
3
  describe Braintree::Digest do
4
4
  describe "self.hexdigest" do
5
5
  it "returns the sha1 hmac of the input string (test case 6 from RFC 2202)" do
6
- original_key = Braintree::Configuration.private_key
7
6
  private_key = "\xaa" * 80
8
7
  data = "Test Using Larger Than Block-Size Key - Hash Key First"
9
- Braintree::Digest.hexdigest(private_key, data).should == "aa4ae5e15272d00e95705637ce8a3b55ed402112"
8
+ expect(Braintree::Digest.hexdigest(private_key, data)).to eq("aa4ae5e15272d00e95705637ce8a3b55ed402112")
10
9
  end
11
10
 
12
11
  it "returns the sha1 hmac of the input string (test case 7 from RFC 2202)" do
13
12
  private_key = "\xaa" * 80
14
13
  data = "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data"
15
- Braintree::Digest.hexdigest(private_key, data).should == "e8e99d0f45237d786d6bbaa7965c7808bbff1a91"
14
+ expect(Braintree::Digest.hexdigest(private_key, data)).to eq("e8e99d0f45237d786d6bbaa7965c7808bbff1a91")
16
15
  end
17
16
 
18
17
  it "doesn't blow up if message is nil" do
19
18
  expect { Braintree::Digest.hexdigest("key", nil) }.to_not raise_error
20
19
  end
21
20
  end
21
+
22
+ describe "self.secure_compare" do
23
+ it "returns true if two strings are equal" do
24
+ expect(Braintree::Digest.secure_compare("A_string", "A_string")).to be(true)
25
+ end
26
+
27
+ it "returns false if two strings are different and the same length" do
28
+ expect(Braintree::Digest.secure_compare("A_string", "A_strong")).to be(false)
29
+ end
30
+
31
+ it "returns false if one is a prefix of the other" do
32
+ expect(Braintree::Digest.secure_compare("A_string", "A_string_that_is_longer")).to be(false)
33
+ end
34
+ end
22
35
  end
23
36
 
@@ -0,0 +1,131 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::Disbursement do
4
+ describe "new" do
5
+ it "is protected" do
6
+ expect do
7
+ Braintree::Disbursement.new
8
+ end.to raise_error(NoMethodError, /protected method .new/)
9
+ end
10
+ end
11
+
12
+ describe "inspect" do
13
+ it "prints attributes of disbursement object" do
14
+ disbursement = Braintree::Disbursement._new(
15
+ :gateway,
16
+ :id => "123456",
17
+ :merchant_account => {
18
+ :id => "sandbox_sub_merchant_account",
19
+ :master_merchant_account => {
20
+ :id => "sandbox_master_merchant_account",
21
+ :status => "active"
22
+ },
23
+ :status => "active"
24
+ },
25
+ :transaction_ids => ["sub_merchant_transaction"],
26
+ :amount => "100.00",
27
+ :disbursement_date => "2013-04-10",
28
+ :exception_message => "invalid_account_number",
29
+ :follow_up_action => "update",
30
+ :retry => false,
31
+ :success => false,
32
+ )
33
+
34
+ expect(disbursement.inspect).to include('id: "123456"')
35
+ expect(disbursement.inspect).to include('amount: "100.0"')
36
+ expect(disbursement.inspect).to include('exception_message: "invalid_account_number"')
37
+ expect(disbursement.inspect).to include("disbursement_date: 2013-04-10")
38
+ expect(disbursement.inspect).to include('follow_up_action: "update"')
39
+ expect(disbursement.inspect).to include("merchant_account: #<Braintree::MerchantAccount: ")
40
+ expect(disbursement.inspect).to include('transaction_ids: ["sub_merchant_transaction"]')
41
+ expect(disbursement.inspect).to include("retry: false")
42
+ expect(disbursement.inspect).to include("success: false")
43
+ end
44
+ end
45
+
46
+ describe "success?" do
47
+ it "is an alias of success" do
48
+ disbursement = Braintree::Disbursement._new(
49
+ :gateway,
50
+ :merchant_account => {
51
+ :id => "sandbox_sub_merchant_account",
52
+ :master_merchant_account => {
53
+ :id => "sandbox_master_merchant_account",
54
+ :status => "active"
55
+ },
56
+ :status => "active"
57
+ },
58
+ :success => false,
59
+ :disbursement_date => "2013-04-10",
60
+ )
61
+ expect(disbursement.success?).to eq(false)
62
+
63
+ disbursement = Braintree::Disbursement._new(
64
+ :gateway,
65
+ :merchant_account => {
66
+ :id => "sandbox_sub_merchant_account",
67
+ :master_merchant_account => {
68
+ :id => "sandbox_master_merchant_account",
69
+ :status => "active"
70
+ },
71
+ :status => "active"
72
+ },
73
+ :success => true,
74
+ :disbursement_date => "2013-04-10",
75
+ )
76
+ expect(disbursement.success?).to eq(true)
77
+ end
78
+ end
79
+
80
+ describe "credit?" do
81
+ subject do
82
+ described_class._new(
83
+ :gateway,
84
+ merchant_account: {
85
+ id: "sandbox_master_merchant_account",
86
+ status: "active",
87
+ },
88
+ success: true,
89
+ amount: "100.00",
90
+ disbursement_type: type,
91
+ disbursement_date: "2013-04-10",
92
+ )
93
+ end
94
+
95
+ context "when the disbursement type is credit" do
96
+ let(:type) { described_class::Types::Credit }
97
+ it { is_expected.to be_credit }
98
+ end
99
+
100
+ context "when the disbursement type is not credit" do
101
+ let(:type) { described_class::Types::Debit }
102
+ it { is_expected.not_to be_credit }
103
+ end
104
+ end
105
+
106
+ describe "debit?" do
107
+ subject do
108
+ described_class._new(
109
+ :gateway,
110
+ merchant_account: {
111
+ id: "sandbox_master_merchant_account",
112
+ status: "active",
113
+ },
114
+ success: true,
115
+ amount: "100.00",
116
+ disbursement_type: type,
117
+ disbursement_date: "2013-04-10",
118
+ )
119
+ end
120
+
121
+ context "when the disbursement type is debit" do
122
+ let(:type) { described_class::Types::Debit }
123
+ it { is_expected.to be_debit }
124
+ end
125
+
126
+ context "when the disbursement type is not debit" do
127
+ let(:type) { described_class::Types::Credit }
128
+ it { is_expected.not_to be_debit }
129
+ end
130
+ end
131
+ end