braintree 2.102.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/braintree.gemspec +6 -3
  4. data/lib/braintree.rb +3 -17
  5. data/lib/braintree/address.rb +0 -22
  6. data/lib/braintree/address_gateway.rb +2 -2
  7. data/lib/braintree/base_module.rb +6 -0
  8. data/lib/braintree/bin_data.rb +9 -2
  9. data/lib/braintree/configuration.rb +1 -1
  10. data/lib/braintree/credit_card.rb +5 -76
  11. data/lib/braintree/credit_card_gateway.rb +3 -32
  12. data/lib/braintree/credit_card_verification.rb +14 -0
  13. data/lib/braintree/customer.rb +3 -72
  14. data/lib/braintree/customer_gateway.rb +0 -23
  15. data/lib/braintree/dispute.rb +1 -7
  16. data/lib/braintree/dispute/{history_event.rb → status_history.rb} +3 -1
  17. data/lib/braintree/dispute/transaction.rb +2 -0
  18. data/lib/braintree/dispute_gateway.rb +2 -7
  19. data/lib/braintree/error_codes.rb +152 -170
  20. data/lib/braintree/exceptions.rb +5 -3
  21. data/lib/braintree/gateway.rb +0 -14
  22. data/lib/braintree/{android_pay_card.rb → google_pay_card.rb} +1 -1
  23. data/lib/braintree/local_payment_completed.rb +1 -1
  24. data/lib/braintree/merchant_account_gateway.rb +2 -0
  25. data/lib/braintree/payment_instrument_type.rb +1 -4
  26. data/lib/braintree/payment_method_gateway.rb +4 -8
  27. data/lib/braintree/payment_method_parser.rb +1 -7
  28. data/lib/braintree/risk_data.rb +4 -1
  29. data/lib/braintree/subscription.rb +5 -5
  30. data/lib/braintree/successful_result.rb +0 -1
  31. data/lib/braintree/test/credit_card.rb +1 -0
  32. data/lib/braintree/test/nonce.rb +5 -20
  33. data/lib/braintree/transaction.rb +9 -73
  34. data/lib/braintree/transaction/address_details.rb +11 -0
  35. data/lib/braintree/transaction/disbursement_details.rb +1 -0
  36. data/lib/braintree/transaction/{android_pay_details.rb → google_pay_details.rb} +1 -1
  37. data/lib/braintree/transaction/paypal_details.rb +3 -0
  38. data/lib/braintree/transaction/subscription_details.rb +2 -0
  39. data/lib/braintree/transaction_gateway.rb +14 -21
  40. data/lib/braintree/transaction_search.rb +0 -1
  41. data/lib/braintree/util.rb +17 -2
  42. data/lib/braintree/version.rb +2 -2
  43. data/lib/braintree/webhook_notification.rb +0 -10
  44. data/lib/braintree/webhook_testing_gateway.rb +0 -43
  45. data/lib/braintree/xml/libxml.rb +1 -0
  46. data/lib/braintree/xml/parser.rb +11 -34
  47. data/spec/integration/braintree/address_spec.rb +2 -89
  48. data/spec/integration/braintree/client_api/spec_helper.rb +92 -66
  49. data/spec/integration/braintree/credit_card_spec.rb +20 -467
  50. data/spec/integration/braintree/credit_card_verification_spec.rb +1 -0
  51. data/spec/integration/braintree/customer_spec.rb +22 -362
  52. data/spec/integration/braintree/dispute_search_spec.rb +3 -3
  53. data/spec/integration/braintree/dispute_spec.rb +1 -2
  54. data/spec/integration/braintree/merchant_spec.rb +2 -2
  55. data/spec/integration/braintree/payment_method_spec.rb +77 -120
  56. data/spec/integration/braintree/paypal_account_spec.rb +1 -1
  57. data/spec/integration/braintree/subscription_spec.rb +11 -16
  58. data/spec/integration/braintree/transaction_search_spec.rb +3 -3
  59. data/spec/integration/braintree/transaction_spec.rb +274 -524
  60. data/spec/integration/spec_helper.rb +1 -4
  61. data/spec/spec_helper.rb +1 -11
  62. data/spec/unit/braintree/address_spec.rb +0 -8
  63. data/spec/unit/braintree/credit_card_spec.rb +28 -21
  64. data/spec/unit/braintree/credit_card_verification_spec.rb +7 -0
  65. data/spec/unit/braintree/customer_spec.rb +4 -12
  66. data/spec/unit/braintree/dispute_spec.rb +4 -12
  67. data/spec/unit/braintree/http_spec.rb +3 -3
  68. data/spec/unit/braintree/local_payment_completed_spec.rb +14 -0
  69. data/spec/unit/braintree/transaction/paypal_details_spec.rb +59 -0
  70. data/spec/unit/braintree/transaction_spec.rb +17 -37
  71. data/spec/unit/braintree/util_spec.rb +37 -3
  72. data/spec/unit/braintree/webhook_notification_spec.rb +1 -1
  73. data/spec/unit/braintree/xml/parser_spec.rb +21 -16
  74. metadata +28 -32
  75. data/lib/braintree/amex_express_checkout_card.rb +0 -38
  76. data/lib/braintree/coinbase_account.rb +0 -34
  77. data/lib/braintree/europe_bank_account.rb +0 -36
  78. data/lib/braintree/europe_bank_account_gateway.rb +0 -17
  79. data/lib/braintree/ideal_payment.rb +0 -61
  80. data/lib/braintree/ideal_payment_gateway.rb +0 -19
  81. data/lib/braintree/masterpass_card.rb +0 -81
  82. data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -21
  83. data/lib/braintree/transaction/coinbase_details.rb +0 -16
  84. data/lib/braintree/transaction/ideal_payment_details.rb +0 -19
  85. data/lib/braintree/transaction/masterpass_card_details.rb +0 -47
  86. data/lib/braintree/transparent_redirect.rb +0 -40
  87. data/lib/braintree/transparent_redirect_gateway.rb +0 -105
  88. data/lib/braintree/xml/rexml.rb +0 -71
  89. data/spec/hacks/tcp_socket.rb +0 -18
  90. data/spec/integration/braintree/coinbase_spec.rb +0 -34
  91. data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
  92. data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
  93. data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
  94. data/spec/unit/braintree/xml/rexml_spec.rb +0 -51
@@ -13,6 +13,7 @@ module Braintree
13
13
 
14
14
  def initialize(attributes)
15
15
  set_instance_variables_from_hash attributes unless attributes.nil?
16
+ @disbursement_date = Date.parse(disbursement_date) unless disbursement_date.nil?
16
17
  end
17
18
 
18
19
  def funds_held?
@@ -1,6 +1,6 @@
1
1
  module Braintree
2
2
  class Transaction
3
- class AndroidPayDetails
3
+ class GooglePayDetails
4
4
  include BaseModule
5
5
 
6
6
  attr_reader :bin
@@ -4,11 +4,14 @@ module Braintree
4
4
  include BaseModule
5
5
 
6
6
  attr_reader :authorization_id
7
+ attr_reader :billing_agreement_id
7
8
  attr_reader :capture_id
8
9
  attr_reader :custom_field
9
10
  attr_reader :debug_id
10
11
  attr_reader :description
11
12
  attr_reader :image_url
13
+ attr_reader :implicitly_vaulted_payment_method_global_id
14
+ attr_reader :implicitly_vaulted_payment_method_token
12
15
  attr_reader :payee_email
13
16
  attr_reader :payee_id
14
17
  attr_reader :payer_email
@@ -8,6 +8,8 @@ module Braintree
8
8
 
9
9
  def initialize(attributes)
10
10
  set_instance_variables_from_hash attributes unless attributes.nil?
11
+ @billing_period_start_date = Date.parse(billing_period_start_date) unless billing_period_start_date.nil?
12
+ @billing_period_end_date = Date.parse(billing_period_end_date) unless billing_period_end_date.nil?
11
13
  end
12
14
  end
13
15
  end
@@ -52,17 +52,6 @@ module Braintree
52
52
  return_object_or_raise(:transaction) { clone_transaction(*args) }
53
53
  end
54
54
 
55
- # Deprecated
56
- def create_from_transparent_redirect(query_string)
57
- params = @gateway.transparent_redirect.parse_and_validate_query_string query_string
58
- _do_create("/transactions/all/confirm_transparent_redirect_request", :id => params[:id])
59
- end
60
-
61
- def create_transaction_url
62
- warn "[DEPRECATED] Transaction.create_transaction_url is deprecated. Please use TransparentRedirect.url"
63
- "#{@config.base_merchant_url}/transactions/all/create_via_transparent_redirect_request"
64
- end
65
-
66
55
  def credit(attributes)
67
56
  create(attributes.merge(:type => 'credit'))
68
57
  end
@@ -124,7 +113,7 @@ module Braintree
124
113
  if response.has_key?(:search_results)
125
114
  ResourceCollection.new(response) { |ids| _fetch_transactions(search, ids) }
126
115
  else
127
- raise DownForMaintenanceError
116
+ raise UnexpectedError, "expected :search_results"
128
117
  end
129
118
  end
130
119
 
@@ -184,21 +173,22 @@ module Braintree
184
173
 
185
174
  def self._create_signature # :nodoc:
186
175
  [
187
- :amount, :customer_id, :merchant_account_id, :order_id, :channel, :payment_method_token,
188
- :purchase_order_number, :recurring, :transaction_source, :shipping_address_id, :type, :tax_amount, :tax_exempt,
189
- :venmo_sdk_payment_method_code, :device_session_id, :service_fee_amount, :device_data, :fraud_merchant_id,
190
- :shipping_amount, :discount_amount, :ships_from_postal_code,
191
- :billing_address_id, :payment_method_nonce, :three_d_secure_token, :three_d_secure_authentication_id,
192
- :shared_payment_method_token, :shared_billing_address_id, :shared_customer_id, :shared_shipping_address_id, :shared_payment_method_nonce,
176
+ :amount, :billing_address_id, :channel, :customer_id, :device_data, :discount_amount,
177
+ :merchant_account_id, :order_id, :payment_method_nonce, :payment_method_token,
178
+ :product_sku, :purchase_order_number, :service_fee_amount, :shared_billing_address_id,
179
+ :shared_customer_id, :shared_payment_method_nonce, :shared_payment_method_token,
180
+ :shared_shipping_address_id, :shipping_address_id, :shipping_amount,
181
+ :ships_from_postal_code, :tax_amount, :tax_exempt, :three_d_secure_authentication_id,
182
+ :three_d_secure_token, :transaction_source, :type, :venmo_sdk_payment_method_code,
193
183
  {:line_items => [:quantity, :name, :description, :kind, :unit_amount, :unit_tax_amount, :total_amount, :discount_amount, :tax_amount, :unit_of_measure, :product_code, :commodity_code, :url]},
194
- {:risk_data => [:customer_browser, :customer_ip]},
184
+ {:risk_data => [:customer_browser, :customer_device_id, :customer_ip, :customer_location_zip, :customer_tenure]},
195
185
  {:credit_card => [:token, :cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year, :number]},
196
186
  {:customer => [:id, :company, :email, :fax, :first_name, :last_name, :phone, :website]},
197
187
  {
198
188
  :billing => AddressGateway._shared_signature
199
189
  },
200
190
  {
201
- :shipping => AddressGateway._shared_signature
191
+ :shipping => AddressGateway._shared_signature + [:shipping_method],
202
192
  },
203
193
  {
204
194
  :three_d_secure_pass_thru => [
@@ -255,7 +245,7 @@ module Braintree
255
245
  ]},
256
246
  ]},
257
247
  {:apple_pay_card => [:number, :cardholder_name, :cryptogram, :expiration_month, :expiration_year, :eci_indicator]},
258
- {:android_pay_card => [:number, :cryptogram, :google_transaction_id, :expiration_month, :expiration_year, :source_card_type, :source_card_last_four, :eci_indicator]}
248
+ {:google_pay_card => [:number, :cryptogram, :google_transaction_id, :expiration_month, :expiration_year, :source_card_type, :source_card_last_four, :eci_indicator]}
259
249
  ]
260
250
  end
261
251
 
@@ -289,6 +279,9 @@ module Braintree
289
279
  end
290
280
 
291
281
  def _do_create(path, params=nil) # :nodoc:
282
+ if !params.nil?
283
+ params = Util.replace_key(params, :google_pay_card, :android_pay_card)
284
+ end
292
285
  response = @config.http.post("#{@config.base_merchant_path}#{path}", params)
293
286
  _handle_transaction_response(response)
294
287
  end
@@ -28,7 +28,6 @@ module Braintree
28
28
  :paypal_authorization_id,
29
29
  :paypal_payer_email,
30
30
  :processor_authorization_code,
31
- :europe_bank_account_iban,
32
31
  :settlement_batch_id,
33
32
  :shipping_company,
34
33
  :shipping_country_name,
@@ -53,6 +53,8 @@ module Braintree
53
53
  raise AuthorizationError, message
54
54
  when 404
55
55
  raise NotFoundError
56
+ when 408
57
+ raise RequestTimeoutError
56
58
  when 426
57
59
  raise UpgradeRequiredError, "Please upgrade your client library."
58
60
  when 429
@@ -60,7 +62,9 @@ module Braintree
60
62
  when 500
61
63
  raise ServerError
62
64
  when 503
63
- raise DownForMaintenanceError
65
+ raise ServiceUnavailableError
66
+ when 504
67
+ raise GatewayTimeoutError
64
68
  else
65
69
  raise UnexpectedError, "Unexpected HTTP_RESPONSE #{status_code.to_i}"
66
70
  end
@@ -87,7 +91,7 @@ module Braintree
87
91
  when "INTERNAL"
88
92
  raise ServerError
89
93
  when "SERVICE_AVAILABILITY"
90
- raise DownForMaintenanceError
94
+ raise ServiceUnavailableError
91
95
  else
92
96
  raise UnexpectedError, "Unexpected Response: #{error[:message]}"
93
97
  end
@@ -126,6 +130,17 @@ module Braintree
126
130
  !invalid_keys.any?
127
131
  end
128
132
 
133
+ def self.replace_key(hash, target_key, replacement_key)
134
+ hash.inject({}) do |new_hash, (key, value)|
135
+ if value.is_a?(Hash)
136
+ value = replace_key(value, target_key, replacement_key)
137
+ end
138
+
139
+ key = replacement_key if key == target_key
140
+ new_hash.merge(key => value)
141
+ end
142
+ end
143
+
129
144
  def self._flatten_valid_keys(valid_keys, namespace = nil)
130
145
  valid_keys.inject([]) do |result, key|
131
146
  if key.is_a?(Hash)
@@ -1,7 +1,7 @@
1
1
  module Braintree
2
2
  module Version
3
- Major = 2
4
- Minor = 102
3
+ Major = 3
4
+ Minor = 1
5
5
  Tiny = 0
6
6
 
7
7
  String = "#{Major}.#{Minor}.#{Tiny}"
@@ -36,18 +36,10 @@ module Braintree
36
36
 
37
37
  AccountUpdaterDailyReport = "account_updater_daily_report"
38
38
 
39
- # NEXT_MAJOR_VERSION Remove this class as legacy Ideal has been removed/disabled in the Braintree Gateway
40
- # DEPRECATED If you're looking to accept iDEAL as a payment method contact accounts@braintreepayments.com for a solution.
41
- IdealPaymentComplete = "ideal_payment_complete"
42
- IdealPaymentFailed = "ideal_payment_failed"
43
-
44
39
  OAuthAccessRevoked = "oauth_access_revoked"
45
40
  ConnectedMerchantStatusTransitioned = "connected_merchant_status_transitioned"
46
41
  ConnectedMerchantPayPalStatusChanged = "connected_merchant_paypal_status_changed"
47
42
 
48
- # NEXT_MAJOR_VERSION remove GrantedPaymentInstrumentUpdate. Kind is not sent by Braintree Gateway.
49
- # Kind will either be GrantorUpdatedGrantedPaymentMethod or RecipientUpdatedGrantedPaymentMethod.
50
- GrantedPaymentInstrumentUpdate = "granted_payment_instrument_update"
51
43
  GrantorUpdatedGrantedPaymentMethod = "grantor_updated_granted_payment_method"
52
44
  RecipientUpdatedGrantedPaymentMethod = "recipient_updated_granted_payment_method"
53
45
  GrantedPaymentInstrumentRevoked = "granted_payment_instrument_revoked"
@@ -63,7 +55,6 @@ module Braintree
63
55
  attr_reader :dispute
64
56
  attr_reader :granted_payment_instrument_update
65
57
  attr_reader :revoked_payment_method_metadata
66
- attr_reader :ideal_payment
67
58
  attr_reader :kind
68
59
  attr_reader :local_payment_completed
69
60
  attr_reader :oauth_access_revocation
@@ -93,7 +84,6 @@ module Braintree
93
84
  @disbursement = Disbursement._new(gateway, @subject[:disbursement]) if @subject.has_key?(:disbursement)
94
85
  @dispute = Dispute._new(@subject[:dispute]) if @subject.has_key?(:dispute)
95
86
  @account_updater_daily_report = AccountUpdaterDailyReport._new(@subject[:account_updater_daily_report]) if @subject.has_key?(:account_updater_daily_report)
96
- @ideal_payment = Braintree::IdealPayment._new(gateway, @subject[:ideal_payment]) if @subject.has_key?(:ideal_payment)
97
87
  @connected_merchant_status_transitioned = ConnectedMerchantStatusTransitioned._new(@subject[:connected_merchant_status_transitioned]) if @subject.has_key?(:connected_merchant_status_transitioned)
98
88
  @connected_merchant_paypal_status_changed = ConnectedMerchantPayPalStatusChanged._new(@subject[:connected_merchant_paypal_status_changed]) if @subject.has_key?(:connected_merchant_paypal_status_changed)
99
89
  @granted_payment_instrument_update = GrantedPaymentInstrumentUpdate._new(@subject[:granted_payment_instrument_update]) if @subject.has_key?(:granted_payment_instrument_update)
@@ -78,17 +78,6 @@ module Braintree
78
78
  _auth_status_transitioned_sample_xml(id)
79
79
  when Braintree::WebhookNotification::Kind::ConnectedMerchantPayPalStatusChanged
80
80
  _auth_paypal_status_changed_sample_xml(id)
81
- # NEXT_MAJOR_VERSION Remove this class as legacy Ideal has been removed/disabled in the Braintree Gateway
82
- # DEPRECATED If you're looking to accept iDEAL as a payment method contact accounts@braintreepayments.com for a solution.
83
- when Braintree::WebhookNotification::Kind::IdealPaymentComplete
84
- _ideal_payment_complete_sample_xml(id)
85
- # NEXT_MAJOR_VERSION Remove this class as legacy Ideal has been removed/disabled in the Braintree Gateway
86
- # DEPRECATED If you're looking to accept iDEAL as a payment method contact accounts@braintreepayments.com for a solution.
87
- when Braintree::WebhookNotification::Kind::IdealPaymentFailed
88
- _ideal_payment_failed_sample_xml(id)
89
- # NEXT_MAJOR_VERSION remove GrantedPaymentInstrumentUpdate
90
- when Braintree::WebhookNotification::Kind::GrantedPaymentInstrumentUpdate
91
- _granted_payment_instrument_update_sample_xml(id)
92
81
  when Braintree::WebhookNotification::Kind::GrantorUpdatedGrantedPaymentMethod
93
82
  _granted_payment_instrument_update_sample_xml(id)
94
83
  when Braintree::WebhookNotification::Kind::RecipientUpdatedGrantedPaymentMethod
@@ -867,38 +856,6 @@ module Braintree
867
856
  XML
868
857
  end
869
858
 
870
- def _ideal_payment_complete_sample_xml(id)
871
- <<-XML
872
- <ideal-payment>
873
- <id>#{id}</id>
874
- <status>COMPLETE</status>
875
- <issuer>ABCISSUER</issuer>
876
- <order-id>ORDERABC</order-id>
877
- <currency>EUR</currency>
878
- <amount>10.00</amount>
879
- <created-at>2016-11-29T23:27:34.547Z</created-at>
880
- <approval-url>https://example.com</approval-url>
881
- <ideal-transaction-id>1234567890</ideal-transaction-id>
882
- </ideal-payment>
883
- XML
884
- end
885
-
886
- def _ideal_payment_failed_sample_xml(id)
887
- <<-XML
888
- <ideal-payment>
889
- <id>#{id}</id>
890
- <status>FAILED</status>
891
- <issuer>ABCISSUER</issuer>
892
- <order-id>ORDERABC</order-id>
893
- <currency>EUR</currency>
894
- <amount>10.00</amount>
895
- <created-at>2016-11-29T23:27:34.547Z</created-at>
896
- <approval-url>https://example.com</approval-url>
897
- <ideal-transaction-id>1234567890</ideal-transaction-id>
898
- </ideal-payment>
899
- XML
900
- end
901
-
902
859
  def _granted_payment_instrument_update_sample_xml(id)
903
860
  <<-XML
904
861
  <granted-payment-instrument-update>
@@ -1,3 +1,4 @@
1
+ require 'libxml'
1
2
  # Portions of this code were copied and modified from Ruby on Rails, released
2
3
  # under the MIT license, copyright (c) 2005-2009 David Heinemeier Hansson
3
4
  module Braintree
@@ -11,23 +11,14 @@ module Braintree
11
11
  "boolean" => Proc.new { |boolean| %w(1 true).include?(boolean.strip) },
12
12
  }
13
13
 
14
- def self.hash_from_xml(xml, parser = _determine_parser)
15
- standardized_hash_structure = parser.parse(xml)
16
- with_underscores_in_keys = _unrename_keys(standardized_hash_structure)
17
- typecasted_xml = _typecast_xml_value(with_underscores_in_keys)
18
- Util.symbolize_keys(typecasted_xml)
14
+ def self.hash_from_xml(xml)
15
+ standardized_hash_structure = ::Braintree::Xml::Libxml.parse(xml)
16
+ transformed_xml = _transform_xml(standardized_hash_structure)
17
+ Util.symbolize_keys(transformed_xml)
19
18
  end
20
19
 
21
- def self._determine_parser
22
- # LibXML causes a segfault in Ruby 2.0.0. We need to fall back to Rexml to prevent this segfault.
23
- if !RUBY_VERSION.start_with?("2.0") && defined?(::LibXML::XML) && ::LibXML::XML.respond_to?(:default_keep_blanks=)
24
- ::Braintree::Xml::Libxml
25
- else
26
- ::Braintree::Xml::Rexml
27
- end
28
- end
29
-
30
- def self._typecast_xml_value(value)
20
+ # Transform into standard Ruby types and convert all keys to snake_case instead of dash-case
21
+ def self._transform_xml(value)
31
22
  case value.class.to_s
32
23
  when 'Hash'
33
24
  if value['type'] == 'array'
@@ -37,9 +28,9 @@ module Braintree
37
28
  else
38
29
  case entries.class.to_s # something weird with classes not matching here. maybe singleton methods breaking is_a?
39
30
  when "Array"
40
- entries.collect { |v| _typecast_xml_value(v) }
31
+ entries.collect { |v| _transform_xml(v) }
41
32
  when "Hash"
42
- [_typecast_xml_value(entries)]
33
+ [_transform_xml(entries)]
43
34
  else
44
35
  raise "can't typecast #{entries.inspect}"
45
36
  end
@@ -65,13 +56,13 @@ module Braintree
65
56
  nil
66
57
  else
67
58
  xml_value = value.inject({}) do |h,(k,v)|
68
- h[k] = _typecast_xml_value(v)
59
+ h[k.to_s.tr("-", "_")] = _transform_xml(v) # convert dashes to underscores in keys
69
60
  h
70
61
  end
71
62
  xml_value
72
63
  end
73
64
  when 'Array'
74
- value.map! { |i| _typecast_xml_value(i) }
65
+ value.map! { |i| _transform_xml(i) }
75
66
  case value.length
76
67
  when 0 then nil
77
68
  when 1 then value.first
@@ -80,21 +71,7 @@ module Braintree
80
71
  when 'String'
81
72
  value
82
73
  else
