braintree 2.104.0 → 4.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) 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 +1 -1
  5. data/lib/braintree/address.rb +2 -23
  6. data/lib/braintree/apple_pay.rb +1 -1
  7. data/lib/braintree/apple_pay_card.rb +11 -1
  8. data/lib/braintree/apple_pay_options.rb +1 -1
  9. data/lib/braintree/authorization_adjustment.rb +1 -1
  10. data/lib/braintree/base_module.rb +6 -0
  11. data/lib/braintree/bin_data.rb +9 -2
  12. data/lib/braintree/client_token.rb +1 -1
  13. data/lib/braintree/configuration.rb +12 -12
  14. data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
  15. data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
  16. data/lib/braintree/credit_card.rb +2 -77
  17. data/lib/braintree/credit_card_gateway.rb +17 -36
  18. data/lib/braintree/credit_card_verification.rb +18 -5
  19. data/lib/braintree/credit_card_verification_search.rb +1 -1
  20. data/lib/braintree/customer.rb +9 -78
  21. data/lib/braintree/customer_gateway.rb +2 -23
  22. data/lib/braintree/customer_search.rb +1 -1
  23. data/lib/braintree/disbursement.rb +1 -1
  24. data/lib/braintree/{transaction/coinbase_details.rb → dispute/paypal_message.rb} +5 -6
  25. data/lib/braintree/dispute/{history_event.rb → status_history.rb} +3 -1
  26. data/lib/braintree/dispute.rb +32 -8
  27. data/lib/braintree/dispute_gateway.rb +4 -9
  28. data/lib/braintree/dispute_search.rb +6 -3
  29. data/lib/braintree/document_upload.rb +1 -1
  30. data/lib/braintree/enriched_customer_data.rb +21 -0
  31. data/lib/braintree/error_codes.rb +150 -171
  32. data/lib/braintree/exceptions.rb +5 -3
  33. data/lib/braintree/exchange_rate.rb +13 -0
  34. data/lib/braintree/exchange_rate_quote.rb +24 -0
  35. data/lib/braintree/exchange_rate_quote_gateway.rb +35 -0
  36. data/lib/braintree/exchange_rate_quote_input.rb +21 -0
  37. data/lib/braintree/exchange_rate_quote_request.rb +18 -0
  38. data/lib/braintree/exchange_rate_quote_response.rb +18 -0
  39. data/lib/braintree/gateway.rb +4 -14
  40. data/lib/braintree/{android_pay_card.rb → google_pay_card.rb} +11 -3
  41. data/lib/braintree/granted_payment_instrument_update.rb +1 -1
  42. data/lib/braintree/graphql_client.rb +7 -7
  43. data/lib/braintree/http.rb +4 -3
  44. data/lib/braintree/local_payment_completed.rb +2 -2
  45. data/lib/braintree/local_payment_expired.rb +21 -0
  46. data/lib/braintree/local_payment_funded.rb +22 -0
  47. data/lib/braintree/local_payment_reversed.rb +19 -0
  48. data/lib/braintree/merchant.rb +1 -1
  49. data/lib/braintree/merchant_account.rb +1 -1
  50. data/lib/braintree/merchant_account_gateway.rb +3 -1
  51. data/lib/braintree/merchant_gateway.rb +1 -1
  52. data/lib/braintree/modification.rb +1 -1
  53. data/lib/braintree/oauth_credentials.rb +1 -1
  54. data/lib/braintree/oauth_gateway.rb +5 -5
  55. data/lib/braintree/payment_instrument_type.rb +10 -14
  56. data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
  57. data/lib/braintree/payment_method_gateway.rb +15 -17
  58. data/lib/braintree/payment_method_nonce.rb +7 -4
  59. data/lib/braintree/payment_method_nonce_details.rb +37 -0
  60. data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
  61. data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
  62. data/lib/braintree/payment_method_parser.rb +1 -8
  63. data/lib/braintree/plan.rb +21 -1
  64. data/lib/braintree/plan_gateway.rb +100 -0
  65. data/lib/braintree/processor_response_types.rb +3 -3
  66. data/lib/braintree/resource_collection.rb +8 -3
  67. data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
  68. data/lib/braintree/risk_data/liability_shift.rb +22 -0
  69. data/lib/braintree/risk_data.rb +5 -1
  70. data/lib/braintree/samsung_pay_card.rb +1 -1
  71. data/lib/braintree/settlement_batch_summary.rb +2 -2
  72. data/lib/braintree/subscription.rb +11 -11
  73. data/lib/braintree/successful_result.rb +3 -2
  74. data/lib/braintree/test/credit_card.rb +1 -0
  75. data/lib/braintree/test/nonce.rb +4 -23
  76. data/lib/braintree/three_d_secure_info.rb +22 -12
  77. data/lib/braintree/transaction/disbursement_details.rb +1 -0
  78. data/lib/braintree/transaction/{android_pay_details.rb → google_pay_details.rb} +1 -1
  79. data/lib/braintree/transaction/installment/adjustment.rb +33 -0
  80. data/lib/braintree/transaction/installment.rb +28 -0
  81. data/lib/braintree/transaction/paypal_details.rb +3 -0
  82. data/lib/braintree/transaction/subscription_details.rb +2 -0
  83. data/lib/braintree/transaction.rb +65 -120
  84. data/lib/braintree/transaction_gateway.rb +39 -27
  85. data/lib/braintree/transaction_line_item.rb +1 -1
  86. data/lib/braintree/transaction_review.rb +18 -0
  87. data/lib/braintree/transaction_search.rb +5 -3
  88. data/lib/braintree/unknown_payment_method.rb +1 -1
  89. data/lib/braintree/us_bank_account.rb +3 -3
  90. data/lib/braintree/us_bank_account_verification.rb +1 -1
  91. data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
  92. data/lib/braintree/util.rb +21 -6
  93. data/lib/braintree/venmo_account.rb +1 -1
  94. data/lib/braintree/venmo_profile_data.rb +23 -0
  95. data/lib/braintree/version.rb +2 -2
  96. data/lib/braintree/visa_checkout_card.rb +2 -2
  97. data/lib/braintree/webhook_notification.rb +44 -30
  98. data/lib/braintree/webhook_notification_gateway.rb +5 -5
  99. data/lib/braintree/webhook_testing_gateway.rb +104 -43
  100. data/lib/braintree/xml/generator.rb +5 -4
  101. data/lib/braintree/xml/parser.rb +22 -35
  102. data/lib/braintree/xml/rexml.rb +4 -5
  103. data/lib/braintree.rb +28 -23
  104. data/spec/integration/braintree/add_on_spec.rb +1 -1
  105. data/spec/integration/braintree/address_spec.rb +30 -113
  106. data/spec/integration/braintree/advanced_search_spec.rb +45 -45
  107. data/spec/integration/braintree/apple_pay_spec.rb +3 -3
  108. data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
  109. data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
  110. data/spec/integration/braintree/client_api/spec_helper.rb +5 -31
  111. data/spec/integration/braintree/credit_card_spec.rb +219 -593
  112. data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
  113. data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
  114. data/spec/integration/braintree/customer_search_spec.rb +8 -8
  115. data/spec/integration/braintree/customer_spec.rb +484 -513
  116. data/spec/integration/braintree/dispute_search_spec.rb +35 -6
  117. data/spec/integration/braintree/dispute_spec.rb +6 -7
  118. data/spec/integration/braintree/error_codes_spec.rb +1 -1
  119. data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
  120. data/spec/integration/braintree/graphql_client_spec.rb +0 -2
  121. data/spec/integration/braintree/http_spec.rb +2 -2
  122. data/spec/integration/braintree/merchant_account_spec.rb +28 -29
  123. data/spec/integration/braintree/merchant_spec.rb +14 -14
  124. data/spec/integration/braintree/oauth_spec.rb +11 -11
  125. data/spec/integration/braintree/payment_method_nonce_spec.rb +29 -35
  126. data/spec/integration/braintree/payment_method_spec.rb +535 -270
  127. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +17 -13
  128. data/spec/integration/braintree/paypal_account_spec.rb +28 -28
  129. data/spec/integration/braintree/plan_spec.rb +82 -0
  130. data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
  131. data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
  132. data/spec/integration/braintree/subscription_spec.rb +144 -149
  133. data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
  134. data/spec/integration/braintree/test_transaction_spec.rb +10 -10
  135. data/spec/integration/braintree/transaction_search_spec.rb +175 -70
  136. data/spec/integration/braintree/transaction_spec.rb +955 -894
  137. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -26
  138. data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
  139. data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
  140. data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
  141. data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
  142. data/spec/integration/spec_helper.rb +16 -7
  143. data/spec/oauth_test_helper.rb +1 -1
  144. data/spec/script/httpsd.rb +6 -6
  145. data/spec/spec_helper.rb +8 -14
  146. data/spec/unit/braintree/address_spec.rb +1 -9
  147. data/spec/unit/braintree/apple_pay_card_spec.rb +7 -1
  148. data/spec/unit/braintree/client_token_spec.rb +2 -2
  149. data/spec/unit/braintree/configuration_spec.rb +42 -42
  150. data/spec/unit/braintree/credit_card_spec.rb +13 -32
  151. data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
  152. data/spec/unit/braintree/credit_card_verification_spec.rb +8 -4
  153. data/spec/unit/braintree/customer_spec.rb +21 -22
  154. data/spec/unit/braintree/disbursement_spec.rb +7 -7
  155. data/spec/unit/braintree/dispute_search_spec.rb +3 -0
  156. data/spec/unit/braintree/dispute_spec.rb +75 -21
  157. data/spec/unit/braintree/enriched_customer_data_spec.rb +32 -0
  158. data/spec/unit/braintree/error_result_spec.rb +5 -5
  159. data/spec/unit/braintree/errors_spec.rb +8 -8
  160. data/spec/unit/braintree/exchange_rate_quote_input_spec.rb +42 -0
  161. data/spec/unit/braintree/exchange_rate_quote_request_spec.rb +82 -0
  162. data/spec/unit/braintree/exchange_rate_quote_response_spec.rb +52 -0
  163. data/spec/unit/braintree/exchange_rate_quote_spec.rb +42 -0
  164. data/spec/unit/braintree/exchange_rate_spec.rb +23 -0
  165. data/spec/unit/braintree/http_spec.rb +10 -8
  166. data/spec/unit/braintree/local_payment_completed_spec.rb +14 -0
  167. data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
  168. data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
  169. data/spec/unit/braintree/merchant_account_spec.rb +1 -1
  170. data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +45 -0
  171. data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
  172. data/spec/unit/braintree/payment_method_nonce_details_spec.rb +43 -0
  173. data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
  174. data/spec/unit/braintree/payment_method_spec.rb +1 -1
  175. data/spec/unit/braintree/paypal_account_spec.rb +2 -2
  176. data/spec/unit/braintree/resource_collection_spec.rb +30 -1
  177. data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
  178. data/spec/unit/braintree/risk_data_spec.rb +38 -8
  179. data/spec/unit/braintree/subscription_search_spec.rb +1 -1
  180. data/spec/unit/braintree/successful_result_spec.rb +1 -1
  181. data/spec/unit/braintree/three_d_secure_info_spec.rb +32 -14
  182. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +3 -3
  183. data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
  184. data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
  185. data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
  186. data/spec/unit/braintree/transaction/paypal_details_spec.rb +7 -1
  187. data/spec/unit/braintree/transaction_search_spec.rb +12 -12
  188. data/spec/unit/braintree/transaction_spec.rb +36 -54
  189. data/spec/unit/braintree/util_spec.rb +55 -21
  190. data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
  191. data/spec/unit/braintree/venmo_profile_data_spec.rb +32 -0
  192. data/spec/unit/braintree/webhook_notification_spec.rb +166 -57
  193. data/spec/unit/braintree/xml/parser_spec.rb +21 -16
  194. data/spec/unit/braintree/xml_spec.rb +31 -31
  195. metadata +62 -30
  196. data/lib/braintree/amex_express_checkout_card.rb +0 -40
  197. data/lib/braintree/coinbase_account.rb +0 -34
  198. data/lib/braintree/europe_bank_account.rb +0 -36
  199. data/lib/braintree/europe_bank_account_gateway.rb +0 -17
  200. data/lib/braintree/ideal_payment.rb +0 -61
  201. data/lib/braintree/ideal_payment_gateway.rb +0 -19
  202. data/lib/braintree/masterpass_card.rb +0 -83
  203. data/lib/braintree/settlement_batch.rb +0 -0
  204. data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -21
  205. data/lib/braintree/transaction/ideal_payment_details.rb +0 -19
  206. data/lib/braintree/transaction/masterpass_card_details.rb +0 -49
  207. data/lib/braintree/transparent_redirect.rb +0 -40
  208. data/lib/braintree/transparent_redirect_gateway.rb +0 -105
  209. data/spec/hacks/tcp_socket.rb +0 -18
  210. data/spec/integration/braintree/coinbase_spec.rb +0 -34
  211. data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
  212. data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
  213. data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
