braintree 2.83.0 → 2.84.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/address.rb +12 -12
  3. data/lib/braintree/address/country_names.rb +4 -1
  4. data/lib/braintree/address_gateway.rb +10 -0
  5. data/lib/braintree/client_token.rb +2 -2
  6. data/lib/braintree/client_token_gateway.rb +2 -0
  7. data/lib/braintree/credit_card.rb +20 -20
  8. data/lib/braintree/credit_card_gateway.rb +18 -0
  9. data/lib/braintree/credit_card_verification.rb +2 -2
  10. data/lib/braintree/customer.rb +18 -18
  11. data/lib/braintree/customer_gateway.rb +14 -2
  12. data/lib/braintree/dispute.rb +12 -12
  13. data/lib/braintree/dispute/history_event.rb +2 -0
  14. data/lib/braintree/dispute_search.rb +3 -0
  15. data/lib/braintree/document_upload.rb +6 -2
  16. data/lib/braintree/document_upload_gateway.rb +6 -0
  17. data/lib/braintree/ideal_payment.rb +3 -3
  18. data/lib/braintree/ideal_payment_gateway.rb +0 -1
  19. data/lib/braintree/merchant_account.rb +14 -6
  20. data/lib/braintree/merchant_account_gateway.rb +10 -0
  21. data/lib/braintree/payment_method.rb +20 -12
  22. data/lib/braintree/payment_method_gateway.rb +10 -0
  23. data/lib/braintree/payment_method_nonce.rb +8 -4
  24. data/lib/braintree/payment_method_nonce_gateway.rb +6 -0
  25. data/lib/braintree/settlement_batch_summary_gateway.rb +2 -0
  26. data/lib/braintree/subscription.rb +18 -14
  27. data/lib/braintree/subscription_gateway.rb +18 -0
  28. data/lib/braintree/transaction.rb +54 -54
  29. data/lib/braintree/transaction_gateway.rb +44 -1
  30. data/lib/braintree/transparent_redirect.rb +12 -12
  31. data/lib/braintree/us_bank_account.rb +5 -5
  32. data/lib/braintree/us_bank_account_gateway.rb +0 -1
  33. data/lib/braintree/version.rb +1 -1
  34. data/lib/braintree/webhook_notification.rb +4 -4
  35. data/lib/braintree/webhook_testing.rb +2 -2
  36. data/spec/httpsd.pid +1 -0
  37. data/spec/integration/braintree/client_api/spec_helper.rb +0 -15
  38. data/spec/integration/braintree/customer_spec.rb +73 -0
  39. data/spec/integration/braintree/dispute_search_spec.rb +69 -0
  40. data/spec/integration/braintree/document_upload_spec.rb +13 -0
  41. data/spec/integration/braintree/merchant_account_spec.rb +22 -0
  42. data/spec/integration/braintree/payment_method_nonce_spec.rb +29 -0
  43. data/spec/integration/braintree/payment_method_spec.rb +63 -93
  44. data/spec/integration/braintree/subscription_spec.rb +13 -0
  45. data/spec/integration/braintree/transaction_search_spec.rb +0 -41
  46. data/spec/integration/braintree/transaction_spec.rb +12 -1
  47. data/spec/unit/braintree/dispute_search_spec.rb +3 -0
  48. data/spec/unit/braintree/transaction_spec.rb +0 -1
  49. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 37cea606be7947a8b853f64c671fdbf463b53a6f
4
- data.tar.gz: 62c6fa628bcd6bef30444c9bd3949167ba89e994
3
+ metadata.gz: 363bcd4d73f995c9a4d466742eeec1496685280b
4
+ data.tar.gz: a1cd82c6bb218c247760888361869e070290a74f
5
5
  SHA512:
6
- metadata.gz: f7112f55aed9b3218f0112ed9c5a07f82f523eba4ea6553c45495ef93860624b319a59b40b0e832d299b9ffea87bfefa9c69266fb271fb2c24987b07e79b2187
7
- data.tar.gz: 3e8caab33783ba3d89b048b4208611e2506cf02837d8f35b52723ca34114cd7c76491315f2f14211ef06218ef041b5f68e5ff28fb48ba4fea34c302a538d6bec
6
+ metadata.gz: 07ef9f0eafcf69cd852a6a296d3a3662915cd13460574b11af1dc111cf6c50febb6036563f27d625397a268e317f08156714064ce230797b4008a839bb8a2249
7
+ data.tar.gz: c85e68010fb8f18916c7ed9d71dec1e5ed9b97e494db6fc3e47b63561bd5fa1a42d4e4ececf6d8849ad4f0d1e37192ad5c0df006e67f10ae5a114d331821f568
@@ -19,28 +19,28 @@ module Braintree
19
19
  attr_reader :street_address
20
20
  attr_reader :updated_at
21
21
 
22
- def self.create(attributes)
23
- Configuration.gateway.address.create(attributes)
22
+ def self.create(*args)
23
+ Configuration.gateway.address.create(*args)
24
24
  end
25
25
 
26
- def self.create!(attributes)
27
- return_object_or_raise(:address) { create(attributes) }
26
+ def self.create!(*args)
27
+ Configuration.gateway.address.create!(*args)
28
28
  end
29
29
 
30
- def self.delete(customer_or_customer_id, address_id)
31
- Configuration.gateway.address.delete(customer_or_customer_id, address_id)
30
+ def self.delete(*args)
31
+ Configuration.gateway.address.delete(*args)
32
32
  end
33
33
 
34
- def self.find(customer_or_customer_id, address_id)
35
- Configuration.gateway.address.find(customer_or_customer_id, address_id)
34
+ def self.find(*args)
35
+ Configuration.gateway.address.find(*args)
36
36
  end
37
37
 
38
- def self.update(customer_or_customer_id, address_id, attributes)
39
- Configuration.gateway.address.update(customer_or_customer_id, address_id, attributes)
38
+ def self.update(*args)
39
+ Configuration.gateway.address.update(*args)
40
40
  end
41
41
 
42
- def self.update!(customer_or_customer_id, address_id, attributes)
43
- return_object_or_raise(:address) { update(customer_or_customer_id, address_id, attributes) }
42
+ def self.update!(*args)
43
+ Configuration.gateway.address.update!(*args)
44
44
  end
45
45
 
46
46
  def initialize(gateway, attributes) # :nodoc:
@@ -29,6 +29,7 @@ module Braintree
29
29
  ["Bermuda", "BM", "BMU", "060"],
30
30
  ["Bhutan", "BT", "BTN", "064"],
31
31
  ["Bolivia", "BO", "BOL", "068"],
32
+ ["Bonaire, Sint Eustatius and Saba", "BQ", "BES", "535"],
32
33
  ["Bosnia and Herzegovina", "BA", "BIH", "070"],
33
34
  ["Botswana", "BW", "BWA", "072"],
34
35
  ["Bouvet Island", "BV", "BVT", "074"],
@@ -58,6 +59,7 @@ module Braintree
58
59
  ["Côte d'Ivoire", "CI", "CIV", "384"],
59
60
  ["Croatia", "HR", "HRV", "191"],
60
61
  ["Cuba", "CU", "CUB", "192"],
62
+ ["Curaçao", "CW", "CUW", "531"],
61
63
  ["Cyprus", "CY", "CYP", "196"],
62
64
  ["Czech Republic", "CZ", "CZE", "203"],
63
65
  ["Denmark", "DK", "DNK", "208"],
@@ -156,7 +158,6 @@ module Braintree
156
158
  ["Nauru", "NR", "NRU", "520"],
157
159
  ["Nepal", "NP", "NPL", "524"],
158
160
  ["Netherlands", "NL", "NLD", "528"],
159
- ["Netherlands Antilles", "AN", "ANT", "530"],
160
161
  ["New Caledonia", "NC", "NCL", "540"],
161
162
  ["New Zealand", "NZ", "NZL", "554"],
162
163
  ["Nicaragua", "NI", "NIC", "558"],
@@ -200,12 +201,14 @@ module Braintree
200
201
  ["Seychelles", "SC", "SYC", "690"],
201
202
  ["Sierra Leone", "SL", "SLE", "694"],
202
203
  ["Singapore", "SG", "SGP", "702"],
204
+ ["Sint Maarten (Dutch part)", "SX", "SXM", "534"],
203
205
  ["Slovakia", "SK", "SVK", "703"],
204
206
  ["Slovenia", "SI", "SVN", "705"],
205
207
  ["Solomon Islands", "SB", "SLB", "090"],
206
208
  ["Somalia", "SO", "SOM", "706"],
207
209
  ["South Africa", "ZA", "ZAF", "710"],
208
210
  ["South Georgia and South Sandwich Islands", "GS", "SGS", "239"],
211
+ ["South Sudan", "SS", "SSD", "728"],
209
212
  ["Spain", "ES", "ESP", "724"],
210
213
  ["Sri Lanka", "LK", "LKA", "144"],
211
214
  ["Sudan", "SD", "SDN", "736"],
@@ -1,5 +1,7 @@
1
1
  module Braintree
2
2
  class AddressGateway # :nodoc
3
+ include BaseModule
4
+
3
5
  def initialize(gateway)
4
6
  @gateway = gateway
5
7
  @config = gateway.config
@@ -24,6 +26,10 @@ module Braintree
24
26
  end
25
27
  end
26
28
 
29
+ def create!(*args)
30
+ return_object_or_raise(:address) { create(*args) }
31
+ end
32
+
27
33
  def delete(customer_or_customer_id, address_id)
28
34
  customer_id = _determine_customer_id(customer_or_customer_id)
29
35
  @config.http.delete("#{@config.base_merchant_path}/customers/#{customer_id}/addresses/#{address_id}")
@@ -52,6 +58,10 @@ module Braintree
52
58
  end
53
59
  end
54
60
 
61
+ def update!(*args)
62
+ return_object_or_raise(:address) { update(*args) }
63
+ end
64
+
55
65
  def _determine_customer_id(customer_or_customer_id) # :nodoc:
56
66
  customer_id = customer_or_customer_id.is_a?(Customer) ? customer_or_customer_id.id : customer_or_customer_id
57
67
  unless customer_id =~ /\A[\w_-]+\z/
@@ -4,8 +4,8 @@ module Braintree
4
4
  module ClientToken
5
5
  DEFAULT_VERSION = 2
6
6
 
7
- def self.generate(options={})
8
- Configuration.gateway.client_token.generate(options)
7
+ def self.generate(*args)
8
+ Configuration.gateway.client_token.generate(*args)
9
9
  end
10
10
  end
11
11
  end
@@ -1,5 +1,7 @@
1
1
  module Braintree
2
2
  class ClientTokenGateway
3
+ include BaseModule
4
+
3
5
  def initialize(gateway)
4
6
  @gateway = gateway
5
7
  @config = gateway.config
@@ -61,12 +61,12 @@ module Braintree
61
61
  attr_reader :updated_at
62
62
  attr_reader :verification
63
63
 
64
- def self.create(attributes)
65
- Configuration.gateway.credit_card.create(attributes)
64
+ def self.create(*args)
65
+ Configuration.gateway.credit_card.create(*args)
66
66
  end
67
67
 
68
- def self.create!(attributes)
69
- return_object_or_raise(:credit_card) { create(attributes) }
68
+ def self.create!(*args)
69
+ Configuration.gateway.credit_card.create!(*args)
70
70
  end
71
71
 
72
72
  # Deprecated. Use Braintree::TransparentRedirect.url
@@ -89,29 +89,29 @@ module Braintree
89
89
  return_object_or_raise(:transaction) { credit(token, transaction_attributes) }
90
90
  end
91
91
 
92
- def self.delete(token)
93
- Configuration.gateway.credit_card.delete(token)
92
+ def self.delete(*args)
93
+ Configuration.gateway.credit_card.delete(*args)
94
94
  end
95
95
 
96
- def self.expired(options = {})
97
- Configuration.gateway.credit_card.expired(options)
96
+ def self.expired(*args)
97
+ Configuration.gateway.credit_card.expired(*args)
98
98
  end
