braintree 2.74.0 → 4.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (286) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE +1 -1
  3. data/braintree.gemspec +13 -7
  4. data/lib/braintree/account_updater_daily_report.rb +2 -2
  5. data/lib/braintree/ach_mandate.rb +2 -1
  6. data/lib/braintree/address/country_names.rb +4 -1
  7. data/lib/braintree/address.rb +30 -38
  8. data/lib/braintree/address_gateway.rb +12 -2
  9. data/lib/braintree/advanced_search.rb +8 -0
  10. data/lib/braintree/apple_pay.rb +29 -0
  11. data/lib/braintree/apple_pay_card.rb +28 -4
  12. data/lib/braintree/apple_pay_gateway.rb +37 -0
  13. data/lib/braintree/apple_pay_options.rb +19 -0
  14. data/lib/braintree/authorization_adjustment.rb +23 -0
  15. data/lib/braintree/base_module.rb +10 -0
  16. data/lib/braintree/bin_data.rb +33 -0
  17. data/lib/braintree/client_token.rb +3 -3
  18. data/lib/braintree/client_token_gateway.rb +3 -1
  19. data/lib/braintree/configuration.rb +57 -10
  20. data/lib/braintree/connected_merchant_paypal_status_changed.rb +6 -2
  21. data/lib/braintree/connected_merchant_status_transitioned.rb +6 -2
  22. data/lib/braintree/credentials_parser.rb +5 -1
  23. data/lib/braintree/credit_card.rb +53 -107
  24. data/lib/braintree/credit_card_gateway.rb +43 -30
  25. data/lib/braintree/credit_card_verification.rb +61 -21
  26. data/lib/braintree/credit_card_verification_gateway.rb +19 -6
  27. data/lib/braintree/credit_card_verification_search.rb +1 -1
  28. data/lib/braintree/customer.rb +51 -98
  29. data/lib/braintree/customer_gateway.rb +30 -23
  30. data/lib/braintree/customer_search.rb +1 -1
  31. data/lib/braintree/descriptor.rb +3 -1
  32. data/lib/braintree/disbursement.rb +24 -2
  33. data/lib/braintree/dispute/evidence.rb +24 -0
  34. data/lib/braintree/{transaction/coinbase_details.rb → dispute/paypal_message.rb} +5 -3
  35. data/lib/braintree/dispute/status_history.rb +18 -0
  36. data/lib/braintree/dispute/transaction.rb +20 -0
  37. data/lib/braintree/dispute/transaction_details.rb +2 -1
  38. data/lib/braintree/dispute.rb +114 -10
  39. data/lib/braintree/dispute_gateway.rb +142 -0
  40. data/lib/braintree/dispute_search.rb +31 -0
  41. data/lib/braintree/document_upload.rb +37 -0
  42. data/lib/braintree/document_upload_gateway.rb +38 -0
  43. data/lib/braintree/enriched_customer_data.rb +21 -0
  44. data/lib/braintree/error_codes.rb +328 -109
  45. data/lib/braintree/error_result.rb +8 -1
  46. data/lib/braintree/exceptions.rb +5 -3
  47. data/lib/braintree/exchange_rate.rb +13 -0
  48. data/lib/braintree/exchange_rate_quote.rb +24 -0
  49. data/lib/braintree/exchange_rate_quote_gateway.rb +35 -0
  50. data/lib/braintree/exchange_rate_quote_input.rb +21 -0
  51. data/lib/braintree/exchange_rate_quote_request.rb +18 -0
  52. data/lib/braintree/exchange_rate_quote_response.rb +18 -0
  53. data/lib/braintree/facilitated_details.rb +21 -0
  54. data/lib/braintree/facilitator_details.rb +2 -1
  55. data/lib/braintree/gateway.rb +29 -11
  56. data/lib/braintree/google_pay_card.rb +61 -0
  57. data/lib/braintree/granted_payment_instrument_update.rb +23 -0
  58. data/lib/braintree/graphql_client.rb +34 -0
  59. data/lib/braintree/http.rb +81 -20
  60. data/lib/braintree/local_payment_completed.rb +23 -0
  61. data/lib/braintree/local_payment_expired.rb +21 -0
  62. data/lib/braintree/local_payment_funded.rb +22 -0
  63. data/lib/braintree/local_payment_reversed.rb +19 -0
  64. data/lib/braintree/merchant.rb +11 -4
  65. data/lib/braintree/merchant_account/address_details.rb +4 -1
  66. data/lib/braintree/merchant_account/business_details.rb +4 -1
  67. data/lib/braintree/merchant_account/funding_details.rb +6 -1
  68. data/lib/braintree/merchant_account/individual_details.rb +7 -2
  69. data/lib/braintree/merchant_account.rb +23 -10
  70. data/lib/braintree/merchant_account_gateway.rb +13 -1
  71. data/lib/braintree/merchant_gateway.rb +2 -2
  72. data/lib/braintree/modification.rb +1 -1
  73. data/lib/braintree/oauth_credentials.rb +5 -2
  74. data/lib/braintree/oauth_gateway.rb +8 -14
  75. data/lib/braintree/paginated_result.rb +3 -1
  76. data/lib/braintree/payment_instrument_type.rb +11 -11
  77. data/lib/braintree/payment_method.rb +20 -12
  78. data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
  79. data/lib/braintree/payment_method_gateway.rb +82 -54
  80. data/lib/braintree/payment_method_nonce.rb +22 -8
  81. data/lib/braintree/payment_method_nonce_details.rb +40 -0
  82. data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
  83. data/lib/braintree/payment_method_nonce_gateway.rb +19 -2
  84. data/lib/braintree/payment_method_parser.rb +28 -0
  85. data/lib/braintree/paypal_account.rb +10 -1
  86. data/lib/braintree/plan.rb +25 -5
  87. data/lib/braintree/plan_gateway.rb +100 -0
  88. data/lib/braintree/processor_response_types.rb +7 -0
  89. data/lib/braintree/resource_collection.rb +8 -3
  90. data/lib/braintree/revoked_payment_method_metadata.rb +22 -0
  91. data/lib/braintree/risk_data/liability_shift.rb +22 -0
  92. data/lib/braintree/risk_data.rb +12 -2
  93. data/lib/braintree/samsung_pay_card.rb +83 -0
  94. data/lib/braintree/sepa_direct_debit_account.rb +60 -0
  95. data/lib/braintree/sepa_direct_debit_account_gateway.rb +25 -0
  96. data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +28 -0
  97. data/lib/braintree/settlement_batch_summary.rb +2 -1
  98. data/lib/braintree/settlement_batch_summary_gateway.rb +2 -0
  99. data/lib/braintree/subscription/status_details.rb +8 -1
  100. data/lib/braintree/subscription.rb +56 -41
  101. data/lib/braintree/subscription_gateway.rb +25 -2
  102. data/lib/braintree/successful_result.rb +23 -1
  103. data/lib/braintree/test/authentication_id.rb +21 -0
  104. data/lib/braintree/test/credit_card.rb +13 -0
  105. data/lib/braintree/test/nonce.rb +28 -20
  106. data/lib/braintree/test/transaction_amounts.rb +1 -0
  107. data/lib/braintree/three_d_secure_info.rb +34 -2
  108. data/lib/braintree/transaction/address_details.rb +24 -4
  109. data/lib/braintree/transaction/apple_pay_details.rb +20 -2
  110. data/lib/braintree/transaction/credit_card_details.rb +45 -6
  111. data/lib/braintree/transaction/customer_details.rb +8 -1
  112. data/lib/braintree/transaction/disbursement_details.rb +6 -1
  113. data/lib/braintree/transaction/google_pay_details.rb +41 -0
  114. data/lib/braintree/transaction/installment/adjustment.rb +33 -0
  115. data/lib/braintree/transaction/installment.rb +28 -0
  116. data/lib/braintree/transaction/local_payment_details.rb +24 -0
  117. data/lib/braintree/transaction/paypal_details.rb +26 -4
  118. data/lib/braintree/transaction/paypal_here_details.rb +23 -0
  119. data/lib/braintree/transaction/{masterpass_card_details.rb → samsung_pay_card_details.rb} +21 -6
  120. data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +27 -0
  121. data/lib/braintree/transaction/status_details.rb +5 -1
  122. data/lib/braintree/transaction/subscription_details.rb +4 -1
  123. data/lib/braintree/transaction/us_bank_account_details.rb +8 -1
  124. data/lib/braintree/transaction/venmo_account_details.rb +5 -1
  125. data/lib/braintree/transaction/visa_checkout_card_details.rb +19 -4
  126. data/lib/braintree/transaction.rb +201 -188
  127. data/lib/braintree/transaction_gateway.rb +124 -30
  128. data/lib/braintree/transaction_line_item.rb +40 -0
  129. data/lib/braintree/transaction_line_item_gateway.rb +19 -0
  130. data/lib/braintree/transaction_review.rb +18 -0
  131. data/lib/braintree/transaction_search.rb +6 -3
  132. data/lib/braintree/unknown_payment_method.rb +3 -2
  133. data/lib/braintree/us_bank_account.rb +24 -8
  134. data/lib/braintree/us_bank_account_gateway.rb +0 -1
  135. data/lib/braintree/us_bank_account_verification.rb +81 -0
  136. data/lib/braintree/us_bank_account_verification_gateway.rb +51 -0
  137. data/lib/braintree/us_bank_account_verification_search.rb +19 -0
  138. data/lib/braintree/util.rb +79 -9
  139. data/lib/braintree/validation_error.rb +13 -3
  140. data/lib/braintree/validation_error_collection.rb +2 -1
  141. data/lib/braintree/venmo_account.rb +11 -4
  142. data/lib/braintree/venmo_profile_data.rb +23 -0
  143. data/lib/braintree/version.rb +2 -2
  144. data/lib/braintree/visa_checkout_card.rb +29 -13
  145. data/lib/braintree/webhook_notification.rb +66 -26
  146. data/lib/braintree/webhook_notification_gateway.rb +5 -3
  147. data/lib/braintree/webhook_testing.rb +2 -2
  148. data/lib/braintree/webhook_testing_gateway.rb +721 -55
  149. data/lib/braintree/xml/generator.rb +6 -4
  150. data/lib/braintree/xml/parser.rb +22 -35
  151. data/lib/braintree/xml/rexml.rb +4 -5
  152. data/lib/braintree.rb +60 -22
  153. data/lib/ssl/api_braintreegateway_com.ca.crt +50 -0
  154. data/spec/fixtures/files/bt_logo.png +0 -0
  155. data/spec/fixtures/files/gif_extension_bt_logo.gif +0 -0
  156. data/spec/fixtures/files/malformed_pdf.pdf +1 -0
  157. data/spec/fixtures/files/too_long.pdf +0 -0
  158. data/spec/integration/braintree/add_on_spec.rb +3 -3
  159. data/spec/integration/braintree/address_spec.rb +30 -113
  160. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  161. data/spec/integration/braintree/apple_pay_spec.rb +63 -0
  162. data/spec/integration/braintree/braintree_gateway_spec.rb +72 -0
  163. data/spec/integration/braintree/client_api/client_token_spec.rb +14 -32
  164. data/spec/integration/braintree/client_api/spec_helper.rb +104 -65
  165. data/spec/integration/braintree/credit_card_spec.rb +460 -615
  166. data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
  167. data/spec/integration/braintree/credit_card_verification_spec.rb +222 -6
  168. data/spec/integration/braintree/customer_search_spec.rb +8 -8
  169. data/spec/integration/braintree/customer_spec.rb +810 -498
  170. data/spec/integration/braintree/discount_spec.rb +1 -1
  171. data/spec/integration/braintree/dispute_search_spec.rb +167 -0
  172. data/spec/integration/braintree/dispute_spec.rb +333 -0
  173. data/spec/integration/braintree/document_upload_spec.rb +87 -0
  174. data/spec/integration/braintree/error_codes_spec.rb +1 -1
  175. data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
  176. data/spec/integration/braintree/graphql_client_spec.rb +72 -0
  177. data/spec/integration/braintree/http_spec.rb +12 -4
  178. data/spec/integration/braintree/merchant_account_spec.rb +74 -26
  179. data/spec/integration/braintree/merchant_spec.rb +39 -13
  180. data/spec/integration/braintree/oauth_spec.rb +18 -25
  181. data/spec/integration/braintree/payment_method_nonce_spec.rb +239 -5
  182. data/spec/integration/braintree/payment_method_spec.rb +882 -300
  183. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +416 -0
  184. data/spec/integration/braintree/paypal_account_spec.rb +32 -31
  185. data/spec/integration/braintree/plan_spec.rb +82 -0
  186. data/spec/integration/braintree/samsung_pay_card_spec.rb +144 -0
  187. data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +196 -0
  188. data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
  189. data/spec/integration/braintree/subscription_spec.rb +274 -180
  190. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  191. data/spec/integration/braintree/test_transaction_spec.rb +18 -18
  192. data/spec/integration/braintree/transaction_line_item_spec.rb +38 -0
  193. data/spec/integration/braintree/transaction_search_spec.rb +280 -152
  194. data/spec/integration/braintree/transaction_spec.rb +3709 -1175
  195. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +438 -0
  196. data/spec/integration/braintree/us_bank_account_spec.rb +38 -17
  197. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +178 -0
  198. data/spec/integration/braintree/us_bank_account_verification_spec.rb +240 -0
  199. data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
  200. data/spec/integration/spec_helper.rb +27 -6
  201. data/spec/oauth_test_helper.rb +1 -1
  202. data/spec/script/httpsd.rb +6 -6
  203. data/spec/spec_helper.rb +26 -23
  204. data/spec/unit/braintree/address_spec.rb +1 -9
  205. data/spec/unit/braintree/apple_pay_card_spec.rb +104 -4
  206. data/spec/unit/braintree/client_token_spec.rb +2 -2
  207. data/spec/unit/braintree/configuration_spec.rb +108 -33
  208. data/spec/unit/braintree/credit_card_spec.rb +62 -33
  209. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +51 -0
  210. data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
  211. data/spec/unit/braintree/credit_card_verification_spec.rb +39 -6
  212. data/spec/unit/braintree/customer_spec.rb +107 -27
  213. data/spec/unit/braintree/disbursement_spec.rb +59 -7
  214. data/spec/unit/braintree/dispute_search_spec.rb +66 -0
  215. data/spec/unit/braintree/dispute_spec.rb +472 -8
  216. data/spec/unit/braintree/document_upload_spec.rb +35 -0
  217. data/spec/unit/braintree/enriched_customer_data_spec.rb +32 -0
  218. data/spec/unit/braintree/error_result_spec.rb +5 -5
  219. data/spec/unit/braintree/errors_spec.rb +8 -8
  220. data/spec/unit/braintree/exchange_rate_quote_input_spec.rb +42 -0
  221. data/spec/unit/braintree/exchange_rate_quote_request_spec.rb +82 -0
  222. data/spec/unit/braintree/exchange_rate_quote_response_spec.rb +52 -0
  223. data/spec/unit/braintree/exchange_rate_quote_spec.rb +42 -0
  224. data/spec/unit/braintree/exchange_rate_spec.rb +23 -0
  225. data/spec/unit/braintree/http_spec.rb +93 -5
  226. data/spec/unit/braintree/local_payment_completed_spec.rb +50 -0
  227. data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
  228. data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
  229. data/spec/unit/braintree/merchant_account_spec.rb +1 -1
  230. data/spec/unit/braintree/modification_spec.rb +1 -1
  231. data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +45 -0
  232. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
  233. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +51 -0
  234. data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
  235. data/spec/unit/braintree/payment_method_spec.rb +1 -1
  236. data/spec/unit/braintree/paypal_account_spec.rb +2 -2
  237. data/spec/unit/braintree/resource_collection_spec.rb +30 -1
  238. data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
  239. data/spec/unit/braintree/risk_data_spec.rb +40 -6
  240. data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +29 -0
  241. data/spec/unit/braintree/sepa_debit_account_spec.rb +86 -0
  242. data/spec/unit/braintree/subscription_search_spec.rb +1 -1
  243. data/spec/unit/braintree/subscription_spec.rb +2 -2
  244. data/spec/unit/braintree/successful_result_spec.rb +1 -1
  245. data/spec/unit/braintree/three_d_secure_info_spec.rb +34 -6
  246. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +19 -3
  247. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  248. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  249. data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
  250. data/spec/unit/braintree/transaction/paypal_details_spec.rb +63 -0
  251. data/spec/unit/braintree/transaction/sepa_direct_debit_account_details_spec.rb +33 -0
  252. data/spec/unit/braintree/transaction_gateway_spec.rb +111 -0
  253. data/spec/unit/braintree/transaction_search_spec.rb +12 -12
  254. data/spec/unit/braintree/transaction_spec.rb +171 -55
  255. data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +60 -0
  256. data/spec/unit/braintree/us_bank_account_verification_spec.rb +93 -0
  257. data/spec/unit/braintree/util_spec.rb +162 -19
  258. data/spec/unit/braintree/validation_error_collection_spec.rb +336 -133
  259. data/spec/unit/braintree/venmo_profile_data_spec.rb +32 -0
  260. data/spec/unit/braintree/webhook_notification_spec.rb +546 -114
  261. data/spec/unit/braintree/xml/parser_spec.rb +21 -16
  262. data/spec/unit/braintree/xml_spec.rb +31 -24
  263. data/spec/unit/braintree_spec.rb +1 -0
  264. metadata +290 -198
  265. data/README.rdoc +0 -93
  266. data/lib/braintree/amex_express_checkout_card.rb +0 -26
  267. data/lib/braintree/android_pay_card.rb +0 -35
  268. data/lib/braintree/coinbase_account.rb +0 -25
  269. data/lib/braintree/europe_bank_account.rb +0 -34
  270. data/lib/braintree/europe_bank_account_gateway.rb +0 -17
  271. data/lib/braintree/ideal_payment.rb +0 -46
  272. data/lib/braintree/ideal_payment_gateway.rb +0 -18
  273. data/lib/braintree/masterpass_card.rb +0 -66
  274. data/lib/braintree/settlement_batch.rb +0 -0
  275. data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -14
  276. data/lib/braintree/transaction/android_pay_details.rb +0 -17
  277. data/lib/braintree/transaction/ideal_payment_details.rb +0 -13
  278. data/lib/braintree/transparent_redirect.rb +0 -40
  279. data/lib/braintree/transparent_redirect_gateway.rb +0 -105
  280. data/spec/hacks/tcp_socket.rb +0 -18
  281. data/spec/httpsd.pid +0 -1
  282. data/spec/integration/braintree/coinbase_spec.rb +0 -31
  283. data/spec/integration/braintree/ideal_payment_spec.rb +0 -87
  284. data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
  285. data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
  286. data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
@@ -1,26 +0,0 @@
1
- module Braintree
2
- class AmexExpressCheckoutCard
3
- include BaseModule # :nodoc:
4
-
5
- attr_reader :bin, :card_member_expiry_date, :card_member_number, :card_type, :created_at, :customer_id, :default,
6
- :expiration_month, :expiration_year, :image_url, :source_description, :subscriptions, :token, :updated_at
7
-
8
- def initialize(gateway, attributes) # :nodoc:
9
- @gateway = gateway
10
- set_instance_variables_from_hash(attributes)
11
- @subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) }
12
- end
13
-
14
- def default?
15
- @default
16
- end
17
-
18
- class << self
19
- protected :new
20
- end
21
-
22
- def self._new(*args) # :nodoc:
23
- self.new *args
24
- end
25
- end
26
- end
@@ -1,35 +0,0 @@
1
- module Braintree
2
- class AndroidPayCard
3
- include BaseModule # :nodoc:
4
-
5
- attr_reader :token, :virtual_card_type, :virtual_card_last_4, :source_card_type, :source_card_last_4,
6
- :expiration_month, :expiration_year, :created_at, :updated_at, :image_url, :subscriptions, :bin,
7
- :google_transaction_id, :default, :source_description, :customer_id
8
-
9
- def initialize(gateway, attributes) # :nodoc:
10
- @gateway = gateway
11
- set_instance_variables_from_hash(attributes)
12
- @subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) }
13
- end
14
-
15
- def default?
16
- @default
17
- end
18
-
19
- def card_type
20
- virtual_card_type
21
- end
22
-
23
- def last_4
24
- virtual_card_last_4
25
- end
26
-
27
- class << self
28
- protected :new
29
- end
30
-
31
- def self._new(*args) # :nodoc:
32
- self.new *args
33
- end
34
- end
35
- end
@@ -1,25 +0,0 @@
1
- module Braintree
2
- class CoinbaseAccount
3
- include BaseModule # :nodoc:
4
-
5
- attr_reader :token, :user_id, :user_email, :user_name, :subscriptions, :created_at, :updated_at, :default, :customer_id
6
- def initialize(gateway, attributes) # :nodoc:
7
- @gateway = gateway
8
- set_instance_variables_from_hash(attributes)
9
- @subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) }
10
- end
11
-
12
- class << self
13
- protected :new
14
- end
15
-
16
- def self._new(*args) # :nodoc:
17
- self.new *args
18
- end
19
-
20
- # Returns true if this coinbase account is the customer's default payment method.
21
- def default?
22
- @default
23
- end
24
- end
25
- end
@@ -1,34 +0,0 @@
1
- module Braintree
2
- class EuropeBankAccount
3
- include BaseModule
4
-
5
- module MandateType
6
- Business = 'business'
7
- Consumer = 'consumer'
8
- end
9
-
10
- attr_reader :token, :image_url, :customer_id
11
-
12
- def initialize(gateway, attributes) # :nodoc:
13
- @gateway = gateway
14
- set_instance_variables_from_hash(attributes)
15
- end
16
-
17
- class << self
18
- protected :new
19
- end
20
-
21
- def self._new(*args)
22
- self.new(*args)
23
- end
24
-
25
- def self.find(token)
26
- Configuration.gateway.europe_bank_account.find(token)
27
- end
28
-
29
- def default?
30
- @default
31
- end
32
-
33
- end
34
- end
@@ -1,17 +0,0 @@
1
- module Braintree
2
- class EuropeBankAccountGateway
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/europe_bank_account/#{token}")
12
- EuropeBankAccount._new(@gateway, response[:europe_bank_account])
13
- rescue NotFoundError
14
- raise NotFoundError, "payment method with token #{token.inspect} not found"
15
- end
16
- end
17
- end
@@ -1,46 +0,0 @@
1
- module Braintree
2
- class IdealPayment
3
- include BaseModule
4
-
5
- attr_reader :id, :ideal_transaction_id, :currency, :amount, :status, :order_id, :issuer, :approval_url, :iban_bank_account
6
-
7
- def initialize(gateway, attributes) # :nodoc:
8
- @gateway = gateway
9
- set_instance_variables_from_hash(attributes)
10
- @iban_bank_account = IbanBankAccount.new(attributes[:iban_bank_account]) if attributes[:iban_bank_account]
11
- end
12
-
13
- class << self
14
- protected :new
15
- end
16
-
17
- def self._new(*args) # :nodoc:
18
- self.new *args
19
- end
20
-
21
- def self.sale(ideal_payment_id, transaction_attributes)
22
- Configuration.gateway.transaction.sale(transaction_attributes.merge(
23
- :payment_method_nonce => ideal_payment_id,
24
- :options => { :submit_for_settlement => true }
25
- )
26
- )
27
- end
28
-
29
- def self.sale!(ideal_payment_id, transaction_attributes)
30
- return_object_or_raise(:transaction) { sale(ideal_payment_id, transaction_attributes) }
31
- end
32
-
33
- def self.find(ideal_payment_id)
34
- Configuration.gateway.ideal_payment.find(ideal_payment_id)
35
- end
36
-
37
- class IbanBankAccount
38
- include BaseModule
39
- attr_reader :account_holder_name, :bic, :masked_iban, :iban_account_number_last_4, :iban_country, :description
40
-
41
- def initialize(attributes) # :nodoc:
42
- set_instance_variables_from_hash(attributes)
43
- end
44
- end
45
- end
46
- end
@@ -1,18 +0,0 @@
1
- module Braintree
2
- class IdealPaymentGateway
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(ideal_payment_id)
10
- raise ArgumentError if ideal_payment_id.nil? || ideal_payment_id.to_s.strip == ""
11
- response = @config.http.get("#{@config.base_merchant_path}/ideal_payments/#{ideal_payment_id}")
12
- IdealPayment._new(@gateway, response[:ideal_payment])
13
- rescue NotFoundError
14
- raise NotFoundError, "ideal payment with ideal_payment_id #{ideal_payment_id.inspect} not found"
15
- end
16
-
17
- end
18
- end
@@ -1,66 +0,0 @@
1
- module Braintree
2
- class MasterpassCard
3
- include BaseModule # :nodoc:
4
-
5
- attr_reader :billing_address, :bin, :card_type, :cardholder_name,
6
- :commercial, :country_of_issuance, :created_at, :customer_id,
7
- :customer_location, :debit, :durbin_regulated, :expiration_month,
8
- :expiration_year, :healthcare, :issuing_bank, :last_4, :payroll,
9
- :prepaid, :product_id, :subscriptions, :token, :unique_number_identifier,
10
- :updated_at, :image_url, :verification
11
-
12
- def initialize(gateway, attributes) # :nodoc:
13
- @gateway = gateway
14
- set_instance_variables_from_hash(attributes)
15
- @billing_address = attributes[:billing_address] ? Address._new(@gateway, attributes[:billing_address]) : nil
16
- @subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) }
17
- @verification = _most_recent_verification(attributes)
18
- end
19
-
20
- def _most_recent_verification(attributes)
21
- verification = (attributes[:verifications] || []).sort_by{ |verification| verification[:created_at] }.reverse.first
22
- CreditCardVerification._new(verification) if verification
23
- end
24
-
25
- def default?
26
- @default
27
- end
28
-
29
- # Expiration date formatted as MM/YYYY
30
- def expiration_date
31
- "#{expiration_month}/#{expiration_year}"
32
- end
33
-
34
- def expired?
35
- @expired
36
- end
37
-
38
- def ==(other)
39
- return false unless other.is_a?(MasterpassCard)
40
- token == other.token
41
- end
42
-
43
- def inspect # :nodoc:
44
- first = [:token]
45
- order = first + (self.class._attributes - first)
46
- nice_attributes = order.map do |attr|
47
- "#{attr}: #{send(attr).inspect}"
48
- end
49
- "#<#{self.class} #{nice_attributes.join(', ')}>"
50
- end
51
-
52
- def self._attributes # :nodoc:
53
- [
54
- :billing_address, :bin, :card_type, :cardholder_name, :created_at,
55
- :customer_id, :customer_location, :expiration_month, :expiration_year,
56
- :last_4, :token, :updated_at, :prepaid, :payroll, :product_id,
57
- :commercial, :debit, :durbin_regulated, :healthcare,
58
- :country_of_issuance, :issuing_bank, :image_url
59
- ]
60
- end
61
-
62
- def self._new(*args) # :nodoc:
63
- self.new *args
64
- end
65
- end
66
- end
File without changes
@@ -1,14 +0,0 @@
1
- module Braintree
2
- class Transaction
3
- class AmexExpressCheckoutDetails
4
- include BaseModule
5
-
6
- attr_reader :card_type, :token, :bin, :expiration_month, :expiration_year,
7
- :card_member_number, :card_member_expiry_date, :image_url, :source_description
8
-
9
- def initialize(attributes)
10
- set_instance_variables_from_hash attributes unless attributes.nil?
11
- end
12
- end
13
- end
14
- end
@@ -1,17 +0,0 @@
1
- module Braintree
2
- class Transaction
3
- class AndroidPayDetails
4
- include BaseModule
5
-
6
- attr_reader :card_type, :last_4, :expiration_month, :expiration_year,
7
- :google_transaction_id, :virtual_card_type, :virtual_card_last_4,
8
- :source_card_type, :source_card_last_4, :source_description
9
-
10
- def initialize(attributes)
11
- set_instance_variables_from_hash attributes unless attributes.nil?
12
- @card_type = @virtual_card_type
13
- @last_4 = @virtual_card_last_4
14
- end
15
- end
16
- end
17
- end
@@ -1,13 +0,0 @@
1
- module Braintree
2
- class Transaction
3
- class IdealPaymentDetails # :nodoc:
4
- include BaseModule
5
-
6
- attr_reader :ideal_payment_id, :ideal_transaction_id, :masked_iban, :bic, :image_url
7
-
8
- def initialize(attributes)
9
- set_instance_variables_from_hash attributes unless attributes.nil?
10
- end
11
- end
12
- end
13
- end
@@ -1,40 +0,0 @@
1
- module Braintree
2
- module TransparentRedirect
3
- module Kind # :nodoc:
4
- CreateCustomer = "create_customer"
5
- UpdateCustomer = "update_customer"
6
- CreatePaymentMethod = "create_payment_method"
7
- UpdatePaymentMethod = "update_payment_method"
8
- CreateTransaction = "create_transaction"
9
- end
10
-
11
- def self.confirm(query_string)
12
- Configuration.gateway.transparent_redirect.confirm(query_string)
13
- end
14
-
15
- def self.create_credit_card_data(params)
16
- Configuration.gateway.transparent_redirect.create_credit_card_data(params)
17
- end
18
-
19
- def self.create_customer_data(params)
20
- Configuration.gateway.transparent_redirect.create_customer_data(params)
21
- end
22
-
23
- def self.transaction_data(params)
24
- Configuration.gateway.transparent_redirect.transaction_data(params)
25
- end
26
-
27
- def self.update_credit_card_data(params)
28
- Configuration.gateway.transparent_redirect.update_credit_card_data(params)
29
- end
30
-
31
- def self.update_customer_data(params)
32
- Configuration.gateway.transparent_redirect.update_customer_data(params)
33
- end
34
-
35
- # Returns the URL to which Transparent Redirect Requests should be posted
36
- def self.url
37
- Configuration.gateway.transparent_redirect.url
38
- end
39
- end
40
- end
@@ -1,105 +0,0 @@
1
- module Braintree
2
- class TransparentRedirectGateway # :nodoc
3
- TransparentRedirectKeys = [:redirect_url] # :nodoc:
4
- CreateCustomerSignature = TransparentRedirectKeys + [{:customer => CustomerGateway._create_signature}] # :nodoc:
5
- UpdateCustomerSignature = TransparentRedirectKeys + [:customer_id, {:customer => CustomerGateway._update_signature}] # :nodoc:
6
- TransactionSignature = TransparentRedirectKeys + [{:transaction => TransactionGateway._create_signature}] # :nodoc:
7
- CreateCreditCardSignature = TransparentRedirectKeys + [{:credit_card => CreditCardGateway._create_signature}] # :nodoc:
8
- UpdateCreditCardSignature = TransparentRedirectKeys + [:payment_method_token, {:credit_card => CreditCardGateway._update_signature}] # :nodoc:
9
-
10
- def initialize(gateway)
11
- @gateway = gateway
12
- @config = gateway.config
13
- @config.assert_has_access_token_or_keys
14
- end
15
-
16
- def confirm(query_string)
17
- params = @gateway.transparent_redirect.parse_and_validate_query_string query_string
18
- confirmation_gateway = {
19
- TransparentRedirect::Kind::CreateCustomer => :customer,
20
- TransparentRedirect::Kind::UpdateCustomer => :customer,
21
- TransparentRedirect::Kind::CreatePaymentMethod => :credit_card,
22
- TransparentRedirect::Kind::UpdatePaymentMethod => :credit_card,
23
- TransparentRedirect::Kind::CreateTransaction => :transaction
24
- }[params[:kind]]
25
-
26
- @gateway.send(confirmation_gateway)._do_create("/transparent_redirect_requests/#{params[:id]}/confirm")
27
- end
28
-
29
- def create_credit_card_data(params)
30
- Util.verify_keys(CreateCreditCardSignature, params)
31
- params[:kind] = TransparentRedirect::Kind::CreatePaymentMethod
32
- _data(params)
33
- end
34
-
35
- def create_customer_data(params)
36
- Util.verify_keys(CreateCustomerSignature, params)
37
- params[:kind] = TransparentRedirect::Kind::CreateCustomer
38
- _data(params)
39
- end
40
-
41
- def parse_and_validate_query_string(query_string) # :nodoc:
42
- params = Util.symbolize_keys(Util.parse_query_string(query_string))
43
- query_string_without_hash = query_string.split("&").reject{|param| param =~ /\Ahash=/}.join("&")
44
- decoded_query_string_without_hash = Util.url_decode(query_string_without_hash)
45
- encoded_query_string_without_hash = Util.url_encode(query_string_without_hash)
46
-
47
- if params[:http_status] == nil
48
- raise UnexpectedError, "expected query string to have an http_status param"
49
- elsif params[:http_status] != '200'
50
- Util.raise_exception_for_status_code(params[:http_status], params[:bt_message])
51
- end
52
-
53
- query_strings_without_hash = [query_string_without_hash, encoded_query_string_without_hash, decoded_query_string_without_hash]
54
-
55
- if query_strings_without_hash.any? { |query_string| @config.signature_service.hash(query_string) == params[:hash] }
56
- params
57
- else
58
- raise ForgedQueryString
59
- end
60
- end
61
-
62
- def transaction_data(params)
63
- Util.verify_keys(TransactionSignature, params)
64
- params[:kind] = TransparentRedirect::Kind::CreateTransaction
65
- transaction_type = params[:transaction] && params[:transaction][:type]
66
- unless %w[sale credit].include?(transaction_type)
67
- raise ArgumentError, "expected transaction[type] of sale or credit, was: #{transaction_type.inspect}"
68
- end
69
- _data(params)
70
- end
71
-
72
- def update_credit_card_data(params)
73
- Util.verify_keys(UpdateCreditCardSignature, params)
74
- unless params[:payment_method_token]
75
- raise ArgumentError, "expected params to contain :payment_method_token of payment method to update"
76
- end
77
- params[:kind] = TransparentRedirect::Kind::UpdatePaymentMethod
78
- _data(params)
79
- end
80
-
81
- def update_customer_data(params)
82
- Util.verify_keys(UpdateCustomerSignature, params)
83
- unless params[:customer_id]
84
- raise ArgumentError, "expected params to contain :customer_id of customer to update"
85
- end
86
- params[:kind] = TransparentRedirect::Kind::UpdateCustomer
87
- _data(params)
88
- end
89
-
90
- def url
91
- "#{@config.base_merchant_url}/transparent_redirect_requests"
92
- end
93
-
94
- def _data(params) # :nodoc:
95
- raise ArgumentError, "expected params to contain :redirect_url" unless params[:redirect_url]
96
-
97
- @config.signature_service.sign(params.merge(
98
- :api_version => @config.api_version,
99
- :time => Time.now.utc.strftime("%Y%m%d%H%M%S"),
100
- :public_key => @config.public_key
101
- ))
102
- end
103
- end
104
- end
105
-
@@ -1,18 +0,0 @@
1
- require 'timeout'
2
- require 'socket'
3
-
4
- TCPSocket.class_eval do
5
- def self.wait_for_service(options)
6
- Timeout::timeout(options[:timeout] || 20) do
7
- loop do
8
- begin
9
- socket = TCPSocket.new(options[:host], options[:port])
10
- socket.close
11
- return
12
- rescue Errno::ECONNREFUSED
13
- sleep 0.5
14
- end
15
- end
16
- end
17
- end
18
- end
data/spec/httpsd.pid DELETED
@@ -1 +0,0 @@
1
- 15408
@@ -1,31 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
-
3
- describe "Coinbase" do
4
-
5
- def assert_valid_coinbase_attrs(account_or_details)
6
- [:user_id, :user_name, :user_email].each do |attr|
7
- [nil,""].should_not include(account_or_details.send(attr))
8
- end
9
- end
10
-
11
- it "works for transaction#create" do
12
- result = Braintree::Transaction.sale(:payment_method_nonce => Braintree::Test::Nonce::Coinbase, :amount => "0.02")
13
- result.should be_success
14
- assert_valid_coinbase_attrs(result.transaction.coinbase_details)
15
- end
16
-
17
- it "works for vaulting" do
18
- customer = Braintree::Customer.create!
19
- vaulted = Braintree::PaymentMethod.create(:customer_id => customer.id, :payment_method_nonce => Braintree::Test::Nonce::Coinbase).payment_method
20
- assert_valid_coinbase_attrs(vaulted)
21
-
22
- found = Braintree::PaymentMethod.find(vaulted.token).payment_method
23
- assert_valid_coinbase_attrs(found)
24
- end
25
-
26
- it "is returned on Customers" do
27
- customer = Braintree::Customer.create!(:payment_method_nonce => Braintree::Test::Nonce::Coinbase)
28
- customer.payment_methods.should == customer.coinbase_accounts
29
- assert_valid_coinbase_attrs(customer.coinbase_accounts[0])
30
- end
31
- end
@@ -1,87 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
- require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
3
-
4
- describe Braintree::IdealPayment do
5
- context "self.sale" do
6
- it "creates a transaction using an Ideal payment token and returns a result object" do
7
- ideal_payment_id = generate_valid_ideal_payment_nonce
8
-
9
- result = Braintree::IdealPayment.sale(
10
- ideal_payment_id,
11
- :order_id => SpecHelper::DefaultOrderId,
12
- :merchant_account_id => "ideal_merchant_account",
13
- :amount => Braintree::Test::TransactionAmounts::Authorize
14
- )
15
-
16
- result.success?.should == true
17
- result.transaction.amount.should == BigDecimal.new(Braintree::Test::TransactionAmounts::Authorize)
18
- result.transaction.type.should == "sale"
19
- ideal_payment_details = result.transaction.ideal_payment_details
20
- ideal_payment_details.ideal_payment_id.should =~ /^idealpayment_\w{6,}$/
21
- ideal_payment_details.ideal_transaction_id.should =~ /^\d{16,}$/
22
- ideal_payment_details.image_url.should start_with("https://")
23
- ideal_payment_details.masked_iban.should_not be_empty
24
- ideal_payment_details.bic.should_not be_empty
25
- end
26
- end
27
-
28
- context "self.sale!" do
29
- it "creates a transaction using an ideal payment and returns a result object" do
30
- ideal_payment_id = generate_valid_ideal_payment_nonce
31
-
32
- transaction = Braintree::IdealPayment.sale!(
33
- ideal_payment_id,
34
- :order_id => SpecHelper::DefaultOrderId,
35
- :merchant_account_id => "ideal_merchant_account",
36
- :amount => Braintree::Test::TransactionAmounts::Authorize
37
- )
38
-
39
- transaction.amount.should == BigDecimal.new(Braintree::Test::TransactionAmounts::Authorize)
40
- transaction.type.should == "sale"
41
- ideal_payment_details = transaction.ideal_payment_details
42
- ideal_payment_details.ideal_payment_id.should =~ /^idealpayment_\w{6,}$/
43
- ideal_payment_details.ideal_transaction_id.should =~ /^\d{16,}$/
44
- ideal_payment_details.image_url.should start_with("https://")
45
- ideal_payment_details.masked_iban.should_not be_empty
46
- ideal_payment_details.bic.should_not be_empty
47
- end
48
-
49
- it "does not create a transaction using an ideal payment and returns raises an exception" do
50
- expect do
51
- Braintree::IdealPayment.sale!(
52
- "invalid_nonce",
53
- :merchant_account_id => "ideal_merchant_account",
54
- :amount => Braintree::Test::TransactionAmounts::Authorize
55
- )
56
- end.to raise_error(Braintree::ValidationsFailed)
57
- end
58
- end
59
-
60
- context "self.find" do
61
- it "finds the Ideal payment with an id" do
62
- ideal_payment_id = generate_valid_ideal_payment_nonce
63
- ideal_payment = Braintree::IdealPayment.find(ideal_payment_id)
64
-
65
- ideal_payment.id.should =~ /^idealpayment_\w{6,}$/
66
- ideal_payment.ideal_transaction_id.should =~ /^\d{16,}$/
67
- ideal_payment.currency.should_not be_empty
68
- ideal_payment.amount.should_not be_empty
69
- ideal_payment.status.should_not be_empty
70
- ideal_payment.order_id.should_not be_empty
71
- ideal_payment.issuer.should_not be_empty
72
- ideal_payment.approval_url.should start_with("https://")
73
- ideal_payment.iban_bank_account.account_holder_name.should_not be_empty
74
- ideal_payment.iban_bank_account.bic.should_not be_empty
75
- ideal_payment.iban_bank_account.masked_iban.should_not be_empty
76
- ideal_payment.iban_bank_account.iban_account_number_last_4.should =~ /^\d{4}$/
77
- ideal_payment.iban_bank_account.iban_country.should_not be_empty
78
- ideal_payment.iban_bank_account.description.should_not be_empty
79
- end
80
-
81
- it "raises if the Ideal payment is not found" do
82
- expect do
83
- Braintree::IdealPayment.find("idealpayment_nxyqkq_s654wq_92jr64_mnr4kr_yjz")
84
- end.to raise_error(Braintree::NotFoundError)
85
- end
86
- end
87
- end