stripe 5.20.0 → 5.24.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +16 -0
- data/VERSION +1 -1
- data/lib/stripe.rb +32 -166
- data/lib/stripe/api_operations/create.rb +1 -1
- data/lib/stripe/api_operations/delete.rb +7 -3
- data/lib/stripe/api_operations/list.rb +1 -1
- data/lib/stripe/api_operations/nested_resource.rb +6 -5
- data/lib/stripe/api_operations/request.rb +19 -3
- data/lib/stripe/api_operations/save.rb +7 -4
- data/lib/stripe/api_resource.rb +4 -3
- data/lib/stripe/list_object.rb +2 -2
- data/lib/stripe/oauth.rb +3 -3
- data/lib/stripe/object_types.rb +3 -0
- data/lib/stripe/resources.rb +3 -0
- data/lib/stripe/resources/account.rb +2 -1
- data/lib/stripe/resources/account_link.rb +1 -0
- data/lib/stripe/resources/apple_pay_domain.rb +1 -0
- data/lib/stripe/resources/application_fee.rb +1 -0
- data/lib/stripe/resources/balance.rb +1 -0
- data/lib/stripe/resources/balance_transaction.rb +1 -0
- data/lib/stripe/resources/bank_account.rb +2 -1
- data/lib/stripe/resources/billing_portal/session.rb +1 -0
- data/lib/stripe/resources/bitcoin_receiver.rb +1 -0
- data/lib/stripe/resources/card.rb +1 -0
- data/lib/stripe/resources/charge.rb +1 -0
- data/lib/stripe/resources/checkout/session.rb +4 -0
- data/lib/stripe/resources/country_spec.rb +1 -0
- data/lib/stripe/resources/coupon.rb +1 -0
- data/lib/stripe/resources/credit_note.rb +3 -2
- data/lib/stripe/resources/customer.rb +2 -1
- data/lib/stripe/resources/dispute.rb +1 -0
- data/lib/stripe/resources/ephemeral_key.rb +1 -0
- data/lib/stripe/resources/event.rb +1 -0
- data/lib/stripe/resources/exchange_rate.rb +1 -0
- data/lib/stripe/resources/file.rb +1 -0
- data/lib/stripe/resources/file_link.rb +1 -0
- data/lib/stripe/resources/invoice.rb +3 -2
- data/lib/stripe/resources/invoice_item.rb +1 -0
- data/lib/stripe/resources/issuing/authorization.rb +1 -0
- data/lib/stripe/resources/issuing/card.rb +1 -0
- data/lib/stripe/resources/issuing/cardholder.rb +1 -0
- data/lib/stripe/resources/issuing/dispute.rb +1 -0
- data/lib/stripe/resources/issuing/transaction.rb +1 -0
- data/lib/stripe/resources/line_item.rb +7 -0
- data/lib/stripe/resources/mandate.rb +1 -0
- data/lib/stripe/resources/order.rb +1 -0
- data/lib/stripe/resources/order_return.rb +1 -0
- data/lib/stripe/resources/payment_intent.rb +1 -0
- data/lib/stripe/resources/payment_method.rb +1 -0
- data/lib/stripe/resources/payout.rb +1 -0
- data/lib/stripe/resources/plan.rb +1 -0
- data/lib/stripe/resources/price.rb +12 -0
- data/lib/stripe/resources/product.rb +1 -0
- data/lib/stripe/resources/promotion_code.rb +12 -0
- data/lib/stripe/resources/radar/early_fraud_warning.rb +1 -0
- data/lib/stripe/resources/radar/value_list.rb +1 -0
- data/lib/stripe/resources/radar/value_list_item.rb +1 -0
- data/lib/stripe/resources/recipient.rb +1 -0
- data/lib/stripe/resources/refund.rb +1 -0
- data/lib/stripe/resources/reporting/report_run.rb +1 -0
- data/lib/stripe/resources/reporting/report_type.rb +1 -0
- data/lib/stripe/resources/review.rb +1 -0
- data/lib/stripe/resources/setup_intent.rb +1 -0
- data/lib/stripe/resources/sigma/scheduled_query_run.rb +1 -0
- data/lib/stripe/resources/sku.rb +1 -0
- data/lib/stripe/resources/source.rb +4 -3
- data/lib/stripe/resources/subscription.rb +1 -0
- data/lib/stripe/resources/subscription_item.rb +2 -1
- data/lib/stripe/resources/subscription_schedule.rb +1 -0
- data/lib/stripe/resources/tax_rate.rb +1 -0
- data/lib/stripe/resources/terminal/connection_token.rb +1 -0
- data/lib/stripe/resources/terminal/location.rb +1 -0
- data/lib/stripe/resources/terminal/reader.rb +1 -0
- data/lib/stripe/resources/three_d_secure.rb +1 -0
- data/lib/stripe/resources/token.rb +1 -0
- data/lib/stripe/resources/topup.rb +1 -0
- data/lib/stripe/resources/transfer.rb +1 -0
- data/lib/stripe/resources/webhook_endpoint.rb +1 -0
- data/lib/stripe/stripe_configuration.rb +167 -0
- data/lib/stripe/stripe_object.rb +1 -1
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/account_link_test.rb +3 -3
- data/test/stripe/checkout/session_test.rb +12 -0
- data/test/stripe/price_test.rb +48 -0
- data/test/stripe/promotion_code_test.rb +42 -0
- data/test/stripe/stripe_configuration_test.rb +128 -0
- data/test/stripe/subscription_item_test.rb +1 -1
- data/test/stripe_test.rb +88 -19
- data/test/test_helper.rb +1 -1
- metadata +12 -2
data/lib/stripe/resources/sku.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -31,13 +32,13 @@ module Stripe
|
|
31
32
|
|
32
33
|
url = "#{Customer.resource_url}/#{CGI.escape(customer)}/sources" \
|
33
34
|
"/#{CGI.escape(id)}"
|
34
|
-
resp, opts =
|
35
|
+
resp, opts = execute_resource_request(:delete, url, params, opts)
|
35
36
|
initialize_from(resp.data, opts)
|
36
37
|
end
|
37
38
|
|
38
39
|
def source_transactions(params = {}, opts = {})
|
39
|
-
resp, opts =
|
40
|
-
|
40
|
+
resp, opts = execute_resource_request(:get, resource_url + "/source_transactions", params,
|
41
|
+
opts)
|
41
42
|
Util.convert_to_stripe_object(resp.data, opts)
|
42
43
|
end
|
43
44
|
extend Gem::Deprecate
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -16,7 +17,7 @@ module Stripe
|
|
16
17
|
resource_plural: "usage_record_summaries"
|
17
18
|
|
18
19
|
def usage_record_summaries(params = {}, opts = {})
|
19
|
-
resp, opts =
|
20
|
+
resp, opts = execute_resource_request(:get, resource_url + "/usage_record_summaries", params, opts)
|
20
21
|
Util.convert_to_stripe_object(resp.data, opts)
|
21
22
|
end
|
22
23
|
extend Gem::Deprecate
|
@@ -0,0 +1,167 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
# Configurable options:
|
5
|
+
#
|
6
|
+
# =ca_bundle_path=
|
7
|
+
# The location of a file containing a bundle of CA certificates. By default
|
8
|
+
# the library will use an included bundle that can successfully validate
|
9
|
+
# Stripe certificates.
|
10
|
+
#
|
11
|
+
# =log_level=
|
12
|
+
# When set prompts the library to log some extra information to $stdout and
|
13
|
+
# $stderr about what it's doing. For example, it'll produce information about
|
14
|
+
# requests, responses, and errors that are received. Valid log levels are
|
15
|
+
# `debug` and `info`, with `debug` being a little more verbose in places.
|
16
|
+
#
|
17
|
+
# Use of this configuration is only useful when `.logger` is _not_ set. When
|
18
|
+
# it is, the decision what levels to print is entirely deferred to the logger.
|
19
|
+
#
|
20
|
+
# =logger=
|
21
|
+
# The logger should support the same interface as the `Logger` class that's
|
22
|
+
# part of Ruby's standard library (hint, anything in `Rails.logger` will
|
23
|
+
# likely be suitable).
|
24
|
+
#
|
25
|
+
# If `.logger` is set, the value of `.log_level` is ignored. The decision on
|
26
|
+
# what levels to print is entirely deferred to the logger.
|
27
|
+
class StripeConfiguration
|
28
|
+
attr_accessor :api_key
|
29
|
+
attr_accessor :api_version
|
30
|
+
attr_accessor :client_id
|
31
|
+
attr_accessor :enable_telemetry
|
32
|
+
attr_accessor :logger
|
33
|
+
attr_accessor :stripe_account
|
34
|
+
|
35
|
+
attr_reader :api_base
|
36
|
+
attr_reader :uploads_base
|
37
|
+
attr_reader :connect_base
|
38
|
+
attr_reader :ca_bundle_path
|
39
|
+
attr_reader :log_level
|
40
|
+
attr_reader :initial_network_retry_delay
|
41
|
+
attr_reader :max_network_retries
|
42
|
+
attr_reader :max_network_retry_delay
|
43
|
+
attr_reader :open_timeout
|
44
|
+
attr_reader :read_timeout
|
45
|
+
attr_reader :proxy
|
46
|
+
attr_reader :verify_ssl_certs
|
47
|
+
|
48
|
+
def self.setup
|
49
|
+
new.tap do |instance|
|
50
|
+
yield(instance) if block_given?
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Create a new config based off an existing one. This is useful when the
|
55
|
+
# caller wants to override the global configuration
|
56
|
+
def reverse_duplicate_merge(hash)
|
57
|
+
dup.tap do |instance|
|
58
|
+
hash.each do |option, value|
|
59
|
+
instance.public_send("#{option}=", value)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def initialize
|
65
|
+
@ca_bundle_path = Stripe::DEFAULT_CA_BUNDLE_PATH
|
66
|
+
@enable_telemetry = true
|
67
|
+
@verify_ssl_certs = true
|
68
|
+
|
69
|
+
@max_network_retries = 0
|
70
|
+
@initial_network_retry_delay = 0.5
|
71
|
+
@max_network_retry_delay = 2
|
72
|
+
|
73
|
+
@open_timeout = 30
|
74
|
+
@read_timeout = 80
|
75
|
+
|
76
|
+
@api_base = "https://api.stripe.com"
|
77
|
+
@connect_base = "https://connect.stripe.com"
|
78
|
+
@uploads_base = "https://files.stripe.com"
|
79
|
+
end
|
80
|
+
|
81
|
+
def log_level=(val)
|
82
|
+
# Backwards compatibility for values that we briefly allowed
|
83
|
+
if val == "debug"
|
84
|
+
val = Stripe::LEVEL_DEBUG
|
85
|
+
elsif val == "info"
|
86
|
+
val = Stripe::LEVEL_INFO
|
87
|
+
end
|
88
|
+
|
89
|
+
levels = [Stripe::LEVEL_INFO, Stripe::LEVEL_DEBUG, Stripe::LEVEL_ERROR]
|
90
|
+
|
91
|
+
if !val.nil? && !levels.include?(val)
|
92
|
+
raise ArgumentError,
|
93
|
+
"log_level should only be set to `nil`, `debug` or `info`"
|
94
|
+
end
|
95
|
+
@log_level = val
|
96
|
+
end
|
97
|
+
|
98
|
+
def max_network_retries=(val)
|
99
|
+
@max_network_retries = val.to_i
|
100
|
+
end
|
101
|
+
|
102
|
+
def open_timeout=(open_timeout)
|
103
|
+
@open_timeout = open_timeout
|
104
|
+
StripeClient.clear_all_connection_managers
|
105
|
+
end
|
106
|
+
|
107
|
+
def read_timeout=(read_timeout)
|
108
|
+
@read_timeout = read_timeout
|
109
|
+
StripeClient.clear_all_connection_managers
|
110
|
+
end
|
111
|
+
|
112
|
+
def proxy=(proxy)
|
113
|
+
@proxy = proxy
|
114
|
+
StripeClient.clear_all_connection_managers
|
115
|
+
end
|
116
|
+
|
117
|
+
def verify_ssl_certs=(verify_ssl_certs)
|
118
|
+
@verify_ssl_certs = verify_ssl_certs
|
119
|
+
StripeClient.clear_all_connection_managers
|
120
|
+
end
|
121
|
+
|
122
|
+
def uploads_base=(uploads_base)
|
123
|
+
@uploads_base = uploads_base
|
124
|
+
StripeClient.clear_all_connection_managers
|
125
|
+
end
|
126
|
+
|
127
|
+
def connect_base=(connect_base)
|
128
|
+
@connect_base = connect_base
|
129
|
+
StripeClient.clear_all_connection_managers
|
130
|
+
end
|
131
|
+
|
132
|
+
def api_base=(api_base)
|
133
|
+
@api_base = api_base
|
134
|
+
StripeClient.clear_all_connection_managers
|
135
|
+
end
|
136
|
+
|
137
|
+
def ca_bundle_path=(path)
|
138
|
+
@ca_bundle_path = path
|
139
|
+
|
140
|
+
# empty this field so a new store is initialized
|
141
|
+
@ca_store = nil
|
142
|
+
|
143
|
+
StripeClient.clear_all_connection_managers
|
144
|
+
end
|
145
|
+
|
146
|
+
# A certificate store initialized from the the bundle in #ca_bundle_path and
|
147
|
+
# which is used to validate TLS on every request.
|
148
|
+
#
|
149
|
+
# This was added to the give the gem "pseudo thread safety" in that it seems
|
150
|
+
# when initiating many parallel requests marshaling the certificate store is
|
151
|
+
# the most likely point of failure (see issue #382). Any program attempting
|
152
|
+
# to leverage this pseudo safety should make a call to this method (i.e.
|
153
|
+
# `Stripe.ca_store`) in their initialization code because it marshals lazily
|
154
|
+
# and is itself not thread safe.
|
155
|
+
def ca_store
|
156
|
+
@ca_store ||= begin
|
157
|
+
store = OpenSSL::X509::Store.new
|
158
|
+
store.add_file(ca_bundle_path)
|
159
|
+
store
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def enable_telemetry?
|
164
|
+
enable_telemetry
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
data/lib/stripe/stripe_object.rb
CHANGED
@@ -375,7 +375,7 @@ module Stripe
|
|
375
375
|
begin
|
376
376
|
super
|
377
377
|
rescue NoMethodError => e
|
378
|
-
# If we notice the accessed name
|
378
|
+
# If we notice the accessed name of our set of transient values we can
|
379
379
|
# give the user a slightly more helpful error message. If not, just
|
380
380
|
# raise right away.
|
381
381
|
raise unless @transient_values.include?(name)
|
data/lib/stripe/version.rb
CHANGED
@@ -7,9 +7,9 @@ module Stripe
|
|
7
7
|
should "be creatable" do
|
8
8
|
link = Stripe::AccountLink.create(
|
9
9
|
account: "acct_123",
|
10
|
-
|
11
|
-
|
12
|
-
type: "
|
10
|
+
refresh_url: "https://stripe.com/refresh",
|
11
|
+
return_url: "https://stripe.com/return",
|
12
|
+
type: "account_onboarding"
|
13
13
|
)
|
14
14
|
assert_requested :post, "#{Stripe.api_base}/v1/account_links"
|
15
15
|
assert link.is_a?(Stripe::AccountLink)
|
@@ -36,6 +36,18 @@ module Stripe
|
|
36
36
|
assert_requested :get, "#{Stripe.api_base}/v1/checkout/sessions/cs_123"
|
37
37
|
assert charge.is_a?(Stripe::Checkout::Session)
|
38
38
|
end
|
39
|
+
|
40
|
+
context "#list_line_items" do
|
41
|
+
should "list the session's line items" do
|
42
|
+
sources = Stripe::Checkout::Session.list_line_items(
|
43
|
+
"cs_123"
|
44
|
+
)
|
45
|
+
assert_requested :get, "#{Stripe.api_base}/v1/checkout/sessions/cs_123/line_items"
|
46
|
+
assert sources.is_a?(Stripe::ListObject)
|
47
|
+
assert sources.data.is_a?(Array)
|
48
|
+
assert sources.data[0].is_a?(Stripe::LineItem)
|
49
|
+
end
|
50
|
+
end
|
39
51
|
end
|
40
52
|
end
|
41
53
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require ::File.expand_path("../test_helper", __dir__)
|
4
|
+
|
5
|
+
module Stripe
|
6
|
+
class PriceTest < Test::Unit::TestCase
|
7
|
+
should "be listable" do
|
8
|
+
prices = Stripe::Price.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/prices"
|
10
|
+
assert prices.data.is_a?(Array)
|
11
|
+
assert prices.data[0].is_a?(Stripe::Price)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "be retrievable" do
|
15
|
+
price = Stripe::Price.retrieve("price_123")
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/prices/price_123"
|
17
|
+
assert price.is_a?(Stripe::Price)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "be creatable" do
|
21
|
+
price = Stripe::Price.create(
|
22
|
+
unit_amount: 5000,
|
23
|
+
currency: "usd",
|
24
|
+
recurring: {
|
25
|
+
interval: "month",
|
26
|
+
},
|
27
|
+
product_data: {
|
28
|
+
name: "Product name",
|
29
|
+
}
|
30
|
+
)
|
31
|
+
assert_requested :post, "#{Stripe.api_base}/v1/prices"
|
32
|
+
assert price.is_a?(Stripe::Price)
|
33
|
+
end
|
34
|
+
|
35
|
+
should "be saveable" do
|
36
|
+
price = Stripe::Price.retrieve("price_123")
|
37
|
+
price.metadata["key"] = "value"
|
38
|
+
price.save
|
39
|
+
assert_requested :post, "#{Stripe.api_base}/v1/prices/#{price.id}"
|
40
|
+
end
|
41
|
+
|
42
|
+
should "be updateable" do
|
43
|
+
price = Stripe::Price.update("price_123", metadata: { foo: "bar" })
|
44
|
+
assert_requested :post, "#{Stripe.api_base}/v1/prices/price_123"
|
45
|
+
assert price.is_a?(Stripe::Price)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require ::File.expand_path("../test_helper", __dir__)
|
4
|
+
|
5
|
+
module Stripe
|
6
|
+
class PromotionCodeTest < Test::Unit::TestCase
|
7
|
+
should "be listable" do
|
8
|
+
promotion_codes = Stripe::PromotionCode.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/promotion_codes"
|
10
|
+
assert promotion_codes.data.is_a?(Array)
|
11
|
+
assert promotion_codes.first.is_a?(Stripe::PromotionCode)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "be retrievable" do
|
15
|
+
coupon = Stripe::PromotionCode.retrieve("PROMO_123")
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/promotion_codes/PROMO_123"
|
17
|
+
assert coupon.is_a?(Stripe::PromotionCode)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "be creatable" do
|
21
|
+
coupon = Stripe::PromotionCode.create(
|
22
|
+
coupon: "co_123",
|
23
|
+
code: "MYCODE"
|
24
|
+
)
|
25
|
+
assert_requested :post, "#{Stripe.api_base}/v1/promotion_codes"
|
26
|
+
assert coupon.is_a?(Stripe::PromotionCode)
|
27
|
+
end
|
28
|
+
|
29
|
+
should "be saveable" do
|
30
|
+
coupon = Stripe::PromotionCode.retrieve("PROMO_123")
|
31
|
+
coupon.metadata["key"] = "value"
|
32
|
+
coupon.save
|
33
|
+
assert_requested :post, "#{Stripe.api_base}/v1/promotion_codes/#{coupon.id}"
|
34
|
+
end
|
35
|
+
|
36
|
+
should "be updateable" do
|
37
|
+
coupon = Stripe::PromotionCode.update("PROMO_123", metadata: { key: "value" })
|
38
|
+
assert_requested :post, "#{Stripe.api_base}/v1/promotion_codes/PROMO_123"
|
39
|
+
assert coupon.is_a?(Stripe::PromotionCode)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|