99
99
 
100
- def self.expiring_between(start_date, end_date, options = {})
101
- Configuration.gateway.credit_card.expiring_between(start_date, end_date, options)
100
+ def self.expiring_between(*args)
101
+ Configuration.gateway.credit_card.expiring_between(*args)
102
102
  end
103
103
 
104
- def self.find(token)
105
- Configuration.gateway.credit_card.find(token)
104
+ def self.find(*args)
105
+ Configuration.gateway.credit_card.find(*args)
106
106
  end
107
107
 
108
- def self.from_nonce(nonce)
109
- Configuration.gateway.credit_card.from_nonce(nonce)
108
+ def self.from_nonce(*args)
109
+ Configuration.gateway.credit_card.from_nonce(*args)
110
110
  end
111
111
 
112
112
  # Deprecated. Use Braintree::PaymentMethod.grant
113
- def self.grant(token, allow_vaulting)
114
- Configuration.gateway.credit_card.grant(token, allow_vaulting)
113
+ def self.grant(*args)
114
+ Configuration.gateway.credit_card.grant(*args)
115
115
  end
116
116
 
117
117
  def self.sale(token, transaction_attributes)
@@ -122,12 +122,12 @@ module Braintree
122
122
  return_object_or_raise(:transaction) { sale(token, transaction_attributes) }
123
123
  end
124
124
 
125
- def self.update(token, attributes)
126
- Configuration.gateway.credit_card.update(token, attributes)
125
+ def self.update(*args)
126
+ Configuration.gateway.credit_card.update(*args)
127
127
  end
128
128
 
129
- def self.update!(token, attributes)
130
- return_object_or_raise(:credit_card) { update(token, attributes) }
129
+ def self.update!(*args)
130
+ Configuration.gateway.credit_card.update!(*args)
131
131
  end
132
132
 
133
133
  # Deprecated. Use Braintree::TransparentRedirect.confirm
@@ -1,5 +1,7 @@
1
1
  module Braintree
2
2
  class CreditCardGateway # :nodoc:
3
+ include BaseModule
4
+
3
5
  def initialize(gateway)
4
6
  @gateway = gateway
5
7
  @config = gateway.config
@@ -14,6 +16,10 @@ module Braintree
14
16
  _do_create("/payment_methods", :credit_card => attributes)
15
17
  end
16
18
 
19
+ def create!(*args)
20
+ return_object_or_raise(:credit_card) { create(*args) }
21
+ end
22
+
17
23
  # Deprecated
18
24
  def create_credit_card_url
19
25
  "#{@config.base_merchant_url}/payment_methods/all/create_via_transparent_redirect_request"
@@ -25,6 +31,14 @@ module Braintree
25
31
  _do_create("/payment_methods/all/confirm_transparent_redirect_request", :id => params[:id])
26
32
  end
27
33
 
34
+ def credit(token, transaction_attributes)
35
+ @gateway.transaction.credit(transaction_attributes.merge(:payment_method_token => token))
36
+ end
37
+
38
+ def credit!(*args)
39
+ return_object_or_raise(:transaction) { credit(*args) }
40
+ end
41
+
28
42
  def delete(token)
29
43
  @config.http.delete("#{@config.base_merchant_path}/payment_methods/credit_card/#{token}")
30
44
  end
@@ -67,6 +81,10 @@ module Braintree
67
81
  _do_update(:put, "/payment_methods/credit_card/#{token}", :credit_card => attributes)
68
82
  end
69
83
 
84
+ def update!(*args)
85
+ return_object_or_raise(:credit_card) { update(*args) }
86
+ end
87
+
70
88
  # Deprecated
71
89
  def update_from_transparent_redirect(query_string)
72
90
  warn "[DEPRECATED] CreditCard.update_via_transparent_redirect_request is deprecated. Please use TransparentRedirect.confirm"
@@ -73,8 +73,8 @@ module Braintree
73
73
  self.new *args
74
74
  end
75
75
 