@@ -0,0 +1,13 @@
1
+ module Braintree
2
+ class ExchangeRate
3
+ include BaseModule # :nodoc:
4
+
5
+ def initialize(gateway, attributes) # :nodoc:
6
+ set_instance_variables_from_hash(attributes)
7
+ end
8
+
9
+ def self.generate(exchange_rate_quote_request)
10
+ Configuration.gateway.exchange_rate_quote.generate(exchange_rate_quote_request)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ module Braintree
2
+ class ExchangeRateQuote
3
+ include BaseModule # :nodoc:
4
+
5
+ attr_reader :attrs
6
+ attr_reader :base_amount
7
+ attr_reader :exchange_rate
8
+ attr_reader :expires_at
9
+ attr_reader :id
10
+ attr_reader :quote_amount
11
+ attr_reader :refreshes_at
12
+ attr_reader :trade_rate
13
+
14
+ def initialize(attributes) # :nodoc:
15
+ @attrs = attributes.keys
16
+ set_instance_variables_from_hash(attributes)
17
+ end
18
+
19
+ def inspect # :nodoc:
20
+ inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
21
+ "#<#{self.class} #{inspected_attributes.join(" ")}>"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,35 @@
1
+ module Braintree
2
+ class ExchangeRateQuoteGateway # :nodoc
3
+ def initialize(gateway)
4
+ @gateway = gateway
5
+ end
6
+
7
+ DEFINITION = <<-GRAPHQL
8
+ mutation GenerateExchangeRateQuoteInput($input: GenerateExchangeRateQuoteInput!) {
9
+ generateExchangeRateQuote(input: $input) {
10
+ quotes {
11
+ id
12
+ baseAmount {value, currencyCode}
13
+ quoteAmount {value, currencyCode}
14
+ exchangeRate
15
+ tradeRate
16
+ expiresAt
17
+ refreshesAt
18
+ }
19
+ }
20
+ }
21
+ GRAPHQL
22
+
23
+ def generate(params)
24
+ response = @gateway.config.graphql_client.query(DEFINITION, {input: params})
25
+
26
+ if response.has_key?(:data) && response[:data][:generateExchangeRateQuote]
27
+ response[:data][:generateExchangeRateQuote]
28
+ elsif response[:errors]
29
+ ErrorResult.new(@gateway, response[:errors])
30
+ else
31
+ raise UnexpectedError, "expected :generateExchangeRateQuote or :api_error_response in GraphQL response"
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,21 @@
1
+ module Braintree
2
+ class ExchangeRateQuoteInput
3
+ include BaseModule # :nodoc:
4
+
5
+ attr_reader :attrs
6
+ attr_reader :base_currency
7
+ attr_reader :base_amount
8
+ attr_reader :markup
9
+ attr_reader :quote_currency
10
+
11
+ def initialize(attributes) # :nodoc:
12
+ @attrs = attributes.keys
13
+ set_instance_variables_from_hash(attributes)
14
+ end
15
+
16
+ def inspect # :nodoc:
17
+ inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
18
+ "#<#{self.class} #{inspected_attributes.join(" ")}>"
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ module Braintree
2
+ class ExchangeRateQuoteRequest
3
+ include BaseModule # :nodoc:
4
+
5
+ attr_reader :quotes
6
+
7
+ def initialize(attributes) # :nodoc:
8
+ @attrs = attributes.keys
9
+ set_instance_variables_from_hash(attributes)
10
+ @quotes = (@quotes || []).map { |quote_hash| ExchangeRateQuoteInput.new(quote_hash) }
11
+ end
12
+
13
+ def inspect # :nodoc:
14
+ inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
15
+ "#<#{self.class} #{inspected_attributes.join(" ")}>"
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module Braintree
2
+ class ExchangeRateQuoteResponse
3
+ include BaseModule # :nodoc:
4
+
5
+ attr_reader :quotes
6
+
7
+ def initialize(attributes) # :nodoc:
8
+ @attrs = attributes.keys
9
+ set_instance_variables_from_hash(attributes)
10
+ @quotes = (@quotes || []).map { |quote_hash| ExchangeRateQuote.new(quote_hash) }
11
+ end
12
+
13
+ def inspect # :nodoc:
14
+ inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
15
+ "#<#{self.class} #{inspected_attributes.join(" ")}>"
16
+ end
17
+ end
18
+ end
@@ -50,6 +50,10 @@ module Braintree
50
50
  DocumentUploadGateway.new(self)
51
51
  end
52
52
 
53
+ def exchange_rate_quote
54
+ ExchangeRateQuoteGateway.new(self)
55
+ end
56
+
53
57
  def oauth
54
58
  OAuthGateway.new(self)
55
59
  end
@@ -74,12 +78,6 @@ module Braintree
74
78
  UsBankAccountGateway.new(self)
75
79
  end
76
80
 
77
- # NEXT_MAJOR_VERSION Remove this class as legacy Ideal has been removed/disabled in the Braintree Gateway
78
- # DEPRECATED If you're looking to accept iDEAL as a payment method contact accounts@braintreepayments.com for a solution.
79
- def ideal_payment
80
- IdealPaymentGateway.new(self)
81
- end
82
-
83
81
  def merchant
84
82
  MerchantGateway.new(self)
85
83
  end
@@ -88,10 +86,6 @@ module Braintree
88
86
  MerchantAccountGateway.new(self)
89
87
  end
90
88
 
91
- def europe_bank_account
92
- EuropeBankAccountGateway.new(self)
93
- end
94
-
95
89
  def settlement_batch_summary
96
90
  SettlementBatchSummaryGateway.new(self)
97
91
  end
@@ -100,10 +94,6 @@ module Braintree
100
94
  SubscriptionGateway.new(self)
