The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::API::Stripe::Billing::Subscription - A Stripe Subscription Object

SYNOPSIS

VERSION

    0.1.1

DESCRIPTION

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

CONSTRUCTOR

new( %ARG )

Creates a new Net::API::Stripe objects. It may also take an hash like arguments, that also are method of the same name.

verbose

Toggles verbose mode on/off

debug

Toggles debug mode on/off

METHODS

id string

Unique identifier for the object.

object string, value is "subscription"

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

application_fee_percent decimal

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

billing()
billing_cycle_anchor timestamp

Determines the date of the first full invoice, and, for plans with month or year intervals, the day of the month for subsequent invoices.

billing_thresholds hash

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

This is a Net::API::Stripe::Billing::Thresholds object.

amount_gte integer

Monetary threshold that triggers the subscription to create an invoice

reset_billing_cycle_anchor boolean

Indicates if the billing_cycle_anchor should be reset when a threshold is reached. If true, billing_cycle_anchor will be updated to the date/time the threshold was last reached; otherwise, the value will remain unchanged. This value may not be true if the subscription contains items with plans that have aggregate_usage=last_ever.

cancel_at timestamp

This is an undocumented property returned by Stripe, and I assume this is a duplicate to the canceled_at one.

This is added here, so returned data does not yield a warning, but obviously this should not be used otherwise.

According to Stripe support as of 2019-11-07, this is:

If the associated subscription has been set up to be canceled at a future date, the ‘cancel_at’ property is used to specify the future timestamp of when it will be canceled.

cancel_at_period_end boolean

If the subscription has been canceled with the at_period_end flag set to true, cancel_at_period_end on the subscription will be true. You can use this attribute to determine whether a subscription that has a status of active is scheduled to be canceled at the end of the current period.

canceled_at timestamp

If the subscription has been canceled, the date of that cancellation. If the subscription was canceled with cancel_at_period_end, canceled_at will still reflect the date of the initial cancellation request, not the end of the subscription period when the subscription is automatically moved to a canceled state.

collection_method string

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.

created timestamp

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

current_period_end timestamp

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

current_period_start timestamp

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

customer string (expandable)

ID of the customer who owns the subscription. When expanded, this is a Net::API::Stripe::Customer object.

days_until_due integer

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.

default_payment_method string (expandable)

ID of the default payment method for the subscription. It must belong to the customer associated with the subscription. If not set, invoices will use the default payment method in the customer’s invoice settings.

When expanded, this is a Net::API::Stripe::Payment::Method object.

default_source string (expandable)

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 not set, defaults to the customer’s default source.

When expanded, this is a Net::API::Stripe::Payment::Source object.

default_tax_rates array of hashes

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.

This is an array of Net::API::Stripe::Tax::Rate objects.

discount hash, discount object

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 is a Net::API::Stripe::Billing::Discount object.

ended_at timestamp

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

invoice_customer_balance_settings()
items list

List of subscription items, each with an attached plan.

This is a Net::API::Stripe::Billing::Subscription::Items object.

latest_invoice string (expandable)

The most recent invoice this subscription has generated.

When expanded, this is a Net::API::Stripe::Billing::Invoice object.

livemode boolean

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

metadata hash

Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.

next_pending_invoice_item_invoice

This is an undocumented property on Stripe, but found in its sample data.

This is managed with a virtual module Net::API::Billing::Subscription::Item::Invoice

pending_invoice_item_interval()
pending_setup_intent string (expandable)

You can use this SetupIntent 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.

When expanded, this is a Net::API::Stripe::Payment::Intent::Setup object.

pending_update() hash

If specified, pending updates that will be applied to the subscription once the latest_invoice has been paid.

billing_cycle_anchor timestamp

If the update is applied, determines the date of the first full invoice, and, for plans with month or year intervals, the day of the month for subsequent invoices.

expires_at timestamp

The point after which the changes reflected by this update will be discarded and no longer applied.

subscription_items array of hashes

List of subscription items (Net::APi::Stripe::Billing::Subscription::Item), each with an attached plan, that will be set if the update is applied.

trial_end timestamp

Unix timestamp representing the end of the trial period the customer will get before being charged for the first time, if the update is applied.

trial_from_plan boolean

Indicates if a plan’s trial_period_days should be applied to the subscription. Setting trial_end per subscription is preferred, and this defaults to false. Setting this flag to true together with trial_end is not allowed.

plan hash, plan object

Hash describing the plan the customer is subscribed to. Only set if the subscription contains a single plan.

This is a Net::API::Stripe::Billing::Plan object.

quantity integer

The quantity of the plan to which the customer is subscribed. For example, if your plan is $10/user/month, and your customer has 5 users, you could pass 5 as the quantity to have the customer charged $50 (5 x $10) monthly. Only set if the subscription contains a single plan.

schedule string expandable

The schedule attached to the subscription. When expanded, this is a Net::API::Stripe::Billing::Subscription::Schedule object.

start timestamp

Date of the last substantial change to this subscription. For example, a change to the items array, or a change of status, will reset this timestamp.

start_date timestamp

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

status string

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

For collection_method=charge_automatically a subscription moves into incomplete if the initial payment attempt fails. A subscription in this state can only have metadata and default_source updated. Once the first invoice is paid, the subscription moves into an active state. If the first invoice is not paid within 23 hours, the subscription transitions to incomplete_expired. This is a terminal state, 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.

If subscription collection_method=charge_automatically it becomes past_due when payment to renew it fails and canceled or unpaid (depending on your subscriptions settings) when Stripe has exhausted all payment retry attempts.

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.

tax_percent()
trial_end timestamp

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

trial_start timestamp

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

API SAMPLE

        {
          "id": "sub_EccdFNq60pUMDL",
          "object": "subscription",
          "application_fee_percent": null,
          "billing": "charge_automatically",
          "billing_cycle_anchor": 1551492959,
          "billing_thresholds": null,
          "cancel_at_period_end": false,
          "canceled_at": 1555726796,
          "collection_method": "charge_automatically",
          "created": 1551492959,
          "current_period_end": 1556763359,
          "current_period_start": 1554171359,
          "customer": "cus_EccdcylryhFDnC",
          "days_until_due": null,
          "default_payment_method": null,
          "default_source": null,
          "default_tax_rates": [],
          "discount": null,
          "ended_at": 1555726796,
          "items": {
                "object": "list",
                "data": [
                  {
                        "id": "si_Eccd4op26fXydB",
                        "object": "subscription_item",
                        "billing_thresholds": null,
                        "created": 1551492959,
                        "metadata": {},
                        "plan": {
                          "id": "professional-monthly-jpy",
                          "object": "plan",
                          "active": true,
                          "aggregate_usage": null,
                          "amount": 8000,
                          "amount_decimal": "8000",
                          "billing_scheme": "per_unit",
                          "created": 1541833564,
                          "currency": "jpy",
                          "interval": "month",
                          "interval_count": 1,
                          "livemode": false,
                          "metadata": {},
                          "nickname": null,
                          "product": "prod_Dwk1QNPjrMJlY8",
                          "tiers": null,
                          "tiers_mode": null,
                          "transform_usage": null,
                          "trial_period_days": null,
                          "usage_type": "licensed"
                        },
                        "quantity": 1,
                        "subscription": "sub_EccdFNq60pUMDL",
                        "tax_rates": []
                  }
                ],
                "has_more": false,
                "url": "/v1/subscription_items?subscription=sub_EccdFNq60pUMDL"
          },
          "latest_invoice": "in_1EKcARCeyNCl6fY2BaXPdnwG",
          "livemode": false,
          "metadata": {},
          "pending_setup_intent": null,
          "plan": {
                "id": "professional-monthly-jpy",
                "object": "plan",
                "active": true,
                "aggregate_usage": null,
                "amount": 8000,
                "amount_decimal": "8000",
                "billing_scheme": "per_unit",
                "created": 1541833564,
                "currency": "jpy",
                "interval": "month",
                "interval_count": 1,
                "livemode": false,
                "metadata": {},
                "nickname": null,
                "product": "prod_Dwk1QNPjrMJlY8",
                "tiers": null,
                "tiers_mode": null,
                "transform_usage": null,
                "trial_period_days": null,
                "usage_type": "licensed"
          },
          "quantity": 1,
          "start": 1554430777,
          "start_date": 1551492959,
          "status": "canceled",
          "tax_percent": null,
          "trial_end": null,
          "trial_start": null
        }

HISTORY

v0.1

Initial version

AUTHOR

Jacques Deguest <jack@deguest.jp>

SEE ALSO

Stripe API documentation:

https://stripe.com/docs/api/subscriptions, https://stripe.com/docs/billing/subscriptions/creating

COPYRIGHT & LICENSE

Copyright (c) 2018-2019 DEGUEST Pte. Ltd.

You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 150:

You forgot a '=back' before '=head1'