stripe 5.20.0 → 5.24.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -4
  3. data/.travis.yml +1 -1
  4. data/CHANGELOG.md +16 -0
  5. data/VERSION +1 -1
  6. data/lib/stripe.rb +32 -166
  7. data/lib/stripe/api_operations/create.rb +1 -1
  8. data/lib/stripe/api_operations/delete.rb +7 -3
  9. data/lib/stripe/api_operations/list.rb +1 -1
  10. data/lib/stripe/api_operations/nested_resource.rb +6 -5
  11. data/lib/stripe/api_operations/request.rb +19 -3
  12. data/lib/stripe/api_operations/save.rb +7 -4
  13. data/lib/stripe/api_resource.rb +4 -3
  14. data/lib/stripe/list_object.rb +2 -2
  15. data/lib/stripe/oauth.rb +3 -3
  16. data/lib/stripe/object_types.rb +3 -0
  17. data/lib/stripe/resources.rb +3 -0
  18. data/lib/stripe/resources/account.rb +2 -1
  19. data/lib/stripe/resources/account_link.rb +1 -0
  20. data/lib/stripe/resources/apple_pay_domain.rb +1 -0
  21. data/lib/stripe/resources/application_fee.rb +1 -0
  22. data/lib/stripe/resources/balance.rb +1 -0
  23. data/lib/stripe/resources/balance_transaction.rb +1 -0
  24. data/lib/stripe/resources/bank_account.rb +2 -1
  25. data/lib/stripe/resources/billing_portal/session.rb +1 -0
  26. data/lib/stripe/resources/bitcoin_receiver.rb +1 -0
  27. data/lib/stripe/resources/card.rb +1 -0
  28. data/lib/stripe/resources/charge.rb +1 -0
  29. data/lib/stripe/resources/checkout/session.rb +4 -0
  30. data/lib/stripe/resources/country_spec.rb +1 -0
  31. data/lib/stripe/resources/coupon.rb +1 -0
  32. data/lib/stripe/resources/credit_note.rb +3 -2
  33. data/lib/stripe/resources/customer.rb +2 -1
  34. data/lib/stripe/resources/dispute.rb +1 -0
  35. data/lib/stripe/resources/ephemeral_key.rb +1 -0
  36. data/lib/stripe/resources/event.rb +1 -0
  37. data/lib/stripe/resources/exchange_rate.rb +1 -0
  38. data/lib/stripe/resources/file.rb +1 -0
  39. data/lib/stripe/resources/file_link.rb +1 -0
  40. data/lib/stripe/resources/invoice.rb +3 -2
  41. data/lib/stripe/resources/invoice_item.rb +1 -0
  42. data/lib/stripe/resources/issuing/authorization.rb +1 -0
  43. data/lib/stripe/resources/issuing/card.rb +1 -0
  44. data/lib/stripe/resources/issuing/cardholder.rb +1 -0
  45. data/lib/stripe/resources/issuing/dispute.rb +1 -0
  46. data/lib/stripe/resources/issuing/transaction.rb +1 -0
  47. data/lib/stripe/resources/line_item.rb +7 -0
  48. data/lib/stripe/resources/mandate.rb +1 -0
  49. data/lib/stripe/resources/order.rb +1 -0
  50. data/lib/stripe/resources/order_return.rb +1 -0
  51. data/lib/stripe/resources/payment_intent.rb +1 -0
  52. data/lib/stripe/resources/payment_method.rb +1 -0
  53. data/lib/stripe/resources/payout.rb +1 -0
  54. data/lib/stripe/resources/plan.rb +1 -0
  55. data/lib/stripe/resources/price.rb +12 -0
  56. data/lib/stripe/resources/product.rb +1 -0
  57. data/lib/stripe/resources/promotion_code.rb +12 -0
  58. data/lib/stripe/resources/radar/early_fraud_warning.rb +1 -0
  59. data/lib/stripe/resources/radar/value_list.rb +1 -0
  60. data/lib/stripe/resources/radar/value_list_item.rb +1 -0
  61. data/lib/stripe/resources/recipient.rb +1 -0
  62. data/lib/stripe/resources/refund.rb +1 -0
  63. data/lib/stripe/resources/reporting/report_run.rb +1 -0
  64. data/lib/stripe/resources/reporting/report_type.rb +1 -0
  65. data/lib/stripe/resources/review.rb +1 -0
  66. data/lib/stripe/resources/setup_intent.rb +1 -0
  67. data/lib/stripe/resources/sigma/scheduled_query_run.rb +1 -0
  68. data/lib/stripe/resources/sku.rb +1 -0
  69. data/lib/stripe/resources/source.rb +4 -3
  70. data/lib/stripe/resources/subscription.rb +1 -0
  71. data/lib/stripe/resources/subscription_item.rb +2 -1
  72. data/lib/stripe/resources/subscription_schedule.rb +1 -0
  73. data/lib/stripe/resources/tax_rate.rb +1 -0
  74. data/lib/stripe/resources/terminal/connection_token.rb +1 -0
  75. data/lib/stripe/resources/terminal/location.rb +1 -0
  76. data/lib/stripe/resources/terminal/reader.rb +1 -0
  77. data/lib/stripe/resources/three_d_secure.rb +1 -0
  78. data/lib/stripe/resources/token.rb +1 -0
  79. data/lib/stripe/resources/topup.rb +1 -0
  80. data/lib/stripe/resources/transfer.rb +1 -0
  81. data/lib/stripe/resources/webhook_endpoint.rb +1 -0
  82. data/lib/stripe/stripe_configuration.rb +167 -0
  83. data/lib/stripe/stripe_object.rb +1 -1
  84. data/lib/stripe/version.rb +1 -1
  85. data/test/stripe/account_link_test.rb +3 -3
  86. data/test/stripe/checkout/session_test.rb +12 -0
  87. data/test/stripe/price_test.rb +48 -0
  88. data/test/stripe/promotion_code_test.rb +42 -0
  89. data/test/stripe/stripe_configuration_test.rb +128 -0
  90. data/test/stripe/subscription_item_test.rb +1 -1
  91. data/test/stripe_test.rb +88 -19
  92. data/test/test_helper.rb +1 -1
  93. metadata +12 -2
@@ -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 = request(http_verb, url, params, 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 = request(:get, resource_url, @retrieve_params)
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 = request(method, path, params, 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)
@@ -92,8 +92,8 @@ module Stripe
92
92
 
93
93
  def retrieve(id, opts = {})
94
94
  id, retrieve_params = Util.normalize_id(id)
95
- resp, opts = request(:get, "#{resource_url}/#{CGI.escape(id)}",
96
- retrieve_params, opts)
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
 
@@ -5,7 +5,7 @@ module Stripe
5
5
  module OAuthOperations
6
6
  extend APIOperations::Request::ClassMethods
7
7
 
8
- def self.request(method, url, params, opts)
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.request(
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.request(
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
@@ -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,
@@ -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 = request(:get, resource_url + "/persons", params, 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
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -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 = request(:post, resource_url + "/verify", params, 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
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -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
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -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 = request(:get, resource_url + "/preview", params, 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 = request(:get, resource_url + "/preview/lines", params, 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 = request(:delete, resource_url + "/discount")
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
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -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 = request(:get, resource_url + "/upcoming", params, 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 = request(:get, resource_url + "/upcoming/lines", params, 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
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Stripe
4
+ class LineItem < APIResource
5
+ OBJECT_NAME = "item"
6
+ end
7
+ end
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -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
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -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
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe