Class: Stripe::Subscription

Inherits:
APIResource show all
Extended by:
APIOperations::Create, APIOperations::List, APIOperations::Search
Includes:
APIOperations::Save
Defined in:
lib/stripe/resources/subscription.rb

Overview

Subscriptions allow you to charge a customer on a recurring basis.

Related guide: [Creating subscriptions](stripe.com/docs/billing/subscriptions/creating)

Defined Under Namespace

Classes: AutomaticTax, BillingCycleAnchorConfig, BillingThresholds, CancelParams, CancellationDetails, CreateParams, DeleteDiscountParams, InvoiceSettings, LastPriceMigrationError, ListParams, PauseCollection, PaymentSettings, PendingInvoiceItemInterval, PendingUpdate, Prebilling, ResumeParams, RetrieveParams, SearchParams, TransferData, TrialSettings, UpdateParams

Constant Summary collapse

OBJECT_NAME =
"subscription"

Constants inherited from StripeObject

Stripe::StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary collapse

Attributes inherited from APIResource

#save_with_parent

Attributes inherited from StripeObject

#last_response

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::List

list

Methods included from APIOperations::Search

_search

Methods included from APIOperations::Save

included, #save

Methods inherited from APIResource

class_name, custom_method, #refresh, #request_stripe_object, resource_url, #resource_url, retrieve, save_nested_resource

Methods included from APIOperations::Request

included

Methods inherited from StripeObject

#==, #[], #[]=, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values

Constructor Details

This class inherits a constructor from Stripe::StripeObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject

Instance Attribute Details

#applicationObject (readonly)

ID of the Connect Application that created the subscription.



2261
2262
2263
# File 'lib/stripe/resources/subscription.rb', line 2261

def application
  @application
end

#application_fee_percentObject (readonly)

A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice total that will be transferred to the application owner’s Stripe account.



2264
2265
2266
# File 'lib/stripe/resources/subscription.rb', line 2264

def application_fee_percent
  @application_fee_percent
end

#automatic_taxObject (readonly)

Attribute for field automatic_tax



2267
2268
2269
# File 'lib/stripe/resources/subscription.rb', line 2267

def automatic_tax
  @automatic_tax
end

#billing_cycle_anchorObject (readonly)

The reference point that aligns future [billing cycle](stripe.com/docs/subscriptions/billing-cycle) dates. It sets the day of week for ‘week` intervals, the day of month for `month` and `year` intervals, and the month of year for `year` intervals. The timestamp is in UTC format.



2270
2271
2272
# File 'lib/stripe/resources/subscription.rb', line 2270

def billing_cycle_anchor
  @billing_cycle_anchor
end

#billing_cycle_anchor_configObject (readonly)

The fixed values used to calculate the ‘billing_cycle_anchor`.



2273
2274
2275
# File 'lib/stripe/resources/subscription.rb', line 2273

def billing_cycle_anchor_config
  @billing_cycle_anchor_config
end

#billing_thresholdsObject (readonly)

Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period



2276
2277
2278
# File 'lib/stripe/resources/subscription.rb', line 2276

def billing_thresholds
  @billing_thresholds
end

#cancel_atObject (readonly)

A date in the future at which the subscription will automatically get canceled



2279
2280
2281
# File 'lib/stripe/resources/subscription.rb', line 2279

def cancel_at
  @cancel_at
end

#cancel_at_period_endObject (readonly)

Whether this subscription will (if ‘status=active`) or did (if `status=canceled`) cancel at the end of the current billing period.



2282
2283
2284
# File 'lib/stripe/resources/subscription.rb', line 2282

def cancel_at_period_end
  @cancel_at_period_end
end

#canceled_atObject (readonly)

If the subscription has been canceled, the date of that cancellation. If the subscription was canceled with ‘cancel_at_period_end`, `canceled_at` will reflect the time of the most recent update request, not the end of the subscription period when the subscription is automatically moved to a canceled state.



2285
2286
2287
# File 'lib/stripe/resources/subscription.rb', line 2285

def canceled_at
  @canceled_at
end

#cancellation_detailsObject (readonly)

Details about why this subscription was cancelled



2288
2289
2290
# File 'lib/stripe/resources/subscription.rb', line 2288

def cancellation_details
  @cancellation_details
end

#collection_methodObject (readonly)

Either ‘charge_automatically`, or `send_invoice`. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as `active`.



2291
2292
2293
# File 'lib/stripe/resources/subscription.rb', line 2291

def collection_method
  @collection_method
end

#createdObject (readonly)

Time at which the object was created. Measured in seconds since the Unix epoch.



2294
2295
2296
# File 'lib/stripe/resources/subscription.rb', line 2294

def created
  @created
end

#currencyObject (readonly)

Three-letter [ISO currency code](www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](stripe.com/docs/currencies).



2297
2298
2299
# File 'lib/stripe/resources/subscription.rb', line 2297

def currency
  @currency
end

#current_period_endObject (readonly)

End of the current period that the subscription has been invoiced for. At the end of this period, a new invoice will be created.



2300
2301
2302
# File 'lib/stripe/resources/subscription.rb', line 2300

def current_period_end
  @current_period_end
end

#current_period_startObject (readonly)

Start of the current period that the subscription has been invoiced for.



2303
2304
2305
# File 'lib/stripe/resources/subscription.rb', line 2303

def current_period_start
  @current_period_start
end

#customerObject (readonly)

ID of the customer who owns the subscription.



2306
2307
2308
# File 'lib/stripe/resources/subscription.rb', line 2306

def customer
  @customer
end

#days_until_dueObject (readonly)

Number of days a customer has to pay invoices generated by this subscription. This value will be ‘null` for subscriptions where `collection_method=charge_automatically`.



2309
2310
2311
# File 'lib/stripe/resources/subscription.rb', line 2309

def days_until_due
  @days_until_due
end

#default_payment_methodObject (readonly)

ID of the default payment method for the subscription. It must belong to the customer associated with the subscription. This takes precedence over ‘default_source`. If neither are set, invoices will use the customer’s [invoice_settings.default_payment_method](stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method) or [default_source](stripe.com/docs/api/customers/object#customer_object-default_source).



2312
2313
2314
# File 'lib/stripe/resources/subscription.rb', line 2312

def default_payment_method
  @default_payment_method
end

#default_sourceObject (readonly)

ID of the default payment source for the subscription. It must belong to the customer associated with the subscription and be in a chargeable state. If ‘default_payment_method` is also set, `default_payment_method` will take precedence. If neither are set, invoices will use the customer’s [invoice_settings.default_payment_method](stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method) or [default_source](stripe.com/docs/api/customers/object#customer_object-default_source).



2315
2316
2317
# File 'lib/stripe/resources/subscription.rb', line 2315

def default_source
  @default_source
end

#default_tax_ratesObject (readonly)

The tax rates that will apply to any subscription item that does not have ‘tax_rates` set. Invoices created will have their `default_tax_rates` populated from the subscription.



2318
2319
2320
# File 'lib/stripe/resources/subscription.rb', line 2318

def default_tax_rates
  @default_tax_rates
end

#descriptionObject (readonly)

The subscription’s description, meant to be displayable to the customer. Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces and certain local payment methods UIs.



2321
2322
2323
# File 'lib/stripe/resources/subscription.rb', line 2321

def description
  @description
end

#discountObject (readonly)

Describes the current discount applied to this subscription, if there is one. When billing, a discount applied to a subscription overrides a discount applied on a customer-wide basis. This field has been deprecated and will be removed in a future API version. Use ‘discounts` instead.



2324
2325
2326
# File 'lib/stripe/resources/subscription.rb', line 2324

def discount
  @discount
end

#discountsObject (readonly)

The discounts applied to the subscription. Subscription item discounts are applied before subscription discounts. Use ‘expand[]=discounts` to expand each discount.



2327
2328
2329
# File 'lib/stripe/resources/subscription.rb', line 2327

def discounts
  @discounts
end

#ended_atObject (readonly)

If the subscription has ended, the date the subscription ended.



2330
2331
2332
# File 'lib/stripe/resources/subscription.rb', line 2330

def ended_at
  @ended_at
end

#idObject (readonly)

Unique identifier for the object.



2333
2334
2335
# File 'lib/stripe/resources/subscription.rb', line 2333

def id
  @id
end

#invoice_settingsObject (readonly)

Attribute for field invoice_settings



2336
2337
2338
# File 'lib/stripe/resources/subscription.rb', line 2336

def invoice_settings
  @invoice_settings
end

#itemsObject (readonly)

List of subscription items, each with an attached price.



2339
2340
2341
# File 'lib/stripe/resources/subscription.rb', line 2339

def items
  @items
end

#last_price_migration_errorObject (readonly)

Details of the most recent price migration that failed for the subscription.



2342
2343
2344
# File 'lib/stripe/resources/subscription.rb', line 2342

def last_price_migration_error
  @last_price_migration_error
end

#latest_invoiceObject (readonly)

The most recent invoice this subscription has generated.



2345
2346
2347
# File 'lib/stripe/resources/subscription.rb', line 2345

def latest_invoice
  @latest_invoice
end

#livemodeObject (readonly)

Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.



2348
2349
2350
# File 'lib/stripe/resources/subscription.rb', line 2348

def livemode
  @livemode
end

#metadataObject (readonly)

Set of [key-value pairs](stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.



2351
2352
2353
# File 'lib/stripe/resources/subscription.rb', line 2351

def 
  @metadata
end

#next_pending_invoice_item_invoiceObject (readonly)

Specifies the approximate timestamp on which any pending invoice items will be billed according to the schedule provided at ‘pending_invoice_item_interval`.



2354
2355
2356
# File 'lib/stripe/resources/subscription.rb', line 2354

def next_pending_invoice_item_invoice
  @next_pending_invoice_item_invoice
end

#objectObject (readonly)

String representing the object’s type. Objects of the same type share the same value.



2357
2358
2359
# File 'lib/stripe/resources/subscription.rb', line 2357

def object
  @object
end

#on_behalf_ofObject (readonly)

The account (if any) the charge was made on behalf of for charges associated with this subscription. See the Connect documentation for details.



2360
2361
2362
# File 'lib/stripe/resources/subscription.rb', line 2360

def on_behalf_of
  @on_behalf_of
end

#pause_collectionObject (readonly)

If specified, payment collection for this subscription will be paused. Note that the subscription status will be unchanged and will not be updated to ‘paused`. Learn more about [pausing collection](stripe.com/docs/billing/subscriptions/pause-payment).



2363
2364
2365
# File 'lib/stripe/resources/subscription.rb', line 2363

def pause_collection
  @pause_collection
end

#payment_settingsObject (readonly)

Payment settings passed on to invoices created by the subscription.



2366
2367
2368
# File 'lib/stripe/resources/subscription.rb', line 2366

def payment_settings
  @payment_settings
end

#pending_invoice_item_intervalObject (readonly)

Specifies an interval for how often to bill for any pending invoice items. It is analogous to calling [Create an invoice](stripe.com/docs/api#create_invoice) for the given subscription at the specified interval.



2369
2370
2371
# File 'lib/stripe/resources/subscription.rb', line 2369

def pending_invoice_item_interval
  @pending_invoice_item_interval
end

#pending_setup_intentObject (readonly)

You can use this [SetupIntent](stripe.com/docs/api/setup_intents) to collect user authentication when creating a subscription without immediate payment or updating a subscription’s payment method, allowing you to optimize for off-session payments. Learn more in the [SCA Migration Guide](stripe.com/docs/billing/migration/strong-customer-authentication#scenario-2).



2372
2373
2374
# File 'lib/stripe/resources/subscription.rb', line 2372

def pending_setup_intent
  @pending_setup_intent
end

#pending_updateObject (readonly)

If specified, [pending updates](stripe.com/docs/billing/subscriptions/pending-updates) that will be applied to the subscription once the ‘latest_invoice` has been paid.



2375
2376
2377
# File 'lib/stripe/resources/subscription.rb', line 2375

def pending_update
  @pending_update
end

#prebillingObject (readonly)

Time period and invoice for a Subscription billed in advance.



2378
2379
2380
# File 'lib/stripe/resources/subscription.rb', line 2378

def prebilling
  @prebilling
end

#scheduleObject (readonly)

The schedule attached to the subscription



2381
2382
2383
# File 'lib/stripe/resources/subscription.rb', line 2381

def schedule
  @schedule
end

#start_dateObject (readonly)

Date when the subscription was first created. The date might differ from the ‘created` date due to backdating.



2384
2385
2386
# File 'lib/stripe/resources/subscription.rb', line 2384

def start_date
  @start_date
end

#statusObject (readonly)

Possible values are ‘incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `canceled`, `unpaid`, or `paused`.

For ‘collection_method=charge_automatically` a subscription moves into `incomplete` if the initial payment attempt fails. A subscription in this status can only have metadata and default_source updated. Once the first invoice is paid, the subscription moves into an `active` status. If the first invoice is not paid within 23 hours, the subscription transitions to `incomplete_expired`. This is a terminal status, the open invoice will be voided and no further invoices will be generated.

A subscription that is currently in a trial period is ‘trialing` and moves to `active` when the trial period is over.

A subscription can only enter a ‘paused` status [when a trial ends without a payment method](stripe.com/docs/billing/subscriptions/trials#create-free-trials-without-payment). A `paused` subscription doesn’t generate invoices and can be resumed after your customer adds their payment method. The ‘paused` status is different from [pausing collection](stripe.com/docs/billing/subscriptions/pause-payment), which still generates invoices and leaves the subscription’s status unchanged.

If subscription ‘collection_method=charge_automatically`, it becomes `past_due` when payment is required but cannot be paid (due to failed payment or awaiting additional user actions). Once Stripe has exhausted all payment retry attempts, the subscription will become `canceled` or `unpaid` (depending on your subscriptions settings).

If subscription ‘collection_method=send_invoice` it becomes `past_due` when its invoice is not paid by the due date, and `canceled` or `unpaid` if it is still not paid by an additional deadline after that. Note that when a subscription has a status of `unpaid`, no subsequent invoices will be attempted (invoices will be created, but then immediately automatically closed). After receiving updated payment information from a customer, you may choose to reopen and pay their closed invoices.



2397
2398
2399
# File 'lib/stripe/resources/subscription.rb', line 2397

def status
  @status
end

#test_clockObject (readonly)

ID of the test clock this subscription belongs to.



2400
2401
2402
# File 'lib/stripe/resources/subscription.rb', line 2400

def test_clock
  @test_clock
end

#transfer_dataObject (readonly)

The account (if any) the subscription’s payments will be attributed to for tax reporting, and where funds from each payment will be transferred to for each of the subscription’s invoices.



2403
2404
2405
# File 'lib/stripe/resources/subscription.rb', line 2403

def transfer_data
  @transfer_data
end

#trial_endObject (readonly)

If the subscription has a trial, the end of that trial.



2406
2407
2408
# File 'lib/stripe/resources/subscription.rb', line 2406

def trial_end
  @trial_end
end

#trial_settingsObject (readonly)

Settings related to subscription trials.



2409
2410
2411
# File 'lib/stripe/resources/subscription.rb', line 2409

def trial_settings
  @trial_settings
end

#trial_startObject (readonly)

If the subscription has a trial, the beginning of that trial.



2412
2413
2414
# File 'lib/stripe/resources/subscription.rb', line 2412

def trial_start
  @trial_start
end

Class Method Details

.cancel(subscription_exposed_id, params = {}, opts = {}) ⇒ Object

Cancels a customer’s subscription immediately. The customer won’t be charged again for the subscription. After it’s canceled, you can no longer update the subscription or its [metadata](stripe.com/metadata).

Any pending invoice items that you’ve created are still charged at the end of the period, unless manually [deleted](stripe.com/docs/api#delete_invoiceitem). If you’ve set the subscription to cancel at the end of the period, any pending prorations are also left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations are removed.

By default, upon subscription cancellation, Stripe stops automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all.



2433
2434
2435
2436
2437
2438
2439
2440
# File 'lib/stripe/resources/subscription.rb', line 2433

def self.cancel(subscription_exposed_id, params = {}, opts = {})
  request_stripe_object(
    method: :delete,
    path: format("/v1/subscriptions/%<subscription_exposed_id>s", { subscription_exposed_id: CGI.escape(subscription_exposed_id) }),
    params: params,
    opts: opts
  )
end

.create(params = {}, opts = {}) ⇒ Object

Creates a new subscription on an existing customer. Each customer can have up to 500 active or scheduled subscriptions.

When you create a subscription with collection_method=charge_automatically, the first invoice is finalized as part of the request. The payment_behavior parameter determines the exact behavior of the initial payment.

To start subscriptions where the first invoice always begins in a draft status, use [subscription schedules](stripe.com/docs/billing/subscriptions/subscription-schedules#managing) instead. Schedules provide the flexibility to model more complex billing configurations that change over time.



2449
2450
2451
# File 'lib/stripe/resources/subscription.rb', line 2449

def self.create(params = {}, opts = {})
  request_stripe_object(method: :post, path: "/v1/subscriptions", params: params, opts: opts)
end

.delete_discount(subscription_exposed_id, params = {}, opts = {}) ⇒ Object

Removes the currently applied discount on a subscription.



2464
2465
2466
2467
2468
2469
2470
2471
# File 'lib/stripe/resources/subscription.rb', line 2464

def self.delete_discount(subscription_exposed_id, params = {}, opts = {})
  request_stripe_object(
    method: :delete,
    path: format("/v1/subscriptions/%<subscription_exposed_id>s/discount", { subscription_exposed_id: CGI.escape(subscription_exposed_id) }),
    params: params,
    opts: opts
  )
end

.list(params = {}, opts = {}) ⇒ Object

By default, returns a list of subscriptions that have not been canceled. In order to list canceled subscriptions, specify status=canceled.



2474
2475
2476
# File 'lib/stripe/resources/subscription.rb', line 2474

def self.list(params = {}, opts = {})
  request_stripe_object(method: :get, path: "/v1/subscriptions", params: params, opts: opts)
end

.object_nameObject



15
16
17
# File 'lib/stripe/resources/subscription.rb', line 15

def self.object_name
  "subscription"
end

.resume(subscription, params = {}, opts = {}) ⇒ Object

Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor and creating prorations. If a resumption invoice is generated, it must be paid or marked uncollectible before the subscription will be unpaused. If payment succeeds the subscription will become active, and if payment fails the subscription will be past_due. The resumption invoice will void automatically if not paid by the expiration date.



2489
2490
2491
2492
2493
2494
2495
2496
# File 'lib/stripe/resources/subscription.rb', line 2489

def self.resume(subscription, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/subscriptions/%<subscription>s/resume", { subscription: CGI.escape(subscription) }),
    params: params,
    opts: opts
  )
end

.search(params = {}, opts = {}) ⇒ Object



2498
2499
2500
2501
2502
2503
2504
2505
# File 'lib/stripe/resources/subscription.rb', line 2498

def self.search(params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: "/v1/subscriptions/search",
    params: params,
    opts: opts
  )
end

.search_auto_paging_each(params = {}, opts = {}, &blk) ⇒ Object



2507
2508
2509
# File 'lib/stripe/resources/subscription.rb', line 2507

def self.search_auto_paging_each(params = {}, opts = {}, &blk)
  search(params, opts).auto_paging_each(&blk)
end

.update(id, params = {}, opts = {}) ⇒ Object

Updates an existing subscription to match the specified parameters. When changing prices or quantities, we optionally prorate the price we charge next month to make up for any price changes. To preview how the proration is calculated, use the [create preview](stripe.com/docs/api/invoices/create_preview) endpoint.

By default, we prorate subscription changes. For example, if a customer signs up on May 1 for a 100 price, they’ll be billed 100 immediately. If on May 15 they switch to a 200 price, then on June 1 they’ll be billed 250 (200 for a renewal of her subscription, plus a 50 prorating adjustment for half of the previous month’s 100 difference). Similarly, a downgrade generates a credit that is applied to the next invoice. We also prorate when you make quantity changes.

Switching prices does not normally change the billing date or generate an immediate charge unless:

The billing interval is changed (for example, from monthly to yearly). The subscription moves from free to paid. A trial starts or ends.

In these cases, we apply a credit for the unused time on the previous price, immediately charge the customer using the new price, and reset the billing date. Learn about how [Stripe immediately attempts payment for subscription changes](stripe.com/docs/billing/subscriptions/upgrade-downgrade#immediate-payment).

If you want to charge for an upgrade immediately, pass proration_behavior as always_invoice to create prorations, automatically invoice the customer for those proration adjustments, and attempt to collect payment. If you pass create_prorations, the prorations are created but not automatically invoiced. If you want to bill the customer for the prorations before the subscription’s renewal date, you need to manually [invoice the customer](stripe.com/docs/api/invoices/create).

If you don’t want to prorate, set the proration_behavior option to none. With this option, the customer is billed 100 on May 1 and 200 on June 1. Similarly, if you set proration_behavior to none when switching between different billing intervals (for example, from monthly to yearly), we don’t generate any credits for the old subscription’s unused time. We still reset the billing date and bill immediately for the new subscription.

Updating the quantity on a subscription many times in an hour may result in [rate limiting. If you need to bill for a frequently changing quantity, consider integrating <a href=“/docs/billing/subscriptions/usage-based”>usage-based billing](stripe.com/docs/rate-limits) instead.



2532
2533
2534
2535
2536
2537
2538
2539
# File 'lib/stripe/resources/subscription.rb', line 2532

def self.update(id, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/subscriptions/%<id>s", { id: CGI.escape(id) }),
    params: params,
    opts: opts
  )
end

Instance Method Details

#cancel(params = {}, opts = {}) ⇒ Object

Cancels a customer’s subscription immediately. The customer won’t be charged again for the subscription. After it’s canceled, you can no longer update the subscription or its [metadata](stripe.com/metadata).

Any pending invoice items that you’ve created are still charged at the end of the period, unless manually [deleted](stripe.com/docs/api#delete_invoiceitem). If you’ve set the subscription to cancel at the end of the period, any pending prorations are also left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations are removed.

By default, upon subscription cancellation, Stripe stops automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all.



2419
2420
2421
2422
2423
2424
2425
2426
# File 'lib/stripe/resources/subscription.rb', line 2419

def cancel(params = {}, opts = {})
  request_stripe_object(
    method: :delete,
    path: format("/v1/subscriptions/%<subscription_exposed_id>s", { subscription_exposed_id: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#delete_discount(params = {}, opts = {}) ⇒ Object

Removes the currently applied discount on a subscription.



2454
2455
2456
2457
2458
2459
2460
2461
# File 'lib/stripe/resources/subscription.rb', line 2454

def delete_discount(params = {}, opts = {})
  request_stripe_object(
    method: :delete,
    path: format("/v1/subscriptions/%<subscription_exposed_id>s/discount", { subscription_exposed_id: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#resume(params = {}, opts = {}) ⇒ Object

Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor and creating prorations. If a resumption invoice is generated, it must be paid or marked uncollectible before the subscription will be unpaused. If payment succeeds the subscription will become active, and if payment fails the subscription will be past_due. The resumption invoice will void automatically if not paid by the expiration date.



2479
2480
2481
2482
2483
2484
2485
2486
# File 'lib/stripe/resources/subscription.rb', line 2479

def resume(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/subscriptions/%<subscription>s/resume", { subscription: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end