Class: AdvancedBilling::Subscription
- Defined in:
- lib/advanced_billing/models/subscription.rb
Overview
Subscription Model.
Instance Attribute Summary collapse
-
#activated_at ⇒ String
Timestamp for when the subscription began (i.e. when it came out of trial, or when it began in the case of no trial).
-
#automatically_resume_at ⇒ String
The date the subscription is scheduled to automatically resume from the on_hold state.
-
#balance_in_cents ⇒ Integer
Gives the current outstanding subscription balance in the number of cents.
-
#bank_account ⇒ SubscriptionBankAccount
The day of the month that the subscription will charge according to calendar billing rules, if used.
-
#cancel_at_end_of_period ⇒ TrueClass | FalseClass
Whether or not the subscription will (or has) canceled at the end of the period.
-
#canceled_at ⇒ String
The timestamp of the most recent cancellation.
-
#cancellation_message ⇒ String
Seller-provided reason for, or note about, the cancellation.
-
#cancellation_method ⇒ CancellationMethod
The process used to cancel the subscription, if the subscription has been canceled.
-
#coupon_code ⇒ String
(deprecated) The coupon code of the single coupon currently applied to the subscription.
-
#coupon_codes ⇒ Array[String]
An array for all the coupons attached to the subscription.
-
#coupon_use_count ⇒ Integer
(deprecated) How many times the subscription’s single coupon has been used.
-
#coupon_uses_allowed ⇒ Integer
(deprecated) How many times the subscription’s single coupon may be used.
-
#coupons ⇒ Array[SubscriptionIncludedCoupon]
Additional coupon data.
-
#created_at ⇒ String
The creation date for this subscription.
-
#credit_balance_in_cents ⇒ Integer
Time zone for the Dunning Communication Delay feature.
-
#credit_card ⇒ PaymentProfile
The day of the month that the subscription will charge according to calendar billing rules, if used.
-
#currency ⇒ String
Time zone for the Dunning Communication Delay feature.
-
#current_billing_amount_in_cents ⇒ Integer
The balance in cents plus the estimated renewal amount in cents.
-
#current_period_ends_at ⇒ String
Timestamp relating to the end of the current (recurring) period (i.e.,when the next regularly scheduled attempted charge will occur).
-
#current_period_started_at ⇒ String
Timestamp relating to the start of the current (recurring) period.
-
#customer ⇒ Customer
The day of the month that the subscription will charge according to calendar billing rules, if used.
-
#delayed_cancel_at ⇒ String
Timestamp for when the subscription is currently set to cancel.
-
#dunning_communication_delay_enabled ⇒ TrueClass | FalseClass
Enable Communication Delay feature, making sure no communication (email or SMS) is sent to the Customer between 9PM and 8AM in time zone set by the ‘dunning_communication_delay_time_zone` attribute.
-
#dunning_communication_delay_time_zone ⇒ String
Time zone for the Dunning Communication Delay feature.
-
#expires_at ⇒ String
Timestamp giving the expiration date of this subscription (if any).
-
#group ⇒ SubscriptionGroupInlined
The day of the month that the subscription will charge according to calendar billing rules, if used.
-
#id ⇒ Integer
The subscription unique id within Chargify.
-
#locale ⇒ String
Time zone for the Dunning Communication Delay feature.
-
#net_terms ⇒ Integer
On Relationship Invoicing, the number of days before a renewal invoice is due.
-
#next_assessment_at ⇒ String
Timestamp that indicates when capture of payment will be tried or,retried.
-
#next_product_handle ⇒ String
If a delayed product change is scheduled, the handle of the product that the subscription will be changed to at the next renewal.
-
#next_product_id ⇒ Integer
If a delayed product change is scheduled, the ID of the product that the subscription will be changed to at the next renewal.
-
#next_product_price_point_id ⇒ Integer
If a delayed product change is scheduled, the ID of the product price point that the subscription will be changed to at the next renewal.
-
#offer_id ⇒ Integer
The ID of the offer associated with the subscription.
-
#on_hold_at ⇒ String
The timestamp of the most recent on hold action.
-
#payer_id ⇒ Integer
On Relationship Invoicing, the ID of the individual paying for the subscription.
-
#payment_collection_method ⇒ PaymentCollectionMethod
The day of the month that the subscription will charge according to calendar billing rules, if used.
-
#payment_type ⇒ String
The payment profile type for the active profile on file.
-
#prepaid_dunning ⇒ TrueClass | FalseClass
Boolean representing whether the subscription is prepaid and currently in dunning.
-
#prepayment_balance_in_cents ⇒ Integer
Time zone for the Dunning Communication Delay feature.
-
#previous_state ⇒ String
Only valid for webhook payloads The previous state for webhooks that have indicated a change in state.
-
#product ⇒ Product
The day of the month that the subscription will charge according to calendar billing rules, if used.
-
#product_price_in_cents ⇒ Integer
(Added Nov 5 2013) The recurring amount of the product (and version),currently subscribed.
-
#product_price_point_id ⇒ Integer
The product price point currently subscribed to.
-
#product_price_point_type ⇒ String
One of the following: custom, default, catalog.
-
#product_version_number ⇒ Integer
The version of the product for the subscription.
-
#reason_code ⇒ String
If the subscription is canceled, this is their churn code.
-
#receives_invoice_emails ⇒ TrueClass | FalseClass
Time zone for the Dunning Communication Delay feature.
-
#reference ⇒ String
The reference value (provided by your app) for the subscription itelf.
-
#referral_code ⇒ String
The subscription’s unique code that can be given to referrals.
-
#scheduled_cancellation_at ⇒ String
Time zone for the Dunning Communication Delay feature.
-
#signup_payment_id ⇒ Integer
The ID of the transaction that generated the revenue.
-
#signup_revenue ⇒ String
The revenue, formatted as a string of decimal separated dollars and,cents, from the subscription signup ($50.00 would be formatted as,50.00).
-
#snap_day ⇒ String
The day of the month that the subscription will charge according to calendar billing rules, if used.
-
#state ⇒ String
The current state of the subscription.
-
#stored_credential_transaction_id ⇒ Integer
For European sites subject to PSD2 and using 3D Secure, this can be used to reference a previous transaction for the customer.
-
#total_revenue_in_cents ⇒ Integer
Gives the total revenue from the subscription in the number of cents.
-
#trial_ended_at ⇒ String
Timestamp for when the trial period (if any) ended.
-
#trial_started_at ⇒ String
Timestamp for when the trial period (if any) began.
-
#updated_at ⇒ String
The date of last update for this subscription.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
Methods inherited from BaseModel
Constructor Details
#initialize(id = SKIP, state = SKIP, balance_in_cents = SKIP, total_revenue_in_cents = SKIP, product_price_in_cents = SKIP, product_version_number = SKIP, current_period_ends_at = SKIP, next_assessment_at = SKIP, trial_started_at = SKIP, trial_ended_at = SKIP, activated_at = SKIP, expires_at = SKIP, created_at = SKIP, updated_at = SKIP, cancellation_message = SKIP, cancellation_method = SKIP, cancel_at_end_of_period = SKIP, canceled_at = SKIP, current_period_started_at = SKIP, previous_state = SKIP, signup_payment_id = SKIP, signup_revenue = SKIP, delayed_cancel_at = SKIP, coupon_code = SKIP, snap_day = SKIP, payment_collection_method = SKIP, customer = SKIP, product = SKIP, credit_card = SKIP, group = SKIP, bank_account = SKIP, payment_type = SKIP, referral_code = SKIP, next_product_id = SKIP, next_product_handle = SKIP, coupon_use_count = SKIP, coupon_uses_allowed = SKIP, reason_code = SKIP, automatically_resume_at = SKIP, coupon_codes = SKIP, offer_id = SKIP, payer_id = SKIP, current_billing_amount_in_cents = SKIP, product_price_point_id = SKIP, product_price_point_type = SKIP, next_product_price_point_id = SKIP, net_terms = SKIP, stored_credential_transaction_id = SKIP, reference = SKIP, on_hold_at = SKIP, prepaid_dunning = SKIP, coupons = SKIP, dunning_communication_delay_enabled = false, dunning_communication_delay_time_zone = SKIP, receives_invoice_emails = SKIP, locale = SKIP, currency = SKIP, scheduled_cancellation_at = SKIP, credit_balance_in_cents = SKIP, prepayment_balance_in_cents = SKIP) ⇒ Subscription
Returns a new instance of Subscription.
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 |
# File 'lib/advanced_billing/models/subscription.rb', line 469 def initialize(id = SKIP, state = SKIP, balance_in_cents = SKIP, total_revenue_in_cents = SKIP, product_price_in_cents = SKIP, product_version_number = SKIP, current_period_ends_at = SKIP, next_assessment_at = SKIP, trial_started_at = SKIP, trial_ended_at = SKIP, activated_at = SKIP, expires_at = SKIP, created_at = SKIP, updated_at = SKIP, = SKIP, cancellation_method = SKIP, cancel_at_end_of_period = SKIP, canceled_at = SKIP, current_period_started_at = SKIP, previous_state = SKIP, signup_payment_id = SKIP, signup_revenue = SKIP, delayed_cancel_at = SKIP, coupon_code = SKIP, snap_day = SKIP, payment_collection_method = SKIP, customer = SKIP, product = SKIP, credit_card = SKIP, group = SKIP, bank_account = SKIP, payment_type = SKIP, referral_code = SKIP, next_product_id = SKIP, next_product_handle = SKIP, coupon_use_count = SKIP, coupon_uses_allowed = SKIP, reason_code = SKIP, automatically_resume_at = SKIP, coupon_codes = SKIP, offer_id = SKIP, payer_id = SKIP, current_billing_amount_in_cents = SKIP, product_price_point_id = SKIP, product_price_point_type = SKIP, next_product_price_point_id = SKIP, net_terms = SKIP, stored_credential_transaction_id = SKIP, reference = SKIP, on_hold_at = SKIP, prepaid_dunning = SKIP, coupons = SKIP, dunning_communication_delay_enabled = false, dunning_communication_delay_time_zone = SKIP, receives_invoice_emails = SKIP, locale = SKIP, currency = SKIP, scheduled_cancellation_at = SKIP, credit_balance_in_cents = SKIP, prepayment_balance_in_cents = SKIP) @id = id unless id == SKIP @state = state unless state == SKIP @balance_in_cents = balance_in_cents unless balance_in_cents == SKIP @total_revenue_in_cents = total_revenue_in_cents unless total_revenue_in_cents == SKIP @product_price_in_cents = product_price_in_cents unless product_price_in_cents == SKIP @product_version_number = product_version_number unless product_version_number == SKIP @current_period_ends_at = current_period_ends_at unless current_period_ends_at == SKIP @next_assessment_at = next_assessment_at unless next_assessment_at == SKIP @trial_started_at = trial_started_at unless trial_started_at == SKIP @trial_ended_at = trial_ended_at unless trial_ended_at == SKIP @activated_at = activated_at unless activated_at == SKIP @expires_at = expires_at unless expires_at == SKIP @created_at = created_at unless created_at == SKIP @updated_at = updated_at unless updated_at == SKIP @cancellation_message = unless == SKIP @cancellation_method = cancellation_method unless cancellation_method == SKIP @cancel_at_end_of_period = cancel_at_end_of_period unless cancel_at_end_of_period == SKIP @canceled_at = canceled_at unless canceled_at == SKIP unless current_period_started_at == SKIP @current_period_started_at = current_period_started_at end @previous_state = previous_state unless previous_state == SKIP @signup_payment_id = signup_payment_id unless signup_payment_id == SKIP @signup_revenue = signup_revenue unless signup_revenue == SKIP @delayed_cancel_at = delayed_cancel_at unless delayed_cancel_at == SKIP @coupon_code = coupon_code unless coupon_code == SKIP @snap_day = snap_day unless snap_day == SKIP unless payment_collection_method == SKIP @payment_collection_method = payment_collection_method end @customer = customer unless customer == SKIP @product = product unless product == SKIP @credit_card = credit_card unless credit_card == SKIP @group = group unless group == SKIP @bank_account = bank_account unless bank_account == SKIP @payment_type = payment_type unless payment_type == SKIP @referral_code = referral_code unless referral_code == SKIP @next_product_id = next_product_id unless next_product_id == SKIP @next_product_handle = next_product_handle unless next_product_handle == SKIP @coupon_use_count = coupon_use_count unless coupon_use_count == SKIP @coupon_uses_allowed = coupon_uses_allowed unless coupon_uses_allowed == SKIP @reason_code = reason_code unless reason_code == SKIP @automatically_resume_at = automatically_resume_at unless automatically_resume_at == SKIP @coupon_codes = coupon_codes unless coupon_codes == SKIP @offer_id = offer_id unless offer_id == SKIP @payer_id = payer_id unless payer_id == SKIP unless current_billing_amount_in_cents == SKIP @current_billing_amount_in_cents = current_billing_amount_in_cents end @product_price_point_id = product_price_point_id unless product_price_point_id == SKIP @product_price_point_type = product_price_point_type unless product_price_point_type == SKIP unless next_product_price_point_id == SKIP @next_product_price_point_id = next_product_price_point_id end @net_terms = net_terms unless net_terms == SKIP unless stored_credential_transaction_id == SKIP @stored_credential_transaction_id = stored_credential_transaction_id end @reference = reference unless reference == SKIP @on_hold_at = on_hold_at unless on_hold_at == SKIP @prepaid_dunning = prepaid_dunning unless prepaid_dunning == SKIP @coupons = coupons unless coupons == SKIP unless dunning_communication_delay_enabled == SKIP @dunning_communication_delay_enabled = dunning_communication_delay_enabled end unless dunning_communication_delay_time_zone == SKIP @dunning_communication_delay_time_zone = dunning_communication_delay_time_zone end @receives_invoice_emails = receives_invoice_emails unless receives_invoice_emails == SKIP @locale = locale unless locale == SKIP @currency = currency unless currency == SKIP unless scheduled_cancellation_at == SKIP @scheduled_cancellation_at = scheduled_cancellation_at end @credit_balance_in_cents = credit_balance_in_cents unless credit_balance_in_cents == SKIP unless prepayment_balance_in_cents == SKIP @prepayment_balance_in_cents = prepayment_balance_in_cents end end |
Instance Attribute Details
#activated_at ⇒ String
Timestamp for when the subscription began (i.e. when it came out of trial, or when it began in the case of no trial)
68 69 70 |
# File 'lib/advanced_billing/models/subscription.rb', line 68 def activated_at @activated_at end |
#automatically_resume_at ⇒ String
The date the subscription is scheduled to automatically resume from the on_hold state.
199 200 201 |
# File 'lib/advanced_billing/models/subscription.rb', line 199 def automatically_resume_at @automatically_resume_at end |
#balance_in_cents ⇒ Integer
Gives the current outstanding subscription balance in the number of cents.
24 25 26 |
# File 'lib/advanced_billing/models/subscription.rb', line 24 def balance_in_cents @balance_in_cents end |
#bank_account ⇒ SubscriptionBankAccount
The day of the month that the subscription will charge according to calendar billing rules, if used.
162 163 164 |
# File 'lib/advanced_billing/models/subscription.rb', line 162 def bank_account @bank_account end |
#cancel_at_end_of_period ⇒ TrueClass | FalseClass
Whether or not the subscription will (or has) canceled at the end of the period.
94 95 96 |
# File 'lib/advanced_billing/models/subscription.rb', line 94 def cancel_at_end_of_period @cancel_at_end_of_period end |
#canceled_at ⇒ String
The timestamp of the most recent cancellation
98 99 100 |
# File 'lib/advanced_billing/models/subscription.rb', line 98 def canceled_at @canceled_at end |
#cancellation_message ⇒ String
Seller-provided reason for, or note about, the cancellation.
84 85 86 |
# File 'lib/advanced_billing/models/subscription.rb', line 84 def @cancellation_message end |
#cancellation_method ⇒ CancellationMethod
The process used to cancel the subscription, if the subscription has been canceled. It is nil if the subscription’s state is not canceled.
89 90 91 |
# File 'lib/advanced_billing/models/subscription.rb', line 89 def cancellation_method @cancellation_method end |
#coupon_code ⇒ String
(deprecated) The coupon code of the single coupon currently applied to the subscription. See coupon_codes instead as subscriptions can now have more than one coupon.
127 128 129 |
# File 'lib/advanced_billing/models/subscription.rb', line 127 def coupon_code @coupon_code end |
#coupon_codes ⇒ Array[String]
An array for all the coupons attached to the subscription.
203 204 205 |
# File 'lib/advanced_billing/models/subscription.rb', line 203 def coupon_codes @coupon_codes end |
#coupon_use_count ⇒ Integer
(deprecated) How many times the subscription’s single coupon has been used. This field has no replacement for multiple coupons.
185 186 187 |
# File 'lib/advanced_billing/models/subscription.rb', line 185 def coupon_use_count @coupon_use_count end |
#coupon_uses_allowed ⇒ Integer
(deprecated) How many times the subscription’s single coupon may be used. This field has no replacement for multiple coupons.
190 191 192 |
# File 'lib/advanced_billing/models/subscription.rb', line 190 def coupon_uses_allowed @coupon_uses_allowed end |
#coupons ⇒ Array[SubscriptionIncludedCoupon]
Additional coupon data. To use this data you also have to include the following param in the request`include[]=coupons`. Only in Read Subscription Endpoint.
261 262 263 |
# File 'lib/advanced_billing/models/subscription.rb', line 261 def coupons @coupons end |
#created_at ⇒ String
The creation date for this subscription
76 77 78 |
# File 'lib/advanced_billing/models/subscription.rb', line 76 def created_at @created_at end |
#credit_balance_in_cents ⇒ Integer
Time zone for the Dunning Communication Delay feature.
291 292 293 |
# File 'lib/advanced_billing/models/subscription.rb', line 291 def credit_balance_in_cents @credit_balance_in_cents end |
#credit_card ⇒ PaymentProfile
The day of the month that the subscription will charge according to calendar billing rules, if used.
152 153 154 |
# File 'lib/advanced_billing/models/subscription.rb', line 152 def credit_card @credit_card end |
#currency ⇒ String
Time zone for the Dunning Communication Delay feature.
283 284 285 |
# File 'lib/advanced_billing/models/subscription.rb', line 283 def currency @currency end |
#current_billing_amount_in_cents ⇒ Integer
The balance in cents plus the estimated renewal amount in cents.
217 218 219 |
# File 'lib/advanced_billing/models/subscription.rb', line 217 def current_billing_amount_in_cents @current_billing_amount_in_cents end |
#current_period_ends_at ⇒ String
Timestamp relating to the end of the current (recurring) period (i.e.,when the next regularly scheduled attempted charge will occur)
45 46 47 |
# File 'lib/advanced_billing/models/subscription.rb', line 45 def current_period_ends_at @current_period_ends_at end |
#current_period_started_at ⇒ String
Timestamp relating to the start of the current (recurring) period
102 103 104 |
# File 'lib/advanced_billing/models/subscription.rb', line 102 def current_period_started_at @current_period_started_at end |
#customer ⇒ Customer
The day of the month that the subscription will charge according to calendar billing rules, if used.
142 143 144 |
# File 'lib/advanced_billing/models/subscription.rb', line 142 def customer @customer end |
#delayed_cancel_at ⇒ String
Timestamp for when the subscription is currently set to cancel.
121 122 123 |
# File 'lib/advanced_billing/models/subscription.rb', line 121 def delayed_cancel_at @delayed_cancel_at end |
#dunning_communication_delay_enabled ⇒ TrueClass | FalseClass
Enable Communication Delay feature, making sure no communication (email or SMS) is sent to the Customer between 9PM and 8AM in time zone set by the ‘dunning_communication_delay_time_zone` attribute.
267 268 269 |
# File 'lib/advanced_billing/models/subscription.rb', line 267 def dunning_communication_delay_enabled @dunning_communication_delay_enabled end |
#dunning_communication_delay_time_zone ⇒ String
Time zone for the Dunning Communication Delay feature.
271 272 273 |
# File 'lib/advanced_billing/models/subscription.rb', line 271 def dunning_communication_delay_time_zone @dunning_communication_delay_time_zone end |
#expires_at ⇒ String
Timestamp giving the expiration date of this subscription (if any)
72 73 74 |
# File 'lib/advanced_billing/models/subscription.rb', line 72 def expires_at @expires_at end |
#group ⇒ SubscriptionGroupInlined
The day of the month that the subscription will charge according to calendar billing rules, if used.
157 158 159 |
# File 'lib/advanced_billing/models/subscription.rb', line 157 def group @group end |
#id ⇒ Integer
The subscription unique id within Chargify.
14 15 16 |
# File 'lib/advanced_billing/models/subscription.rb', line 14 def id @id end |
#locale ⇒ String
Time zone for the Dunning Communication Delay feature.
279 280 281 |
# File 'lib/advanced_billing/models/subscription.rb', line 279 def locale @locale end |
#net_terms ⇒ Integer
On Relationship Invoicing, the number of days before a renewal invoice is due.
235 236 237 |
# File 'lib/advanced_billing/models/subscription.rb', line 235 def net_terms @net_terms end |
#next_assessment_at ⇒ String
Timestamp that indicates when capture of payment will be tried or,retried. This value will usually track the current_period_ends_at, but,will diverge if a renewal payment fails and must be retried. In that,case, the current_period_ends_at will advance to the end of the next,period (time doesn’t stop because a payment was missed) but the,next_assessment_at will be scheduled for the auto-retry time (i.e. 24,hours in the future, in some cases)
55 56 57 |
# File 'lib/advanced_billing/models/subscription.rb', line 55 def next_assessment_at @next_assessment_at end |
#next_product_handle ⇒ String
If a delayed product change is scheduled, the handle of the product that the subscription will be changed to at the next renewal.
180 181 182 |
# File 'lib/advanced_billing/models/subscription.rb', line 180 def next_product_handle @next_product_handle end |
#next_product_id ⇒ Integer
If a delayed product change is scheduled, the ID of the product that the subscription will be changed to at the next renewal.
175 176 177 |
# File 'lib/advanced_billing/models/subscription.rb', line 175 def next_product_id @next_product_id end |
#next_product_price_point_id ⇒ Integer
If a delayed product change is scheduled, the ID of the product price point that the subscription will be changed to at the next renewal.
230 231 232 |
# File 'lib/advanced_billing/models/subscription.rb', line 230 def next_product_price_point_id @next_product_price_point_id end |
#offer_id ⇒ Integer
The ID of the offer associated with the subscription.
207 208 209 |
# File 'lib/advanced_billing/models/subscription.rb', line 207 def offer_id @offer_id end |
#on_hold_at ⇒ String
The timestamp of the most recent on hold action.
249 250 251 |
# File 'lib/advanced_billing/models/subscription.rb', line 249 def on_hold_at @on_hold_at end |
#payer_id ⇒ Integer
On Relationship Invoicing, the ID of the individual paying for the subscription. Defaults to the Customer ID unless the ‘Customer Hierarchies & WhoPays’ feature is enabled.
213 214 215 |
# File 'lib/advanced_billing/models/subscription.rb', line 213 def payer_id @payer_id end |
#payment_collection_method ⇒ PaymentCollectionMethod
The day of the month that the subscription will charge according to calendar billing rules, if used.
137 138 139 |
# File 'lib/advanced_billing/models/subscription.rb', line 137 def payment_collection_method @payment_collection_method end |
#payment_type ⇒ String
The payment profile type for the active profile on file.
166 167 168 |
# File 'lib/advanced_billing/models/subscription.rb', line 166 def payment_type @payment_type end |
#prepaid_dunning ⇒ TrueClass | FalseClass
Boolean representing whether the subscription is prepaid and currently in dunning. Only returned for Relationship Invoicing sites with the feature enabled
255 256 257 |
# File 'lib/advanced_billing/models/subscription.rb', line 255 def prepaid_dunning @prepaid_dunning end |
#prepayment_balance_in_cents ⇒ Integer
Time zone for the Dunning Communication Delay feature.
295 296 297 |
# File 'lib/advanced_billing/models/subscription.rb', line 295 def prepayment_balance_in_cents @prepayment_balance_in_cents end |
#previous_state ⇒ String
Only valid for webhook payloads The previous state for webhooks that have indicated a change in state. For normal API calls, this will always be the same as the state (current state)
108 109 110 |
# File 'lib/advanced_billing/models/subscription.rb', line 108 def previous_state @previous_state end |
#product ⇒ Product
The day of the month that the subscription will charge according to calendar billing rules, if used.
147 148 149 |
# File 'lib/advanced_billing/models/subscription.rb', line 147 def product @product end |
#product_price_in_cents ⇒ Integer
(Added Nov 5 2013) The recurring amount of the product (and version),currently subscribed. NOTE: this may differ from the current price of,the product, if you’ve changed the price of the product but haven’t,moved this subscription to a newer version.
35 36 37 |
# File 'lib/advanced_billing/models/subscription.rb', line 35 def product_price_in_cents @product_price_in_cents end |
#product_price_point_id ⇒ Integer
The product price point currently subscribed to.
221 222 223 |
# File 'lib/advanced_billing/models/subscription.rb', line 221 def product_price_point_id @product_price_point_id end |
#product_price_point_type ⇒ String
One of the following: custom, default, catalog.
225 226 227 |
# File 'lib/advanced_billing/models/subscription.rb', line 225 def product_price_point_type @product_price_point_type end |
#product_version_number ⇒ Integer
The version of the product for the subscription. Note that this is a deprecated field kept for backwards-compatibility.
40 41 42 |
# File 'lib/advanced_billing/models/subscription.rb', line 40 def product_version_number @product_version_number end |
#reason_code ⇒ String
If the subscription is canceled, this is their churn code.
194 195 196 |
# File 'lib/advanced_billing/models/subscription.rb', line 194 def reason_code @reason_code end |
#receives_invoice_emails ⇒ TrueClass | FalseClass
Time zone for the Dunning Communication Delay feature.
275 276 277 |
# File 'lib/advanced_billing/models/subscription.rb', line 275 def receives_invoice_emails @receives_invoice_emails end |
#reference ⇒ String
The reference value (provided by your app) for the subscription itelf.
245 246 247 |
# File 'lib/advanced_billing/models/subscription.rb', line 245 def reference @reference end |
#referral_code ⇒ String
The subscription’s unique code that can be given to referrals.
170 171 172 |
# File 'lib/advanced_billing/models/subscription.rb', line 170 def referral_code @referral_code end |
#scheduled_cancellation_at ⇒ String
Time zone for the Dunning Communication Delay feature.
287 288 289 |
# File 'lib/advanced_billing/models/subscription.rb', line 287 def scheduled_cancellation_at @scheduled_cancellation_at end |
#signup_payment_id ⇒ Integer
The ID of the transaction that generated the revenue
112 113 114 |
# File 'lib/advanced_billing/models/subscription.rb', line 112 def signup_payment_id @signup_payment_id end |
#signup_revenue ⇒ String
The revenue, formatted as a string of decimal separated dollars and,cents, from the subscription signup ($50.00 would be formatted as,50.00)
117 118 119 |
# File 'lib/advanced_billing/models/subscription.rb', line 117 def signup_revenue @signup_revenue end |
#snap_day ⇒ String
The day of the month that the subscription will charge according to calendar billing rules, if used.
132 133 134 |
# File 'lib/advanced_billing/models/subscription.rb', line 132 def snap_day @snap_day end |
#state ⇒ String
The current state of the subscription. Please see the documentation for [Subscription States](help.chargify.com/subscriptions/subscription-states.html)
20 21 22 |
# File 'lib/advanced_billing/models/subscription.rb', line 20 def state @state end |
#stored_credential_transaction_id ⇒ Integer
For European sites subject to PSD2 and using 3D Secure, this can be used to reference a previous transaction for the customer. This will ensure the card will be charged successfully at renewal.
241 242 243 |
# File 'lib/advanced_billing/models/subscription.rb', line 241 def stored_credential_transaction_id @stored_credential_transaction_id end |
#total_revenue_in_cents ⇒ Integer
Gives the total revenue from the subscription in the number of cents.
28 29 30 |
# File 'lib/advanced_billing/models/subscription.rb', line 28 def total_revenue_in_cents @total_revenue_in_cents end |
#trial_ended_at ⇒ String
Timestamp for when the trial period (if any) ended
63 64 65 |
# File 'lib/advanced_billing/models/subscription.rb', line 63 def trial_ended_at @trial_ended_at end |
#trial_started_at ⇒ String
Timestamp for when the trial period (if any) began
59 60 61 |
# File 'lib/advanced_billing/models/subscription.rb', line 59 def trial_started_at @trial_started_at end |
#updated_at ⇒ String
The date of last update for this subscription
80 81 82 |
# File 'lib/advanced_billing/models/subscription.rb', line 80 def updated_at @updated_at end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 |
# File 'lib/advanced_billing/models/subscription.rb', line 590 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : SKIP state = hash.key?('state') ? hash['state'] : SKIP balance_in_cents = hash.key?('balance_in_cents') ? hash['balance_in_cents'] : SKIP total_revenue_in_cents = hash.key?('total_revenue_in_cents') ? hash['total_revenue_in_cents'] : SKIP product_price_in_cents = hash.key?('product_price_in_cents') ? hash['product_price_in_cents'] : SKIP product_version_number = hash.key?('product_version_number') ? hash['product_version_number'] : SKIP current_period_ends_at = hash.key?('current_period_ends_at') ? hash['current_period_ends_at'] : SKIP next_assessment_at = hash.key?('next_assessment_at') ? hash['next_assessment_at'] : SKIP trial_started_at = hash.key?('trial_started_at') ? hash['trial_started_at'] : SKIP trial_ended_at = hash.key?('trial_ended_at') ? hash['trial_ended_at'] : SKIP activated_at = hash.key?('activated_at') ? hash['activated_at'] : SKIP expires_at = hash.key?('expires_at') ? hash['expires_at'] : SKIP created_at = hash.key?('created_at') ? hash['created_at'] : SKIP updated_at = hash.key?('updated_at') ? hash['updated_at'] : SKIP = hash.key?('cancellation_message') ? hash['cancellation_message'] : SKIP cancellation_method = hash.key?('cancellation_method') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:SubscriptionCancellationMethod), hash['cancellation_method'] ) : SKIP cancel_at_end_of_period = hash.key?('cancel_at_end_of_period') ? hash['cancel_at_end_of_period'] : SKIP canceled_at = hash.key?('canceled_at') ? hash['canceled_at'] : SKIP current_period_started_at = hash.key?('current_period_started_at') ? hash['current_period_started_at'] : SKIP previous_state = hash.key?('previous_state') ? hash['previous_state'] : SKIP signup_payment_id = hash.key?('signup_payment_id') ? hash['signup_payment_id'] : SKIP signup_revenue = hash.key?('signup_revenue') ? hash['signup_revenue'] : SKIP delayed_cancel_at = hash.key?('delayed_cancel_at') ? hash['delayed_cancel_at'] : SKIP coupon_code = hash.key?('coupon_code') ? hash['coupon_code'] : SKIP snap_day = hash.key?('snap_day') ? hash['snap_day'] : SKIP payment_collection_method = hash.key?('payment_collection_method') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:SubscriptionPaymentCollectionMethod), hash['payment_collection_method'] ) : SKIP customer = Customer.from_hash(hash['customer']) if hash['customer'] product = Product.from_hash(hash['product']) if hash['product'] credit_card = PaymentProfile.from_hash(hash['credit_card']) if hash['credit_card'] group = hash.key?('group') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:SubscriptionGroup2), hash['group'] ) : SKIP bank_account = SubscriptionBankAccount.from_hash(hash['bank_account']) if hash['bank_account'] payment_type = hash.key?('payment_type') ? hash['payment_type'] : SKIP referral_code = hash.key?('referral_code') ? hash['referral_code'] : SKIP next_product_id = hash.key?('next_product_id') ? hash['next_product_id'] : SKIP next_product_handle = hash.key?('next_product_handle') ? hash['next_product_handle'] : SKIP coupon_use_count = hash.key?('coupon_use_count') ? hash['coupon_use_count'] : SKIP coupon_uses_allowed = hash.key?('coupon_uses_allowed') ? hash['coupon_uses_allowed'] : SKIP reason_code = hash.key?('reason_code') ? hash['reason_code'] : SKIP automatically_resume_at = hash.key?('automatically_resume_at') ? hash['automatically_resume_at'] : SKIP coupon_codes = hash.key?('coupon_codes') ? hash['coupon_codes'] : SKIP offer_id = hash.key?('offer_id') ? hash['offer_id'] : SKIP payer_id = hash.key?('payer_id') ? hash['payer_id'] : SKIP current_billing_amount_in_cents = hash.key?('current_billing_amount_in_cents') ? hash['current_billing_amount_in_cents'] : SKIP product_price_point_id = hash.key?('product_price_point_id') ? hash['product_price_point_id'] : SKIP product_price_point_type = hash.key?('product_price_point_type') ? hash['product_price_point_type'] : SKIP next_product_price_point_id = hash.key?('next_product_price_point_id') ? hash['next_product_price_point_id'] : SKIP net_terms = hash.key?('net_terms') ? hash['net_terms'] : SKIP stored_credential_transaction_id = hash.key?('stored_credential_transaction_id') ? hash['stored_credential_transaction_id'] : SKIP reference = hash.key?('reference') ? hash['reference'] : SKIP on_hold_at = hash.key?('on_hold_at') ? hash['on_hold_at'] : SKIP prepaid_dunning = hash.key?('prepaid_dunning') ? hash['prepaid_dunning'] : SKIP # Parameter is an array, so we need to iterate through it coupons = nil unless hash['coupons'].nil? coupons = [] hash['coupons'].each do |structure| coupons << (SubscriptionIncludedCoupon.from_hash(structure) if structure) end end coupons = SKIP unless hash.key?('coupons') dunning_communication_delay_enabled = hash['dunning_communication_delay_enabled'] ||= false dunning_communication_delay_time_zone = hash.key?('dunning_communication_delay_time_zone') ? hash['dunning_communication_delay_time_zone'] : SKIP receives_invoice_emails = hash.key?('receives_invoice_emails') ? hash['receives_invoice_emails'] : SKIP locale = hash.key?('locale') ? hash['locale'] : SKIP currency = hash.key?('currency') ? hash['currency'] : SKIP scheduled_cancellation_at = hash.key?('scheduled_cancellation_at') ? hash['scheduled_cancellation_at'] : SKIP credit_balance_in_cents = hash.key?('credit_balance_in_cents') ? hash['credit_balance_in_cents'] : SKIP prepayment_balance_in_cents = hash.key?('prepayment_balance_in_cents') ? hash['prepayment_balance_in_cents'] : SKIP # Create object from extracted values. Subscription.new(id, state, balance_in_cents, total_revenue_in_cents, product_price_in_cents, product_version_number, current_period_ends_at, next_assessment_at, trial_started_at, trial_ended_at, activated_at, expires_at, created_at, updated_at, , cancellation_method, cancel_at_end_of_period, canceled_at, current_period_started_at, previous_state, signup_payment_id, signup_revenue, delayed_cancel_at, coupon_code, snap_day, payment_collection_method, customer, product, credit_card, group, bank_account, payment_type, referral_code, next_product_id, next_product_handle, coupon_use_count, coupon_uses_allowed, reason_code, automatically_resume_at, coupon_codes, offer_id, payer_id, current_billing_amount_in_cents, product_price_point_id, product_price_point_type, next_product_price_point_id, net_terms, stored_credential_transaction_id, reference, on_hold_at, prepaid_dunning, coupons, dunning_communication_delay_enabled, dunning_communication_delay_time_zone, receives_invoice_emails, locale, currency, scheduled_cancellation_at, credit_balance_in_cents, prepayment_balance_in_cents) end |
.names ⇒ Object
A mapping from model property names to API property names.
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# File 'lib/advanced_billing/models/subscription.rb', line 298 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['state'] = 'state' @_hash['balance_in_cents'] = 'balance_in_cents' @_hash['total_revenue_in_cents'] = 'total_revenue_in_cents' @_hash['product_price_in_cents'] = 'product_price_in_cents' @_hash['product_version_number'] = 'product_version_number' @_hash['current_period_ends_at'] = 'current_period_ends_at' @_hash['next_assessment_at'] = 'next_assessment_at' @_hash['trial_started_at'] = 'trial_started_at' @_hash['trial_ended_at'] = 'trial_ended_at' @_hash['activated_at'] = 'activated_at' @_hash['expires_at'] = 'expires_at' @_hash['created_at'] = 'created_at' @_hash['updated_at'] = 'updated_at' @_hash['cancellation_message'] = 'cancellation_message' @_hash['cancellation_method'] = 'cancellation_method' @_hash['cancel_at_end_of_period'] = 'cancel_at_end_of_period' @_hash['canceled_at'] = 'canceled_at' @_hash['current_period_started_at'] = 'current_period_started_at' @_hash['previous_state'] = 'previous_state' @_hash['signup_payment_id'] = 'signup_payment_id' @_hash['signup_revenue'] = 'signup_revenue' @_hash['delayed_cancel_at'] = 'delayed_cancel_at' @_hash['coupon_code'] = 'coupon_code' @_hash['snap_day'] = 'snap_day' @_hash['payment_collection_method'] = 'payment_collection_method' @_hash['customer'] = 'customer' @_hash['product'] = 'product' @_hash['credit_card'] = 'credit_card' @_hash['group'] = 'group' @_hash['bank_account'] = 'bank_account' @_hash['payment_type'] = 'payment_type' @_hash['referral_code'] = 'referral_code' @_hash['next_product_id'] = 'next_product_id' @_hash['next_product_handle'] = 'next_product_handle' @_hash['coupon_use_count'] = 'coupon_use_count' @_hash['coupon_uses_allowed'] = 'coupon_uses_allowed' @_hash['reason_code'] = 'reason_code' @_hash['automatically_resume_at'] = 'automatically_resume_at' @_hash['coupon_codes'] = 'coupon_codes' @_hash['offer_id'] = 'offer_id' @_hash['payer_id'] = 'payer_id' @_hash['current_billing_amount_in_cents'] = 'current_billing_amount_in_cents' @_hash['product_price_point_id'] = 'product_price_point_id' @_hash['product_price_point_type'] = 'product_price_point_type' @_hash['next_product_price_point_id'] = 'next_product_price_point_id' @_hash['net_terms'] = 'net_terms' @_hash['stored_credential_transaction_id'] = 'stored_credential_transaction_id' @_hash['reference'] = 'reference' @_hash['on_hold_at'] = 'on_hold_at' @_hash['prepaid_dunning'] = 'prepaid_dunning' @_hash['coupons'] = 'coupons' @_hash['dunning_communication_delay_enabled'] = 'dunning_communication_delay_enabled' @_hash['dunning_communication_delay_time_zone'] = 'dunning_communication_delay_time_zone' @_hash['receives_invoice_emails'] = 'receives_invoice_emails' @_hash['locale'] = 'locale' @_hash['currency'] = 'currency' @_hash['scheduled_cancellation_at'] = 'scheduled_cancellation_at' @_hash['credit_balance_in_cents'] = 'credit_balance_in_cents' @_hash['prepayment_balance_in_cents'] = 'prepayment_balance_in_cents' @_hash end |
.nullables ⇒ Object
An array for nullable fields
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 |
# File 'lib/advanced_billing/models/subscription.rb', line 434 def self.nullables %w[ trial_started_at trial_ended_at expires_at cancellation_message cancellation_method cancel_at_end_of_period canceled_at delayed_cancel_at coupon_code snap_day payment_collection_method group payment_type referral_code next_product_id next_product_handle coupon_use_count coupon_uses_allowed reason_code automatically_resume_at offer_id next_product_price_point_id net_terms stored_credential_transaction_id reference on_hold_at dunning_communication_delay_time_zone receives_invoice_emails locale scheduled_cancellation_at ] end |
.optionals ⇒ Object
An array for optional fields
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
# File 'lib/advanced_billing/models/subscription.rb', line 368 def self.optionals %w[ id state balance_in_cents total_revenue_in_cents product_price_in_cents product_version_number current_period_ends_at next_assessment_at trial_started_at trial_ended_at activated_at expires_at created_at updated_at cancellation_message cancellation_method cancel_at_end_of_period canceled_at current_period_started_at previous_state signup_payment_id signup_revenue delayed_cancel_at coupon_code snap_day payment_collection_method customer product credit_card group bank_account payment_type referral_code next_product_id next_product_handle coupon_use_count coupon_uses_allowed reason_code automatically_resume_at coupon_codes offer_id payer_id current_billing_amount_in_cents product_price_point_id product_price_point_type next_product_price_point_id net_terms stored_credential_transaction_id reference on_hold_at prepaid_dunning coupons dunning_communication_delay_enabled dunning_communication_delay_time_zone receives_invoice_emails locale currency scheduled_cancellation_at credit_balance_in_cents prepayment_balance_in_cents ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
768 769 770 771 772 773 774 |
# File 'lib/advanced_billing/models/subscription.rb', line 768 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |