stripe 6.3.0 → 6.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/Makefile +1 -1
  4. data/OPENAPI_VERSION +1 -1
  5. data/VERSION +1 -1
  6. data/lib/stripe/api_operations/create.rb +6 -2
  7. data/lib/stripe/api_operations/delete.rb +12 -7
  8. data/lib/stripe/api_operations/list.rb +6 -9
  9. data/lib/stripe/api_operations/nested_resource.rb +62 -34
  10. data/lib/stripe/api_operations/request.rb +10 -0
  11. data/lib/stripe/api_operations/save.rb +6 -3
  12. data/lib/stripe/api_operations/search.rb +6 -9
  13. data/lib/stripe/api_resource.rb +1 -1
  14. data/lib/stripe/resources/account.rb +28 -8
  15. data/lib/stripe/resources/apps/secret.rb +10 -12
  16. data/lib/stripe/resources/charge.rb +10 -3
  17. data/lib/stripe/resources/checkout/session.rb +10 -3
  18. data/lib/stripe/resources/credit_note.rb +22 -7
  19. data/lib/stripe/resources/customer.rb +66 -25
  20. data/lib/stripe/resources/dispute.rb +10 -3
  21. data/lib/stripe/resources/financial_connections/account.rb +30 -7
  22. data/lib/stripe/resources/identity/verification_session.rb +20 -5
  23. data/lib/stripe/resources/invoice.rb +62 -15
  24. data/lib/stripe/resources/issuing/authorization.rb +20 -5
  25. data/lib/stripe/resources/issuing/card.rb +10 -3
  26. data/lib/stripe/resources/issuing/dispute.rb +10 -3
  27. data/lib/stripe/resources/order.rb +40 -9
  28. data/lib/stripe/resources/payment_intent.rb +60 -13
  29. data/lib/stripe/resources/payment_link.rb +10 -3
  30. data/lib/stripe/resources/payment_method.rb +20 -5
  31. data/lib/stripe/resources/payout.rb +20 -5
  32. data/lib/stripe/resources/quote.rb +50 -11
  33. data/lib/stripe/resources/refund.rb +19 -5
  34. data/lib/stripe/resources/review.rb +10 -3
  35. data/lib/stripe/resources/setup_intent.rb +30 -7
  36. data/lib/stripe/resources/source.rb +16 -6
  37. data/lib/stripe/resources/subscription.rb +10 -3
  38. data/lib/stripe/resources/subscription_item.rb +6 -2
  39. data/lib/stripe/resources/subscription_schedule.rb +20 -5
  40. data/lib/stripe/resources/terminal/reader.rb +49 -11
  41. data/lib/stripe/resources/test_helpers/test_clock.rb +10 -3
  42. data/lib/stripe/resources/topup.rb +10 -3
  43. data/lib/stripe/resources/transfer.rb +10 -3
  44. data/lib/stripe/resources/treasury/financial_account.rb +20 -5
  45. data/lib/stripe/resources/treasury/inbound_transfer.rb +39 -9
  46. data/lib/stripe/resources/treasury/outbound_payment.rb +39 -9
  47. data/lib/stripe/resources/treasury/outbound_transfer.rb +43 -9
  48. data/lib/stripe/resources/treasury/received_credit.rb +5 -6
  49. data/lib/stripe/resources/treasury/received_debit.rb +5 -6
  50. data/lib/stripe/util.rb +29 -3
  51. data/lib/stripe/version.rb +1 -1
  52. metadata +2 -2
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stripe
4
- VERSION = "6.3.0"
4
+ VERSION = "6.4.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.3.0
4
+ version: 6.4.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-06-08 00:00:00.000000000 Z
11
+ date: 2022-06-17 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.