stripe 5.19.0 → 5.23.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 +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +16 -1
- data/VERSION +1 -1
- 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/version.rb +1 -1
- data/lib/stripe/webhook.rb +17 -0
- 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/subscription_item_test.rb +1 -1
- data/test/stripe/webhook_test.rb +23 -1
- data/test/test_helper.rb +1 -1
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33f1cdd1289229d711bcba485944474bfc3b645aaf0402bf2d4236eff4a87a4e
|
4
|
+
data.tar.gz: d2e05e209525b15095fcdbbfacb9f3e05ce4d7eb902c06c19f468bbd5a192184
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2dcb34a7af495d2a704d3b48c35b08b1680bb24ea541e46e90c247ca57689fbaf213f798ef018a9fa9ed17644e42e76b7666f8fac2dd104f495f460492c5fb99
|
7
|
+
data.tar.gz: 232b4bef2acfc1b452ee1314c67d6e688a01a5860e4be93ad49491b65506cc3e10763c3a1090e2aeaa5137a1438f42a8f7e4f7741f4e1909f894ddb5dcef3639
|
data/.rubocop.yml
CHANGED
@@ -44,10 +44,10 @@ Metrics/ClassLength:
|
|
44
44
|
- "test/**/*.rb"
|
45
45
|
|
46
46
|
Metrics/MethodLength:
|
47
|
-
# There's ~2 long methods in `StripeClient
|
48
|
-
# little, we could move this to be closer to ~30
|
49
|
-
# probably too short).
|
50
|
-
Max:
|
47
|
+
# There's ~2 long methods in `StripeClient` and one in `NestedResource`. If
|
48
|
+
# we want to truncate those a little, we could move this to be closer to ~30
|
49
|
+
# (but the default of 10 is probably too short).
|
50
|
+
Max: 55
|
51
51
|
|
52
52
|
Metrics/ModuleLength:
|
53
53
|
Enabled: false
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## - 2020-
|
3
|
+
## 5.23.1 - 2020-08-05
|
4
|
+
* [#936](https://github.com/stripe/stripe-ruby/pull/936) Rename API resource's `request` method
|
5
|
+
|
6
|
+
## 5.23.0 - 2020-08-05
|
7
|
+
* [#937](https://github.com/stripe/stripe-ruby/pull/937) Add support for the `PromotionCode` resource and APIs
|
8
|
+
|
9
|
+
## 5.22.0 - 2020-05-11
|
10
|
+
* [#918](https://github.com/stripe/stripe-ruby/pull/918) Add support for the `LineItem` resource and APIs
|
11
|
+
|
12
|
+
## 5.21.0 - 2020-04-29
|
13
|
+
* [#917](https://github.com/stripe/stripe-ruby/pull/917) Add support for the `Price` resource and APIs
|
14
|
+
|
15
|
+
## 5.20.0 - 2020-04-27
|
16
|
+
* [#916](https://github.com/stripe/stripe-ruby/pull/916) Add new `.generate_header` method for webhooks
|
17
|
+
|
18
|
+
## 5.19.0 - 2020-04-24
|
4
19
|
* [#915](https://github.com/stripe/stripe-ruby/pull/915) Expose `Stripe::Webhook.compute_signature` publicly
|
5
20
|
|
6
21
|
## 5.18.0 - 2020-04-22
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.
|
1
|
+
5.23.1
|
@@ -4,7 +4,7 @@ module Stripe
|
|
4
4
|
module APIOperations
|
5
5
|
module Create
|
6
6
|
def create(params = {}, opts = {})
|
7
|
-
resp, opts =
|
7
|
+
resp, opts = execute_resource_request(:post, resource_url, params, opts)
|
8
8
|
Util.convert_to_stripe_object(resp.data, opts)
|
9
9
|
end
|
10
10
|
end
|
@@ -15,15 +15,19 @@ module Stripe
|
|
15
15
|
# * +opts+ - A Hash of additional options (separate from the params /
|
16
16
|
# object values) to be added to the request. E.g. to allow for an
|
17
17
|
# idempotency_key to be passed in the request headers, or for the
|
18
|
-
# api_key to be overwritten. See
|
18
|
+
# api_key to be overwritten. See
|
19
|
+
# {APIOperations::Request.execute_resource_request}.
|
19
20
|
def delete(id, params = {}, opts = {})
|
20
|
-
resp, opts =
|
21
|
+
resp, opts = execute_resource_request(:delete,
|
22
|
+
"#{resource_url}/#{id}",
|
23
|
+
params, opts)
|
21
24
|
Util.convert_to_stripe_object(resp.data, opts)
|
22
25
|
end
|
23
26
|
end
|
24
27
|
|
25
28
|
def delete(params = {}, opts = {})
|
26
|
-
resp, opts =
|
29
|
+
resp, opts = execute_resource_request(:delete, resource_url,
|
30
|
+
params, opts)
|
27
31
|
initialize_from(resp.data, opts)
|
28
32
|
end
|
29
33
|
|
@@ -6,7 +6,7 @@ module Stripe
|
|
6
6
|
def list(filters = {}, opts = {})
|
7
7
|
opts = Util.normalize_opts(opts)
|
8
8
|
|
9
|
-
resp, opts =
|
9
|
+
resp, opts = execute_resource_request(:get, resource_url, filters, opts)
|
10
10
|
obj = ListObject.construct_from(resp.data, opts)
|
11
11
|
|
12
12
|
# set filters so that we can fetch the same limit, expansions, and
|
@@ -31,35 +31,36 @@ module Stripe
|
|
31
31
|
define_singleton_method(:"create_#{resource}") \
|
32
32
|
do |id, params = {}, opts = {}|
|
33
33
|
url = send(resource_url_method, id)
|
34
|
-
resp, opts =
|
34
|
+
resp, opts = execute_resource_request(:post, url, params, opts)
|
35
35
|
Util.convert_to_stripe_object(resp.data, opts)
|
36
36
|
end
|
37
37
|
when :retrieve
|
38
38
|
define_singleton_method(:"retrieve_#{resource}") \
|
39
39
|
do |id, nested_id, opts = {}|
|
40
40
|
url = send(resource_url_method, id, nested_id)
|
41
|
-
resp, opts =
|
41
|
+
resp, opts = execute_resource_request(:get, url, {}, opts)
|
42
42
|
Util.convert_to_stripe_object(resp.data, opts)
|
43
43
|
end
|
44
44
|
when :update
|
45
45
|
define_singleton_method(:"update_#{resource}") \
|
46
46
|
do |id, nested_id, params = {}, opts = {}|
|
47
47
|
url = send(resource_url_method, id, nested_id)
|
48
|
-
resp, opts =
|
48
|
+
resp, opts = execute_resource_request(:post, url, params, opts)
|
49
49
|
Util.convert_to_stripe_object(resp.data, opts)
|
50
50
|
end
|
51
51
|
when :delete
|
52
52
|
define_singleton_method(:"delete_#{resource}") \
|
53
53
|
do |id, nested_id, params = {}, opts = {}|
|
54
54
|
url = send(resource_url_method, id, nested_id)
|
55
|
-
resp, opts =
|
55
|
+
resp, opts = execute_resource_request(:delete, url, params,
|
56
|
+
opts)
|
56
57
|
Util.convert_to_stripe_object(resp.data, opts)
|
57
58
|
end
|
58
59
|
when :list
|
59
60
|
define_singleton_method(:"list_#{resource_plural}") \
|
60
61
|
do |id, params = {}, opts = {}|
|
61
62
|
url = send(resource_url_method, id)
|
62
|
-
resp, opts =
|
63
|
+
resp, opts = execute_resource_request(:get, url, params, opts)
|
63
64
|
Util.convert_to_stripe_object(resp.data, opts)
|
64
65
|
end
|
65
66
|
else
|
@@ -4,7 +4,8 @@ module Stripe
|
|
4
4
|
module APIOperations
|
5
5
|
module Request
|
6
6
|
module ClassMethods
|
7
|
-
def
|
7
|
+
def execute_resource_request(method, url,
|
8
|
+
params = {}, opts = {})
|
8
9
|
params ||= {}
|
9
10
|
|
10
11
|
error_on_invalid_params(params)
|
@@ -36,6 +37,17 @@ module Stripe
|
|
36
37
|
[resp, opts_to_persist]
|
37
38
|
end
|
38
39
|
|
40
|
+
# This method used to be called `request`, but it's such a short name
|
41
|
+
# that it eventually conflicted with the name of a field on an API
|
42
|
+
# resource (specifically, `Event#request`), so it was renamed to
|
43
|
+
# something more unique.
|
44
|
+
#
|
45
|
+
# The former name had been around for just about forever though, and
|
46
|
+
# although all internal uses have been renamed, I've left this alias in
|
47
|
+
# place for backwards compatibility. Consider removing it on the next
|
48
|
+
# major.
|
49
|
+
alias request execute_resource_request
|
50
|
+
|
39
51
|
private def error_on_non_string_user_opts(opts)
|
40
52
|
Util::OPTS_USER_SPECIFIED.each do |opt|
|
41
53
|
next unless opts.key?(opt)
|
@@ -71,10 +83,14 @@ module Stripe
|
|
71
83
|
base.extend(ClassMethods)
|
72
84
|
end
|
73
85
|
|
74
|
-
protected def
|
86
|
+
protected def execute_resource_request(method, url,
|
87
|
+
params = {}, opts = {})
|
75
88
|
opts = @opts.merge(Util.normalize_opts(opts))
|
76
|
-
self.class.
|
89
|
+
self.class.execute_resource_request(method, url, params, opts)
|
77
90
|
end
|
91
|
+
|
92
|
+
# See notes on `alias` above.
|
93
|
+
alias request execute_resource_request
|
78
94
|
end
|
79
95
|
end
|
80
96
|
end
|
@@ -15,7 +15,8 @@ module Stripe
|
|
15
15
|
# * +opts+ - A Hash of additional options (separate from the params /
|
16
16
|
# object values) to be added to the request. E.g. to allow for an
|
17
17
|
# idempotency_key to be passed in the request headers, or for the
|
18
|
-
# api_key to be overwritten. See
|
18
|
+
# api_key to be overwritten. See
|
19
|
+
# {APIOperations::Request.execute_resource_request}.
|
19
20
|
def update(id, params = {}, opts = {})
|
20
21
|
params.each_key do |k|
|
21
22
|
if protected_fields.include?(k)
|
@@ -23,7 +24,8 @@ module Stripe
|
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
|
-
resp, opts =
|
27
|
+
resp, opts = execute_resource_request(:post, "#{resource_url}/#{id}",
|
28
|
+
params, opts)
|
27
29
|
Util.convert_to_stripe_object(resp.data, opts)
|
28
30
|
end
|
29
31
|
end
|
@@ -43,7 +45,8 @@ module Stripe
|
|
43
45
|
# * +opts+ - A Hash of additional options (separate from the params /
|
44
46
|
# object values) to be added to the request. E.g. to allow for an
|
45
47
|
# idempotency_key to be passed in the request headers, or for the
|
46
|
-
# api_key to be overwritten. See
|
48
|
+
# api_key to be overwritten. See
|
49
|
+
# {APIOperations::Request.execute_resource_request}.
|
47
50
|
def save(params = {}, opts = {})
|
48
51
|
# We started unintentionally (sort of) allowing attributes sent to
|
49
52
|
# +save+ to override values used during the update. So as not to break
|
@@ -59,7 +62,7 @@ module Stripe
|
|
59
62
|
# generated a uri for this object with an identifier baked in
|
60
63
|
values.delete(:id)
|
61
64
|
|
62
|
-
resp, opts =
|
65
|
+
resp, opts = execute_resource_request(:post, save_url, values, opts)
|
63
66
|
initialize_from(resp.data, opts)
|
64
67
|
end
|
65
68
|
|
data/lib/stripe/api_resource.rb
CHANGED
@@ -76,7 +76,7 @@ module Stripe
|
|
76
76
|
end
|
77
77
|
|
78
78
|
url = "#{resource_url}/#{CGI.escape(id)}/#{CGI.escape(http_path)}"
|
79
|
-
resp, opts =
|
79
|
+
resp, opts = execute_resource_request(http_verb, url, params, opts)
|
80
80
|
Util.convert_to_stripe_object(resp.data, opts)
|
81
81
|
end
|
82
82
|
end
|
@@ -93,7 +93,8 @@ module Stripe
|
|
93
93
|
end
|
94
94
|
|
95
95
|
def refresh
|
96
|
-
resp, opts =
|
96
|
+
resp, opts = execute_resource_request(:get, resource_url,
|
97
|
+
@retrieve_params)
|
97
98
|
initialize_from(resp.data, opts)
|
98
99
|
end
|
99
100
|
|
@@ -105,7 +106,7 @@ module Stripe
|
|
105
106
|
end
|
106
107
|
|
107
108
|
protected def request_stripe_object(method:, path:, params:, opts: {})
|
108
|
-
resp, opts =
|
109
|
+
resp, opts = execute_resource_request(method, path, params, opts)
|
109
110
|
|
110
111
|
# If we're getting back this thing, update; otherwise, instantiate.
|
111
112
|
if Util.object_name_matches_class?(resp.data[:object], self.class)
|
data/lib/stripe/list_object.rb
CHANGED
@@ -92,8 +92,8 @@ module Stripe
|
|
92
92
|
|
93
93
|
def retrieve(id, opts = {})
|
94
94
|
id, retrieve_params = Util.normalize_id(id)
|
95
|
-
|
96
|
-
|
95
|
+
url = "#{resource_url}/#{CGI.escape(id)}"
|
96
|
+
resp, opts = execute_resource_request(:get, url, retrieve_params, opts)
|
97
97
|
Util.convert_to_stripe_object(resp.data, opts)
|
98
98
|
end
|
99
99
|
|
data/lib/stripe/oauth.rb
CHANGED
@@ -5,7 +5,7 @@ module Stripe
|
|
5
5
|
module OAuthOperations
|
6
6
|
extend APIOperations::Request::ClassMethods
|
7
7
|
|
8
|
-
def self.
|
8
|
+
def self.execute_resource_request(method, url, params, opts)
|
9
9
|
opts = Util.normalize_opts(opts)
|
10
10
|
opts[:client] ||= StripeClient.active_client
|
11
11
|
opts[:api_base] ||= Stripe.connect_base
|
@@ -44,7 +44,7 @@ module Stripe
|
|
44
44
|
def self.token(params = {}, opts = {})
|
45
45
|
opts = Util.normalize_opts(opts)
|
46
46
|
opts[:api_key] = params[:client_secret] if params[:client_secret]
|
47
|
-
resp, opts = OAuthOperations.
|
47
|
+
resp, opts = OAuthOperations.execute_resource_request(
|
48
48
|
:post, "/oauth/token", params, opts
|
49
49
|
)
|
50
50
|
# This is just going to return a generic StripeObject, but that's okay
|
@@ -54,7 +54,7 @@ module Stripe
|
|
54
54
|
def self.deauthorize(params = {}, opts = {})
|
55
55
|
opts = Util.normalize_opts(opts)
|
56
56
|
params[:client_id] = get_client_id(params)
|
57
|
-
resp, opts = OAuthOperations.
|
57
|
+
resp, opts = OAuthOperations.execute_resource_request(
|
58
58
|
:post, "/oauth/deauthorize", params, opts
|
59
59
|
)
|
60
60
|
# This is just going to return a generic StripeObject, but that's okay
|
data/lib/stripe/object_types.rb
CHANGED
@@ -49,6 +49,7 @@ module Stripe
|
|
49
49
|
Issuing::Cardholder::OBJECT_NAME => Issuing::Cardholder,
|
50
50
|
Issuing::Dispute::OBJECT_NAME => Issuing::Dispute,
|
51
51
|
Issuing::Transaction::OBJECT_NAME => Issuing::Transaction,
|
52
|
+
LineItem::OBJECT_NAME => LineItem,
|
52
53
|
LoginLink::OBJECT_NAME => LoginLink,
|
53
54
|
Mandate::OBJECT_NAME => Mandate,
|
54
55
|
Order::OBJECT_NAME => Order,
|
@@ -58,7 +59,9 @@ module Stripe
|
|
58
59
|
Payout::OBJECT_NAME => Payout,
|
59
60
|
Person::OBJECT_NAME => Person,
|
60
61
|
Plan::OBJECT_NAME => Plan,
|
62
|
+
Price::OBJECT_NAME => Price,
|
61
63
|
Product::OBJECT_NAME => Product,
|
64
|
+
PromotionCode::OBJECT_NAME => PromotionCode,
|
62
65
|
Radar::EarlyFraudWarning::OBJECT_NAME => Radar::EarlyFraudWarning,
|
63
66
|
Radar::ValueList::OBJECT_NAME => Radar::ValueList,
|
64
67
|
Radar::ValueListItem::OBJECT_NAME => Radar::ValueListItem,
|
data/lib/stripe/resources.rb
CHANGED
@@ -38,6 +38,7 @@ require "stripe/resources/issuing/card_details"
|
|
38
38
|
require "stripe/resources/issuing/cardholder"
|
39
39
|
require "stripe/resources/issuing/dispute"
|
40
40
|
require "stripe/resources/issuing/transaction"
|
41
|
+
require "stripe/resources/line_item"
|
41
42
|
require "stripe/resources/login_link"
|
42
43
|
require "stripe/resources/mandate"
|
43
44
|
require "stripe/resources/order"
|
@@ -47,7 +48,9 @@ require "stripe/resources/payment_method"
|
|
47
48
|
require "stripe/resources/payout"
|
48
49
|
require "stripe/resources/person"
|
49
50
|
require "stripe/resources/plan"
|
51
|
+
require "stripe/resources/price"
|
50
52
|
require "stripe/resources/product"
|
53
|
+
require "stripe/resources/promotion_code"
|
51
54
|
require "stripe/resources/radar/early_fraud_warning"
|
52
55
|
require "stripe/resources/radar/value_list"
|
53
56
|
require "stripe/resources/radar/value_list_item"
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -64,7 +65,7 @@ module Stripe
|
|
64
65
|
end
|
65
66
|
|
66
67
|
def persons(params = {}, opts = {})
|
67
|
-
resp, opts =
|
68
|
+
resp, opts = execute_resource_request(:get, resource_url + "/persons", params, opts)
|
68
69
|
Util.convert_to_stripe_object(resp.data, opts)
|
69
70
|
end
|
70
71
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -9,7 +10,7 @@ module Stripe
|
|
9
10
|
OBJECT_NAME = "bank_account"
|
10
11
|
|
11
12
|
def verify(params = {}, opts = {})
|
12
|
-
resp, opts =
|
13
|
+
resp, opts = execute_resource_request(:post, resource_url + "/verify", params, opts)
|
13
14
|
initialize_from(resp.data, opts)
|
14
15
|
end
|
15
16
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -5,8 +6,11 @@ module Stripe
|
|
5
6
|
class Session < APIResource
|
6
7
|
extend Stripe::APIOperations::Create
|
7
8
|
extend Stripe::APIOperations::List
|
9
|
+
extend Stripe::APIOperations::NestedResource
|
8
10
|
|
9
11
|
OBJECT_NAME = "checkout.session"
|
12
|
+
|
13
|
+
nested_resource_class_methods :line_item, operations: %i[list]
|
10
14
|
end
|
11
15
|
end
|
12
16
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -20,12 +21,12 @@ module Stripe
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def self.preview(params, opts = {})
|
23
|
-
resp, opts =
|
24
|
+
resp, opts = execute_resource_request(:get, resource_url + "/preview", params, opts)
|
24
25
|
Util.convert_to_stripe_object(resp.data, opts)
|
25
26
|
end
|
26
27
|
|
27
28
|
def self.list_preview_line_items(params, opts = {})
|
28
|
-
resp, opts =
|
29
|
+
resp, opts = execute_resource_request(:get, resource_url + "/preview/lines", params, opts)
|
29
30
|
Util.convert_to_stripe_object(resp.data, opts)
|
30
31
|
end
|
31
32
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -28,7 +29,7 @@ module Stripe
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def delete_discount
|
31
|
-
resp, opts =
|
32
|
+
resp, opts = execute_resource_request(:delete, resource_url + "/discount")
|
32
33
|
initialize_from(resp.data, opts, true)
|
33
34
|
end
|
34
35
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -61,12 +62,12 @@ module Stripe
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def self.upcoming(params, opts = {})
|
64
|
-
resp, opts =
|
65
|
+
resp, opts = execute_resource_request(:get, resource_url + "/upcoming", params, opts)
|
65
66
|
Util.convert_to_stripe_object(resp.data, opts)
|
66
67
|
end
|
67
68
|
|
68
69
|
def self.list_upcoming_line_items(params, opts = {})
|
69
|
-
resp, opts =
|
70
|
+
resp, opts = execute_resource_request(:get, resource_url + "/upcoming/lines", params, opts)
|
70
71
|
Util.convert_to_stripe_object(resp.data, opts)
|
71
72
|
end
|
72
73
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Stripe
|
5
|
+
class Price < APIResource
|
6
|
+
extend Stripe::APIOperations::Create
|
7
|
+
extend Stripe::APIOperations::List
|
8
|
+
include Stripe::APIOperations::Save
|
9
|
+
|
10
|
+
OBJECT_NAME = "price"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Stripe
|
5
|
+
class PromotionCode < APIResource
|
6
|
+
extend Stripe::APIOperations::Create
|
7
|
+
extend Stripe::APIOperations::List
|
8
|
+
include Stripe::APIOperations::Save
|
9
|
+
|
10
|
+
OBJECT_NAME = "promotion_code"
|
11
|
+
end
|
12
|
+
end
|
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
|
data/lib/stripe/version.rb
CHANGED
data/lib/stripe/webhook.rb
CHANGED
@@ -39,6 +39,23 @@ module Stripe
|
|
39
39
|
timestamped_payload)
|
40
40
|
end
|
41
41
|
|
42
|
+
# Generates a value that would be added to a `Stripe-Signature` for a
|
43
|
+
# given webhook payload.
|
44
|
+
#
|
45
|
+
# Note that this isn't needed to verify webhooks in any way, and is
|
46
|
+
# mainly here for use in test cases (those that are both within this
|
47
|
+
# project and without).
|
48
|
+
def self.generate_header(timestamp, signature, scheme: EXPECTED_SCHEME)
|
49
|
+
raise ArgumentError, "timestamp should be an instance of Time" \
|
50
|
+
unless timestamp.is_a?(Time)
|
51
|
+
raise ArgumentError, "signature should be a string" \
|
52
|
+
unless signature.is_a?(String)
|
53
|
+
raise ArgumentError, "scheme should be a string" \
|
54
|
+
unless scheme.is_a?(String)
|
55
|
+
|
56
|
+
"t=#{timestamp.to_i},#{scheme}=#{signature}"
|
57
|
+
end
|
58
|
+
|
42
59
|
# Extracts the timestamp and the signature(s) with the desired scheme
|
43
60
|
# from the header
|
44
61
|
def self.get_timestamp_and_signatures(header, scheme)
|
@@ -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
|
data/test/stripe/webhook_test.rb
CHANGED
@@ -22,7 +22,11 @@ module Stripe
|
|
22
22
|
opts[:payload],
|
23
23
|
opts[:secret]
|
24
24
|
)
|
25
|
-
|
25
|
+
Stripe::Webhook::Signature.generate_header(
|
26
|
+
opts[:timestamp],
|
27
|
+
opts[:signature],
|
28
|
+
scheme: opts[:scheme]
|
29
|
+
)
|
26
30
|
end
|
27
31
|
|
28
32
|
context ".compute_signature" do
|
@@ -38,6 +42,24 @@ module Stripe
|
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
45
|
+
context ".generate_header" do
|
46
|
+
should "generate a header in valid format" do
|
47
|
+
timestamp = Time.now
|
48
|
+
signature = Stripe::Webhook::Signature.compute_signature(
|
49
|
+
timestamp,
|
50
|
+
EVENT_PAYLOAD,
|
51
|
+
SECRET
|
52
|
+
)
|
53
|
+
scheme = "v1"
|
54
|
+
header = Stripe::Webhook::Signature.generate_header(
|
55
|
+
timestamp,
|
56
|
+
signature,
|
57
|
+
scheme: scheme
|
58
|
+
)
|
59
|
+
assert_equal("t=#{timestamp.to_i},#{scheme}=#{signature}", header)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
41
63
|
context ".construct_event" do
|
42
64
|
should "return an Event instance from a valid JSON payload and valid signature header" do
|
43
65
|
header = generate_header
|
data/test/test_helper.rb
CHANGED
@@ -16,7 +16,7 @@ require ::File.expand_path("test_data", __dir__)
|
|
16
16
|
require ::File.expand_path("stripe_mock", __dir__)
|
17
17
|
|
18
18
|
# If changing this number, please also change it in `.travis.yml`.
|
19
|
-
MOCK_MINIMUM_VERSION = "0.
|
19
|
+
MOCK_MINIMUM_VERSION = "0.95.0"
|
20
20
|
MOCK_PORT = Stripe::StripeMock.start
|
21
21
|
|
22
22
|
# Disable all real network connections except those that are outgoing to
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.23.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Stripe is the easiest way to accept payments online. See https://stripe.com
|
14
14
|
for details.
|
@@ -93,6 +93,7 @@ files:
|
|
93
93
|
- lib/stripe/resources/issuing/cardholder.rb
|
94
94
|
- lib/stripe/resources/issuing/dispute.rb
|
95
95
|
- lib/stripe/resources/issuing/transaction.rb
|
96
|
+
- lib/stripe/resources/line_item.rb
|
96
97
|
- lib/stripe/resources/login_link.rb
|
97
98
|
- lib/stripe/resources/mandate.rb
|
98
99
|
- lib/stripe/resources/order.rb
|
@@ -102,7 +103,9 @@ files:
|
|
102
103
|
- lib/stripe/resources/payout.rb
|
103
104
|
- lib/stripe/resources/person.rb
|
104
105
|
- lib/stripe/resources/plan.rb
|
106
|
+
- lib/stripe/resources/price.rb
|
105
107
|
- lib/stripe/resources/product.rb
|
108
|
+
- lib/stripe/resources/promotion_code.rb
|
106
109
|
- lib/stripe/resources/radar/early_fraud_warning.rb
|
107
110
|
- lib/stripe/resources/radar/value_list.rb
|
108
111
|
- lib/stripe/resources/radar/value_list_item.rb
|
@@ -191,7 +194,9 @@ files:
|
|
191
194
|
- test/stripe/payout_test.rb
|
192
195
|
- test/stripe/person_test.rb
|
193
196
|
- test/stripe/plan_test.rb
|
197
|
+
- test/stripe/price_test.rb
|
194
198
|
- test/stripe/product_test.rb
|
199
|
+
- test/stripe/promotion_code_test.rb
|
195
200
|
- test/stripe/radar/early_fraud_warning_test.rb
|
196
201
|
- test/stripe/radar/value_list_item_test.rb
|
197
202
|
- test/stripe/radar/value_list_test.rb
|
@@ -307,7 +312,9 @@ test_files:
|
|
307
312
|
- test/stripe/payout_test.rb
|
308
313
|
- test/stripe/person_test.rb
|
309
314
|
- test/stripe/plan_test.rb
|
315
|
+
- test/stripe/price_test.rb
|
310
316
|
- test/stripe/product_test.rb
|
317
|
+
- test/stripe/promotion_code_test.rb
|
311
318
|
- test/stripe/radar/early_fraud_warning_test.rb
|
312
319
|
- test/stripe/radar/value_list_item_test.rb
|
313
320
|
- test/stripe/radar/value_list_test.rb
|