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
@@ -4,11 +4,7 @@ module Braintree
4
4
  include Braintree::Util::IdEquality
5
5
 
6
6
  attr_reader :addresses
7
- attr_reader :amex_express_checkout_cards # Deprecated
8
- # NEXT_MAJOR_VERSION rename Android Pay to Google Pay
9
- attr_reader :android_pay_cards
10
7
  attr_reader :apple_pay_cards
11
- attr_reader :coinbase_accounts
12
8
  attr_reader :company
13
9
  attr_reader :created_at
14
10
  attr_reader :credit_cards
@@ -16,13 +12,14 @@ module Braintree
16
12
  attr_reader :email
17
13
  attr_reader :fax
18
14
  attr_reader :first_name
15
+ attr_reader :google_pay_cards
19
16
  attr_reader :graphql_id
20
17
  attr_reader :id
21
18
  attr_reader :last_name
22
- attr_reader :masterpass_cards # Deprecated
23
19
  attr_reader :paypal_accounts
24
20
  attr_reader :phone
25
21
  attr_reader :samsung_pay_cards
22
+ attr_reader :tax_identifiers
26
23
  attr_reader :updated_at
27
24
  attr_reader :us_bank_accounts
28
25
  attr_reader :venmo_accounts
@@ -41,24 +38,12 @@ module Braintree
41
38
  Configuration.gateway.customer.create!(*args)
42
39
  end
43
40
 
44
- # Deprecated. Use Braintree::TransparentRedirect.url
45
- def self.create_customer_url
46
- warn "[DEPRECATED] Customer.create_customer_url is deprecated. Please use TransparentRedirect.url"
47
- Configuration.gateway.customer.create_customer_url
48
- end
49
-
50
- # Deprecated. Use Braintree::TransparentRedirect.confirm
51
- def self.create_from_transparent_redirect(*args)
52
- warn "[DEPRECATED] Customer.create_from_transparent_redirect is deprecated. Please use TransparentRedirect.confirm"
53
- Configuration.gateway.customer.create_from_transparent_redirect(*args)
54
- end
55
-
56
41
  def self.credit(customer_id, transaction_attributes)
57
42
  Transaction.credit(transaction_attributes.merge(:customer_id => customer_id))
58
43
  end
59
44
 
60
45
  def self.credit!(customer_id, transaction_attributes)
61
- return_object_or_raise(:transaction){ credit(customer_id, transaction_attributes) }
46
+ return_object_or_raise(:transaction) { credit(customer_id, transaction_attributes) }
62
47
  end
63
48
 
64
49
  def self.delete(*args)
@@ -94,35 +79,19 @@ module Braintree
94
79
  Configuration.gateway.customer.update!(*args)
95
80
  end
96
81
 
97
- # Deprecated. Use Braintree::TransparentRedirect.url
98
- def self.update_customer_url
99
- warn "[DEPRECATED] Customer.update_customer_url is deprecated. Please use TransparentRedirect.url"
100
- Configuration.gateway.customer.update_customer_url
101
- end
102
-
103
- # Deprecated. Use Braintree::TransparentRedirect.confirm
104
- def self.update_from_transparent_redirect(*args)
105
- warn "[DEPRECATED] Customer.update_from_transparent_redirect is deprecated. Please use TransparentRedirect.confirm"
106
- Configuration.gateway.customer.update_from_transparent_redirect(*args)
107
- end
108
-
109
82
  def initialize(gateway, attributes) # :nodoc:
110
83
  @gateway = gateway
111
84
  set_instance_variables_from_hash(attributes)
112
85
  @credit_cards = (@credit_cards || []).map { |pm| CreditCard._new gateway, pm }
113
86
  @paypal_accounts = (@paypal_accounts || []).map { |pm| PayPalAccount._new gateway, pm }
114
- @coinbase_accounts = (@coinbase_accounts || []).map { |pm| CoinbaseAccount._new gateway, pm }
115
87
  @apple_pay_cards = (@apple_pay_cards || []).map { |pm| ApplePayCard._new gateway, pm }