101
95
  end
102
96
 
103
- def transparent_redirect
104
- TransparentRedirectGateway.new(self)
105
- end
106
-
107
97
  def transaction
108
98
  TransactionGateway.new(self)
109
99
  end
@@ -1,16 +1,24 @@
1
1
  module Braintree
2
- # NEXT_MAJOR_VERSION rename Android Pay to Google Pay
3
- class AndroidPayCard
2
+ class GooglePayCard
4
3
  include BaseModule # :nodoc:
5
4
 
6
5
  attr_reader :bin
6
+ attr_reader :commercial
7
+ attr_reader :country_of_issuance
7
8
  attr_reader :created_at
8
9
  attr_reader :customer_id
10
+ attr_reader :debit
9
11
  attr_reader :default
12
+ attr_reader :durbin_regulated
10
13
  attr_reader :expiration_month
11
14
  attr_reader :expiration_year
12
15
  attr_reader :google_transaction_id
16
+ attr_reader :healthcare
13
17
  attr_reader :image_url
18
+ attr_reader :issuing_bank
19
+ attr_reader :payroll
20
+ attr_reader :prepaid
21
+ attr_reader :product_id
14
22
  attr_reader :source_card_last_4
15
23
  attr_reader :source_card_type
16
24
  attr_reader :source_description
