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
@@ -0,0 +1,32 @@
1
+ module Braintree
2
+ class PaymentMethodNonceDetailsPayerInfo
3
+ include BaseModule
4
+
5
+ attr_reader :billing_agreement_id
6
+ attr_reader :country_code
7
+ attr_reader :email
8
+ attr_reader :first_name
9
+ attr_reader :last_name
10
+ attr_reader :payer_id
11
+
12
+ def initialize(attributes)
13
+ set_instance_variables_from_hash attributes unless attributes.nil?
14
+ end
15
+
16
+ def inspect
17
+ attr_order = [
18
+ :billing_agreement_id,
19
+ :country_code,
20
+ :email,
21
+ :first_name,
22
+ :last_name,
23
+ :payer_id,
24
+ ]
25
+
26
+ formatted_attrs = attr_order.map do |attr|
27
+ "#{attr}: #{send(attr).inspect}"
28
+ end
29
+ "#<PaymentMethodNonceDetailsPayerInfo #{formatted_attrs.join(", ")}>"
30
+ end
31
+ end
32
+ end
@@ -1,5 +1,5 @@
1
1
  module Braintree
2
- class PaymentMethodNonceGateway # :nodoc:
2
+ class PaymentMethodNonceGateway
3
3
  include BaseModule
4
4
 
5
5
  def initialize(gateway)
@@ -8,12 +8,23 @@ module Braintree
8
8
  @config.assert_has_access_token_or_keys
9
9
  end
10
10
 
11
- def create(payment_method_token)
12
- response = @config.http.post("#{@config.base_merchant_path}/payment_methods/#{payment_method_token}/nonces")
11
+ def create(payment_method_token, args = {payment_method_nonce: {}})
12
+ Util.verify_keys(PaymentMethodNonceGateway._create_signature, args)
13
+
14
+ response = @config.http.post("#{@config.base_merchant_path}/payment_methods/#{payment_method_token}/nonces", args)
13
15
  payment_method_nonce = PaymentMethodNonce._new(@gateway, response.fetch(:payment_method_nonce))
14
16
  SuccessfulResult.new(:payment_method_nonce => payment_method_nonce)
15
17
  end
16
18
 
19
+ def self._create_signature
20
+ [ {
21
+ :payment_method_nonce=> [
22
+ :merchant_account_id, :authentication_insight,
23
+ {:authentication_insight_options => [:amount, :recurring_customer_consent, :recurring_max_amount]}
24
+ ]
25
+ }]
26
+ end
27
+
17
28
  def create!(*args)
18
29
  return_object_or_raise(:payment_method_nonce) { create(*args) }
19
30
  end
@@ -6,24 +6,21 @@ module Braintree
6
6
  CreditCard._new(gateway, attributes[:credit_card])
7
7
  elsif attributes[:paypal_account]
8
8
  PayPalAccount._new(gateway, attributes[:paypal_account])
9
- elsif attributes[:coinbase_account]
10
- CoinbaseAccount._new(gateway, attributes[:coinbase_account])
11
9
  elsif attributes[:us_bank_account]
12
10
  UsBankAccount._new(gateway, attributes[:us_bank_account])
13
11
  elsif attributes[:apple_pay_card]
14
12
  ApplePayCard._new(gateway, attributes[:apple_pay_card])
15
13
  elsif attributes[:android_pay_card]
16
- AndroidPayCard._new(gateway, attributes[:android_pay_card])
17
- elsif attributes[:amex_express_checkout_card]
18
- AmexExpressCheckoutCard._new(gateway, attributes[:amex_express_checkout_card])
14
+ GooglePayCard._new(gateway, attributes[:android_pay_card])
19
15
  elsif attributes[:venmo_account]
20
16
  VenmoAccount._new(gateway, attributes[:venmo_account])
21
17
  elsif attributes[:visa_checkout_card]
22
18
  VisaCheckoutCard._new(gateway, attributes[:visa_checkout_card])
23
- elsif attributes[:masterpass_card]
24
- MasterpassCard._new(gateway, attributes[:masterpass_card])
25
19
  elsif attributes[:samsung_pay_card]
20
+ warn "[DEPRECATED] SamsungPayCard is no longer a supported payment method type"
26
21
  SamsungPayCard._new(gateway, attributes[:samsung_pay_card])
22
+ elsif attributes[:sepa_debit_account]
23
+ SepaDirectDebitAccount._new(gateway, attributes[:sepa_debit_account])
27
24
  else
28
25
  UnknownPaymentMethod._new(gateway, attributes)
29
26
  end
@@ -5,7 +5,9 @@ module Braintree
5
5
  attr_reader :billing_agreement_id
6
6
  attr_reader :created_at
7
7
  attr_reader :customer_id
8
+ attr_reader :edit_paypal_vault_id
8
9
  attr_reader :email
10
+ attr_reader :funding_source_description
9
11
  attr_reader :image_url
10
12
  attr_reader :payer_id
11
13
  attr_reader :revoked_at
@@ -13,7 +15,7 @@ module Braintree
13
15
  attr_reader :token
14
16
  attr_reader :updated_at
15
17
 
16
- def initialize(gateway, attributes) # :nodoc:
18
+ def initialize(gateway, attributes)
17
19
  @gateway = gateway
18
20
  set_instance_variables_from_hash(attributes)
19
21
  @subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) }
@@ -51,7 +53,6 @@ module Braintree
51
53
  return_object_or_raise(:transaction) { sale(token, transaction_attributes) }
52
54
  end
53
55
 
54
- # Returns true if this paypal account is the customer's default payment method.
55
56
  def default?
56
57
  @default
57
58
  end
@@ -28,7 +28,7 @@ module Braintree
28
28
  @config.http.delete("#{@config.base_merchant_path}/payment_methods/paypal_account/#{token}")
29
29
  end
30
30
 
31
- def _do_create(path, params) # :nodoc:
31
+ def _do_create(path, params)
32
32
  response = @config.http.post("#{@config.base_merchant_path}#{path}", params)
33
33
  if response[:paypal_account]
34
34
  SuccessfulResult.new(:paypal_account => PayPalAccount._new(@gateway, response[:paypal_account]))
@@ -39,7 +39,7 @@ module Braintree
39
39
  end
40
40
  end
41
41
 
42
- def _do_update(http_verb, path, params) # :nodoc:
42
+ def _do_update(http_verb, path, params)
43
43
  response = @config.http.send(http_verb, "#{@config.base_merchant_path}#{path}", params)
44
44
  if response[:paypal_account]
45
45
  SuccessfulResult.new(:paypal_account => PayPalAccount._new(@gateway, response[:paypal_account]))
@@ -50,7 +50,7 @@ module Braintree
50
50
  end
51
51
  end
52
52
 
53
- def self._create_signature # :nodoc:
53
+ def self._create_signature
54
54
  options = [:fail_on_duplicate_payment_method, :make_default]
55
55
  [
56
56
  :email, :token, :billing_agreement_id, :customer_id,
@@ -58,14 +58,14 @@ module Braintree
58
58
  ]
59
59
  end
60
60
 
61
- def self._create_nested_signature # :nodoc:
61
+ def self._create_nested_signature
62
62
  [
63
63
  :email, :token, :billing_agreement_id,
64
64
  {:options => [:make_default]}
65
65
  ]
66
66
  end
67
67
 
68
- def self._update_signature # :nodoc:
68
+ def self._update_signature
69
69
  options = [:fail_on_duplicate_payment_method, :make_default]
70
70
  [:email, :token, :billing_agreement_id, {:options => options}]
71
71
  end
@@ -23,7 +23,7 @@ module Braintree
23
23
  Configuration.gateway.plan.all
24
24
  end
25
25
 
26
- def initialize(gateway, attributes) # :nodoc:
26
+ def initialize(gateway, attributes)
27
27
  @gateway = gateway
28
28
  set_instance_variables_from_hash(attributes)
29
29
  add_ons.map! { |attrs| AddOn._new(attrs) }
@@ -33,10 +33,30 @@ module Braintree
33
33
 
34
34
  class << self
35
35
  protected :new
36
+
37
+ def create(*args)
38
+ Configuration.gateway.plan.create(*args)
39
+ end
40
+
41
+ def create!(*args)
42
+ Configuration.gateway.plan.create!(*args)
43
+ end
44
+
45
+ def find(*args)
46
+ Configuration.gateway.plan.find(*args)
47
+ end
48
+
49
+ def update(*args)
50
+ Configuration.gateway.plan.update(*args)
51
+ end
52
+
53
+ def update!(*args)
54
+ Configuration.gateway.plan.update!(*args)
55
+ end
36
56
  end
37
57
 
38
58
  def self._new(*args)
39
- self.new *args
59
+ self.new(*args)
40
60
  end
41
61
  end
42
62
  end
@@ -1,5 +1,7 @@
1
1
  module Braintree
2
- class PlanGateway # :nodoc:
2
+ class PlanGateway
3
+ include BaseModule
4
+
3
5
  def initialize(gateway)
4
6
  @gateway = gateway
5
7
  @config = gateway.config
@@ -13,5 +15,103 @@ module Braintree
13
15
  Plan._new(@gateway, attributes)
14
16
  end
15
17
  end
18
+
19
+ def create(attributes)
20
+ Util.verify_keys(PlanGateway._create_signature, attributes)
21
+ _do_create "/plans", :plan => attributes
22
+ end
23
+
24
+ def create!(*args)
25
+ return_object_or_raise(:plan) { create(*args) }
26
+ end
27
+
28
+ def find(id)
29
+ raise ArgumentError if id.nil? || id.to_s.strip == ""
30
+ response = @config.http.get("#{@config.base_merchant_path}/plans/#{id}")
31
+ Plan._new(@gateway, response[:plan])
32
+ rescue NotFoundError
33
+ raise NotFoundError, "plan with id #{id.inspect} not found"
34
+ end
35
+
36
+ def update(plan_id, attributes)
37
+ Util.verify_keys(PlanGateway._update_signature, attributes)
38
+ response = @config.http.put("#{@config.base_merchant_path}/plans/#{plan_id}", :plan => attributes)
39
+ if response[:plan]
40
+ SuccessfulResult.new(:plan => Plan._new(@gateway, response[:plan]))
41
+ elsif response[:api_error_response]
42
+ ErrorResult.new(@gateway, response[:api_error_response])
43
+ else
44
+ raise UnexpectedError, "expected :plan or :api_error_response"
45
+ end
46
+ end
47
+
48
+ def update!(*args)
49
+ return_object_or_raise(:plan) { update(*args) }
50
+ end
51
+
52
+ def self._create_signature
53
+ [
54
+ :billing_day_of_month,
55
+ :billing_frequency,
56
+ :currency_iso_code,
57
+ :description,
58
+ :id,
59
+ :merchant_id,
60
+ :name,
61
+ :number_of_billing_cycles,
62
+ :price,
63
+ :trial_duration,
64
+ :trial_duration_unit,
65
+ :trial_period
66
+ ] + _add_on_discount_signature
67
+ end
68
+
69
+ def self._update_signature
70
+ [
71
+ :billing_day_of_month,
72
+ :billing_frequency,
73
+ :currency_iso_code,
74
+ :description,
75
+ :id,
76
+ :merchant_id,
77
+ :name,
78
+ :number_of_billing_cycles,
79
+ :price,
80
+ :trial_duration,
81
+ :trial_duration_unit,
82
+ :trial_period
83
+ ] + _add_on_discount_signature
84
+ end
85
+
86
+ def self._add_on_discount_signature
87
+ [
88
+ {
89
+ :add_ons => [
90
+ {:add => [:amount, :inherited_from_id, :never_expires, :number_of_billing_cycles, :quantity]},
91
+ {:update => [:amount, :existing_id, :never_expires, :number_of_billing_cycles, :quantity]},
92
+ {:remove => [:_any_key_]}
93
+ ]
94
+ },
95
+ {
96
+ :discounts => [
97
+ {:add => [:amount, :inherited_from_id, :never_expires, :number_of_billing_cycles, :quantity]},
98
+ {:update => [:amount, :existing_id, :never_expires, :number_of_billing_cycles, :quantity]},
99
+ {:remove => [:_any_key_]}
100
+ ]
101
+ }
102
+ ]
103
+ end
104
+
105
+ def _do_create(path, params)
106
+ response = @config.http.post("#{@config.base_merchant_path}#{path}", params)
107
+ if response[:plan]
108
+ SuccessfulResult.new(:plan => Plan._new(@gateway, response[:plan]))
109
+ elsif response[:api_error_response]
110
+ ErrorResult.new(@gateway, response[:api_error_response])
111
+ else
112
+ raise UnexpectedError, "expected :plan or :api_error_response"
113
+ end
114
+ end
16
115
  end
17
116
  end
117
+
@@ -1,7 +1,7 @@
1
1
  module Braintree
2
2
  module ProcessorResponseTypes
3
- Approved = 'approved'
4
- SoftDeclined = 'soft_declined'
5
- HardDeclined = 'hard_declined'
3
+ Approved = "approved"
4
+ SoftDeclined = "soft_declined"
5
+ HardDeclined = "hard_declined"
6
6
  end
7
7
  end
@@ -1,10 +1,10 @@
1
1
  module Braintree
2
- class ResourceCollection # :nodoc:
2
+ class ResourceCollection
3
3
  include Enumerable
4
4
 
5
5
  attr_reader :ids
6
6
 
7
- def initialize(response, &block) # :nodoc:
7
+ def initialize(response, &block)
8
8
  @ids = Util.extract_attribute_as_array(response[:search_results], :ids)
9
9
  @page_size = response[:search_results][:page_size]
10
10
  @paging_block = block
@@ -22,9 +22,14 @@ module Braintree
22
22
  @ids.empty?
23
23
  end
24
24
 
25
- # Returns the first item in the collection or nil if the collection is empty
26
- def first
27
- @paging_block.call([@ids.first]).first
25
+ # Returns the first or the first N items in the collection or nil if the collection is empty
26
+ def first(amount = 1)
27
+ return nil if @ids.empty?
28
+ return @paging_block.call([@ids.first]).first if amount == 1
29
+
30
+ @ids.first(amount).each_slice(@page_size).flat_map do |page_of_ids|
31
+ @paging_block.call(page_of_ids)
32
+ end
28
33
  end
29
34
 
30
35
  # Only the maximum size of a resource collection can be determined since the data on the server can change while
@@ -14,8 +14,8 @@ module Braintree
14
14
 
15
15
  class << self
16
16
  protected :new
17
- def _new(*args) # :nodoc:
18
- self.new *args
17
+ def _new(*args)
18
+ self.new(*args)
19
19
  end
20
20
  end
21
21
  end
@@ -0,0 +1,22 @@
1
+ module Braintree
2
+ class RiskData
3
+ class LiabilityShift
4
+ include BaseModule
5
+
6
+ attr_reader :responsible_party
7
+ attr_reader :conditions
8
+
9
+ def initialize(attributes)
10
+ set_instance_variables_from_hash attributes unless attributes.nil?
11
+ end
12
+
13
+ def inspect
14
+ attr_order = [:responsible_party, :conditions]
15
+ formatted_attrs = attr_order.map do |attr|
16
+ "#{attr}: #{send(attr).inspect}"
17
+ end
18
+ "#<LiabilityShift #{formatted_attrs.join(", ")}>"
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,18 +1,25 @@
1
1
  module Braintree
2
- class RiskData # :nodoc:
2
+ class RiskData
3
3
  include BaseModule
4
4
 
5
+ attr_reader :customer_device_id
6
+ attr_reader :customer_location_zip
7
+ attr_reader :customer_tenure
5
8
  attr_reader :decision
9
+ attr_reader :decision_reasons
6
10
  attr_reader :device_data_captured
7
- attr_reader :id
8
11
  attr_reader :fraud_service_provider
12
+ attr_reader :id
13
+ attr_reader :liability_shift
14
+ attr_reader :transaction_risk_score
9
15
 
10
16
  def initialize(attributes)
11
17
  set_instance_variables_from_hash attributes unless attributes.nil?
18
+ @liability_shift = LiabilityShift.new(attributes[:liability_shift]) if attributes[:liability_shift]
12
19
  end
13
20
 
14
21
  def inspect
15
- attr_order = [:id, :decision, :device_data_captured, :fraud_service_provider]
22
+ attr_order = [:id, :decision, :decision_reasons, :device_data_captured, :fraud_service_provider, :liability_shift, :transaction_risk_score]
16
23
  formatted_attrs = attr_order.map do |attr|
17
24
  "#{attr}: #{send(attr).inspect}"
18
25
  end
@@ -1,6 +1,8 @@
1
1
  module Braintree
2
+ # NEXT_MAJOR_VERSION remove this class
3
+ # SamsungPayCard has been deprecated
2
4
  class SamsungPayCard
3
- include BaseModule # :nodoc:
5
+ include BaseModule
4
6
  include Braintree::Util::TokenEquality
5
7
 
6
8
  attr_reader :billing_address
@@ -29,7 +31,7 @@ module Braintree
29
31
  attr_reader :unique_number_identifier
30
32
  attr_reader :updated_at
31
33
 
32
- def initialize(gateway, attributes) # :nodoc:
34
+ def initialize(gateway, attributes)
33
35
  @gateway = gateway
34
36
  set_instance_variables_from_hash(attributes)
35
37
  @billing_address = attributes[:billing_address] ? Address._new(@gateway, attributes[:billing_address]) : nil
@@ -49,7 +51,7 @@ module Braintree
49
51
  @expired
50
52
  end
51
53
 
52
- def inspect # :nodoc:
54
+ def inspect
53
55
  first = [:token]
54
56
  order = first + (self.class._attributes - first)
55
57
  nice_attributes = order.map do |attr|
@@ -66,7 +68,7 @@ module Braintree
66
68
  protected :new
67
69
  end
68
70
 
69
- def self._attributes # :nodoc:
71
+ def self._attributes
70
72
  [
71
73
  :billing_address, :bin, :cardholder_name, :card_type, :created_at, :customer_id,
72
74
  :customer_location, :expiration_month, :expiration_year,
@@ -76,8 +78,8 @@ module Braintree
76
78
  ]
77
79
  end
78
80
 
79
- def self._new(*args) # :nodoc:
80
- self.new *args
81
+ def self._new(*args)
82
+ self.new(*args)
81
83
  end
82
84
  end
83
85
  end