83
- raise "can't typecast #{value.class.name} - #{value.inspect}"
84
- end
85
- end
86
-
87
- def self._unrename_keys(params)
88
- case params.class.to_s
89
- when "Hash"
90
- params.inject({}) do |h,(k,v)|
91
- h[k.to_s.tr("-", "_")] = _unrename_keys(v)
92
- h
93
- end
94
- when "Array"
95
- params.map { |v| _unrename_keys(v) }
96
- else
97
- params
74
+ raise "can't transform #{value.class.name} - #{value.inspect}"
98
75
  end
99
76
  end
100
77
  end
@@ -347,98 +347,11 @@ describe Braintree::Address do
347
347
  it "deletes the address" do
348
348
  customer = Braintree::Customer.create!(:last_name => "Wilson")
349
349
  address = Braintree::Address.create!(:customer_id => customer.id, :street_address => "123 E Main St")
350
- address.delete.success?.should == true
350
+ result = Braintree::Address.delete(customer.id, address.id)
351
+ result.success?.should == true
351
352
  expect do
352
353
  Braintree::Address.find(customer.id, address.id)
353
354
  end.to raise_error(Braintree::NotFoundError)
354
355
  end
355
356
  end
356
-
357
- describe "update" do
358
- it "returns a success response and updates the address if valid" do
359
- customer = Braintree::Customer.create!(:last_name => "Miller")
360
- address = Braintree::Address.create!(
361
- :customer_id => customer.id,
362
- :street_address => "1812 E Old St",
363
- :extended_address => "Suite Old 201",
364
- :locality => "Old Chicago",
365
- :region => "IL",
366
- :postal_code => "60620",
367
- :country_name => "United States of America"
368
- )
369
- result = address.update(
370
- :street_address => "123 E New St",
371
- :extended_address => "New Suite 3",
372
- :locality => "Chicago",
373
- :region => "Illinois",
374
- :postal_code => "60621",
375
- :country_name => "United States of America"
376
- )
377
- result.success?.should == true
378
- result.address.should == address
379
- address.street_address.should == "123 E New St"
380
- address.extended_address.should == "New Suite 3"
381
- address.locality.should == "Chicago"
382
- address.region.should == "Illinois"
383
- address.postal_code.should == "60621"
384
- address.country_name.should == "United States of America"
385
- end
386
-
387
- it "returns an error response if invalid" do
388
- customer = Braintree::Customer.create!(:last_name => "Miller")
389
- address = Braintree::Address.create!(
390
- :customer_id => customer.id,
391
- :country_name => "United States of America"
392
- )
393
- result = address.update(
394
- :street_address => "123 E New St",
395
- :country_name => "United States of Invalid"
396
- )
397
- result.success?.should == false
398
- result.errors.for(:address).on(:country_name)[0].message.should == "Country name is not an accepted country."
399
- end
400
- end
401
-
402
- describe "update!" do
403
- it "returns true and updates the address if valid" do
404
- customer = Braintree::Customer.create!(:last_name => "Miller")
405
- address = Braintree::Address.create!(
406
- :customer_id => customer.id,
407
- :street_address => "1812 E Old St",
408
- :extended_address => "Suite Old 201",
409
- :locality => "Old Chicago",
410
- :region => "IL",
411
- :postal_code => "60620",
412
- :country_name => "United States of America"
413
- )
414
- address.update!(
415
- :street_address => "123 E New St",
416
- :extended_address => "New Suite 3",
417
- :locality => "Chicago",
418
- :region => "Illinois",
419
- :postal_code => "60621",
420
- :country_name => "United States of America"
421
- ).should == address
422
- address.street_address.should == "123 E New St"
423
- address.extended_address.should == "New Suite 3"
424
- address.locality.should == "Chicago"
425
- address.region.should == "Illinois"
426
- address.postal_code.should == "60621"
427
- address.country_name.should == "United States of America"
428
- end
429
-
430
- it "raises a ValidationsFailed invalid" do
431
- customer = Braintree::Customer.create!(:last_name => "Miller")
432
- address = Braintree::Address.create!(
433
- :customer_id => customer.id,
434
- :country_name => "United States of America"
435
- )
436
- expect do
437
- address.update!(
438
- :street_address => "123 E New St",
439
- :country_name => "United States of Invalid"
440
- )
441
- end.to raise_error(Braintree::ValidationsFailed)
442
- end
443
- end
444
357
  end