stripe 6.2.0 → 6.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -7
  3. data/Makefile +1 -1
  4. data/OPENAPI_VERSION +1 -1
  5. data/README.md +1 -1
  6. data/VERSION +1 -1
  7. data/lib/stripe/api_operations/create.rb +6 -2
  8. data/lib/stripe/api_operations/delete.rb +12 -7
  9. data/lib/stripe/api_operations/list.rb +6 -9
  10. data/lib/stripe/api_operations/nested_resource.rb +62 -34
  11. data/lib/stripe/api_operations/request.rb +10 -0
  12. data/lib/stripe/api_operations/save.rb +6 -3
  13. data/lib/stripe/api_operations/search.rb +6 -9
  14. data/lib/stripe/api_resource.rb +1 -1
  15. data/lib/stripe/api_version.rb +8 -0
  16. data/lib/stripe/resources/account.rb +28 -8
  17. data/lib/stripe/resources/apps/secret.rb +10 -12
  18. data/lib/stripe/resources/charge.rb +10 -3
  19. data/lib/stripe/resources/checkout/session.rb +10 -3
  20. data/lib/stripe/resources/credit_note.rb +22 -7
  21. data/lib/stripe/resources/customer.rb +94 -16
  22. data/lib/stripe/resources/dispute.rb +10 -3
  23. data/lib/stripe/resources/financial_connections/account.rb +30 -7
  24. data/lib/stripe/resources/identity/verification_session.rb +20 -5
  25. data/lib/stripe/resources/invoice.rb +62 -15
  26. data/lib/stripe/resources/issuing/authorization.rb +20 -5
  27. data/lib/stripe/resources/issuing/card.rb +90 -3
  28. data/lib/stripe/resources/issuing/dispute.rb +10 -3
  29. data/lib/stripe/resources/order.rb +40 -9
  30. data/lib/stripe/resources/payment_intent.rb +60 -13
  31. data/lib/stripe/resources/payment_link.rb +10 -3
  32. data/lib/stripe/resources/payment_method.rb +20 -5
  33. data/lib/stripe/resources/payout.rb +20 -5
  34. data/lib/stripe/resources/quote.rb +50 -11
  35. data/lib/stripe/resources/refund.rb +19 -5
  36. data/lib/stripe/resources/review.rb +10 -3
  37. data/lib/stripe/resources/setup_intent.rb +30 -7
  38. data/lib/stripe/resources/source.rb +16 -6
  39. data/lib/stripe/resources/subscription.rb +10 -3
  40. data/lib/stripe/resources/subscription_item.rb +6 -2
  41. data/lib/stripe/resources/subscription_schedule.rb +20 -5
  42. data/lib/stripe/resources/terminal/reader.rb +49 -11
  43. data/lib/stripe/resources/test_helpers/test_clock.rb +10 -3
  44. data/lib/stripe/resources/topup.rb +10 -3
  45. data/lib/stripe/resources/transfer.rb +10 -3
  46. data/lib/stripe/resources/treasury/financial_account.rb +20 -5
  47. data/lib/stripe/resources/treasury/inbound_transfer.rb +39 -9
  48. data/lib/stripe/resources/treasury/outbound_payment.rb +39 -9
  49. data/lib/stripe/resources/treasury/outbound_transfer.rb +43 -9
  50. data/lib/stripe/resources/treasury/received_credit.rb +5 -6
  51. data/lib/stripe/resources/treasury/received_debit.rb +5 -6
  52. data/lib/stripe/util.rb +38 -3
  53. data/lib/stripe/version.rb +1 -1
  54. metadata +3 -2
@@ -10,12 +10,19 @@ module Stripe
10
10
 
11
11
  OBJECT_NAME = "test_helpers.test_clock"
12
12
 
13
- custom_method :advance, http_verb: :post
14
-
15
13
  def advance(params = {}, opts = {})
16
14
  request_stripe_object(
17
15
  method: :post,
18
- path: resource_url + "/advance",
16
+ path: format("/v1/test_helpers/test_clocks/%<test_clock>s/advance", { test_clock: CGI.escape(self["id"]) }),
17
+ params: params,
18
+ opts: opts
19
+ )
20
+ end
21
+
22
+ def self.advance(test_clock, params = {}, opts = {})
23
+ request_stripe_object(
24
+ method: :post,
25
+ path: format("/v1/test_helpers/test_clocks/%<test_clock>s/advance", { test_clock: CGI.escape(test_clock) }),
19
26
  params: params,
20
27
  opts: opts
21
28
  )
@@ -9,12 +9,19 @@ module Stripe
9
9
 
10
10
  OBJECT_NAME = "topup"
11
11
 
12
- custom_method :cancel, http_verb: :post
13
-
14
12
  def cancel(params = {}, opts = {})
15
13
  request_stripe_object(
16
14
  method: :post,
17
- path: resource_url + "/cancel",
15
+ path: format("/v1/topups/%<topup>s/cancel", { topup: CGI.escape(self["id"]) }),
16
+ params: params,
17
+ opts: opts
18
+ )
19
+ end
20
+
21
+ def self.cancel(topup, params = {}, opts = {})
22
+ request_stripe_object(
23
+ method: :post,
24
+ path: format("/v1/topups/%<topup>s/cancel", { topup: CGI.escape(topup) }),
18
25
  params: params,
19
26
  opts: opts
20
27
  )
@@ -10,15 +10,22 @@ module Stripe
10
10
 
11
11
  OBJECT_NAME = "transfer"
12
12
 
13
- custom_method :cancel, http_verb: :post
14
-
15
13
  nested_resource_class_methods :reversal,
16
14
  operations: %i[create retrieve update list]
17
15
 
18
16
  def cancel(params = {}, opts = {})
19
17
  request_stripe_object(
20
18
  method: :post,
21
- path: resource_url + "/cancel",
19
+ path: format("/v1/transfers/%<id>s/cancel", { id: CGI.escape(self["id"]) }),
20
+ params: params,
21
+ opts: opts
22
+ )
23
+ end
24
+
25
+ def self.cancel(id, params = {}, opts = {})
26
+ request_stripe_object(
27
+ method: :post,
28
+ path: format("/v1/transfers/%<id>s/cancel", { id: CGI.escape(id) }),
22
29
  params: params,
23
30
  opts: opts
24
31
  )
@@ -10,13 +10,10 @@ module Stripe
10
10
 
11
11
  OBJECT_NAME = "treasury.financial_account"
12
12
 
13
- custom_method :retrieve_features, http_verb: :get, http_path: "features"
14
- custom_method :update_features, http_verb: :post, http_path: "features"
15
-
16
13
  def retrieve_features(params = {}, opts = {})
17
14
  request_stripe_object(
18
15
  method: :get,
19
- path: resource_url + "/features",
16
+ path: format("/v1/treasury/financial_accounts/%<financial_account>s/features", { financial_account: CGI.escape(self["id"]) }),
20
17
  params: params,
21
18
  opts: opts
22
19
  )
@@ -25,7 +22,25 @@ module Stripe
25
22
  def update_features(params = {}, opts = {})
26
23
  request_stripe_object(
27
24
  method: :post,
28
- path: resource_url + "/features",
25
+ path: format("/v1/treasury/financial_accounts/%<financial_account>s/features", { financial_account: CGI.escape(self["id"]) }),
26
+ params: params,
27
+ opts: opts
28
+ )
29
+ end
30
+
31
+ def self.retrieve_features(financial_account, params = {}, opts = {})
32
+ request_stripe_object(
33
+ method: :get,
34
+ path: format("/v1/treasury/financial_accounts/%<financial_account>s/features", { financial_account: CGI.escape(financial_account) }),
35
+ params: params,
36
+ opts: opts
37
+ )
38
+ end
39
+
40
+ def self.update_features(financial_account, params = {}, opts = {})
41
+ request_stripe_object(
42
+ method: :post,
43
+ path: format("/v1/treasury/financial_accounts/%<financial_account>s/features", { financial_account: CGI.escape(financial_account) }),
29
44
  params: params,
30
45
  opts: opts
31
46
  )
@@ -9,12 +9,19 @@ module Stripe
9
9
 
10
10
  OBJECT_NAME = "treasury.inbound_transfer"
11
11
 
12
- custom_method :cancel, http_verb: :post
13
-
14
12
  def cancel(params = {}, opts = {})
15
13
  request_stripe_object(
16
14
  method: :post,
17
- path: resource_url + "/cancel",
15
+ path: format("/v1/treasury/inbound_transfers/%<inbound_transfer>s/cancel", { inbound_transfer: CGI.escape(self["id"]) }),
16
+ params: params,
17
+ opts: opts
18
+ )
19
+ end
20
+
21
+ def self.cancel(inbound_transfer, params = {}, opts = {})
22
+ request_stripe_object(
23
+ method: :post,
24
+ path: format("/v1/treasury/inbound_transfers/%<inbound_transfer>s/cancel", { inbound_transfer: CGI.escape(inbound_transfer) }),
18
25
  params: params,
19
26
  opts: opts
20
27
  )
@@ -27,14 +34,37 @@ module Stripe
27
34
  class TestHelpers < APIResourceTestHelpers
28
35
  RESOURCE_CLASS = InboundTransfer
29
36
 
30
- custom_method :fail, http_verb: :post
31
- custom_method :return_inbound_transfer, http_verb: :post, http_path: "return"
32
- custom_method :succeed, http_verb: :post
37
+ def self.fail(id, params = {}, opts = {})
38
+ request_stripe_object(
39
+ method: :post,
40
+ path: format("/v1/test_helpers/treasury/inbound_transfers/%<id>s/fail", { id: CGI.escape(id) }),
41
+ params: params,
42
+ opts: opts
43
+ )
44
+ end
45
+
46
+ def self.return_inbound_transfer(id, params = {}, opts = {})
47
+ request_stripe_object(
48
+ method: :post,
49
+ path: format("/v1/test_helpers/treasury/inbound_transfers/%<id>s/return", { id: CGI.escape(id) }),
50
+ params: params,
51
+ opts: opts
52
+ )
53
+ end
54
+
55
+ def self.succeed(id, params = {}, opts = {})
56
+ request_stripe_object(
57
+ method: :post,
58
+ path: format("/v1/test_helpers/treasury/inbound_transfers/%<id>s/succeed", { id: CGI.escape(id) }),
59
+ params: params,
60
+ opts: opts
61
+ )
62
+ end
33
63
 
34
64
  def fail(params = {}, opts = {})
35
65
  @resource.request_stripe_object(
36
66
  method: :post,
37
- path: resource_url + "/fail",
67
+ path: format("/v1/test_helpers/treasury/inbound_transfers/%<id>s/fail", { id: CGI.escape(@resource["id"]) }),
38
68
  params: params,
39
69
  opts: opts
40
70
  )
@@ -43,7 +73,7 @@ module Stripe
43
73
  def return_inbound_transfer(params = {}, opts = {})
44
74
  @resource.request_stripe_object(
45
75
  method: :post,
46
- path: resource_url + "/return",
76
+ path: format("/v1/test_helpers/treasury/inbound_transfers/%<id>s/return", { id: CGI.escape(@resource["id"]) }),
47
77
  params: params,
48
78
  opts: opts
49
79
  )
@@ -52,7 +82,7 @@ module Stripe
52
82
  def succeed(params = {}, opts = {})
53
83
  @resource.request_stripe_object(
54
84
  method: :post,
55
- path: resource_url + "/succeed",
85
+ path: format("/v1/test_helpers/treasury/inbound_transfers/%<id>s/succeed", { id: CGI.escape(@resource["id"]) }),
56
86
  params: params,
57
87
  opts: opts
58
88
  )
@@ -9,12 +9,19 @@ module Stripe
9
9
 
10
10
  OBJECT_NAME = "treasury.outbound_payment"
11
11
 
12
- custom_method :cancel, http_verb: :post
13
-
14
12
  def cancel(params = {}, opts = {})
15
13
  request_stripe_object(
16
14
  method: :post,
17
- path: resource_url + "/cancel",
15
+ path: format("/v1/treasury/outbound_payments/%<id>s/cancel", { id: CGI.escape(self["id"]) }),
16
+ params: params,
17
+ opts: opts
18
+ )
19
+ end
20
+
21
+ def self.cancel(id, params = {}, opts = {})
22
+ request_stripe_object(
23
+ method: :post,
24
+ path: format("/v1/treasury/outbound_payments/%<id>s/cancel", { id: CGI.escape(id) }),
18
25
  params: params,
19
26
  opts: opts
20
27
  )
@@ -27,14 +34,37 @@ module Stripe
27
34
  class TestHelpers < APIResourceTestHelpers
28
35
  RESOURCE_CLASS = OutboundPayment
29
36
 
30
- custom_method :fail, http_verb: :post
31
- custom_method :post, http_verb: :post
32
- custom_method :return_outbound_payment, http_verb: :post, http_path: "return"
37
+ def self.fail(id, params = {}, opts = {})
38
+ request_stripe_object(
39
+ method: :post,
40
+ path: format("/v1/test_helpers/treasury/outbound_payments/%<id>s/fail", { id: CGI.escape(id) }),
41
+ params: params,
42
+ opts: opts
43
+ )
44
+ end
45
+
46
+ def self.post(id, params = {}, opts = {})
47
+ request_stripe_object(
48
+ method: :post,
49
+ path: format("/v1/test_helpers/treasury/outbound_payments/%<id>s/post", { id: CGI.escape(id) }),
50
+ params: params,
51
+ opts: opts
52
+ )
53
+ end
54
+
55
+ def self.return_outbound_payment(id, params = {}, opts = {})
56
+ request_stripe_object(
57
+ method: :post,
58
+ path: format("/v1/test_helpers/treasury/outbound_payments/%<id>s/return", { id: CGI.escape(id) }),
59
+ params: params,
60
+ opts: opts
61
+ )
62
+ end
33
63
 
34
64
  def fail(params = {}, opts = {})
35
65
  @resource.request_stripe_object(
36
66
  method: :post,
37
- path: resource_url + "/fail",
67
+ path: format("/v1/test_helpers/treasury/outbound_payments/%<id>s/fail", { id: CGI.escape(@resource["id"]) }),
38
68
  params: params,
39
69
  opts: opts
40
70
  )
@@ -43,7 +73,7 @@ module Stripe
43
73
  def post(params = {}, opts = {})
44
74
  @resource.request_stripe_object(
45
75
  method: :post,
46
- path: resource_url + "/post",
76
+ path: format("/v1/test_helpers/treasury/outbound_payments/%<id>s/post", { id: CGI.escape(@resource["id"]) }),
47
77
  params: params,
48
78
  opts: opts
49
79
  )
@@ -52,7 +82,7 @@ module Stripe
52
82
  def return_outbound_payment(params = {}, opts = {})
53
83
  @resource.request_stripe_object(
54
84
  method: :post,
55
- path: resource_url + "/return",
85
+ path: format("/v1/test_helpers/treasury/outbound_payments/%<id>s/return", { id: CGI.escape(@resource["id"]) }),
56
86
  params: params,
57
87
  opts: opts
58
88
  )
@@ -9,12 +9,19 @@ module Stripe
9
9
 
10
10
  OBJECT_NAME = "treasury.outbound_transfer"
11
11
 
12
- custom_method :cancel, http_verb: :post
13
-
14
12
  def cancel(params = {}, opts = {})
15
13
  request_stripe_object(
16
14
  method: :post,
17
- path: resource_url + "/cancel",
15
+ path: format("/v1/treasury/outbound_transfers/%<outbound_transfer>s/cancel", { outbound_transfer: CGI.escape(self["id"]) }),
16
+ params: params,
17
+ opts: opts
18
+ )
19
+ end
20
+
21
+ def self.cancel(outbound_transfer, params = {}, opts = {})
22
+ request_stripe_object(
23
+ method: :post,
24
+ path: format("/v1/treasury/outbound_transfers/%<outbound_transfer>s/cancel", { outbound_transfer: CGI.escape(outbound_transfer) }),
18
25
  params: params,
19
26
  opts: opts
20
27
  )
@@ -27,14 +34,41 @@ module Stripe
27
34
  class TestHelpers < APIResourceTestHelpers
28
35
  RESOURCE_CLASS = OutboundTransfer
29
36
 
30
- custom_method :fail, http_verb: :post
31
- custom_method :post, http_verb: :post
32
- custom_method :return_outbound_transfer, http_verb: :post, http_path: "return"
37
+ def self.fail(outbound_transfer, params = {}, opts = {})
38
+ request_stripe_object(
39
+ method: :post,
40
+ path: format("/v1/test_helpers/treasury/outbound_transfers/%<outbound_transfer>s/fail", { outbound_transfer: CGI.escape(outbound_transfer) }),
41
+ params: params,
42
+ opts: opts
43
+ )
44
+ end
45
+
46
+ def self.post(outbound_transfer, params = {}, opts = {})
47
+ request_stripe_object(
48
+ method: :post,
49
+ path: format("/v1/test_helpers/treasury/outbound_transfers/%<outbound_transfer>s/post", { outbound_transfer: CGI.escape(outbound_transfer) }),
50
+ params: params,
51
+ opts: opts
52
+ )
53
+ end
54
+
55
+ def self.return_outbound_transfer(
56
+ outbound_transfer,
57
+ params = {},
58
+ opts = {}
59
+ )
60
+ request_stripe_object(
61
+ method: :post,
62
+ path: format("/v1/test_helpers/treasury/outbound_transfers/%<outbound_transfer>s/return", { outbound_transfer: CGI.escape(outbound_transfer) }),
63
+ params: params,
64
+ opts: opts
65
+ )
66
+ end
33
67
 
34
68
  def fail(params = {}, opts = {})
35
69
  @resource.request_stripe_object(
36
70
  method: :post,
37
- path: resource_url + "/fail",
71
+ path: format("/v1/test_helpers/treasury/outbound_transfers/%<outbound_transfer>s/fail", { outbound_transfer: CGI.escape(@resource["id"]) }),
38
72
  params: params,
39
73
  opts: opts
40
74
  )
@@ -43,7 +77,7 @@ module Stripe
43
77
  def post(params = {}, opts = {})
44
78
  @resource.request_stripe_object(
45
79
  method: :post,
46
- path: resource_url + "/post",
80
+ path: format("/v1/test_helpers/treasury/outbound_transfers/%<outbound_transfer>s/post", { outbound_transfer: CGI.escape(@resource["id"]) }),
47
81
  params: params,
48
82
  opts: opts
49
83
  )
@@ -52,7 +86,7 @@ module Stripe
52
86
  def return_outbound_transfer(params = {}, opts = {})
53
87
  @resource.request_stripe_object(
54
88
  method: :post,
55
- path: resource_url + "/return",
89
+ path: format("/v1/test_helpers/treasury/outbound_transfers/%<outbound_transfer>s/return", { outbound_transfer: CGI.escape(@resource["id"]) }),
56
90
  params: params,
57
91
  opts: opts
58
92
  )
@@ -16,13 +16,12 @@ module Stripe
16
16
  RESOURCE_CLASS = ReceivedCredit
17
17
 
18
18
  def self.create(params = {}, opts = {})