@@ -0,0 +1,60 @@
1
+ module Braintree
2
+ class SepaDirectDebitAccount
3
+ include BaseModule
4
+
5
+ attr_reader :bank_reference_token
6
+ attr_reader :created_at
7
+ attr_reader :customer_id
8
+ attr_reader :customer_global_id
9
+ attr_reader :default
10
+ attr_reader :global_id
11
+ attr_reader :image_url
12
+ attr_reader :last_4
13
+ attr_reader :mandate_type
14
+ attr_reader :merchant_or_partner_customer_id
15
+ attr_reader :subscriptions
16
+ attr_reader :token
17
+ attr_reader :updated_at
18
+ attr_reader :view_mandate_url
19
+
20
+ def initialize(gateway, attributes)
21
+ @gateway = gateway
22
+ @subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) }
23
+ set_instance_variables_from_hash(attributes)
24
+ end
25
+
26
+ def default?
27
+ @default
28
+ end
29
+
30
+ class << self
31
+ protected :new
32
+ end
33
+
34
+ def self._new(*args)
35
+ self.new(*args)
36
+ end
37
+
38
+ def self.find(*args)
39
+ Configuration.gateway.sepa_direct_debit_account.find(*args)
40
+ end
41
+
42
+ def self.delete(*args)
43
+ Configuration.gateway.sepa_direct_debit_account.delete(*args)
44
+ end
45
+
46
+ def self.sale(token, transaction_attributes)
47
+ options = transaction_attributes[:options] || {}
48
+ Configuration.gateway.transaction.sale(
49
+ transaction_attributes.merge(
50
+ :payment_method_token => token,
51
+ :options => options.merge(:submit_for_settlement => true),
52
+ ),
53
+ )
54
+ end
55
+
56
+ def self.sale!(token, transaction_attributes)
57
+ return_object_or_raise(:transaction) { sale(token, transaction_attributes) }
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,25 @@
1
+ module Braintree
2
+ class SepaDirectDebitAccountGateway
3
+ def initialize(gateway)
4
+ @gateway = gateway
5
+ @config = gateway.config
6
+ @config.assert_has_access_token_or_keys
7
+ end
8
+
9
+ def find(token)
10
+ raise ArgumentError if token.nil? || token.to_s.strip == ""
11
+ response = @config.http.get("#{@config.base_merchant_path}/payment_methods/sepa_debit_account/#{token}")
12
+ SepaDirectDebitAccount._new(@gateway, response[:sepa_debit_account])
13
+ rescue NotFoundError
14
+ raise NotFoundError, "sepa direct debit account with token #{token.inspect} not found"
15
+ end
16
+
17
+ def delete(token)
18
+ raise ArgumentError if token.nil? || token.to_s.strip == ""
19
+ @config.http.delete("#{@config.base_merchant_path}/payment_methods/sepa_debit_account/#{token}")
20
+ SuccessfulResult.new
21
+ rescue NotFoundError
22
+ raise NotFoundError, "sepa direct debit account with token #{token.inspect} not found"
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,28 @@
1
+ module Braintree
2
+ class SepaDirectDebitAccountNonceDetails
3
+ include BaseModule
4
+
5
+ attr_reader :bank_reference_token
6
+ attr_reader :last_4
7
+ attr_reader :mandate_type
8
+ attr_reader :merchant_or_partner_customer_id
9
+
10
+ def initialize(attributes)
11
+ set_instance_variables_from_hash attributes unless attributes.nil?
12
+ end
13
+
14
+ def inspect
15
+ attr_order = [
16
+ :bank_reference_token,
17
+ :last_4,
18
+ :mandate_type,
19
+ :merchant_or_partner_customer_id,
20
+ ]
21
+
22
+ formatted_attrs = attr_order.map do |attr|
23
+ "#{attr}: #{send(attr).inspect}"
24
+ end
25
+ "#<SepaDirectDebitAccountNonceDetails#{formatted_attrs.join(", ")}>"
26
+ end
27
+ end
28
+ end
@@ -1,11 +1,11 @@
1
1
  module Braintree
2
2
  class SettlementBatchSummary
3
3
  include BaseModule
4
-
4
+
5
5
  attr_reader :records
6
6
 
7
7
  def self.generate(settlement_date, group_by_custom_field = nil)
8
- criteria = { :settlement_date => settlement_date }
8
+ criteria = {:settlement_date => settlement_date}
9
9
  criteria.merge!({:group_by_custom_field => group_by_custom_field}) if group_by_custom_field
10
10
  Configuration.gateway.settlement_batch_summary.generate(criteria)
11
11
  end
@@ -1,5 +1,5 @@
1
1
  module Braintree
2
- class SettlementBatchSummaryGateway # :nodoc
2
+ class SettlementBatchSummaryGateway
3
3
  include BaseModule
4
4
 
5
5
  def initialize(gateway)
@@ -1,5 +1,5 @@
1
1
  module Braintree
2
- module SHA256Digest # :nodoc:
2
+ module SHA256Digest
3
3
  def self.hexdigest(private_key, string)
4
4
  _hmac(private_key, string)
5
5
  end
@@ -1,6 +1,6 @@
1
1
  module Braintree
2
2
  class Subscription
3
- class StatusDetails # :nodoc:
3
+ class StatusDetails
4
4
  include BaseModule
5
5
 
6
6
  attr_reader :balance