Class: Stripe::PlanService
- Inherits:
-
StripeService
- Object
- StripeService
- Stripe::PlanService
- Defined in:
- lib/stripe/services/plan_service.rb
Instance Method Summary collapse
-
#create(params = {}, opts = {}) ⇒ Object
You can now model subscriptions more flexibly using the [Prices API](docs.stripe.com/api#prices).
-
#delete(plan, params = {}, opts = {}) ⇒ Object
Deleting plans means new subscribers can’t be added.
-
#list(params = {}, opts = {}) ⇒ Object
Returns a list of your plans.
-
#retrieve(plan, params = {}, opts = {}) ⇒ Object
Retrieves the plan with the given ID.
-
#update(plan, params = {}, opts = {}) ⇒ Object
Updates the specified plan by setting the values of the parameters passed.
Methods inherited from StripeService
#initialize, #request, #request_stream
Constructor Details
This class inherits a constructor from Stripe::StripeService
Instance Method Details
#create(params = {}, opts = {}) ⇒ Object
You can now model subscriptions more flexibly using the [Prices API](docs.stripe.com/api#prices). It replaces the Plans API and is backwards compatible to simplify your migration.
7 8 9 10 11 |
# File 'lib/stripe/services/plan_service.rb', line 7 def create(params = {}, opts = {}) params = PlanCreateParams.coerce_params(params) unless params.is_a?(Stripe::RequestParams) request(method: :post, path: "/v1/plans", params: params, opts: opts, base_address: :api) end |
#delete(plan, params = {}, opts = {}) ⇒ Object
Deleting plans means new subscribers can’t be added. Existing subscribers aren’t affected.
14 15 16 17 18 19 20 21 22 |
# File 'lib/stripe/services/plan_service.rb', line 14 def delete(plan, params = {}, opts = {}) request( method: :delete, path: format("/v1/plans/%<plan>s", { plan: CGI.escape(plan) }), params: params, opts: opts, base_address: :api ) end |
#list(params = {}, opts = {}) ⇒ Object
Returns a list of your plans.
25 26 27 |
# File 'lib/stripe/services/plan_service.rb', line 25 def list(params = {}, opts = {}) request(method: :get, path: "/v1/plans", params: params, opts: opts, base_address: :api) end |
#retrieve(plan, params = {}, opts = {}) ⇒ Object
Retrieves the plan with the given ID.
30 31 32 33 34 35 36 37 38 |
# File 'lib/stripe/services/plan_service.rb', line 30 def retrieve(plan, params = {}, opts = {}) request( method: :get, path: format("/v1/plans/%<plan>s", { plan: CGI.escape(plan) }), params: params, opts: opts, base_address: :api ) end |
#update(plan, params = {}, opts = {}) ⇒ Object
Updates the specified plan by setting the values of the parameters passed. Any parameters not provided are left unchanged. By design, you cannot change a plan’s ID, amount, currency, or billing cycle.
41 42 43 44 45 46 47 48 49 |
# File 'lib/stripe/services/plan_service.rb', line 41 def update(plan, params = {}, opts = {}) request( method: :post, path: format("/v1/plans/%<plan>s", { plan: CGI.escape(plan) }), params: params, opts: opts, base_address: :api ) end |