stripe 4.18.0 → 4.18.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +11 -1
- data/.rubocop_todo.yml +3 -15
- data/CHANGELOG.md +3 -0
- data/Gemfile +3 -1
- data/VERSION +1 -1
- data/lib/stripe.rb +5 -3
- data/lib/stripe/account.rb +31 -17
- data/lib/stripe/alipay_account.rb +10 -3
- data/lib/stripe/api_operations/nested_resource.rb +12 -6
- data/lib/stripe/api_operations/request.rb +3 -7
- data/lib/stripe/api_operations/save.rb +1 -3
- data/lib/stripe/api_resource.rb +11 -3
- data/lib/stripe/application_fee.rb +2 -1
- data/lib/stripe/application_fee_refund.rb +11 -3
- data/lib/stripe/bank_account.rb +16 -4
- data/lib/stripe/bitcoin_receiver.rb +2 -1
- data/lib/stripe/capability.rb +10 -3
- data/lib/stripe/card.rb +16 -5
- data/lib/stripe/charge.rb +4 -6
- data/lib/stripe/customer.rb +5 -7
- data/lib/stripe/ephemeral_key.rb +4 -1
- data/lib/stripe/errors.rb +8 -8
- data/lib/stripe/invoice.rb +2 -1
- data/lib/stripe/list_object.rb +9 -4
- data/lib/stripe/login_link.rb +4 -1
- data/lib/stripe/order.rb +3 -5
- data/lib/stripe/person.rb +7 -2
- data/lib/stripe/reversal.rb +10 -3
- data/lib/stripe/singleton_api_resource.rb +3 -1
- data/lib/stripe/source.rb +4 -2
- data/lib/stripe/stripe_client.rb +84 -65
- data/lib/stripe/stripe_object.rb +50 -36
- data/lib/stripe/subscription.rb +1 -3
- data/lib/stripe/subscription_item.rb +2 -1
- data/lib/stripe/subscription_schedule_revision.rb +13 -4
- data/lib/stripe/tax_id.rb +7 -3
- data/lib/stripe/transfer.rb +2 -1
- data/lib/stripe/usage_record.rb +12 -3
- data/lib/stripe/util.rb +40 -24
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe/webhook.rb +4 -2
- data/stripe.gemspec +4 -2
- data/test/stripe/account_link_test.rb +1 -1
- data/test/stripe/account_test.rb +1 -1
- data/test/stripe/alipay_account_test.rb +1 -1
- data/test/stripe/api_operations_test.rb +1 -2
- data/test/stripe/api_resource_test.rb +5 -8
- data/test/stripe/apple_pay_domain_test.rb +1 -1
- data/test/stripe/application_fee_refund_test.rb +1 -1
- data/test/stripe/application_fee_test.rb +1 -1
- data/test/stripe/balance_test.rb +1 -1
- data/test/stripe/bank_account_test.rb +1 -1
- data/test/stripe/capability_test.rb +1 -1
- data/test/stripe/charge_test.rb +1 -1
- data/test/stripe/checkout/session_test.rb +1 -1
- data/test/stripe/country_spec_test.rb +1 -1
- data/test/stripe/coupon_test.rb +1 -1
- data/test/stripe/credit_note_test.rb +1 -1
- data/test/stripe/customer_card_test.rb +1 -1
- data/test/stripe/customer_test.rb +1 -1
- data/test/stripe/dispute_test.rb +1 -1
- data/test/stripe/ephemeral_key_test.rb +1 -1
- data/test/stripe/errors_test.rb +1 -1
- data/test/stripe/exchange_rate_test.rb +1 -1
- data/test/stripe/file_link_test.rb +1 -1
- data/test/stripe/file_test.rb +1 -1
- data/test/stripe/file_upload_test.rb +1 -1
- data/test/stripe/invoice_item_test.rb +1 -1
- data/test/stripe/invoice_line_item_test.rb +1 -1
- data/test/stripe/invoice_test.rb +1 -1
- data/test/stripe/issuer_fraud_record_test.rb +1 -1
- data/test/stripe/issuing/authorization_test.rb +1 -1
- data/test/stripe/issuing/card_test.rb +1 -1
- data/test/stripe/issuing/cardholder_test.rb +1 -1
- data/test/stripe/issuing/dispute_test.rb +1 -1
- data/test/stripe/issuing/transaction_test.rb +1 -1
- data/test/stripe/list_object_test.rb +1 -1
- data/test/stripe/login_link_test.rb +1 -1
- data/test/stripe/oauth_test.rb +1 -1
- data/test/stripe/order_return_test.rb +1 -1
- data/test/stripe/order_test.rb +8 -1
- data/test/stripe/payment_intent_test.rb +1 -1
- data/test/stripe/payment_method_test.rb +1 -1
- data/test/stripe/payout_test.rb +1 -1
- data/test/stripe/person_test.rb +1 -1
- data/test/stripe/plan_test.rb +1 -1
- data/test/stripe/product_test.rb +1 -1
- data/test/stripe/radar/early_fraud_warning_test.rb +1 -1
- data/test/stripe/radar/value_list_item_test.rb +1 -1
- data/test/stripe/radar/value_list_test.rb +1 -1
- data/test/stripe/recipient_test.rb +1 -1
- data/test/stripe/refund_test.rb +1 -1
- data/test/stripe/reporting/report_run_test.rb +1 -1
- data/test/stripe/reporting/report_type_test.rb +1 -1
- data/test/stripe/reversal_test.rb +1 -1
- data/test/stripe/review_test.rb +1 -1
- data/test/stripe/sigma/scheduled_query_run_test.rb +1 -1
- data/test/stripe/sku_test.rb +1 -1
- data/test/stripe/source_test.rb +1 -1
- data/test/stripe/source_transaction_test.rb +1 -1
- data/test/stripe/stripe_client_test.rb +1 -1
- data/test/stripe/stripe_object_test.rb +1 -1
- data/test/stripe/stripe_response_test.rb +1 -1
- data/test/stripe/subscription_item_test.rb +1 -1
- data/test/stripe/subscription_schedule_revision_test.rb +1 -1
- data/test/stripe/subscription_schedule_test.rb +1 -1
- data/test/stripe/subscription_test.rb +1 -1
- data/test/stripe/tax_id_test.rb +1 -1
- data/test/stripe/tax_rate_test.rb +1 -1
- data/test/stripe/terminal/connection_token_test.rb +1 -1
- data/test/stripe/terminal/location_test.rb +1 -1
- data/test/stripe/terminal/reader_test.rb +1 -1
- data/test/stripe/three_d_secure_test.rb +1 -1
- data/test/stripe/topup_test.rb +1 -1
- data/test/stripe/transfer_test.rb +1 -1
- data/test/stripe/usage_record_summary_test.rb +1 -1
- data/test/stripe/usage_record_test.rb +1 -1
- data/test/stripe/util_test.rb +1 -1
- data/test/stripe/webhook_endpoint_test.rb +1 -1
- data/test/stripe/webhook_test.rb +2 -2
- data/test/stripe_test.rb +1 -1
- data/test/test_helper.rb +4 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d2bc94a670bcbb6341ce794ad5415d30aece0177fc50a6a176c7a5a33083664
|
4
|
+
data.tar.gz: e45ad1040e1ebe11e4493a8b77c35cbe7b25bda4511a23d4c655a1a2ef3f0a0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4aa8383711814c62576ff737c40fb8f83e40c9c4b60753d54f7cbf42fa3d652083373d5f2d587850e9e76c8d6090ce6fa2e2408157860e108e4a6d72526fe15
|
7
|
+
data.tar.gz: daf904e718c62170c2f8a4da0be10b29d5c040d9a9fbbcb95ad8a57bdd91a862a6cd21aff54fa7de46aa62c9bd79097f801d6b768d4083b7dd24e34e96f6e630
|
data/.rubocop.yml
CHANGED
@@ -13,6 +13,10 @@ Layout/IndentArray:
|
|
13
13
|
Layout/IndentHash:
|
14
14
|
EnforcedStyle: consistent
|
15
15
|
|
16
|
+
Metrics/LineLength:
|
17
|
+
Exclude:
|
18
|
+
- "test/**/*.rb"
|
19
|
+
|
16
20
|
Metrics/MethodLength:
|
17
21
|
# There's ~2 long methods in `StripeClient`. If we want to truncate those a
|
18
22
|
# little, we could move this to be closer to ~30 (but the default of 10 is
|
@@ -22,11 +26,17 @@ Metrics/MethodLength:
|
|
22
26
|
Metrics/ModuleLength:
|
23
27
|
Enabled: false
|
24
28
|
|
29
|
+
Style/AccessModifierDeclarations:
|
30
|
+
EnforcedStyle: inline
|
31
|
+
|
25
32
|
Style/FrozenStringLiteralComment:
|
26
33
|
EnforcedStyle: always
|
27
34
|
|
28
35
|
Style/StringLiterals:
|
29
36
|
EnforcedStyle: double_quotes
|
30
37
|
|
31
|
-
Style/
|
38
|
+
Style/TrailingCommaInArrayLiteral:
|
39
|
+
EnforcedStyleForMultiline: consistent_comma
|
40
|
+
|
41
|
+
Style/TrailingCommaInHashLiteral:
|
32
42
|
EnforcedStyleForMultiline: consistent_comma
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2019-
|
3
|
+
# on 2019-05-24 10:18:48 -0700 using RuboCop version 0.57.2.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -15,7 +15,7 @@ Metrics/AbcSize:
|
|
15
15
|
Metrics/BlockLength:
|
16
16
|
Max: 498
|
17
17
|
|
18
|
-
# Offense count:
|
18
|
+
# Offense count: 11
|
19
19
|
# Configuration parameters: CountComments.
|
20
20
|
Metrics/ClassLength:
|
21
21
|
Max: 673
|
@@ -24,12 +24,6 @@ Metrics/ClassLength:
|
|
24
24
|
Metrics/CyclomaticComplexity:
|
25
25
|
Max: 15
|
26
26
|
|
27
|
-
# Offense count: 364
|
28
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
29
|
-
# URISchemes: http, https
|
30
|
-
Metrics/LineLength:
|
31
|
-
Max: 310
|
32
|
-
|
33
27
|
# Offense count: 6
|
34
28
|
# Configuration parameters: CountKeywordArgs.
|
35
29
|
Metrics/ParameterLists:
|
@@ -39,12 +33,6 @@ Metrics/ParameterLists:
|
|
39
33
|
Metrics/PerceivedComplexity:
|
40
34
|
Max: 17
|
41
35
|
|
42
|
-
# Offense count:
|
43
|
-
Style/ClassVars:
|
44
|
-
Exclude:
|
45
|
-
- 'lib/stripe/stripe_object.rb'
|
46
|
-
- 'test/stripe/api_resource_test.rb'
|
47
|
-
|
48
|
-
# Offense count: 78
|
36
|
+
# Offense count: 84
|
49
37
|
Style/Documentation:
|
50
38
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 4.18.1 - 2019-05-27
|
4
|
+
* [#789](https://github.com/stripe/stripe-ruby/pull/789) Allow `Order#pay` to be called without arguments
|
5
|
+
|
3
6
|
## 4.18.0 - 2019-05-23
|
4
7
|
* [#783](https://github.com/stripe/stripe-ruby/pull/783) Add support for `radar.early_fraud_warning` resource
|
5
8
|
|
data/Gemfile
CHANGED
@@ -18,7 +18,9 @@ group :development do
|
|
18
18
|
# `Gemfile.lock` checked in, so to prevent good builds from suddenly going
|
19
19
|
# bad, pin to a specific version number here. Try to keep this relatively
|
20
20
|
# up-to-date, but it's not the end of the world if it's not.
|
21
|
-
|
21
|
+
# Note that 0.57.2 is the most recent version we can use until we drop
|
22
|
+
# support for Ruby 2.1.
|
23
|
+
gem "rubocop", "0.57.2"
|
22
24
|
|
23
25
|
# Rack 2.0+ requires Ruby >= 2.2.2 which is problematic for the test suite on
|
24
26
|
# older Ruby versions. Check Ruby the version here and put a maximum
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.18.
|
1
|
+
4.18.1
|
data/lib/stripe.rb
CHANGED
@@ -116,7 +116,7 @@ require "stripe/webhook_endpoint"
|
|
116
116
|
require "stripe/oauth"
|
117
117
|
|
118
118
|
module Stripe
|
119
|
-
DEFAULT_CA_BUNDLE_PATH =
|
119
|
+
DEFAULT_CA_BUNDLE_PATH = __dir__ + "/data/ca-certificates.crt"
|
120
120
|
|
121
121
|
@app_info = nil
|
122
122
|
|
@@ -143,7 +143,8 @@ module Stripe
|
|
143
143
|
@enable_telemetry = false
|
144
144
|
|
145
145
|
class << self
|
146
|
-
attr_accessor :stripe_account, :api_key, :api_base, :verify_ssl_certs,
|
146
|
+
attr_accessor :stripe_account, :api_key, :api_base, :verify_ssl_certs,
|
147
|
+
:api_version, :client_id, :connect_base, :uploads_base,
|
147
148
|
:open_timeout, :read_timeout, :proxy
|
148
149
|
|
149
150
|
attr_reader :max_network_retry_delay, :initial_network_retry_delay
|
@@ -215,7 +216,8 @@ module Stripe
|
|
215
216
|
end
|
216
217
|
|
217
218
|
if !val.nil? && ![LEVEL_DEBUG, LEVEL_ERROR, LEVEL_INFO].include?(val)
|
218
|
-
raise ArgumentError,
|
219
|
+
raise ArgumentError,
|
220
|
+
"log_level should only be set to `nil`, `debug` or `info`"
|
219
221
|
end
|
220
222
|
@log_level = val
|
221
223
|
end
|
data/lib/stripe/account.rb
CHANGED
@@ -18,10 +18,12 @@ module Stripe
|
|
18
18
|
operations: %i[retrieve update list],
|
19
19
|
resource_plural: "capabilities"
|
20
20
|
nested_resource_class_methods :external_account,
|
21
|
-
operations: %i[create retrieve update delete
|
21
|
+
operations: %i[create retrieve update delete
|
22
|
+
list]
|
22
23
|
nested_resource_class_methods :login_link, operations: %i[create]
|
23
24
|
nested_resource_class_methods :person,
|
24
|
-
operations: %i[create retrieve update delete
|
25
|
+
operations: %i[create retrieve update delete
|
26
|
+
list]
|
25
27
|
|
26
28
|
# This method is deprecated. Please use `#external_account=` instead.
|
27
29
|
save_nested_resource :bank_account
|
@@ -37,13 +39,18 @@ module Stripe
|
|
37
39
|
|
38
40
|
# @override To make id optional
|
39
41
|
def self.retrieve(id = ARGUMENT_NOT_PROVIDED, opts = {})
|
40
|
-
id = id.equal?(ARGUMENT_NOT_PROVIDED)
|
42
|
+
id = if id.equal?(ARGUMENT_NOT_PROVIDED)
|
43
|
+
nil
|
44
|
+
else
|
45
|
+
Util.check_string_argument!(id)
|
46
|
+
end
|
41
47
|
|
42
48
|
# Account used to be a singleton, where this method's signature was
|
43
49
|
# `(opts={})`. For the sake of not breaking folks who pass in an OAuth
|
44
50
|
# key in opts, let's lurkily string match for it.
|
45
51
|
if opts == {} && id.is_a?(String) && id.start_with?("sk_")
|
46
|
-
# `super` properly assumes a String opts is the apiKey and normalizes
|
52
|
+
# `super` properly assumes a String opts is the apiKey and normalizes
|
53
|
+
# as expected.
|
47
54
|
opts = id
|
48
55
|
id = nil
|
49
56
|
end
|
@@ -55,8 +62,9 @@ module Stripe
|
|
55
62
|
Util.convert_to_stripe_object(resp.data, opts)
|
56
63
|
end
|
57
64
|
|
58
|
-
# We are not adding a helper for capabilities here as the Account object
|
59
|
-
# capabilities property which is a hash and not the sub-list
|
65
|
+
# We are not adding a helper for capabilities here as the Account object
|
66
|
+
# already has a capabilities property which is a hash and not the sub-list
|
67
|
+
# of capabilities.
|
60
68
|
|
61
69
|
def reject(params = {}, opts = {})
|
62
70
|
resp, opts = request(:post, resource_url + "/reject", params, opts)
|
@@ -114,8 +122,11 @@ module Stripe
|
|
114
122
|
self["legal_entity"]
|
115
123
|
end
|
116
124
|
|
117
|
-
def legal_entity=(
|
118
|
-
raise NoMethodError,
|
125
|
+
def legal_entity=(_legal_entity)
|
126
|
+
raise NoMethodError,
|
127
|
+
"Overriding legal_entity can cause serious issues. Instead, set " \
|
128
|
+
"the individual fields of legal_entity like " \
|
129
|
+
"`account.legal_entity.first_name = 'Blah'`"
|
119
130
|
end
|
120
131
|
|
121
132
|
def deauthorize(client_id = nil, opts = {})
|
@@ -128,15 +139,17 @@ module Stripe
|
|
128
139
|
|
129
140
|
ARGUMENT_NOT_PROVIDED = Object.new
|
130
141
|
|
131
|
-
private
|
132
|
-
|
133
|
-
|
134
|
-
|
142
|
+
private def serialize_additional_owners(legal_entity, additional_owners)
|
143
|
+
original_value =
|
144
|
+
legal_entity
|
145
|
+
.instance_variable_get(:@original_values)[:additional_owners]
|
135
146
|
if original_value && original_value.length > additional_owners.length
|
136
147
|
# url params provide no mechanism for deleting an item in an array,
|
137
148
|
# just overwriting the whole array or adding new items. So let's not
|
138
149
|
# allow deleting without a full overwrite until we have a solution.
|
139
|
-
raise ArgumentError,
|
150
|
+
raise ArgumentError,
|
151
|
+
"You cannot delete an item from an array, you must instead " \
|
152
|
+
"set a new array"
|
140
153
|
end
|
141
154
|
|
142
155
|
update_hash = {}
|
@@ -148,10 +161,11 @@ module Stripe
|
|
148
161
|
# StripeObject.
|
149
162
|
update = v.is_a?(StripeObject) ? v.serialize_params : v
|
150
163
|
|
151
|
-
|
152
|
-
update != legal_entity.serialize_params_value(original_value[i], nil,
|
153
|
-
|
154
|
-
|
164
|
+
next unless update != {} && (!original_value ||
|
165
|
+
update != legal_entity.serialize_params_value(original_value[i], nil,
|
166
|
+
false, true))
|
167
|
+
|
168
|
+
update_hash[i.to_s] = update
|
155
169
|
end
|
156
170
|
update_hash
|
157
171
|
end
|
@@ -13,15 +13,22 @@ module Stripe
|
|
13
13
|
"Alipay accounts cannot be accessed without a customer ID."
|
14
14
|
end
|
15
15
|
|
16
|
-
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources
|
16
|
+
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources" \
|
17
|
+
"/#{CGI.escape(id)}"
|
17
18
|
end
|
18
19
|
|
19
20
|
def self.update(_id, _params = nil, _opts = nil)
|
20
|
-
raise NotImplementedError,
|
21
|
+
raise NotImplementedError,
|
22
|
+
"Alipay accounts cannot be updated without a customer ID. " \
|
23
|
+
"Update an Alipay account using `Customer.update_source(" \
|
24
|
+
"'customer_id', 'alipay_account_id', update_params)`"
|
21
25
|
end
|
22
26
|
|
23
27
|
def self.retrieve(_id, _opts = nil)
|
24
|
-
raise NotImplementedError,
|
28
|
+
raise NotImplementedError,
|
29
|
+
"Alipay accounts cannot be retrieved without a customer ID. " \
|
30
|
+
"Retrieve an Alipay account using `Customer.retrieve_source(" \
|
31
|
+
"'customer_id', 'alipay_account_id')`"
|
25
32
|
end
|
26
33
|
end
|
27
34
|
end
|
@@ -10,7 +10,8 @@ module Stripe
|
|
10
10
|
# methods `.create_reversal`, `.retrieve_reversal`, `.update_reversal`,
|
11
11
|
# etc. all become available.
|
12
12
|
module NestedResource
|
13
|
-
def nested_resource_class_methods(resource, path: nil, operations: nil,
|
13
|
+
def nested_resource_class_methods(resource, path: nil, operations: nil,
|
14
|
+
resource_plural: nil)
|
14
15
|
resource_plural ||= "#{resource}s"
|
15
16
|
path ||= resource_plural
|
16
17
|
raise ArgumentError, "operations array required" if operations.nil?
|
@@ -25,31 +26,36 @@ module Stripe
|
|
25
26
|
operations.each do |operation|
|
26
27
|
case operation
|
27
28
|
when :create
|
28
|
-
define_singleton_method(:"create_#{resource}")
|
29
|
+
define_singleton_method(:"create_#{resource}") \
|
30
|
+
do |id, params = {}, opts = {}|
|
29
31
|
url = send(resource_url_method, id)
|
30
32
|
resp, opts = request(:post, url, params, opts)
|
31
33
|
Util.convert_to_stripe_object(resp.data, opts)
|
32
34
|
end
|
33
35
|
when :retrieve
|
34
|
-
define_singleton_method(:"retrieve_#{resource}")
|
36
|
+
define_singleton_method(:"retrieve_#{resource}") \
|
37
|
+
do |id, nested_id, opts = {}|
|
35
38
|
url = send(resource_url_method, id, nested_id)
|
36
39
|
resp, opts = request(:get, url, {}, opts)
|
37
40
|
Util.convert_to_stripe_object(resp.data, opts)
|
38
41
|
end
|
39
42
|
when :update
|
40
|
-
define_singleton_method(:"update_#{resource}")
|
43
|
+
define_singleton_method(:"update_#{resource}") \
|
44
|
+
do |id, nested_id, params = {}, opts = {}|
|
41
45
|
url = send(resource_url_method, id, nested_id)
|
42
46
|
resp, opts = request(:post, url, params, opts)
|
43
47
|
Util.convert_to_stripe_object(resp.data, opts)
|
44
48
|
end
|
45
49
|
when :delete
|
46
|
-
define_singleton_method(:"delete_#{resource}")
|
50
|
+
define_singleton_method(:"delete_#{resource}") \
|
51
|
+
do |id, nested_id, params = {}, opts = {}|
|
47
52
|
url = send(resource_url_method, id, nested_id)
|
48
53
|
resp, opts = request(:delete, url, params, opts)
|
49
54
|
Util.convert_to_stripe_object(resp.data, opts)
|
50
55
|
end
|
51
56
|
when :list
|
52
|
-
define_singleton_method(:"list_#{resource_plural}")
|
57
|
+
define_singleton_method(:"list_#{resource_plural}") \
|
58
|
+
do |id, params = {}, opts = {}|
|
53
59
|
url = send(resource_url_method, id)
|
54
60
|
resp, opts = request(:get, url, params, opts)
|
55
61
|
Util.convert_to_stripe_object(resp.data, opts)
|
@@ -31,12 +31,10 @@ module Stripe
|
|
31
31
|
[resp, opts_to_persist]
|
32
32
|
end
|
33
33
|
|
34
|
-
private
|
35
|
-
|
36
|
-
def warn_on_opts_in_params(params)
|
34
|
+
private def warn_on_opts_in_params(params)
|
37
35
|
Util::OPTS_USER_SPECIFIED.each do |opt|
|
38
36
|
if params.key?(opt)
|
39
|
-
|
37
|
+
warn("WARNING: #{opt} should be in opts instead of params.")
|
40
38
|
end
|
41
39
|
end
|
42
40
|
end
|
@@ -46,9 +44,7 @@ module Stripe
|
|
46
44
|
base.extend(ClassMethods)
|
47
45
|
end
|
48
46
|
|
49
|
-
protected
|
50
|
-
|
51
|
-
def request(method, url, params = {}, opts = {})
|
47
|
+
protected def request(method, url, params = {}, opts = {})
|
52
48
|
opts = @opts.merge(Util.normalize_opts(opts))
|
53
49
|
self.class.request(method, url, params, opts)
|
54
50
|
end
|
@@ -76,9 +76,7 @@ module Stripe
|
|
76
76
|
base.extend(ClassMethods)
|
77
77
|
end
|
78
78
|
|
79
|
-
private
|
80
|
-
|
81
|
-
def save_url
|
79
|
+
private def save_url
|
82
80
|
# This switch essentially allows us "upsert"-like functionality. If the
|
83
81
|
# API resource doesn't have an ID set (suggesting that it's new) and
|
84
82
|
# its class responds to .create (which comes from
|
data/lib/stripe/api_resource.rb
CHANGED
@@ -17,7 +17,9 @@ module Stripe
|
|
17
17
|
|
18
18
|
def self.resource_url
|
19
19
|
if self == APIResource
|
20
|
-
raise NotImplementedError,
|
20
|
+
raise NotImplementedError,
|
21
|
+
"APIResource is an abstract class. You should perform actions " \
|
22
|
+
"on its subclasses (Charge, Customer, etc.)"
|
21
23
|
end
|
22
24
|
# Namespaces are separated in object names with periods (.) and in URLs
|
23
25
|
# with forward slashes (/), so replace the former with the latter.
|
@@ -62,7 +64,9 @@ module Stripe
|
|
62
64
|
# will send a POST request to `/v1/<object_name>/capture`.
|
63
65
|
def self.custom_method(name, http_verb:, http_path: nil)
|
64
66
|
unless %i[get post delete].include?(http_verb)
|
65
|
-
raise ArgumentError,
|
67
|
+
raise ArgumentError,
|
68
|
+
"Invalid http_verb value: #{http_verb.inspect}. Should be one " \
|
69
|
+
"of :get, :post or :delete."
|
66
70
|
end
|
67
71
|
http_path ||= name.to_s
|
68
72
|
define_singleton_method(name) do |id, params = {}, opts = {}|
|
@@ -74,7 +78,11 @@ module Stripe
|
|
74
78
|
|
75
79
|
def resource_url
|
76
80
|
unless (id = self["id"])
|
77
|
-
raise InvalidRequestError.new(
|
81
|
+
raise InvalidRequestError.new(
|
82
|
+
"Could not determine which URL to request: #{self.class} instance " \
|
83
|
+
"has invalid ID: #{id.inspect}",
|
84
|
+
"id"
|
85
|
+
)
|
78
86
|
end
|
79
87
|
"#{self.class.resource_url}/#{CGI.escape(id)}"
|
80
88
|
end
|
@@ -7,7 +7,8 @@ module Stripe
|
|
7
7
|
|
8
8
|
OBJECT_NAME = "application_fee".freeze
|
9
9
|
|
10
|
-
nested_resource_class_methods :refund,
|
10
|
+
nested_resource_class_methods :refund,
|
11
|
+
operations: %i[create retrieve update list]
|
11
12
|
|
12
13
|
# If you don't need access to an updated fee object after the refund, it's
|
13
14
|
# more performant to just call `fee.refunds.create` directly.
|
@@ -8,15 +8,23 @@ module Stripe
|
|
8
8
|
OBJECT_NAME = "fee_refund".freeze
|
9
9
|
|
10
10
|
def resource_url
|
11
|
-
"#{ApplicationFee.resource_url}/#{CGI.escape(fee)}/refunds
|
11
|
+
"#{ApplicationFee.resource_url}/#{CGI.escape(fee)}/refunds" \
|
12
|
+
"/#{CGI.escape(id)}"
|
12
13
|
end
|
13
14
|
|
14
15
|
def self.update(_id, _params = nil, _opts = nil)
|
15
|
-
raise NotImplementedError,
|
16
|
+
raise NotImplementedError,
|
17
|
+
"Application fee refunds cannot be updated without an " \
|
18
|
+
"application fee ID. Update an application fee refund using " \
|
19
|
+
"`ApplicationFee.update_refund('fee_id', 'refund_id', " \
|
20
|
+
"update_params)`"
|
16
21
|
end
|
17
22
|
|
18
23
|
def self.retrieve(_id, _api_key = nil)
|
19
|
-
raise NotImplementedError,
|
24
|
+
raise NotImplementedError,
|
25
|
+
"Application fee refunds cannot be retrieved without an " \
|
26
|
+
"application fee ID. Retrieve an application fee refund using " \
|
27
|
+
"`ApplicationFee.retrieve_refund('fee_id', 'refund_id')`"
|
20
28
|
end
|
21
29
|
end
|
22
30
|
end
|
data/lib/stripe/bank_account.rb
CHANGED
@@ -15,18 +15,30 @@ module Stripe
|
|
15
15
|
|
16
16
|
def resource_url
|
17
17
|
if respond_to?(:customer)
|
18
|
-
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources
|
18
|
+
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources" \
|
19
|
+
"/#{CGI.escape(id)}"
|
19
20
|
elsif respond_to?(:account)
|
20
|
-
"#{Account.resource_url}/#{CGI.escape(account)}/external_accounts
|
21
|
+
"#{Account.resource_url}/#{CGI.escape(account)}/external_accounts" \
|
22
|
+
"/#{CGI.escape(id)}"
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
24
26
|
def self.update(_id, _params = nil, _opts = nil)
|
25
|
-
raise NotImplementedError,
|
27
|
+
raise NotImplementedError,
|
28
|
+
"Bank accounts cannot be updated without a customer ID or an " \
|
29
|
+
" account ID. Update a bank account using " \
|
30
|
+
"`Customer.update_source('customer_id', 'bank_account_id', " \
|
31
|
+
"update_params)` or `Account.update_external_account(" \
|
32
|
+
"'account_id', 'bank_account_id', update_params)`"
|
26
33
|
end
|
27
34
|
|
28
35
|
def self.retrieve(_id, _opts = nil)
|
29
|
-
raise NotImplementedError,
|
36
|
+
raise NotImplementedError,
|
37
|
+
"Bank accounts cannot be retrieve without a customer ID or an " \
|
38
|
+
"account ID. Retrieve a bank account using " \
|
39
|
+
"`Customer.retrieve_source('customer_id', 'bank_account_id')` " \
|
40
|
+
"or `Account.retrieve_external_account('account_id', " \
|
41
|
+
"'bank_account_id')`"
|
30
42
|
end
|
31
43
|
end
|
32
44
|
end
|