Class: Stripe::PlanService

Inherits:
StripeService show all
Defined in:
lib/stripe/services/plan_service.rb

Defined Under Namespace

Classes: CreateParams, DeleteParams, ListParams, RetrieveParams, UpdateParams

Instance Method Summary collapse

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](stripe.com/docs/api#prices). It replaces the Plans API and is backwards compatible to simplify your migration.



256
257
258
# File 'lib/stripe/services/plan_service.rb', line 256

def create(params = {}, opts = {})
  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.



261
262
263
264
265
266
267
268
269
# File 'lib/stripe/services/plan_service.rb', line 261

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.



272
273
274
# File 'lib/stripe/services/plan_service.rb', line 272

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.



277
278
279
280
281
282
283
284
285
# File 'lib/stripe/services/plan_service.rb', line 277

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.



288
289
290
291
292
293
294
295
296
# File 'lib/stripe/services/plan_service.rb', line 288

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