116
- @europe_bank_accounts = (@europe_bank_Accounts || []).map { |pm| EuropeBankAccount._new gateway, pm }
117
- # NEXT_MAJOR_VERSION rename Android Pay to Google Pay
118
- @android_pay_cards = (@android_pay_cards || []).map { |pm| AndroidPayCard._new gateway, pm }
119
- @amex_express_checkout_cards = (@amex_express_checkout_cards || []).map { |pm| AmexExpressCheckoutCard._new gateway, pm }
88
+ @google_pay_cards = (@google_pay_cards || []).map { |pm| GooglePayCard._new gateway, pm }
120
89
  @venmo_accounts = (@venmo_accounts || []).map { |pm| VenmoAccount._new gateway, pm }
121
90
  @us_bank_accounts = (@us_bank_accounts || []).map { |pm| UsBankAccount._new gateway, pm }
122
91
  @visa_checkout_cards = (@visa_checkout_cards|| []).map { |pm| VisaCheckoutCard._new gateway, pm }
123
- @masterpass_cards = (@masterpass_cards|| []).map { |pm| MasterpassCard._new gateway, pm }
124
92
  @samsung_pay_cards = (@samsung_pay_cards|| []).map { |pm| SamsungPayCard._new gateway, pm }
125
93
  @addresses = (@addresses || []).map { |addr| Address._new gateway, addr }
94
+ @tax_identifiers = (@tax_identifiers || []).map { |addr| TaxIdentifier._new gateway, addr }
126
95
  @custom_fields = attributes[:custom_fields].is_a?(Hash) ? attributes[:custom_fields] : {}
127
96
  end
128
97
 
@@ -134,14 +103,6 @@ module Braintree
134
103
  return_object_or_raise(:transaction) { credit(transaction_attributes) }
135
104
  end
136
105
 
137
- # Deprecated. Use Braintree::Customer.default_payment_method
138
- #
139
- # Returns the customer's default credit card.
140
- def default_credit_card
141
- warn "[DEPRECATED] Customer#default_credit_card is deprecated. Please use Customer#default_payment_method"
142
- @credit_cards.find { |credit_card| credit_card.default? }
143
- end
144
-
145
106
  # Returns the customer's default payment method.
146
107
  def default_payment_method
147
108
  payment_methods.find { |payment_instrument| payment_instrument.default? }
@@ -156,9 +117,7 @@ module Braintree
156
117
  @credit_cards +
157
118
  @paypal_accounts +
158
119
  @apple_pay_cards +
159
- @coinbase_accounts +
160
- @android_pay_cards +
161
- @amex_express_checkout_cards +
120
+ @google_pay_cards +
162
121
  @venmo_accounts +
163
122
  @us_bank_accounts +
164
123
  @visa_checkout_cards +
@@ -167,7 +126,7 @@ module Braintree
167
126
 
168
127
  def inspect # :nodoc:
169
128
  first = [:id]
170
- last = [:addresses, :credit_cards, :paypal_accounts]
129
+ last = [:addresses, :credit_cards, :paypal_accounts, :tax_identifiers]
171
130
  order = first + (self.class._attributes - first - last) + last
172
131
  nice_attributes = order.map do |attr|
173
132
  "#{attr}: #{send(attr).inspect}"
@@ -175,51 +134,23 @@ module Braintree
175
134
  "#<#{self.class} #{nice_attributes.join(', ')}>"
176
135
  end
177
136
 
178
- # Deprecated. Use Braintree::Customer.sale
179
- def sale(transaction_attributes)
180
- warn "[DEPRECATED] sale as an instance method is deprecated. Please use Customer.sale"
181
- @gateway.transaction.sale(transaction_attributes.merge(:customer_id => id))
182
- end
183
-
184
- # Deprecated. Use Braintree::Customer.sale!
185
- def sale!(transaction_attributes)
186
- warn "[DEPRECATED] sale! as an instance method is deprecated. Please use Customer.sale!"
187
- return_object_or_raise(:transaction) { sale(transaction_attributes) }
188
- end
189
-
190
137
  # Returns a ResourceCollection of transactions for the customer.
191
138
  def transactions(options = {})
192
139
  @gateway.customer.transactions(id, options)
193
140
  end
194
141
 
195
- # Deprecated. Use Braintree::Customer.update
196
- def update(attributes)
197
- warn "[DEPRECATED] update as an instance method is deprecated. Please use Customer.update"
198
- result = @gateway.customer.update(id, attributes)
199
- if result.success?
200
- copy_instance_variables_from_object result.customer
201
- end
202
- result
203
- end
204
-
205
- # Deprecated. Use Braintree::Customer.update!
206
- def update!(attributes)
207
- warn "[DEPRECATED] update! as an instance method is deprecated. Please use Customer.update!"
208
- return_object_or_raise(:customer) { update(attributes) }
209
- end
210
-
211
142
  class << self
212
143
  protected :new
213
144
  end
214
145
 
215
146
  def self._new(*args) # :nodoc:
216
- self.new *args
147
+ self.new(*args)
217
148
  end
218
149
 
219
150
  def self._attributes # :nodoc:
220
151
  [
221
152
  :addresses, :company, :credit_cards, :email, :fax, :first_name, :id, :last_name, :phone, :website,
222
- :created_at, :updated_at
153
+ :created_at, :updated_at, :tax_identifiers
223
154
  ]
224
155
  end
225
156
 
@@ -22,17 +22,6 @@ module Braintree
22
22
  return_object_or_raise(:customer) { create(*args) }
23
23
  end
24
24
 
25
- # Deprecated
26
- def create_customer_url
27
- "#{@config.base_merchant_url}/customers/all/create_via_transparent_redirect_request"
28
- end
29
-
30
- # Deprecated
31
- def create_from_transparent_redirect(query_string)
32
- params = @gateway.transparent_redirect.parse_and_validate_query_string query_string
33
- _do_create("/customers/all/confirm_transparent_redirect_request", :id => params[:id])
34
- end
35
-
36
25
  def delete(customer_id)
37
26
  @config.http.delete("#{@config.base_merchant_path}/customers/#{customer_id}")
38
27
  SuccessfulResult.new
@@ -71,18 +60,6 @@ module Braintree
71
60
  return_object_or_raise(:customer) { update(*args) }
72
61
  end
73
62
 
74
- # Deprecated
75
- def update_customer_url
76
- warn "[DEPRECATED] Customer.update_customer_url is deprecated. Please use TransparentRedirect.url"
77
- "#{@config.base_merchant_url}/customers/all/update_via_transparent_redirect_request"
78
- end
79
-
80
- # Deprecated
81
- def update_from_transparent_redirect(query_string)
82
- params = @gateway.transparent_redirect.parse_and_validate_query_string(query_string)
83
- _do_update(:post, "/customers/all/confirm_transparent_redirect_request", :id => params[:id])
84
- end
85
-
86
63
  def self._create_signature # :nodoc:
87
64
  credit_card_signature = CreditCardGateway._create_signature - [:customer_id]
88
65
  paypal_account_signature = PayPalAccountGateway._create_nested_signature
@@ -103,6 +80,7 @@ module Braintree
103
80
  {:risk_data => [:customer_browser, :customer_ip]},
104
81
  {:credit_card => credit_card_signature},
105
82
  {:paypal_account => paypal_account_signature},
83
+ {:tax_identifiers => [:country_code, :identifier]},
106
84
  {:options => options},
107
85
  {:custom_fields => :_any_key_}
108
86
  ]
@@ -164,6 +142,7 @@ module Braintree
164
142
  :company, :email, :fax, :first_name, :id, :last_name, :phone, :website,
165
143
  :device_data, :payment_method_nonce, :default_payment_method_token,
166
144
  {:credit_card => credit_card_signature},
145
+ {:tax_identifiers => [:country_code, :identifier]},
167
146
  {:options => options},
168
147
  {:custom_fields => :_any_key_}
169
148
  ]
@@ -19,7 +19,7 @@ module Braintree
19
19
  :payment_method_token,
20
20
  :paypal_account_email,
21
21
  :phone,
22
- :website
22
+ :website,
23
23
  )
24
24
 
25
25
  is_fields :payment_method_token_with_duplicates
@@ -52,7 +52,7 @@ module Braintree
52
52
  class << self
53
53
  protected :new
54
54
  def _new(*args) # :nodoc:
55
- self.new *args
55
+ self.new(*args)
56
56
  end
57
57
  end
58
58
 
@@ -1,12 +1,11 @@
1
1
  module Braintree
2
- class Transaction
3
- class CoinbaseDetails
2
+ class Dispute
3
+ class PayPalMessage # :nodoc:
4
4
  include BaseModule
5
5
 
6
- attr_reader :user_id
7
- attr_reader :user_email
8
- attr_reader :user_name
9
- attr_reader :token
6
+ attr_reader :message,
7
+ :sender,
8
+ :sent_at
10
9
 
11
10
  def initialize(attributes)
12
11
  set_instance_variables_from_hash attributes unless attributes.nil?
@@ -1,6 +1,6 @@
1
1
  module Braintree
2
2
  class Dispute
3
- class HistoryEvent # :nodoc:
3
+ class StatusHistory # :nodoc:
4
4
  include BaseModule
5
5
 
6
6
  attr_reader :disbursement_date
@@ -10,6 +10,8 @@ module Braintree
10
10
 
11
11
  def initialize(attributes)
12
12
  set_instance_variables_from_hash attributes unless attributes.nil?
13
+ @disbursement_date = Date.parse(disbursement_date) unless disbursement_date.nil?
14
+ @effective_date = Date.parse(effective_date) unless effective_date.nil?
13
15
  end
14
16
  end
15
17
  end
@@ -7,6 +7,9 @@ module Braintree
7
7
  attr_reader :amount_disputed
8
8
  attr_reader :amount_won
9
9
  attr_reader :case_number
10
+ # NEXT_MAJOR_VERSION Remove this attribute
11
+ # DEPRECATED The chargeback_protection_level attribute is deprecated in favor of protection_level
12
+ attr_reader :chargeback_protection_level #Deprecated
10
13
  attr_reader :created_at
11
14
  attr_reader :currency_iso_code
12
15
  attr_reader :date_opened
@@ -17,7 +20,9 @@ module Braintree
17
20
  attr_reader :kind
18
21
  attr_reader :merchant_account_id
19
22
  attr_reader :original_dispute_id
23
+ attr_reader :paypal_messages
20
24
  attr_reader :processor_comments
25
+ attr_reader :protection_level
21
26
  attr_reader :reason
22
27
  attr_reader :reason_code
23
28
  attr_reader :reason_description
@@ -65,10 +70,26 @@ module Braintree
65
70
  All = constants.map { |c| const_get(c) }
66
71
  end
67
72
 
73
+ module ChargebackProtectionLevel
74
+ Effortless = "effortless"
75
+ Standard = "standard"
76
+ NotProtected = "not_protected"
77
+
78
+ All = constants.map { |c| const_get(c) }
79
+ end
80
+
81
+ module ProtectionLevel
82
+ EffortlessCBP = "Effortless Chargeback Protection tool"
83
+ StandardCBP = "Chargeback Protection tool"
84
+ NoProtection = "No Protection"
85
+
86
+ All = constants.map { |c| const_get(c) }
87
+ end
88
+
68
89
  class << self
69
90
  protected :new
70
91
  def _new(*args) # :nodoc:
71
- self.new *args
92
+ self.new(*args)
72
93
  end
73
94
  end
74
95
 
@@ -109,23 +130,26 @@ module Braintree
109
130
  @amount = Util.to_big_decimal(amount)
110
131
  @amount_disputed = Util.to_big_decimal(amount_disputed)
111
132
  @amount_won = Util.to_big_decimal(amount_won)
133
+ if (ChargebackProtectionLevel::All - [ChargebackProtectionLevel::NotProtected]).include?(chargeback_protection_level)
134
+ @protection_level = Dispute.const_get("ProtectionLevel::#{chargeback_protection_level.capitalize}CBP")
135
+ else
136
+ @protection_level = ProtectionLevel::NoProtection
137
+ end
112
138
 
113
139
  @evidence = evidence.map do |record|
114
140
  Braintree::Dispute::Evidence.new(record)
115
141
  end unless evidence.nil?
116
142
 
143
+ @paypal_messages = paypal_messages.map do |record|
144
+ Braintree::Dispute::PayPalMessage.new(record)
145
+ end unless paypal_messages.nil?
146
+
117
147
  @transaction_details = TransactionDetails.new(transaction)
118
148
  @transaction = Transaction.new(transaction)
119
149
 
120
150
  @status_history = status_history.map do |event|
121
- Braintree::Dispute::HistoryEvent.new(event)
151
+ Braintree::Dispute::StatusHistory.new(event)
122
152
  end unless status_history.nil?
123
153
  end
124
-
125
- def forwarded_comments
126
- # NEXT_MAJOR_VERSION delete this method since it never returned anything anyway.
127
- warn "[DEPRECATED] #forwarded_comments is deprecated. Please use #processor_comments"
128
- processor_comments
129
- end
130
154
  end
131
155
  end
@@ -25,7 +25,7 @@ module Braintree
25
25
  raise ArgumentError, "dispute_id cannot be blank" if dispute_id.nil? || dispute_id.to_s.strip == ""
26
26
  raise ArgumentError, "document_id_or_request cannot be blank" if document_id_or_request.nil?
27
27
 
28
- request = document_id_or_request.is_a?(Hash) ? document_id_or_request : { document_id: document_id_or_request }
28
+ request = document_id_or_request.is_a?(Hash) ? document_id_or_request : {document_id: document_id_or_request}
29
29
 
30
30
  raise ArgumentError, "document_id contains invalid characters" unless request[:document_id].to_s =~ /\A[\w-]+\z/
31
31
  raise ArgumentError, "document_id cannot be blank" if request[:document_id].nil? || dispute_id.to_s.strip == ""
@@ -55,23 +55,18 @@ module Braintree
55
55
  raise ArgumentError, "dispute_id cannot be blank" if dispute_id.nil? || dispute_id.to_s.strip == ""
56
56
  raise ArgumentError, "content_or_request cannot be blank" if content_or_request.nil?
57
57
 
58
- request = content_or_request.is_a?(String) ? { content: content_or_request } : content_or_request
58
+ request = content_or_request.is_a?(String) ? {content: content_or_request} : content_or_request
59
59
 
60
60
  raise ArgumentError, "content cannot be blank" if request[:content].nil? || request[:content].to_s.strip == ""
61
- raise ArgumentError, "request can only contain the keys [:content, :category, :sequence_number]" if (request.keys - [:category, :content, :tag, :sequence_number]).any?
61
+ raise ArgumentError, "request can only contain the keys [:content, :category, :sequence_number]" if (request.keys - [:category, :content, :sequence_number]).any?
62
62
  raise ArgumentError, "sequence_number must be an integer" if request[:sequence_number] && request[:sequence_number].to_s.match(/\D/)
63
- raise ArgumentError, "tag must be a string" if request[:tag] && !request[:tag].is_a?(String)
64
63
  raise ArgumentError, "category must be a string" if request[:category] && !request[:category].is_a?(String)
65
64
 
66
- warn "[DEPRECATED] tag as an option is deprecated. Please use category" if request[:tag]
67
-
68
- category = request[:category] || request[:tag]
69
-
70
65
  params_for_http_post = {
71
66
  evidence: {
72
67
  comments: request[:content]
73
68
  }.tap do |evidence_params|
74
- evidence_params[:category] = category if category
69
+ evidence_params[:category] = request[:category] if request[:category]
75
70
  evidence_params[:sequence_number] = request[:sequence_number] if request[:sequence_number]
76
71
  end
77
72
  }
@@ -5,9 +5,12 @@ module Braintree
5
5
  :customer_id,
6
6
  :id,
7
7
  :reference_number,
8
- :transaction_id
8
+ :transaction_id,
9
9
  )
10
-
10
+ # NEXT_MAJOR_VERSION Remove this attribute
11
+ # DEPRECATED The chargeback_protection_level attribute is deprecated in favor of protection_level
12
+ multiple_value_field :chargeback_protection_level, :allows => Dispute::ChargebackProtectionLevel::All
13
+ multiple_value_field :protection_level, :allows => Dispute::ProtectionLevel::All
11
14
  multiple_value_field :kind, :allows => Dispute::Kind::All
12
15
  multiple_value_field :merchant_account_id
13
16
  multiple_value_field :reason, :allows => Dispute::Reason::All
@@ -21,7 +24,7 @@ module Braintree
21
24
  :disbursement_date,
22
25
  :effective_date,
23
26
  :received_date,
24
- :reply_by_date
27
+ :reply_by_date,
25
28
  )
26
29
  end
27
30
  end
@@ -30,7 +30,7 @@ module Braintree
30
30
  class << self
31
31
  protected :new
32
32
  def _new(*args) # :nodoc:
33
- self.new *args
33
+ self.new(*args)
34
34
  end
35
35
  end
36
36
  end
@@ -0,0 +1,21 @@
1
+ module Braintree
2
+ class EnrichedCustomerData
3
+ include BaseModule
4
+
5
+ attr_reader :fields_updated
6
+ attr_reader :profile_data
7
+
8
+ def initialize(attributes) # :nodoc:
9
+ set_instance_variables_from_hash(attributes)
10
+ @profile_data = VenmoProfileData._new(attributes[:profile_data])
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
+ end
21
+ end