| 1 | ##---------------------------------------------------------------------------- | ||
| 2 | ## Stripe API - ~/lib/Net/API/Stripe/Billing/Subscription.pm | ||
| 3 | ## Version v0.300.1 | ||
| 4 | ## Copyright(c) 2020 DEGUEST Pte. Ltd. | ||
| 5 | ## Author: Jacques Deguest <@sitael.tokyo.deguest.jp> | ||
| 6 | ## Created 2019/11/02 | ||
| 7 | ## Modified 2020/05/16 | ||
| 8 | ## | ||
| 9 | ##---------------------------------------------------------------------------- | ||
| 10 | ## https://stripe.com/docs/api/subscriptions | ||
| 11 | package Net::API::Stripe::Billing::Subscription; | ||
| 12 | BEGIN | ||
| 13 | { | ||
| 14 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 1 | ▶ | use parent qw( Net::API::Stripe::Generic ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | 1 | ▶ | our( $VERSION ) = 'v0.300.1'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | }; | ||
| 18 | |||
| 19 | 0 | ▶ | sub id { return( shift->_set_get_scalar( 'id', @_ ) ); } |
|
Subroutine
id: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 20 | |||
| 21 | 0 | ▶ | sub object { return( shift->_set_get_scalar( 'object', @_ ) ); } |
|
Subroutine
object: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 22 | |||
| 23 | 0 | ▶ | sub application_fee_percent { return( shift->_set_get_number( 'application_fee_percent', @_ ) ); } |
|
Subroutine
application_fee_percent: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 24 | |||
| 25 | 0 | ▶ | sub backdate_start_date { return( shift->_set_get_datetime( 'backdate_start_date', @_ ) ); } |
|
Subroutine
backdate_start_date: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 26 | |||
| 27 | 0 | ▶ | sub billing { return( shift->_set_get_scalar( 'billing', @_ ) ); } |
|
Subroutine
billing: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 28 | |||
| 29 | 0 | ▶ | sub billing_cycle_anchor { return( shift->_set_get_datetime( 'billing_cycle_anchor', @_ ) ); } |
|
Subroutine
billing_cycle_anchor: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 30 | |||
| 31 | 0 | ▶ | sub billing_thresholds { return( shift->_set_get_object( 'billing_thresholds', 'Net::API::Stripe::Billing::Thresholds', @_ ) ); } |
|
Subroutine
billing_thresholds: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 32 | |||
| 33 | 0 | ▶ | sub cancel_at { return( shift->_set_get_datetime( 'cancel_at', @_ ) ); } |
|
Subroutine
cancel_at: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 34 | |||
| 35 | 0 | ▶ | sub cancel_at_period_end { return( shift->_set_get_boolean( 'cancel_at_period_end', @_ ) ); } |
|
Subroutine
cancel_at_period_end: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 36 | |||
| 37 | 0 | ▶ | sub canceled_at { return( shift->_set_get_datetime( 'canceled_at', @_ ) ); } |
|
Subroutine
canceled_at: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 38 | |||
| 39 | 0 | ▶ | sub collection_method { return( shift->_set_get_scalar( 'collection_method', @_ ) ); } |
|
Subroutine
collection_method: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 40 | |||
| 41 | 0 | ▶ | sub coupon { return( shift->_set_get_scalar( 'coupon', @_ ) ); } |
|
Subroutine
coupon: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 42 | |||
| 43 | 0 | ▶ | sub created { return( shift->_set_get_datetime( 'created', @_ ) ); } |
|
Subroutine
created: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 44 | |||
| 45 | 0 | ▶ | sub current_period_end { return( shift->_set_get_datetime( 'current_period_end', @_ ) ); } |
|
Subroutine
current_period_end: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 46 | |||
| 47 | 0 | ▶ | sub current_period_start { return( shift->_set_get_datetime( 'current_period_start', @_ ) ); } |
|
Subroutine
current_period_start: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 48 | |||
| 49 | 0 | ▶ | sub customer { return( shift->_set_get_scalar_or_object( 'customer', 'Net::API::Stripe::Customer', @_ ) ); } |
|
Subroutine
customer: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 50 | |||
| 51 | 0 | ▶ | sub days_until_due { return( shift->_set_get_number( 'days_until_due', @_ ) ); } |
|
Subroutine
days_until_due: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 52 | |||
| 53 | 0 | ▶ | sub default_payment_method { return( shift->_set_get_scalar_or_object( 'default_payment_method', 'Net::API::Stripe::Payment::Method', @_ ) ); } |
|
Subroutine
default_payment_method: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 54 | |||
| 55 | 0 | ▶ | sub default_source { return( shift->_set_get_scalar_or_object( 'default_source', 'Net::API::Stripe::Payment::Source', @_ ) ); } |
|
Subroutine
default_source: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 56 | |||
| 57 | 0 | ▶ | sub default_tax_rates { return( shift->_set_get_object_array( 'default_tax_rates', 'Net::API::Stripe::Tax::Rate', @_ ) ); } |
|
Subroutine
default_tax_rates: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 58 | |||
| 59 | 0 | ▶ | sub discount { return( shift->_set_get_object( 'discount', 'Net::API::Stripe::Billing::Discount', @_ ) ); } |
|
Subroutine
discount: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 60 | |||
| 61 | 0 | ▶ | sub ended_at { return( shift->_set_get_datetime( 'ended_at', @_ ) ); } |
|
Subroutine
ended_at: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 62 | |||
| 63 | ## To cancel subscriptions | ||
| 64 | 0 | ▶ | sub invoice_now { return( shift->_set_get_boolean( 'invoice_now', @_ ) ); } |
|
Subroutine
invoice_now: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 65 | |||
| 66 | 0 | ▶ | sub invoice_customer_balance_settings { return( shift->_set_get_hash_as_object( 'invoice_customer_balance_settings', 'Net::API::Stripe::Billing::Invoice::BalanceSettings', @_ ) ); } |
|
Subroutine
invoice_customer_balance_settings: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 67 | |||
| 68 | 0 | ▶ | sub items { return( shift->_set_get_object( 'items', 'Net::API::Stripe::Billing::Subscription::Items', @_ ) ); } |
|
Subroutine
items: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 69 | |||
| 70 | 0 | ▶ | sub latest_invoice { return( shift->_set_get_scalar_or_object( 'latest_invoice', 'Net::API::Stripe::Billing::Invoice', @_ ) ); } |
|
Subroutine
latest_invoice: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 71 | |||
| 72 | 0 | ▶ | sub livemode { return( shift->_set_get_boolean( 'livemode', @_ ) ); } |
|
Subroutine
livemode: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 73 | |||
| 74 | 0 | ▶ | sub metadata { return( shift->_set_get_hash( 'metadata', @_ ) ); } |
|
Subroutine
metadata: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 75 | |||
| 76 | 0 | ▶ | sub next_pending_invoice_item_invoice { return( shift->_set_get_hash_as_object( 'next_pending_invoice_item_invoice', 'Net::API::Billing::Subscription::Item::Invoice', @_ ) ); } |
|
Subroutine
next_pending_invoice_item_invoice: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 77 | |||
| 78 | 0 | ▶ | sub off_session { return( shift->_set_get_boolean( 'off_session', @_ ) ); } |
|
Subroutine
off_session: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 79 | |||
| 80 | sub pause_collection | ||
| 81 | { | ||
| 82 | 0 | ▶ | return( shift->_set_get_class( 'pause_collection', |
|
Subroutine
pause_collection: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 83 | { | ||
| 84 | behavior => { type => 'scalar' }, | ||
| 85 | resumes_at => { type => 'datetime' }, | ||
| 86 | }, @_ ) ); | ||
| 87 | } | ||
| 88 | |||
| 89 | 0 | ▶ | sub payment_behavior { return( shift->_set_get_scalar( 'payment_behavior', @_ ) ); } |
|
Subroutine
payment_behavior: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 90 | |||
| 91 | 0 | ▶ | sub pending_invoice_item_interval { return( shift->_set_get_object( 'pending_invoice_item_interval', 'Net::API::Stripe::Billing::Plan', @_ ) ); } |
|
Subroutine
pending_invoice_item_interval: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 92 | |||
| 93 | 0 | ▶ | sub pending_setup_intent { return( shift->_set_get_scalar_or_object( 'pending_setup_intent', 'Net::API::Stripe::Payment::Intent::Setup', @_ ) ); } |
|
Subroutine
pending_setup_intent: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 94 | |||
| 95 | sub pending_update | ||
| 96 | { | ||
| 97 | 0 | ▶ | return( shift->_set_get_class( 'pending_update', |
|
Subroutine
pending_update: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 98 | { | ||
| 99 | billing_cycle_anchor => { type => 'datetime' }, | ||
| 100 | expires_at => { type => 'datetime' }, | ||
| 101 | subscription_items => { type => 'object_array_object', class => 'Net::API::Stripe::Billing::Subscription::Item' }, | ||
| 102 | trial_end => { type => 'datetime' }, | ||
| 103 | trial_from_plan => { type => 'boolean' }, | ||
| 104 | }, @_ ) ); | ||
| 105 | } | ||
| 106 | |||
| 107 | 0 | ▶ | sub plan { return( shift->_set_get_object( 'plan', 'Net::API::Stripe::Billing::Plan', @_ ) ); } |
|
Subroutine
plan: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 108 | |||
| 109 | 0 | ▶ | sub prorate { return( shift->_set_get_boolean( 'prorate', @_ ) ); } |
|
Subroutine
prorate: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 110 | |||
| 111 | 0 | ▶ | sub proration_behavior { return( shift->_set_get_scalar( 'proration_behavior', @_ ) ); } |
|
Subroutine
proration_behavior: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 112 | |||
| 113 | 0 | ▶ | sub quantity { return( shift->_set_get_number( 'quantity', @_ ) ); } |
|
Subroutine
quantity: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 114 | |||
| 115 | 0 | ▶ | sub schedule { return( shift->_set_get_scalar_or_object( 'schedule', 'Net::API::Stripe::Billing::Subscription::Schedule', @_ ) ); } |
|
Subroutine
schedule: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 116 | |||
| 117 | 0 | ▶ | sub start { return( shift->_set_get_datetime( 'start', @_ ) ); } |
|
Subroutine
start: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 118 | |||
| 119 | 0 | ▶ | sub start_date { return( shift->_set_get_datetime( 'start_date', @_ ) ); } |
|
Subroutine
start_date: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 120 | |||
| 121 | 0 | ▶ | sub status { return( shift->_set_get_scalar( 'status', @_ ) ); } |
|
Subroutine
status: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 122 | |||
| 123 | 0 | ▶ | sub tax_percent { return( shift->_set_get_number( 'tax_percent', @_ ) ); } |
|
Subroutine
tax_percent: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 124 | |||
| 125 | 0 | ▶ | sub trial_end { return( shift->_set_get_datetime( 'trial_end', @_ ) ); } |
|
Subroutine
trial_end: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 126 | |||
| 127 | 0 | ▶ | sub trial_from_plan { return( shift->_set_get_boolean( 'trial_from_plan', @_ ) ); } |
|
Subroutine
trial_from_plan: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 128 | |||
| 129 | 0 | ▶ | sub trial_period_days { return( shift->_set_get_number( 'trial_period_days', @_ ) ); } |
|
Subroutine
trial_period_days: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 130 | |||
| 131 | 0 | ▶ | sub trial_start { return( shift->_set_get_datetime( 'trial_start', @_ ) ); } |
|
Subroutine
trial_start: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 132 | |||
| 133 | 1 | 1; | |
| 134 | |||
| 135 | __END__ | ||
| 136 | |||
| 137 | =encoding utf8 | ||
| 138 | |||
| 139 | =head1 NAME | ||
| 140 | |||
| 141 | Net::API::Stripe::Billing::Subscription - A Stripe Subscription Object | ||
| 142 | |||
| 143 | =head1 SYNOPSIS | ||
| 144 | |||
| 145 | my $sub = $stripe->subscription({ | ||
| 146 | application_fee_percent => 2, | ||
| 147 | # Could also be a unix timestamp | ||
| 148 | backdate_start_date => '2020-01-01', | ||
| 149 | billing_cycle_anchor => '2020-04-01', | ||
| 150 | coupon => 'SUMMER10POFF', | ||
| 151 | current_period_end => '2020-06-30', | ||
| 152 | customer => $cust_object, | ||
| 153 | days_until_due => 7, | ||
| 154 | default_payment_method => 'pm_fake123456789', | ||
| 155 | metadata => { transaction_id => 1212, customer_id => 123 }, | ||
| 156 | off_session => $stripe->true, | ||
| 157 | payment_behavior => 'error_if_incomplete', | ||
| 158 | plan => $plan_object, | ||
| 159 | quantity => 1, | ||
| 160 | }); | ||
| 161 | |||
| 162 | =head1 VERSION | ||
| 163 | |||
| 164 | v0.300.1 | ||
| 165 | |||
| 166 | =head1 DESCRIPTION | ||
| 167 | |||
| 168 | Subscriptions allow you to charge a customer on a recurring basis. | ||
| 169 | |||
| 170 | =head1 CONSTRUCTOR | ||
| 171 | |||
| 172 | =over 4 | ||
| 173 | |||
| 174 | =item B<new>( %ARG ) | ||
| 175 | |||
| 176 | Creates a new L<Net::API::Stripe::Billing::Subscription> object. | ||
| 177 | It may also take an hash like arguments, that also are method of the same name. | ||
| 178 | |||
| 179 | =back | ||
| 180 | |||
| 181 | =head1 METHODS | ||
| 182 | |||
| 183 | =over 4 | ||
| 184 | |||
| 185 | =item B<id> string | ||
| 186 | |||
| 187 | Unique identifier for the object. | ||
| 188 | |||
| 189 | =item B<object> string, value is "subscription" | ||
| 190 | |||
| 191 | String representing the object’s type. Objects of the same type share the same value. | ||
| 192 | |||
| 193 | =item B<application_fee_percent> decimal | ||
| 194 | |||
| 195 | 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. | ||
| 196 | |||
| 197 | =item B<backdate_start_date> | ||
| 198 | |||
| 199 | For new subscriptions, a past timestamp to backdate the subscription’s start date to. If set, the first invoice will contain a proration for the timespan between the start date and the current time. Can be combined with trials and the billing cycle anchor. | ||
| 200 | |||
| 201 | =item B<billing>() | ||
| 202 | |||
| 203 | =item B<billing_cycle_anchor> timestamp | ||
| 204 | |||
| 205 | Determines the date of the first full invoice, and, for plans with month or year intervals, the day of the month for subsequent invoices. | ||
| 206 | |||
| 207 | =item B<billing_thresholds> hash | ||
| 208 | |||
| 209 | Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period | ||
| 210 | |||
| 211 | This is a L<Net::API::Stripe::Billing::Thresholds> object. | ||
| 212 | |||
| 213 | =over 8 | ||
| 214 | |||
| 215 | =item B<amount_gte> integer | ||
| 216 | |||
| 217 | Monetary threshold that triggers the subscription to create an invoice | ||
| 218 | |||
| 219 | =item B<reset_billing_cycle_anchor> boolean | ||
| 220 | |||
| 221 | 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. | ||
| 222 | |||
| 223 | =back | ||
| 224 | |||
| 225 | =item B<cancel_at> timestamp | ||
| 226 | |||
| 227 | This is an undocumented property returned by Stripe, and I assume this is a duplicate to the B<canceled_at> one. | ||
| 228 | |||
| 229 | This is added here, so returned data does not yield a warning, but obviously this should not be used otherwise. | ||
| 230 | |||
| 231 | According to Stripe support as of 2019-11-07, this is: | ||
| 232 | |||
| 233 | 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. | ||
| 234 | |||
| 235 | =item B<cancel_at_period_end> boolean | ||
| 236 | |||
| 237 | 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. | ||
| 238 | |||
| 239 | =item B<canceled_at> timestamp | ||
| 240 | |||
| 241 | 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. | ||
| 242 | |||
| 243 | =item B<collection_method> string | ||
| 244 | |||
| 245 | 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. | ||
| 246 | |||
| 247 | =item B<coupon> string | ||
| 248 | |||
| 249 | The code of the coupon to apply to this subscription. A coupon applied to a subscription will only affect invoices created for that particular subscription. | ||
| 250 | |||
| 251 | =item B<created> timestamp | ||
| 252 | |||
| 253 | Time at which the object was created. Measured in seconds since the Unix epoch. | ||
| 254 | |||
| 255 | =item B<current_period_end> timestamp | ||
| 256 | |||
| 257 | End of the current period that the subscription has been invoiced for. At the end of this period, a new invoice will be created. | ||
| 258 | |||
| 259 | =item B<current_period_start> timestamp | ||
| 260 | |||
| 261 | Start of the current period that the subscription has been invoiced for. | ||
| 262 | |||
| 263 | =item B<customer> string (expandable) | ||
| 264 | |||
| 265 | ID of the customer who owns the subscription. When expanded, this is a L<Net::API::Stripe::Customer> object. | ||
| 266 | |||
| 267 | =item B<days_until_due> integer | ||
| 268 | |||
| 269 | 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. | ||
| 270 | |||
| 271 | =item B<default_payment_method> string (expandable) | ||
| 272 | |||
| 273 | 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. | ||
| 274 | |||
| 275 | When expanded, this is a L<Net::API::Stripe::Payment::Method> object. | ||
| 276 | |||
| 277 | =item B<default_source> string (expandable) | ||
| 278 | |||
| 279 | 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. | ||
| 280 | |||
| 281 | When expanded, this is a L<Net::API::Stripe::Payment::Source> object. | ||
| 282 | |||
| 283 | =item B<default_tax_rates> array of hashes | ||
| 284 | |||
| 285 | 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. | ||
| 286 | |||
| 287 | This is an array of L<Net::API::Stripe::Tax::Rate> objects. | ||
| 288 | |||
| 289 | =item B<discount> hash, discount object | ||
| 290 | |||
| 291 | 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. | ||
| 292 | |||
| 293 | This is a L<Net::API::Stripe::Billing::Discount> object. | ||
| 294 | |||
| 295 | =item B<ended_at> timestamp | ||
| 296 | |||
| 297 | If the subscription has ended, the date the subscription ended. | ||
| 298 | |||
| 299 | =item B<invoice_now> boolean | ||
| 300 | |||
| 301 | Will generate a final invoice that invoices for any un-invoiced metered usage and new/pending proration invoice items. | ||
| 302 | |||
| 303 | This is used to cancel a subscription. See here: L<https://stripe.com/docs/api/subscriptions/cancel> | ||
| 304 | |||
| 305 | =item B<invoice_customer_balance_settings>() | ||
| 306 | |||
| 307 | =item B<items> list | ||
| 308 | |||
| 309 | List of subscription items, each with an attached plan. | ||
| 310 | |||
| 311 | This is a L<Net::API::Stripe::Billing::Subscription::Items> object. | ||
| 312 | |||
| 313 | =item B<latest_invoice> string (expandable) | ||
| 314 | |||
| 315 | The most recent invoice this subscription has generated. | ||
| 316 | |||
| 317 | When expanded, this is a L<Net::API::Stripe::Billing::Invoice> object. | ||
| 318 | |||
| 319 | =item B<livemode> boolean | ||
| 320 | |||
| 321 | Has the value true if the object exists in live mode or the value false if the object exists in test mode. | ||
| 322 | |||
| 323 | =item B<metadata> hash | ||
| 324 | |||
| 325 | 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. | ||
| 326 | |||
| 327 | =item B<next_pending_invoice_item_invoice> | ||
| 328 | |||
| 329 | This is an undocumented property on Stripe, but found in its sample data. | ||
| 330 | |||
| 331 | This is managed with a virtual module L<Net::API::Billing::Subscription::Item::Invoice> | ||
| 332 | |||
| 333 | =item B<pause_collection> hash | ||
| 334 | |||
| 335 | If specified, payment collection for this subscription will be paused. | ||
| 336 | |||
| 337 | =over 8 | ||
| 338 | |||
| 339 | =item I<pause_collection.behavior> string | ||
| 340 | |||
| 341 | The payment collection behavior for this subscription while paused. One of keep_as_draft, mark_uncollectible, or void. | ||
| 342 | |||
| 343 | =item I<resumes_at> timestamp | ||
| 344 | |||
| 345 | The time after which the subscription will resume collecting payments. | ||
| 346 | |||
| 347 | =back | ||
| 348 | |||
| 349 | =item B<off_session> boolean | ||
| 350 | |||
| 351 | Indicates if a customer is on or off-session while an invoice payment is attempted. | ||
| 352 | |||
| 353 | =item B<payment_behavior> string | ||
| 354 | |||
| 355 | Use I<allow_incomplete> to create subscriptions with status=incomplete if the first invoice cannot be paid. Creating subscriptions with this status allows you to manage scenarios where additional user actions are needed to pay a subscription’s invoice. For example, SCA regulation may require 3DS authentication to complete payment. See the SCA Migration Guide for Billing to learn more. This is the default behavior. | ||
| 356 | |||
| 357 | Use I<error_if_incomplete> if you want Stripe to return an HTTP 402 status code if a subscription’s first invoice cannot be paid. For example, if a payment method requires 3DS authentication due to SCA regulation and further user action is needed, this parameter does not create a subscription and returns an error instead. This was the default behavior for API versions prior to 2019-03-14. See the changelog to learn more. | ||
| 358 | |||
| 359 | I<pending_if_incomplete> is only used with updates and cannot be passed when creating a subscription. | ||
| 360 | Possible enum values | ||
| 361 | |||
| 362 | =over 8 | ||
| 363 | |||
| 364 | =item I<allow_incomplete> | ||
| 365 | |||
| 366 | =item I<error_if_incomplete> | ||
| 367 | |||
| 368 | =item I<pending_if_incomplete> | ||
| 369 | |||
| 370 | =back | ||
| 371 | |||
| 372 | =item B<pending_invoice_item_interval>() | ||
| 373 | |||
| 374 | Specifies an interval for how often to bill for any pending invoice items. It is analogous to calling Create an invoice for the given subscription at the specified interval. | ||
| 375 | |||
| 376 | =over 8 | ||
| 377 | |||
| 378 | =item I<interval> required | ||
| 379 | |||
| 380 | Specifies invoicing frequency. Either day, week, month or year. | ||
| 381 | |||
| 382 | =item I<interval_count> optional | ||
| 383 | |||
| 384 | The number of intervals between invoices. For example, interval=month and interval_count=3 bills every 3 months. Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). | ||
| 385 | |||
| 386 | =back | ||
| 387 | |||
| 388 | =item B<pending_setup_intent> string (expandable) | ||
| 389 | |||
| 390 | 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. | ||
| 391 | |||
| 392 | When expanded, this is a L<Net::API::Stripe::Payment::Intent::Setup> object. | ||
| 393 | |||
| 394 | =item B<pending_update>() hash | ||
| 395 | |||
| 396 | If specified, pending updates that will be applied to the subscription once the latest_invoice has been paid. | ||
| 397 | |||
| 398 | =over 8 | ||
| 399 | |||
| 400 | =item I<billing_cycle_anchor> timestamp | ||
| 401 | |||
| 402 | 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. | ||
| 403 | |||
| 404 | =item I<expires_at> timestamp | ||
| 405 | |||
| 406 | The point after which the changes reflected by this update will be discarded and no longer applied. | ||
| 407 | |||
| 408 | =item I<subscription_items> array of hashes | ||
| 409 | |||
| 410 | List of subscription items (L<Net::APi::Stripe::Billing::Subscription::Item>), each with an attached plan, that will be set if the update is applied. | ||
| 411 | |||
| 412 | =item I<trial_end> timestamp | ||
| 413 | |||
| 414 | 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. | ||
| 415 | |||
| 416 | =item I<trial_from_plan> boolean | ||
| 417 | |||
| 418 | 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. | ||
| 419 | |||
| 420 | =back | ||
| 421 | |||
| 422 | =item B<plan> hash, plan object | ||
| 423 | |||
| 424 | Hash describing the plan the customer is subscribed to. Only set if the subscription contains a single plan. | ||
| 425 | |||
| 426 | This is a L<Net::API::Stripe::Billing::Plan> object. | ||
| 427 | |||
| 428 | =item B<prorate> boolean (deprecated) | ||
| 429 | |||
| 430 | Boolean (defaults to true) telling us whether to credit for unused time when the billing cycle changes (e.g. when switching plans, resetting billing_cycle_anchor=now, or starting a trial), or if an item’s quantity changes. If false, the anchor period will be free (similar to a trial) and no proration adjustments will be created. This field has been deprecated and will be removed in a future API version. Use proration_behavior=create_prorations as a replacement for prorate=true and proration_behavior=none for prorate=false. | ||
| 431 | |||
| 432 | =item B<proration_behavior> string | ||
| 433 | |||
| 434 | Determines how to handle prorations resulting from the billing_cycle_anchor. Valid values are I<create_prorations> or I<none>. | ||
| 435 | |||
| 436 | Passing I<create_prorations> will cause proration invoice items to be created when applicable. Prorations can be disabled by passing I<none>. If no value is passed, the default is create_prorations. | ||
| 437 | |||
| 438 | =item B<quantity> integer | ||
| 439 | |||
| 440 | 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. | ||
| 441 | |||
| 442 | =item B<schedule> string expandable | ||
| 443 | |||
| 444 | The schedule attached to the subscription. When expanded, this is a L<Net::API::Stripe::Billing::Subscription::Schedule> object. | ||
| 445 | |||
| 446 | =item B<start> timestamp | ||
| 447 | |||
| 448 | 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. | ||
| 449 | |||
| 450 | =item B<start_date> timestamp | ||
| 451 | |||
| 452 | Date when the subscription was first created. The date might differ from the created date due to backdating. | ||
| 453 | |||
| 454 | =item B<status> string | ||
| 455 | |||
| 456 | Possible values are incomplete, incomplete_expired, trialing, active, past_due, canceled, or unpaid. | ||
| 457 | |||
| 458 | 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. | ||
| 459 | |||
| 460 | A subscription that is currently in a trial period is trialing and moves to active when the trial period is over. | ||
| 461 | |||
| 462 | 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. | ||
| 463 | |||
| 464 | 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. | ||
| 465 | |||
| 466 | =item B<tax_percent> decimal (deprecated) | ||
| 467 | |||
| 468 | A non-negative decimal (with at most four decimal places) between 0 and 100. This represents the percentage of the subscription invoice subtotal that will be calculated and added as tax to the final amount in each billing period. For example, a plan which charges $10/month with a tax_percent of 20.0 will charge $12 per invoice. To unset a previously-set value, pass an empty string. This field has been deprecated and will be removed in a future API version, for further information view the migration docs for tax_rates. | ||
| 469 | |||
| 470 | =item B<trial_end> timestamp | ||
| 471 | |||
| 472 | If the subscription has a trial, the end of that trial. | ||
| 473 | |||
| 474 | =item B<trial_from_plan> boolean | ||
| 475 | |||
| 476 | 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. | ||
| 477 | |||
| 478 | =item B<trial_period_days> integer | ||
| 479 | |||
| 480 | Integer representing the number of trial period days before the customer is charged for the first time. This will always overwrite any trials that might apply via a subscribed plan. | ||
| 481 | |||
| 482 | =item B<trial_start> timestamp | ||
| 483 | |||
| 484 | If the subscription has a trial, the beginning of that trial. | ||
| 485 | |||
| 486 | =back | ||
| 487 | |||
| 488 | =head1 API SAMPLE | ||
| 489 | |||
| 490 | { | ||
| 491 | "id": "sub_fake123456789", | ||
| 492 | "object": "subscription", | ||
| 493 | "application_fee_percent": null, | ||
| 494 | "billing": "charge_automatically", | ||
| 495 | "billing_cycle_anchor": 1551492959, | ||
| 496 | "billing_thresholds": null, | ||
| 497 | "cancel_at_period_end": false, | ||
| 498 | "canceled_at": 1555726796, | ||
| 499 | "collection_method": "charge_automatically", | ||
| 500 | "created": 1551492959, | ||
| 501 | "current_period_end": 1556763359, | ||
| 502 | "current_period_start": 1554171359, | ||
| 503 | "customer": "cus_fake123456789", | ||
| 504 | "days_until_due": null, | ||
| 505 | "default_payment_method": null, | ||
| 506 | "default_source": null, | ||
| 507 | "default_tax_rates": [], | ||
| 508 | "discount": null, | ||
| 509 | "ended_at": 1555726796, | ||
| 510 | "items": { | ||
| 511 | "object": "list", | ||
| 512 | "data": [ | ||
| 513 | { | ||
| 514 | "id": "si_fake123456789", | ||
| 515 | "object": "subscription_item", | ||
| 516 | "billing_thresholds": null, | ||
| 517 | "created": 1551492959, | ||
| 518 | "metadata": {}, | ||
| 519 | "plan": { | ||
| 520 | "id": "professional-monthly-jpy", | ||
| 521 | "object": "plan", | ||
| 522 | "active": true, | ||
| 523 | "aggregate_usage": null, | ||
| 524 | "amount": 8000, | ||
| 525 | "amount_decimal": "8000", | ||
| 526 | "billing_scheme": "per_unit", | ||
| 527 | "created": 1541833564, | ||
| 528 | "currency": "jpy", | ||
| 529 | "interval": "month", | ||
| 530 | "interval_count": 1, | ||
| 531 | "livemode": false, | ||
| 532 | "metadata": {}, | ||
| 533 | "nickname": null, | ||
| 534 | "product": "prod_fake123456789", | ||
| 535 | "tiers": null, | ||
| 536 | "tiers_mode": null, | ||
| 537 | "transform_usage": null, | ||
| 538 | "trial_period_days": null, | ||
| 539 | "usage_type": "licensed" | ||
| 540 | }, | ||
| 541 | "quantity": 1, | ||
| 542 | "subscription": "sub_fake123456789", | ||
| 543 | "tax_rates": [] | ||
| 544 | } | ||
| 545 | ], | ||
| 546 | "has_more": false, | ||
| 547 | "url": "/v1/subscription_items?subscription=sub_fake123456789" | ||
| 548 | }, | ||
| 549 | "latest_invoice": "in_fake123456789", | ||
| 550 | "livemode": false, | ||
| 551 | "metadata": {}, | ||
| 552 | "pending_setup_intent": null, | ||
| 553 | "plan": { | ||
| 554 | "id": "professional-monthly-jpy", | ||
| 555 | "object": "plan", | ||
| 556 | "active": true, | ||
| 557 | "aggregate_usage": null, | ||
| 558 | "amount": 8000, | ||
| 559 | "amount_decimal": "8000", | ||
| 560 | "billing_scheme": "per_unit", | ||
| 561 | "created": 1541833564, | ||
| 562 | "currency": "jpy", | ||
| 563 | "interval": "month", | ||
| 564 | "interval_count": 1, | ||
| 565 | "livemode": false, | ||
| 566 | "metadata": {}, | ||
| 567 | "nickname": null, | ||
| 568 | "product": "prod_fake123456789", | ||
| 569 | "tiers": null, | ||
| 570 | "tiers_mode": null, | ||
| 571 | "transform_usage": null, | ||
| 572 | "trial_period_days": null, | ||
| 573 | "usage_type": "licensed" | ||
| 574 | }, | ||
| 575 | "quantity": 1, | ||
| 576 | "start": 1554430777, | ||
| 577 | "start_date": 1551492959, | ||
| 578 | "status": "canceled", | ||
| 579 | "tax_percent": null, | ||
| 580 | "trial_end": null, | ||
| 581 | "trial_start": null | ||
| 582 | } | ||
| 583 | |||
| 584 | =head1 HISTORY | ||
| 585 | |||
| 586 | =head2 v0.1 | ||
| 587 | |||
| 588 | Initial version | ||
| 589 | |||
| 590 | =head1 AUTHOR | ||
| 591 | |||
| 592 | Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> | ||
| 593 | |||
| 594 | =head1 SEE ALSO | ||
| 595 | |||
| 596 | Stripe API documentation: | ||
| 597 | |||
| 598 | L<https://stripe.com/docs/api/subscriptions>, L<https://stripe.com/docs/billing/subscriptions/creating> | ||
| 599 | |||
| 600 | =head1 COPYRIGHT & LICENSE | ||
| 601 | |||
| 602 | Copyright (c) 2020 DEGUEST Pte. Ltd. | ||
| 603 | |||
| 604 | You can use, copy, modify and redistribute this package and associated | ||
| 605 | files under the same terms as Perl itself. | ||
| 606 | |||
| 607 | =cut | ||