76
- def self.find(id)
77
- Configuration.gateway.verification.find(id)
76
+ def self.find(*args)
77
+ Configuration.gateway.verification.find(*args)
78
78
  end
79
79
 
80
80
  def self.search(&block)
@@ -30,12 +30,12 @@ module Braintree
30
30
  Configuration.gateway.customer.all
31
31
  end
32
32
 
33
- def self.create(attributes = {})
34
- Configuration.gateway.customer.create(attributes)
33
+ def self.create(*args)
34
+ Configuration.gateway.customer.create(*args)
35
35
  end
36
36
 
37
- def self.create!(attributes = {})
38
- return_object_or_raise(:customer) { create(attributes) }
37
+ def self.create!(*args)
38
+ Configuration.gateway.customer.create!(*args)
39
39
  end
40
40
 
41
41
  # Deprecated. Use Braintree::TransparentRedirect.url
@@ -45,9 +45,9 @@ module Braintree
45
45
  end
46
46
 
47
47
  # Deprecated. Use Braintree::TransparentRedirect.confirm
48
- def self.create_from_transparent_redirect(query_string)
48
+ def self.create_from_transparent_redirect(*args)
49
49
  warn "[DEPRECATED] Customer.create_from_transparent_redirect is deprecated. Please use TransparentRedirect.confirm"
50
- Configuration.gateway.customer.create_from_transparent_redirect(query_string)
50
+ Configuration.gateway.customer.create_from_transparent_redirect(*args)
51
51
  end
52
52
 
53
53
  def self.credit(customer_id, transaction_attributes)
@@ -58,12 +58,12 @@ module Braintree
58
58
  return_object_or_raise(:transaction){ credit(customer_id, transaction_attributes) }
59
59
  end
60
60
 
61
- def self.delete(customer_id)
62
- Configuration.gateway.customer.delete(customer_id)
61
+ def self.delete(*args)
62
+ Configuration.gateway.customer.delete(*args)
63
63
  end
64
64
 
65
- def self.find(customer_id)
66
- Configuration.gateway.customer.find(customer_id)
65
+ def self.find(*args)
66
+ Configuration.gateway.customer.find(*args)
67
67
  end
68
68
 
69
69
  def self.sale(customer_id, transaction_attributes)
@@ -79,16 +79,16 @@ module Braintree
79
79
  end
80
80
 
81
81
  # Returns a ResourceCollection of transactions for the customer with the given +customer_id+.
82
- def self.transactions(customer_id, options = {})
83
- Configuration.gateway.customer.transactions(customer_id, options = {})
82
+ def self.transactions(*args)
83
+ Configuration.gateway.customer.transactions(*args)
84
84
  end
85
85
 
86
- def self.update(customer_id, attributes)
87
- Configuration.gateway.customer.update(customer_id, attributes)
86
+ def self.update(*args)
87
+ Configuration.gateway.customer.update(*args)
88
88
  end
89
89
 
90
- def self.update!(customer_id, attributes)
91
- return_object_or_raise(:customer) { update(customer_id, attributes) }
90
+ def self.update!(*args)
91
+ Configuration.gateway.customer.update!(*args)
92
92
  end
93
93
 
94
94
  # Deprecated. Use Braintree::TransparentRedirect.url
@@ -98,9 +98,9 @@ module Braintree
98
98
  end
99
99
 
100
100
  # Deprecated. Use Braintree::TransparentRedirect.confirm
101
- def self.update_from_transparent_redirect(query_string)
101
+ def self.update_from_transparent_redirect(*args)
102
102
  warn "[DEPRECATED] Customer.update_from_transparent_redirect is deprecated. Please use TransparentRedirect.confirm"
103
- Configuration.gateway.customer.update_from_transparent_redirect(query_string)
103
+ Configuration.gateway.customer.update_from_transparent_redirect(*args)
104
104
  end
105
105
 
106
106
  def initialize(gateway, attributes) # :nodoc:
@@ -1,5 +1,7 @@
1
1
  module Braintree
2
2
  class CustomerGateway # :nodoc:
3
+ include BaseModule
4
+
3
5
  def initialize(gateway)
4
6
  @gateway = gateway
5
7
  @config = gateway.config
@@ -16,6 +18,10 @@ module Braintree
16
18
  _do_create "/customers", :customer => attributes
17
19
  end
18
20
 
21
+ def create!(*args)
22
+ return_object_or_raise(:customer) { create(*args) }
23
+ end
24
+
19
25
  # Deprecated
20
26
  def create_customer_url
21
27
  "#{@config.base_merchant_url}/customers/all/create_via_transparent_redirect_request"
@@ -32,10 +38,12 @@ module Braintree
32
38
  SuccessfulResult.new
33
39
  end
34
40
 
35
- def find(customer_id)
41
+ def find(customer_id, options = {})
36
42
  raise ArgumentError, "customer_id contains invalid characters" unless customer_id.to_s =~ /\A[\w-]+\z/
37
43
  raise ArgumentError, "customer_id cannot be blank" if customer_id.nil?|| customer_id.to_s.strip == ""
38
- response = @config.http.get("#{@config.base_merchant_path}/customers/#{customer_id}")
44
+
45
+ query_params = options[:association_filter_id].nil? ? "" : "?association_filter_id=#{options[:association_filter_id]}"
46
+ response = @config.http.get("#{@config.base_merchant_path}/customers/#{customer_id}#{query_params}")
39
47
  Customer._new(@gateway, response[:customer])
40
48
  rescue NotFoundError
41
49
  raise NotFoundError, "customer with id #{customer_id.inspect} not found"
@@ -59,6 +67,10 @@ module Braintree
59
67
  _do_update(:put, "/customers/#{customer_id}", :customer => attributes)
60
68
  end
61
69
 
70
+ def update!(*args)
71
+ return_object_or_raise(:customer) { update(*args) }
72
+ end
73
+
62
74
  # Deprecated
63
75
  def update_customer_url
64
76
  warn "[DEPRECATED] Customer.update_customer_url is deprecated. Please use TransparentRedirect.url"
@@ -71,28 +71,28 @@ module Braintree
71
71
  end
72
72
  end
73
73
 
74
- def self.accept(dispute_id)
75
- Configuration.gateway.dispute.accept(dispute_id)
74
+ def self.accept(*args)
75
+ Configuration.gateway.dispute.accept(*args)
76
76
  end
77
77
 
78
- def self.add_file_evidence(dispute_id, document_upload_id)
79
- Configuration.gateway.dispute.add_file_evidence(dispute_id, document_upload_id)
78
+ def self.add_file_evidence(*args)
79
+ Configuration.gateway.dispute.add_file_evidence(*args)
80
80
  end
81
81
 
82
- def self.add_text_evidence(dispute_id, content_or_request)
83
- Configuration.gateway.dispute.add_text_evidence(dispute_id, content_or_request)
82
+ def self.add_text_evidence(*args)
83
+ Configuration.gateway.dispute.add_text_evidence(*args)
84
84
  end
85
85
 
86
- def self.finalize(dispute_id)
87
- Configuration.gateway.dispute.finalize(dispute_id)
86
+ def self.finalize(*args)
87
+ Configuration.gateway.dispute.finalize(*args)
88
88
  end
89
89
 
90
- def self.find(dispute_id)
91
- Configuration.gateway.dispute.find(dispute_id)
90
+ def self.find(*args)
91
+ Configuration.gateway.dispute.find(*args)
92
92
  end
93
93
 
94
- def self.remove_evidence(dispute_id, evidence_id)
95
- Configuration.gateway.dispute.remove_evidence(dispute_id, evidence_id)
94
+ def self.remove_evidence(*args)
95
+ Configuration.gateway.dispute.remove_evidence(*args)
96
96
  end
97
97
 
98
98
  def self.search(&block)
@@ -3,6 +3,8 @@ module Braintree
3
3
  class HistoryEvent # :nodoc:
4
4
  include BaseModule
5
5
 
6
+ attr_reader :disbursement_date
7
+ attr_reader :effective_date
6
8
  attr_reader :status
7
9
  attr_reader :timestamp
8
10