@@ -47,7 +55,7 @@ module Braintree
47
55
  end
48
56
 
49
57
  def self._new(*args) # :nodoc:
50
- self.new *args
58
+ self.new(*args)
51
59
  end
52
60
  end
53
61
  end
@@ -16,7 +16,7 @@ module Braintree
16
16
  class << self
17
17
  protected :new
18
18
  def _new(*args) # :nodoc:
19
- self.new *args
19
+ self.new(*args)
20
20
  end
21
21
  end
22
22
  end
@@ -4,9 +4,9 @@ module Braintree
4
4
  def initialize(config)
5
5
  @config = config
6
6
  @graphql_headers = {
7
- 'Accept' => 'application/json',
8
- 'Braintree-Version' => @config.graphql_api_version,
9
- 'Content-Type' => 'application/json'
7
+ "Accept" => "application/json",
8
+ "Braintree-Version" => @config.graphql_api_version,
9
+ "Content-Type" => "application/json"
10
10
  }
11
11
  end
12
12
 
@@ -14,9 +14,9 @@ module Braintree
14
14
  graphql_connection = _setup_connection(@config.graphql_server, @config.graphql_port)
15
15
 
16
16
  request = {}
17
- request['query'] = definition
18
- request['operationName'] = operationName if operationName
19
- request['variables'] = variables
17
+ request["query"] = definition
18
+ request["operationName"] = operationName if operationName
19
+ request["variables"] = variables
20
20
 
21
21
  response = _http_do Net::HTTP::Post, @config.graphql_base_url, request.to_json, nil, graphql_connection, @graphql_headers
22
22
  data = _parse_response(response)
@@ -27,7 +27,7 @@ module Braintree
27
27
 
28
28
  def _parse_response(response)
29
29
  body = response.body
30
- body = Zlib::GzipReader.new(StringIO.new(body)).read if response.header['Content-Encoding'] == "gzip"
30
+ body = Zlib::GzipReader.new(StringIO.new(body)).read if response.header["Content-Encoding"] == "gzip"
31
31
  JSON.parse(body, :symbolize_names => true)
32
32
  end
33
33
  end
@@ -75,7 +75,7 @@ module Braintree
75
75
  @config.proxy_address,
76
76
  @config.proxy_port,
77
77
  @config.proxy_user,
78
- @config.proxy_pass
78
+ @config.proxy_pass,
79
79
  )
80
80
  else
81
81
  connection = Net::HTTP.new(server, port)
@@ -127,7 +127,7 @@ module Braintree
127
127
  form_params.push(_add_form_field(k, v))
128
128
  end
129
129
  form_params.push(_add_file_part("file", file))
130
- request.body = form_params.collect {|p| "--" + boundary + "#{LINE_FEED}" + p}.join("") + "--" + boundary + "--"
130
+ request.body = form_params.collect { |p| "--" + boundary + "#{LINE_FEED}" + p }.join("") + "--" + boundary + "--"
131
131
  @config.logger.debug _format_and_sanitize_body_for_log(_build_xml(body))
132
132
  else
133
133
  request.body = body
@@ -187,7 +187,8 @@ module Braintree
187
187
  def _format_and_sanitize_body_for_log(input_xml)
188
188
  formatted_xml = input_xml.gsub(/^/, "[Braintree] ")
189
189
  formatted_xml = formatted_xml.gsub(/<number>(.{6}).+?(.{4})<\/number>/m, '<number>\1******\2</number>')
190
- formatted_xml = formatted_xml.gsub(/<cvv>.+?<\/cvv>/m, '<cvv>***</cvv>')
190
+ formatted_xml = formatted_xml.gsub(/<cvv>.+?<\/cvv>/m, "<cvv>***</cvv>")
191
+ formatted_xml = formatted_xml.gsub(/<encrypted-card-data>.+?<\/encrypted-card-data>/m, "<encrypted-card-data>***</encrypted-card-data>")
191
192
  formatted_xml
192
193
  end
193
194
 
@@ -9,7 +9,7 @@ module Braintree
9
9
 
10
10
  def initialize(attributes) # :nodoc:
11
11
  set_instance_variables_from_hash(attributes)
12
- @transaction = Transaction._new(Configuration.gateway, transaction)
12
+ @transaction = Transaction._new(Configuration.gateway, transaction) unless transaction.nil?
13
13
  end
14
14
 
15
15
  class << self
@@ -17,7 +17,7 @@ module Braintree
17
17
  end
18
18
 
19
19
  def self._new(*args) # :nodoc:
20
- self.new *args
20
+ self.new(*args)
21
21
  end
22
22
  end
23
23
  end
@@ -0,0 +1,21 @@
1
+ module Braintree
2
+ class LocalPaymentExpired
3
+ include BaseModule
4
+
5
+ attr_reader :payment_id
6
+ attr_reader :payment_context_id
7
+
8
+ def initialize(attributes) # :nodoc:
9
+ set_instance_variables_from_hash(attributes)
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
+ end
20
+ end
21
+
@@ -0,0 +1,22 @@
1
+ module Braintree
2
+ class LocalPaymentFunded
3
+ include BaseModule
4
+
5
+ attr_reader :payment_id
6
+ attr_reader :payment_context_id
7
+ attr_reader :transaction
8
+
9
+ def initialize(attributes) # :nodoc:
10
+ set_instance_variables_from_hash(attributes)
11
+ @transaction = Transaction._new(Configuration.gateway, transaction)
12
+ end
13
+
14
+ class << self
15
+ protected :new
16
+ end
17
+
18
+ def self._new(*args) # :nodoc:
19
+ self.new(*args)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,19 @@
1
+ module Braintree
2
+ class LocalPaymentReversed
3
+ include BaseModule
4
+
5
+ attr_reader :payment_id
6
+
7
+ def initialize(attributes) # :nodoc:
8
+ set_instance_variables_from_hash(attributes)
9
+ end
10
+
11
+ class << self
12
+ protected :new
13
+ end
14
+
15
+ def self._new(*args) # :nodoc:
16
+ self.new(*args)
17
+ end
18
+ end
19
+ end
@@ -24,7 +24,7 @@ module Braintree
24
24
  end
25
25
 
26
26
  def self._new(*args) # :nodoc:
27
- self.new *args
27
+ self.new(*args)
28
28
  end
29
29
 
30
30
  def self.provision_raw_apple_pay
@@ -61,7 +61,7 @@ module Braintree
61
61
  class << self
62
62
  protected :new
63
63
  def _new(*args) # :nodoc:
64
- self.new *args
64
+ self.new(*args)
65
65
  end
66
66
  end
67
67
 
@@ -74,7 +74,7 @@ module Braintree
74
74
 
75
75
  if response.has_key?(:response) && response[:response][:merchant_account]
76
76
  Braintree::SuccessfulResult.new(
77
- :merchant_account => MerchantAccount._new(@gateway, response[:response][:merchant_account])
77
+ :merchant_account => MerchantAccount._new(@gateway, response[:response][:merchant_account]),
78
78
  )
79
79
  elsif response[:api_error_response]
80
80
  ErrorResult.new(@gateway, response[:api_error_response])
@@ -83,6 +83,7 @@ module Braintree
83
83
  end
84
84
  end
85
85
 
86
+ # this is part of Marketplace and shouldn't be removed unless we're removing all Marketplace code
86
87
  def self._detect_signature(attributes)
87
88
  if attributes.has_key?(:applicant_details)
88
89
  warn "[DEPRECATED] Passing :applicant_details to create is deprecated. Please use :individual, :business, and :funding."
@@ -92,6 +93,7 @@ module Braintree
92
93
  end
93
94
  end
94
95
 
96
+ # this is part of Marketplace and shouldn't be removed unless we're removing all Marketplace code
95
97
  def self._deprecated_create_signature # :nodoc:
96
98
  [
97
99
  {:applicant_details => [
@@ -26,7 +26,7 @@ module Braintree
26
26
  if response.has_key?(:response) && response[:response][:merchant]
27
27
  Braintree::SuccessfulResult.new(
28
28
  :merchant => Merchant._new(@gateway, response[:response][:merchant]),
29
- :credentials => OAuthCredentials._new(response[:response][:credentials])
29
+ :credentials => OAuthCredentials._new(response[:response][:credentials]),
30
30
  )
31
31
  elsif response[:api_error_response]
32
32
  ErrorResult.new(@gateway, response[:api_error_response])
@@ -18,7 +18,7 @@ module Braintree
18
18
  class << self
19
19
  protected :new
20
20
  def _new(*args) # :nodoc:
21
- self.new *args
21
+ self.new(*args)
22
22
  end
23
23
  end
24
24
 
@@ -16,7 +16,7 @@ module Braintree
16
16
  end
17
17
 
18
18
  def self._new(*args) # :nodoc:
19
- self.new *args
19
+ self.new(*args)
20
20
  end
21
21
  end
22
22
  end
@@ -22,7 +22,7 @@ module Braintree
22
22
  })
23
23
  if response[:credentials]
24
24
  Braintree::SuccessfulResult.new(
25
- :credentials => OAuthCredentials._new(response[:credentials])
25
+ :credentials => OAuthCredentials._new(response[:credentials]),
26
26
  )
27
27
  elsif response[:api_error_response]
28
28
  ErrorResult.new(@gateway, response[:api_error_response])
@@ -47,10 +47,10 @@ module Braintree
47
47
  user_params = _sub_query(params, :user)
48
48
  business_params = _sub_query(params, :business)
49
49
  payment_methods = _sub_array_query(params, :payment_methods)
50
- query = params.to_a.
51
- concat(user_params).
52
- concat(business_params).
53
- concat(payment_methods)
50
+ query = params.to_a
51
+ .concat(user_params)
52
+ .concat(business_params)
53
+ .concat(payment_methods)
54
54
 
55
55
  query_string = query.map { |k, v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join("&")
56
56
  "#{@config.base_url}/oauth/connect?#{query_string}"
@@ -1,18 +1,14 @@
1
1
  module Braintree
2
2
  module PaymentInstrumentType
3
- PayPalAccount = 'paypal_account'
4
- EuropeBankAccount = 'europe_bank_account'
5
- CreditCard = 'credit_card'
6
- CoinbaseAccount = 'coinbase_account'
7
- ApplePayCard = 'apple_pay_card'
8
- # NEXT_MAJOR_VERSION rename Android Pay to Google Pay
9
- AndroidPayCard = 'android_pay_card'
10
- VenmoAccount = 'venmo_account'
11
- UsBankAccount = 'us_bank_account'
12
- VisaCheckoutCard = 'visa_checkout_card'
13
- MasterpassCard = 'masterpass_card' # Deprecated
14
- SamsungPayCard = 'samsung_pay_card'
15
- LocalPayment = 'local_payment'
16
- PayPalHere = 'paypal_here'
3
+ PayPalAccount = "paypal_account"
4
+ CreditCard = "credit_card"
5
+ ApplePayCard = "apple_pay_card"
6
+ GooglePayCard = "android_pay_card"
7
+ VenmoAccount = "venmo_account"
8
+ UsBankAccount = "us_bank_account"
9
+ VisaCheckoutCard = "visa_checkout_card"
10
+ SamsungPayCard = "samsung_pay_card"
11
+ LocalPayment = "local_payment"
12
+ PayPalHere = "paypal_here"
17
13
  end
18
14
  end
@@ -0,0 +1,24 @@
1
+ module Braintree
2
+ class PaymentMethodCustomerDataUpdatedMetadata
3
+ include BaseModule
4
+
5
+ attr_reader :token
6
+ attr_reader :payment_method
7
+ attr_reader :datetime_updated
8
+ attr_reader :enriched_customer_data
9
+
10
+ def initialize(gateway, attributes) # :nodoc:
11
+ set_instance_variables_from_hash(attributes)
12
+ @payment_method = PaymentMethodParser.parse_payment_method(gateway, attributes[:payment_method])
13
+ @enriched_customer_data = EnrichedCustomerData._new(enriched_customer_data) if enriched_customer_data
14
+ end
15
+
16
+ class << self
17
+ protected :new
18
+ end
19
+
20
+ def self._new(*args) # :nodoc:
21
+ self.new(*args)
22
+ end
23
+ end
24
+ end
@@ -19,7 +19,6 @@ module Braintree
19
19
 
20
20
  def _do_create(path, params=nil) # :nodoc:
21
21
  response = @config.http.post("#{@config.base_merchant_path}#{path}", params)
22
-
23
22
  if response[:api_error_response]
24
23
  ErrorResult.new(@gateway, response[:api_error_response])
25
24
  elsif response
@@ -43,17 +42,12 @@ module Braintree
43
42
  CreditCard._new(@gateway, response[:credit_card])
44
43
  elsif response.has_key?(:paypal_account)
45
44
  PayPalAccount._new(@gateway, response[:paypal_account])
46
- elsif response[:coinbase_account]
47
- SuccessfulResult.new(:payment_method => CoinbaseAccount._new(@gateway, response[:coinbase_account]))
48
45
  elsif response.has_key?(:us_bank_account)
49
46
  UsBankAccount._new(@gateway, response[:us_bank_account])
50
- elsif response.has_key?(:europe_bank_account)
51
- EuropeBankAccount._new(@gateway, response[:europe_bank_account])
52
47
  elsif response.has_key?(:apple_pay_card)
53
48
  ApplePayCard._new(@gateway, response[:apple_pay_card])
54
49
  elsif response.has_key?(:android_pay_card)
55
- # NEXT_MAJOR_VERSION rename Android Pay to Google Pay
56
- AndroidPayCard._new(@gateway, response[:android_pay_card])
50
+ GooglePayCard._new(@gateway, response[:android_pay_card])
57
51
  elsif response.has_key?(:venmo_account)
58
52
  VenmoAccount._new(@gateway, response[:venmo_account])
59
53
  else
@@ -88,7 +82,7 @@ module Braintree
88
82
  if options.class == Hash
89
83
  grant_options = options
90
84
  elsif [true, false].include?(options)
91
- grant_options = { :allow_vaulting => options }
85
+ grant_options = {:allow_vaulting => options}
92
86
  else
93
87
  raise ArgumentError
94
88
  end
@@ -97,7 +91,7 @@ module Braintree
97
91
  "/payment_methods/grant",
98
92
  :payment_method => {
99
93
  :shared_payment_method_token => token,
100
- }.merge(grant_options)
94
+ }.merge(grant_options),
101
95
  )
102
96
  rescue NotFoundError
103
97
  raise NotFoundError, "payment method with token #{token.inspect} not found"
@@ -121,7 +115,7 @@ module Braintree
121
115
  "/payment_methods/revoke",
122
116
  :payment_method => {
123
117
  :shared_payment_method_token => token
124
- }
118
+ },
125
119
  )
126
120
  rescue NotFoundError
127
121
  raise NotFoundError, "payment method with token #{token.inspect} not found"
@@ -154,9 +148,15 @@ module Braintree
154
148
  billing_address_params = AddressGateway._shared_signature
155
149
  paypal_options_shipping_signature = AddressGateway._shared_signature
156
150
  options = [
157
- :make_default, :verification_merchant_account_id, :verify_card, :venmo_sdk_session,
158
- :verification_amount, :us_bank_account_verification_method,
151
+ :make_default,
152
+ :skip_advanced_fraud_checking,
153
+ :us_bank_account_verification_method,
154
+ :venmo_sdk_session,
159
155
  :verification_account_type,
156
+ :verification_amount,
157
+ :verification_currency_iso_code,
158
+ :verification_merchant_account_id,
159
+ :verify_card,
160
160
  :paypal => [
161
161
  :payee_email,
162
162
  :order_id,
@@ -167,9 +167,9 @@ module Braintree
167
167
  ],
168
168
  ]
169
169
  signature = [
170
- :billing_address_id, :cardholder_name, :cvv, :device_session_id, :expiration_date,
171
- :expiration_month, :expiration_year, :number, :token, :venmo_sdk_payment_method_code,
172
- :device_data, :fraud_merchant_id, :payment_method_nonce,
170
+ :billing_address_id, :cardholder_name, :cvv, :expiration_date, :expiration_month,
171
+ :expiration_year, :number, :token, :venmo_sdk_payment_method_code, :device_data,
172
+ :payment_method_nonce,
173
173
  {:options => options},
174
174
  {:billing_address => billing_address_params}
175
175
  ]
@@ -191,8 +191,6 @@ module Braintree
191
191
  options << :fail_on_duplicate_payment_method
192
192
  signature << :customer_id
193
193
  signature << :paypal_refresh_token
194
- # NEXT_MAJOR_VERSION remove this from the signature
195
- signature << :paypal_vault_without_upgrade
196
194
  when :update
197
195
  billing_address_params << {:options => [:update_existing]}
198
196
  else
@@ -15,6 +15,7 @@ module Braintree
15
15
  end
16
16
 
17
17
  attr_reader :bin_data
18
+ attr_reader :default
18
19
  attr_reader :details
19
20
  attr_reader :nonce
20
21
  attr_reader :three_d_secure_info
@@ -23,14 +24,16 @@ module Braintree
23
24
 
24
25
  def initialize(gateway, attributes) # :nodoc:
25
26
  @gateway = gateway
26
- @nonce = attributes.fetch(:nonce)
27
- @type = attributes.fetch(:type)
28
- @details = attributes.fetch(:details)
29
- @authentication_insight = attributes.fetch(:authentication_insight, nil)
27
+ set_instance_variables_from_hash(attributes)
28
+ @details = PaymentMethodNonceDetails.new(attributes[:details]) if attributes[:details]
30
29
  @three_d_secure_info = ThreeDSecureInfo.new(attributes[:three_d_secure_info]) if attributes[:three_d_secure_info]
31
30
  @bin_data = BinData.new(attributes[:bin_data]) if attributes[:bin_data]
32
31
  end
33
32
 
33
+ def default?
34
+ @default
35
+ end
36
+
34
37
  def to_s # :nodoc:
35
38
  nonce
36
39
  end