19
- resp, opts = execute_resource_request(
20
- :post,
21
- "/v1/test_helpers/treasury/received_credits",
22
- params,
23
- opts
19
+ request_stripe_object(
20
+ method: :post,
21
+ path: "/v1/test_helpers/treasury/received_credits",
22
+ params: params,
23
+ opts: opts
24
24
  )
25
- Util.convert_to_stripe_object(resp.data, opts)
26
25
  end
27
26
  end
28
27
  end
@@ -16,13 +16,12 @@ module Stripe
16
16
  RESOURCE_CLASS = ReceivedDebit
17
17
 
18
18
  def self.create(params = {}, opts = {})
19
- resp, opts = execute_resource_request(
20
- :post,
21
- "/v1/test_helpers/treasury/received_debits",
22
- params,
23
- opts
19
+ request_stripe_object(
20
+ method: :post,
21
+ path: "/v1/test_helpers/treasury/received_debits",
22
+ params: params,
23
+ opts: opts
24
24
  )
25
- Util.convert_to_stripe_object(resp.data, opts)
26
25
  end
27
26
  end
28
27
  end
data/lib/stripe/util.rb CHANGED
@@ -90,7 +90,7 @@ module Stripe
90
90
  opts
91
91
  )
92
92
 
93
- Util.convert_to_stripe_object(resp.data, opts)
93
+ Util.convert_to_stripe_object_with_params(resp.data, params, opts)
94
94
  end
95
95
  end
96
96
 
@@ -104,9 +104,27 @@ module Stripe
104
104
  # ==== Attributes
105
105
  #
106
106
  # * +data+ - Hash of fields and values to be converted into a StripeObject.
107
+ # * +params+ - Params for +StripeObject+ like filters used in search that
108
+ # will be reused on subsequent API calls.
107
109
  # * +opts+ - Options for +StripeObject+ like an API key that will be reused
108
110
  # on subsequent API calls.
109
111
  def self.convert_to_stripe_object(data, opts = {})
112
+ convert_to_stripe_object_with_params(data, {}, opts)
113
+ end
114
+
115
+ # Converts a hash of fields or an array of hashes into a +StripeObject+ or
116
+ # array of +StripeObject+s. These new objects will be created as a concrete
117
+ # type as dictated by their `object` field (e.g. an `object` value of
118
+ # `charge` would create an instance of +Charge+), but if `object` is not
119
+ # present or of an unknown type, the newly created instance will fall back
120
+ # to being a +StripeObject+.
121
+ #
122
+ # ==== Attributes
123
+ #
124
+ # * +data+ - Hash of fields and values to be converted into a StripeObject.
125
+ # * +opts+ - Options for +StripeObject+ like an API key that will be reused
126
+ # on subsequent API calls.
127
+ def self.convert_to_stripe_object_with_params(data, params, opts = {})
110
128
  opts = normalize_opts(opts)
111
129
 
112
130
  case data
@@ -115,8 +133,16 @@ module Stripe
115
133
  when Hash
116
134
  # Try converting to a known object class. If none available, fall back
117
135
  # to generic StripeObject
118
- object_classes.fetch(data[:object], StripeObject)
119
- .construct_from(data, opts)
136
+ obj = object_classes.fetch(data[:object], StripeObject)
137
+ .construct_from(data, opts)
138
+
139
+ # set filters so that we can fetch the same limit, expansions, and
140
+ # predicates when accessing the next and previous pages
141
+ if obj && (obj.is_a?(SearchResultObject) || obj.is_a?(ListObject))
142
+ obj.filters = params.dup
143
+ end
144
+
145
+ obj
120
146
  else
121
147
  data
122
148
  end
@@ -390,6 +416,15 @@ module Stripe
390
416
  # Hopefully val is a string, but protect in case it's not.
391
417
  val = val.to_s
392
418
 
419
+ # Some values returned by the server are encoded in ASCII-8BIT before
420
+ # being parsed as UTF-8 by Marshal. If we don't transform these here, then
421
+ # puts will fail as it tries to render UTF-8 characters as ASCII-8BIT
422
+ # which is not valid.
423
+ if val && val.encoding == Encoding::ASCII_8BIT
424
+ # Dup the string as it is a frozen literal.
425
+ val = val.dup.force_encoding("UTF-8")
426
+ end
427
+
393
428
  if %r{[^\w\-/]} =~ val
394
429
  # If the string contains any special characters, escape any double
395
430
  # quotes it has, remove newlines, and wrap the whole thing in quotes.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stripe
4
- VERSION = "6.2.0"
4
+ VERSION = "6.5.0"
5
5
  end
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: 6.2.0
4
+ version: 6.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-23 00:00:00.000000000 Z
11
+ date: 2022-06-29 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.
@@ -41,6 +41,7 @@ files:
41
41
  - lib/stripe/api_operations/search.rb
42
42
  - lib/stripe/api_resource.rb
43
43
  - lib/stripe/api_resource_test_helpers.rb
44
+ - lib/stripe/api_version.rb
44
45
  - lib/stripe/connection_manager.rb
45
46
  - lib/stripe/error_object.rb
46
47
  - lib/stripe/errors.rb