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
@@ -4,26 +4,26 @@ describe Braintree::Errors do
4
4
  describe "for" do
5
5
  it "accesses errors for the given scope" do
6
6
  errors = Braintree::Errors.new(
7
- :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]}
7
+ :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]},
8
8
  )
9
- errors.for(:level1).size.should == 1
10
- errors.for(:level1)[0].code.should == "code1"
9
+ expect(errors.for(:level1).size).to eq(1)
10
+ expect(errors.for(:level1)[0].code).to eq("code1")
11
11
  end
12
12
 
13
13
  it "returns nil if there are no errors at the given scope" do
14
14
  errors = Braintree::Errors.new(
15
- :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]}
15
+ :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]},
16
16
  )
17
- errors.for(:no_errors_here).should == nil
17
+ expect(errors.for(:no_errors_here)).to eq(nil)
18
18
  end
19
19
  end
20
20
 
21
21
  describe "inspect" do
22
22
  it "is better than the default inspect" do
23
23
  errors = Braintree::Errors.new(
24
- :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]}
24
+ :level1 => {:errors => [{:code => "code1", :attribute => "attr", :message => "message"}]},
25
25
  )
26
- errors.inspect.should == "#<Braintree::Errors level1:[(code1) message]>"
26
+ expect(errors.inspect).to eq("#<Braintree::Errors level1:[(code1) message]>")
27
27
  end
28
28
 
29
29
  it "shows errors 2 levels deep" do
@@ -33,9 +33,9 @@ describe Braintree::Errors do
33
33
  :level2 => {
34
34
  :errors => [{:code => "code2", :attribute => "attr2", :message => "message2"}],
35
35
  }
36
- }
36
+ },
37
37
  )
38
- errors.inspect.should == "#<Braintree::Errors level1:[(code1) message], level1/level2:[(code2) message2]>"
38
+ expect(errors.inspect).to eq("#<Braintree::Errors level1:[(code1) message], level1/level2:[(code2) message2]>")
39
39
  end
40
40
 
41
41
  it "shows errors 3 levels deep" do
@@ -48,9 +48,9 @@ describe Braintree::Errors do
48
48
  :errors => [{:code => "code3", :attribute => "attr3", :message => "message3"}],
49
49
  }
50
50
  }
51
- }
51
+ },
52
52
  )
53
- errors.inspect.should == "#<Braintree::Errors level1:[(code1) message], level1/level2:[(code2) message2], level1/level2/level3:[(code3) message3]>"
53
+ expect(errors.inspect).to eq("#<Braintree::Errors level1:[(code1) message], level1/level2:[(code2) message2], level1/level2/level3:[(code3) message3]>")
54
54
  end
55
55
  end
56
56
 
@@ -65,18 +65,18 @@ describe Braintree::Errors do
65
65
  {:code => "3", :attribute => "attr3", :message => "message3"}
66
66
  ],
67
67
  }
68
- }
68
+ },
69
69
  )
70
- errors.map { |e| e.code }.sort.should == %w[1 2 3]
70
+ expect(errors.map { |e| e.code }.sort).to eq(%w[1 2 3])
71
71
  end
72
72
  end
73
73
 
74
74
  describe "size" do
75
75
  it "returns the number of validation errors at the first level if only has one level" do
76
76
  errors = Braintree::Errors.new(
77
- :level1 => {:errors => [{:code => "1", :attribute => "attr", :message => "message"}]}
77
+ :level1 => {:errors => [{:code => "1", :attribute => "attr", :message => "message"}]},
78
78
  )
79
- errors.size.should == 1
79
+ expect(errors.size).to eq(1)
80
80
  end
81
81
 
82
82
  it "returns the total number of validation errors in the hierarchy" do
@@ -89,9 +89,9 @@ describe Braintree::Errors do
89
89
  {:code => "3", :attribute => "attr3", :message => "message3"}
90
90
  ],
91
91
  }
92
- }
92
+ },
93
93
  )
94
- errors.size.should == 3
94
+ expect(errors.size).to eq(3)
95
95
  end
96
96
  end
97
97
  end
@@ -0,0 +1,42 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::ExchangeRateQuoteInput do
4
+ let(:exchange_rate_quote_input) do
5
+ {
6
+ base_currency: "USD",
7
+ quote_currency: "EUR",
8
+ base_amount: "10.00",
9
+ markup: "2.00"
10
+ }
11
+ end
12
+
13
+ describe "#initialize" do
14
+ it "initialize and sets the input keys to attrs variable" do
15
+ quote_input = described_class.new(exchange_rate_quote_input)
16
+
17
+ expect(quote_input.attrs).to include(:base_currency)
18
+ expect(quote_input.attrs).to include(:quote_currency)
19
+ expect(quote_input.attrs).to include(:base_amount)
20
+ expect(quote_input.attrs).to include(:markup)
21
+ expect(quote_input.attrs.length).to eq(4)
22
+ end
23
+ end
24
+
25
+ describe "inspect" do
26
+ it "includes the base_currency first" do
27
+ output = described_class.new(base_currency: "USD").inspect
28
+
29
+ expect(output).to include("#<Braintree::ExchangeRateQuoteInput base_currency:\"USD\">")
30
+ end
31
+
32
+ it "includes all quote input attributes" do
33
+ quote_input = described_class.new(exchange_rate_quote_input)
34
+ output = quote_input.inspect
35
+
36
+ expect(output).to include("base_currency:\"USD\"")
37
+ expect(output).to include("quote_currency:\"EUR\"")
38
+ expect(output).to include("base_amount:\"10.00\"")
39
+ expect(output).to include("markup:\"2.00\"")
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,82 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::ExchangeRateQuoteRequest do
4
+ describe "#initialize" do
5
+ it "creates and validates the exchange rate quote request" do
6
+ req = Braintree::ExchangeRateQuoteRequest.new(
7
+ :quotes => [
8
+ {
9
+ :base_currency => "USD",
10
+ :quote_currency => "EUR",
11
+ :base_amount => "10.00",
12
+ :markup => "2.00"
13
+ },
14
+ {
15
+ :base_currency => "EUR",
16
+ :quote_currency => "GBP",
17
+ :base_amount => "20.00",
18
+ :markup => "4.00"
19
+ }
20
+ ],
21
+ )
22
+
23
+ expect(req.quotes[0].base_currency).to eq("USD")
24
+ expect(req.quotes[0].quote_currency).to eq("EUR")
25
+ expect(req.quotes[0].base_amount).to eq("10.00")
26
+ expect(req.quotes[0].markup).to eq("2.00")
27
+
28
+ expect(req.quotes[1].base_currency).to eq("EUR")
29
+ expect(req.quotes[1].quote_currency).to eq("GBP")
30
+ expect(req.quotes[1].base_amount).to eq("20.00")
31
+ expect(req.quotes[1].markup).to eq("4.00")
32
+ end
33
+
34
+ it "creates and validates the exchange rate quote request without amount and markup" do
35
+ req = Braintree::ExchangeRateQuoteRequest.new(
36
+ :quotes => [
37
+ {
38
+ :base_currency => "USD",
39
+ :quote_currency => "EUR",
40
+ },
41
+ {
42
+ :base_currency => "EUR",
43
+ :quote_currency => "GBP",
44
+ }
45
+ ],
46
+ )
47
+
48
+ expect(req.quotes[0].base_currency).to eq("USD")
49
+ expect(req.quotes[0].quote_currency).to eq("EUR")
50
+ expect(req.quotes[0].base_amount).to be_nil
51
+ expect(req.quotes[0].markup).to be_nil
52
+
53
+ expect(req.quotes[1].base_currency).to eq("EUR")
54
+ expect(req.quotes[1].quote_currency).to eq("GBP")
55
+ expect(req.quotes[1].base_amount).to be_nil
56
+ expect(req.quotes[1].markup).to be_nil
57
+ end
58
+
59
+ end
60
+
61
+ describe "inspect" do
62
+ it "prints the attributes" do
63
+ exchange_rate_req = Braintree::ExchangeRateQuoteRequest.new(
64
+ :quotes => [
65
+ {
66
+ :base_currency => "USD",
67
+ :quote_currency => "EUR",
68
+ :base_amount => "10.00",
69
+ :markup => "2.00"
70
+ },
71
+ {
72
+ :base_currency => "EUR",
73
+ :quote_currency => "GBP",
74
+ :base_amount => "20.00",
75
+ :markup => "4.00"
76
+ }
77
+ ],
78
+ )
79
+ expect(exchange_rate_req.inspect).to eq(%(#<Braintree::ExchangeRateQuoteRequest quotes:[#<Braintree::ExchangeRateQuoteInput base_currency:"USD" quote_currency:"EUR" base_amount:"10.00" markup:"2.00">, #<Braintree::ExchangeRateQuoteInput base_currency:"EUR" quote_currency:"GBP" base_amount:"20.00" markup:"4.00">]>))
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,52 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::ExchangeRateQuoteResponse do
4
+ describe "#initialize" do
5
+ it "creates and validated the exchange rate quote payload" do
6
+ quote_payload = Braintree::ExchangeRateQuoteResponse.new(
7
+ quotes: [
8
+ {
9
+ :base_amount => "10.00",
10
+ :quote_amount => "9.03",
11
+ :exchange_rate => "0.90"
12
+ },
13
+ {
14
+ :base_amount => "20.00",
15
+ :quote_amount => "18.06",
16
+ :exchange_rate => "0.90"
17
+ }
18
+ ],
19
+ )
20
+
21
+ quote_1 = quote_payload.quotes[0]
22
+ quote_2 = quote_payload.quotes[1]
23
+
24
+ expect(quote_1.base_amount).to eq("10.00")
25
+ expect(quote_1.quote_amount).to eq("9.03")
26
+ expect(quote_1.exchange_rate).to eq("0.90")
27
+
28
+ expect(quote_2.base_amount).to eq("20.00")
29
+ expect(quote_2.quote_amount).to eq("18.06")
30
+ expect(quote_1.exchange_rate).to eq("0.90")
31
+ end
32
+ end
33
+
34
+ describe "inspect" do
35
+ it "prints the attributes" do
36
+ exchange_rate_quote_payload = Braintree::ExchangeRateQuoteResponse.new(
37
+ quotes: [
38
+ {
39
+ :base_amount => "10.00",
40
+ :quote_amount => "9.03"
41
+ },
42
+ {
43
+ :base_amount => "20.00",
44
+ :quote_amount => "18.06"
45
+ }
46
+ ],
47
+ )
48
+
49
+ expect(exchange_rate_quote_payload.inspect).to eq(%(#<Braintree::ExchangeRateQuoteResponse quotes:[#<Braintree::ExchangeRateQuote base_amount:"10.00" quote_amount:"9.03">, #<Braintree::ExchangeRateQuote base_amount:"20.00" quote_amount:"18.06">]>))
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,42 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::ExchangeRateQuote do
4
+ let(:rate_quote) do
5
+ {
6
+ id: "1234",
7
+ base_amount: "10.00",
8
+ exchange_rate: "74",
9
+ quote_amount: "740"
10
+ }
11
+ end
12
+
13
+ describe "#initialize" do
14
+ it "initialize and sets the input keys to attrs variable" do
15
+ quote = described_class.new(rate_quote)
16
+
17
+ expect(quote.attrs).to include(:id)
18
+ expect(quote.attrs).to include(:base_amount)
19
+ expect(quote.attrs).to include(:exchange_rate)
20
+ expect(quote.attrs).to include(:quote_amount)
21
+ expect(quote.attrs.length).to eq(4)
22
+ end
23
+ end
24
+
25
+ describe "inspect" do
26
+ it "includes the id first" do
27
+ output = described_class.new(id: "1234").inspect
28
+
29
+ expect(output).to include("#<Braintree::ExchangeRateQuote id:\"1234\">")
30
+ end
31
+
32
+ it "includes all quote attributes" do
33
+ quote = described_class.new(rate_quote)
34
+ output = quote.inspect
35
+
36
+ expect(output).to include("id:\"1234\"")
37
+ expect(output).to include("base_amount:\"10.00\"")
38
+ expect(output).to include("exchange_rate:\"74\"")
39
+ expect(output).to include("quote_amount:\"740\"")
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe ::Braintree::ExchangeRate do
4
+ let(:rate_quote) do
5
+ {
6
+ id: "1234",
7
+ base_amount: "10.00",
8
+ exchange_rate: "74",
9
+ quote_amount: "740"
10
+ }
11
+ end
12
+
13
+ describe "#initialize" do
14
+ it "initialize and sets the attributes" do
15
+ exchange_rate = described_class.new(:gateway, rate_quote).inspect
16
+
17
+ expect(exchange_rate).to include("@id=\"1234\"")
18
+ expect(exchange_rate).to include("@base_amount=\"10.00\"")
19
+ expect(exchange_rate).to include("@exchange_rate=\"74\"")
20
+ expect(exchange_rate).to include("@quote_amount=\"740\"")
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,8 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Braintree::GooglePayCard do
4
+ it "initializes prepaid reloadable correctly" do
5
+ card = Braintree::GooglePayCard._new(:gateway, {:prepaid_reloadable => "No"})
6
+ expect(card.prepaid_reloadable).to eq("No")
7
+ end
8
+ end
@@ -0,0 +1,81 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
+
3
+
4
+ describe Braintree::CreateCustomerSessionInput do
5
+ let(:input_data) do
6
+ {
7
+ merchant_account_id: "merchant-account-id",
8
+ session_id: "session-id",
9
+ customer: {
10
+ email: "test@example.com" ,
11
+ },
12
+ domain: "example.com"
13
+ }
14
+ end
15
+
16
+ describe "#initialize" do
17
+ it "initializes with attributes" do
18
+ input = Braintree::CreateCustomerSessionInput.new(input_data)
19
+
20
+ expect(input.attrs).to eq(input_data.keys)
21
+ expect(input.merchant_account_id).to eq("merchant-account-id")
22
+ expect(input.session_id).to eq("session-id")
23
+ expect(input.customer).to be_a(Braintree::CustomerSessionInput)
24
+ expect(input.customer.email).to eq("test@example.com")
25
+ expect(input.domain).to eq("example.com")
26
+ end
27
+
28
+ it "handles nil customer" do
29
+ attributes = {merchant_account_id: "merchant-account-id"}
30
+ input = Braintree::CreateCustomerSessionInput.new(attributes)
31
+ expect(input.customer).to be_nil
32
+ end
33
+ end
34
+
35
+
36
+ describe "#inspect" do
37
+ it "returns a string representation of the object" do
38
+ input = Braintree::CreateCustomerSessionInput.new(input_data)
39
+ expected_string = "#<Braintree::CreateCustomerSessionInput merchant_account_id:\"merchant-account-id\" session_id:\"session-id\" customer:#<Braintree::CustomerSessionInput email:\"test@example.com\"> domain:\"example.com\">"
40
+ expect(input.inspect).to eq(expected_string)
41
+
42
+ end
43
+
44
+ it "handles nil values" do
45
+ attributes = {
46
+ merchant_account_id: "merchant-account-id",
47
+ session_id: nil,
48
+ customer: nil
49
+ }
50
+ input = Braintree::CreateCustomerSessionInput.new(attributes)
51
+ expected_string = "#<Braintree::CreateCustomerSessionInput merchant_account_id:\"merchant-account-id\" session_id:nil customer:nil>"
52
+
53
+ expect(input.inspect).to eq(expected_string)
54
+ end
55
+
56
+ end
57
+
58
+ describe "#to_graphql_variables" do
59
+ it "converts the input to graphql variables" do
60
+ input = Braintree::CreateCustomerSessionInput.new(input_data)
61
+ expected_variables = {
62
+ "merchantAccountId" => "merchant-account-id",
63
+ "sessionId" => "session-id",
64
+ "domain" => "example.com",
65
+ "customer" => {"email" => "test@example.com"}
66
+ }
67
+
68
+ expect(input.to_graphql_variables).to eq(expected_variables)
69
+
70
+
71
+ end
72
+
73
+ it "handles nil values" do
74
+ attributes = {merchant_account_id: "merchant-account-id"}
75
+ input = Braintree::CreateCustomerSessionInput.new(attributes)
76
+ expected_variables = {"merchantAccountId" => "merchant-account-id"}
77
+
78
+ expect(input.to_graphql_variables).to eq(expected_variables)
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,110 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
+
3
+
4
+ describe Braintree::CustomerRecommendationsInput do
5
+ let(:input_data) do
6
+ {
7
+ merchant_account_id: "merchant-account-id",
8
+ session_id: "session-id",
9
+ recommendations: ["PAYMENT_RECOMMENDATIONS"],
10
+ customer: {email: "test@example.com"}
11
+ }
12
+ end
13
+ describe "#initialize" do
14
+ it "initializes with attributes" do
15
+ input = Braintree::CustomerRecommendationsInput.new(input_data)
16
+
17
+ expect(input.attrs).to eq(input_data.keys)
18
+ expect(input.merchant_account_id).to eq("merchant-account-id")
19
+ expect(input.session_id).to eq("session-id")
20
+ expect(input.customer).to be_a(Braintree::CustomerSessionInput)
21
+ expect(input.recommendations[0]).to eq("PAYMENT_RECOMMENDATIONS")
22
+ end
23
+
24
+ it "disallows nil session id" do
25
+ attributes = {
26
+ merchant_account_id: "merchant-account-id",
27
+ recommendations: ["PAYMENT_RECOMMENDATIONS"],
28
+ }
29
+ expect do
30
+ Braintree::CustomerRecommendationsInput.new(attributes)
31
+ end.to raise_error(ArgumentError, "Expected hash to contain a :session_id")
32
+ end
33
+
34
+ it "disallows nil recommendations" do
35
+ attributes = {
36
+ merchant_account_id: "merchant-account-id",
37
+ session_id: "session-id",
38
+ }
39
+ expect do
40
+ Braintree::CustomerRecommendationsInput.new(attributes)
41
+ end.to raise_error(ArgumentError, "Expected hash to contain a :recommendations")
42
+ end
43
+
44
+ it "handles nil customer" do
45
+ attributes = {
46
+ merchant_account_id: "merchant-account-id",
47
+ session_id: "session-id",
48
+ recommendations: ["PAYMENT_RECOMMENDATIONS"],
49
+ }
50
+ input = Braintree::CustomerRecommendationsInput.new(attributes)
51
+
52
+ expect(input.customer).to be_nil
53
+ end
54
+ end
55
+
56
+
57
+ describe "#inspect" do
58
+ it "returns a string representation of the object" do
59
+ input = Braintree::CustomerRecommendationsInput.new(input_data)
60
+ expected_string = "#<Braintree::CustomerRecommendationsInput merchant_account_id:\"merchant-account-id\" session_id:\"session-id\" recommendations:[\"PAYMENT_RECOMMENDATIONS\"] customer:#<Braintree::CustomerSessionInput email:\"test@example.com\">>"
61
+ expect(input.inspect).to eq(expected_string)
62
+
63
+ end
64
+
65
+ it "handles nil values" do
66
+ attributes = {
67
+ merchant_account_id: "merchant-account-id",
68
+ session_id: "session-id",
69
+ recommendations: ["PAYMENT_RECOMMENDATIONS"],
70
+ }
71
+ input = Braintree::CustomerRecommendationsInput.new(attributes)
72
+ expected_string = "#<Braintree::CustomerRecommendationsInput merchant_account_id:\"merchant-account-id\" session_id:\"session-id\" recommendations:[\"PAYMENT_RECOMMENDATIONS\"]>"
73
+
74
+ expect(input.inspect).to eq(expected_string)
75
+ end
76
+
77
+ end
78
+
79
+ describe "#to_graphql_variables" do
80
+ it "converts the input to graphql variables" do
81
+ input = Braintree::CustomerRecommendationsInput.new(input_data)
82
+ expected_variables = {
83
+ "merchantAccountId" => "merchant-account-id",
84
+ "sessionId" => "session-id",
85
+ "customer" => {"email" => "test@example.com"},
86
+ "recommendations" => ["PAYMENT_RECOMMENDATIONS"],
87
+ }
88
+
89
+ expect(input.to_graphql_variables).to eq(expected_variables)
90
+ end
91
+
92
+ it "handles nil values" do
93
+ attributes = {
94
+ merchant_account_id: "merchant-account-id",
95
+ session_id: "session-id",
96
+ recommendations: ["PAYMENT_RECOMMENDATIONS"],
97
+ }
98
+ input = Braintree::CustomerRecommendationsInput.new(attributes)
99
+
100
+ expected_variables = {
101
+ "merchantAccountId" => "merchant-account-id",
102
+ "sessionId" => "session-id",
103
+ "recommendations" => ["PAYMENT_RECOMMENDATIONS"],
104
+ }
105
+
106
+ expect(input.to_graphql_variables).to eq(expected_variables)
107
+ end
108
+ end
109
+
110
+ end
@@ -0,0 +1,81 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
+
3
+
4
+ describe Braintree::CustomerSessionInput do
5
+ let(:input_data) do
6
+ {
7
+ email: "test@example.com" ,
8
+ phone: {
9
+ country_phone_code: "1",
10
+ phone_number: "555-123-4567",
11
+ extension_number: "123",
12
+ },
13
+ user_agent: "Mozilla"
14
+ }
15
+ end
16
+
17
+ describe "#initialize" do
18
+ it "initializes with attributes" do
19
+ input = Braintree::CustomerSessionInput.new(input_data)
20
+
21
+ expect(input.attrs).to eq(input_data.keys)
22
+ expect(input.email).to eq("test@example.com")
23
+ expect(input.phone.country_phone_code).to eq("1")
24
+ expect(input.phone.phone_number).to eq("555-123-4567")
25
+ expect(input.phone.extension_number).to eq("123")
26
+ expect(input.user_agent).to eq("Mozilla")
27
+ end
28
+
29
+ it "handles nil email" do
30
+ attributes = {}
31
+ input = Braintree::CustomerSessionInput.new(attributes)
32
+ expect(input.email).to be_nil
33
+ end
34
+ end
35
+
36
+
37
+ describe "#inspect" do
38
+ it "returns a string representation of the object" do
39
+ input = Braintree::CustomerSessionInput.new(input_data)
40
+ expected_string = "#<Braintree::CustomerSessionInput email:\"test@example.com\" phone:#<Braintree::PhoneInput country_phone_code:\"1\" phone_number:\"555-123-4567\" extension_number:\"123\"> user_agent:\"Mozilla\">"
41
+ expect(input.inspect).to eq(expected_string)
42
+
43
+ end
44
+
45
+ it "handles nil values" do
46
+ attributes = {}
47
+ input = Braintree::CustomerSessionInput.new(attributes)
48
+ expected_string = "#<Braintree::CustomerSessionInput >"
49
+
50
+ expect(input.inspect).to eq(expected_string)
51
+ end
52
+
53
+ end
54
+
55
+ describe "#to_graphql_variables" do
56
+ it "converts the input to graphql variables" do
57
+ input = Braintree::CustomerSessionInput.new(input_data)
58
+ expected_variables = {
59
+ "email" => "test@example.com",
60
+ "phone" => {
61
+ "countryPhoneCode" => "1",
62
+ "phoneNumber" => "555-123-4567",
63
+ "extensionNumber" => "123"
64
+ },
65
+ "userAgent" => "Mozilla"
66
+ }
67
+
68
+ expect(input.to_graphql_variables).to eq(expected_variables)
69
+
70
+
71
+ end
72
+
73
+ it "handles nil values" do
74
+ attributes = {}
75
+ input = Braintree::CustomerSessionInput.new(attributes)
76
+ expected_variables = {}
77
+
78
+ expect(input.to_graphql_variables).to eq(expected_variables)
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,51 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
+
3
+
4
+ describe Braintree::PhoneInput do
5
+ let(:phone_input_data) do
6
+ {
7
+ country_phone_code: "1",
8
+ phone_number: "555-123-4567",
9
+ extension_number: "123"
10
+ }
11
+ end
12
+
13
+ let(:partial_phone_input_data) do
14
+ {
15
+ country_phone_code: "1",
16
+ phone_number: "555-123-4567"
17
+ }
18
+ end
19
+
20
+
21
+ describe "#initialize" do
22
+ it "initialize and sets the input keys to attrs variable" do
23
+ phone_input = described_class.new(phone_input_data)
24
+
25
+ expect(phone_input.attrs).to include(:country_phone_code)
26
+ expect(phone_input.attrs).to include(:phone_number)
27
+ expect(phone_input.attrs).to include(:extension_number)
28
+ expect(phone_input.attrs.length).to eq(3)
29
+ end
30
+ end
31
+
32
+ describe "inspect" do
33
+ it "includes all phone input attributes" do
34
+ phone_input = described_class.new(phone_input_data)
35
+ output = phone_input.inspect
36
+
37
+ expect(output).to include("country_phone_code:\"1\"")
38
+ expect(output).to include("phone_number:\"555-123-4567\"")
39
+ expect(output).to include("extension_number:\"123\"")
40
+ end
41
+
42
+ it "includes only specified phone input attributes" do
43
+ phone_input = described_class.new(partial_phone_input_data)
44
+ output = phone_input.inspect
45
+
46
+ expect(output).to include("country_phone_code:\"1\"")
47
+ expect(output).to include("phone_number:\"555-123-4567\"")
48
+ expect(output).not_to include("extension_number")
49
+ end
50
+ end
51
+ end