Class: AdvancedBilling::CreateSubscription

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/create_subscription.rb

Overview

CreateSubscription Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #get_additional_properties, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(product_handle: SKIP, product_id: SKIP, product_price_point_handle: SKIP, product_price_point_id: SKIP, custom_price: SKIP, coupon_code: SKIP, coupon_codes: SKIP, payment_collection_method: SKIP, receives_invoice_emails: SKIP, net_terms: SKIP, customer_id: SKIP, next_billing_at: SKIP, initial_billing_at: SKIP, defer_signup: false, stored_credential_transaction_id: SKIP, sales_rep_id: SKIP, payment_profile_id: SKIP, reference: SKIP, customer_attributes: SKIP, payment_profile_attributes: SKIP, credit_card_attributes: SKIP, bank_account_attributes: SKIP, components: SKIP, calendar_billing: SKIP, metafields: SKIP, customer_reference: SKIP, group: SKIP, ref: SKIP, cancellation_message: SKIP, cancellation_method: SKIP, currency: SKIP, expires_at: SKIP, expiration_tracks_next_billing_change: SKIP, agreement_terms: SKIP, authorizer_first_name: SKIP, authorizer_last_name: SKIP, calendar_billing_first_charge: SKIP, reason_code: SKIP, product_change_delayed: SKIP, offer_id: SKIP, prepaid_configuration: SKIP, previous_billing_at: SKIP, import_mrr: SKIP, canceled_at: SKIP, activated_at: SKIP, agreement_acceptance: SKIP, ach_agreement: SKIP, dunning_communication_delay_enabled: false, dunning_communication_delay_time_zone: SKIP, skip_billing_manifest_taxes: SKIP, additional_properties: {}) ⇒ CreateSubscription

Returns a new instance of CreateSubscription.



450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
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
# File 'lib/advanced_billing/models/create_subscription.rb', line 450

def initialize(product_handle: SKIP, product_id: SKIP,
               product_price_point_handle: SKIP,
               product_price_point_id: SKIP, custom_price: SKIP,
               coupon_code: SKIP, coupon_codes: SKIP,
               payment_collection_method: SKIP,
               receives_invoice_emails: SKIP, net_terms: SKIP,
               customer_id: SKIP, next_billing_at: SKIP,
               initial_billing_at: SKIP, defer_signup: false,
               stored_credential_transaction_id: SKIP, sales_rep_id: SKIP,
               payment_profile_id: SKIP, reference: SKIP,
               customer_attributes: SKIP, payment_profile_attributes: SKIP,
               credit_card_attributes: SKIP, bank_account_attributes: SKIP,
               components: SKIP, calendar_billing: SKIP, metafields: SKIP,
               customer_reference: SKIP, group: SKIP, ref: SKIP,
               cancellation_message: SKIP, cancellation_method: SKIP,
               currency: SKIP, expires_at: SKIP,
               expiration_tracks_next_billing_change: SKIP,
               agreement_terms: SKIP, authorizer_first_name: SKIP,
               authorizer_last_name: SKIP,
               calendar_billing_first_charge: SKIP, reason_code: SKIP,
               product_change_delayed: SKIP, offer_id: SKIP,
               prepaid_configuration: SKIP, previous_billing_at: SKIP,
               import_mrr: SKIP, canceled_at: SKIP, activated_at: SKIP,
               agreement_acceptance: SKIP, ach_agreement: SKIP,
               dunning_communication_delay_enabled: false,
               dunning_communication_delay_time_zone: SKIP,
               skip_billing_manifest_taxes: SKIP, additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @product_handle = product_handle unless product_handle == SKIP
  @product_id = product_id unless product_id == SKIP
  unless product_price_point_handle == SKIP
    @product_price_point_handle =
      product_price_point_handle
  end
  @product_price_point_id = product_price_point_id unless product_price_point_id == SKIP
  @custom_price = custom_price unless custom_price == SKIP
  @coupon_code = coupon_code unless coupon_code == SKIP
  @coupon_codes = coupon_codes unless coupon_codes == SKIP
  unless payment_collection_method == SKIP
    @payment_collection_method =
      payment_collection_method
  end
  @receives_invoice_emails = receives_invoice_emails unless receives_invoice_emails == SKIP
  @net_terms = net_terms unless net_terms == SKIP
  @customer_id = customer_id unless customer_id == SKIP
  @next_billing_at = next_billing_at unless next_billing_at == SKIP
  @initial_billing_at = initial_billing_at unless initial_billing_at == SKIP
  @defer_signup =  unless  == SKIP
  unless stored_credential_transaction_id == SKIP
    @stored_credential_transaction_id =
      stored_credential_transaction_id
  end
  @sales_rep_id = sales_rep_id unless sales_rep_id == SKIP
  @payment_profile_id = payment_profile_id unless payment_profile_id == SKIP
  @reference = reference unless reference == SKIP
  @customer_attributes = customer_attributes unless customer_attributes == SKIP
  unless payment_profile_attributes == SKIP
    @payment_profile_attributes =
      payment_profile_attributes
  end
  @credit_card_attributes = credit_card_attributes unless credit_card_attributes == SKIP
  @bank_account_attributes =  unless  == SKIP
  @components = components unless components == SKIP
  @calendar_billing = calendar_billing unless calendar_billing == SKIP
  @metafields = metafields unless metafields == SKIP
  @customer_reference = customer_reference unless customer_reference == SKIP
  @group = group unless group == SKIP
  @ref = ref unless ref == SKIP
  @cancellation_message = cancellation_message unless cancellation_message == SKIP
  @cancellation_method = cancellation_method unless cancellation_method == SKIP
  @currency = currency unless currency == SKIP
  @expires_at = expires_at unless expires_at == SKIP
  unless expiration_tracks_next_billing_change == SKIP
    @expiration_tracks_next_billing_change =
      expiration_tracks_next_billing_change
  end
  @agreement_terms = agreement_terms unless agreement_terms == SKIP
  @authorizer_first_name = authorizer_first_name unless authorizer_first_name == SKIP
  @authorizer_last_name = authorizer_last_name unless authorizer_last_name == SKIP
  unless calendar_billing_first_charge == SKIP
    @calendar_billing_first_charge =
      calendar_billing_first_charge
  end
  @reason_code = reason_code unless reason_code == SKIP
  @product_change_delayed = product_change_delayed unless product_change_delayed == SKIP
  @offer_id = offer_id unless offer_id == SKIP
  @prepaid_configuration = prepaid_configuration unless prepaid_configuration == SKIP
  @previous_billing_at = previous_billing_at unless previous_billing_at == SKIP
  @import_mrr = import_mrr unless import_mrr == SKIP
  @canceled_at = canceled_at unless canceled_at == SKIP
  @activated_at = activated_at unless activated_at == SKIP
  @agreement_acceptance = agreement_acceptance unless agreement_acceptance == SKIP
  @ach_agreement = ach_agreement unless ach_agreement == 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
  unless skip_billing_manifest_taxes == SKIP
    @skip_billing_manifest_taxes =
      skip_billing_manifest_taxes
  end
end

Instance Attribute Details

#ach_agreementACHAgreement

(Optional) If passed, the proof of the authorized ACH agreement terms will be persisted.

Returns:



308
309
310
# File 'lib/advanced_billing/models/create_subscription.rb', line 308

def ach_agreement
  @ach_agreement
end

#activated_atDateTime

Setting this attribute to true will cause the subscription’s MRR to be added to your MRR analytics immediately. For this value to be honored, a next_billing_at must be present and set to a future date. This key/value will not be returned in the subscription response body.

Returns:

  • (DateTime)


299
300
301
# File 'lib/advanced_billing/models/create_subscription.rb', line 299

def activated_at
  @activated_at
end

#agreement_acceptanceAgreementAcceptance

Required when creating a subscription with Maxio Payments.

Returns:



303
304
305
# File 'lib/advanced_billing/models/create_subscription.rb', line 303

def agreement_acceptance
  @agreement_acceptance
end

#agreement_termsString

(Optional) The ACH authorization agreement terms. If enabled, an email will be sent to the customer with a copy of the terms.

Returns:

  • (String)


231
232
233
# File 'lib/advanced_billing/models/create_subscription.rb', line 231

def agreement_terms
  @agreement_terms
end

#authorizer_first_nameString

(Optional) The first name of the person authorizing the ACH agreement.

Returns:

  • (String)


235
236
237
# File 'lib/advanced_billing/models/create_subscription.rb', line 235

def authorizer_first_name
  @authorizer_first_name
end

#authorizer_last_nameString

(Optional) The last name of the person authorizing the ACH agreement.

Returns:

  • (String)


239
240
241
# File 'lib/advanced_billing/models/create_subscription.rb', line 239

def authorizer_last_name
  @authorizer_last_name
end

#bank_account_attributesBankAccountAttributes

Credit Card data to create a new Subscription. Interchangeable with ‘payment_profile_attributes` property.



160
161
162
# File 'lib/advanced_billing/models/create_subscription.rb', line 160

def 
  @bank_account_attributes
end

#calendar_billingCalendarBilling

(Optional). Cannot be used when also specifying next_billing_at

Returns:



171
172
173
# File 'lib/advanced_billing/models/create_subscription.rb', line 171

def calendar_billing
  @calendar_billing
end

#calendar_billing_first_chargeString

(Optional) One of “prorated” (the default – the prorated product price will be charged immediately), “immediate” (the full product price will be charged immediately), or “delayed” (the full product price will be charged with the first scheduled renewal).

Returns:

  • (String)


246
247
248
# File 'lib/advanced_billing/models/create_subscription.rb', line 246

def calendar_billing_first_charge
  @calendar_billing_first_charge
end

#canceled_atDateTime

Setting this attribute to true will cause the subscription’s MRR to be added to your MRR analytics immediately. For this value to be honored, a next_billing_at must be present and set to a future date. This key/value will not be returned in the subscription response body.

Returns:

  • (DateTime)


292
293
294
# File 'lib/advanced_billing/models/create_subscription.rb', line 292

def canceled_at
  @canceled_at
end

#cancellation_messageString

(Optional) Can be used when canceling a subscription (via the HTTP DELETE method) to make a note about the reason for cancellation.

Returns:

  • (String)


201
202
203
# File 'lib/advanced_billing/models/create_subscription.rb', line 201

def cancellation_message
  @cancellation_message
end

#cancellation_methodString

(Optional) Can be used when canceling a subscription (via the HTTP DELETE method) to make a note about how the subscription was canceled.

Returns:

  • (String)


206
207
208
# File 'lib/advanced_billing/models/create_subscription.rb', line 206

def cancellation_method
  @cancellation_method
end

#componentsArray[CreateSubscriptionComponent]

(Optional) An array of component ids and quantities to be added to the subscription. See [Components](maxio.zendesk.com/hc/en-us/articles/24261141522189-Co mponents-Overview) for more information.

Returns:



167
168
169
# File 'lib/advanced_billing/models/create_subscription.rb', line 167

def components
  @components
end

#coupon_codeString

(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.

Returns:

  • (String)


42
43
44
# File 'lib/advanced_billing/models/create_subscription.rb', line 42

def coupon_code
  @coupon_code
end

#coupon_codesArray[String]

An array for all the coupons attached to the subscription.

Returns:

  • (Array[String])


46
47
48
# File 'lib/advanced_billing/models/create_subscription.rb', line 46

def coupon_codes
  @coupon_codes
end

#credit_card_attributesPaymentProfileAttributes

Credit Card data to create a new Subscription. Interchangeable with ‘payment_profile_attributes` property.



155
156
157
# File 'lib/advanced_billing/models/create_subscription.rb', line 155

def credit_card_attributes
  @credit_card_attributes
end

#currencyString

(Optional) If Multi-Currency is enabled and the currency is configured in Chargify, pass it at signup to create a subscription on a non-default currency. Note that you cannot update the currency of an existing subscription.

Returns:

  • (String)


213
214
215
# File 'lib/advanced_billing/models/create_subscription.rb', line 213

def currency
  @currency
end

#custom_priceSubscriptionCustomPrice

(Optional) Used in place of ‘product_price_point_id` to define a custom price point unique to the subscription. A subscription can have up to 30 custom price points. Exceeding this limit will result in an API error.



36
37
38
# File 'lib/advanced_billing/models/create_subscription.rb', line 36

def custom_price
  @custom_price
end

#customer_attributesCustomerAttributes

The reference value (provided by your app) for the subscription itself.

Returns:



146
147
148
# File 'lib/advanced_billing/models/create_subscription.rb', line 146

def customer_attributes
  @customer_attributes
end

#customer_idInteger

The ID of an existing customer within Chargify. Required, unless a ‘customer_reference` or a set of `customer_attributes` is given.

Returns:

  • (Integer)


69
70
71
# File 'lib/advanced_billing/models/create_subscription.rb', line 69

def customer_id
  @customer_id
end

#customer_referenceString

The reference value (provided by your app) of an existing customer within Chargify. Required, unless a ‘customer_id` or a set of `customer_attributes` is given.

Returns:

  • (String)


183
184
185
# File 'lib/advanced_billing/models/create_subscription.rb', line 183

def customer_reference
  @customer_reference
end

#defer_signupTrueClass | FalseClass

(Optional) Set this attribute to true to create the subscription in the Awaiting Signup Date state. Use this when you want to create a subscription that has an unknown first billing date. When the first billing date is known, update a subscription and set the ‘initial_billing_at` date. The subscription moves to the Awaiting Signup state with a scheduled initial billing date. You can omit the initial_billing_at date to activate the subscription immediately. See [Subscription States](maxio-chargify.zendesk.com/hc/en-us/articles/5404222005773 -Subscription-States) for more information.

Returns:

  • (TrueClass | FalseClass)


116
117
118
# File 'lib/advanced_billing/models/create_subscription.rb', line 116

def 
  @defer_signup
end

#dunning_communication_delay_enabledTrueClass | 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.

Returns:

  • (TrueClass | FalseClass)


314
315
316
# File 'lib/advanced_billing/models/create_subscription.rb', line 314

def dunning_communication_delay_enabled
  @dunning_communication_delay_enabled
end

#dunning_communication_delay_time_zoneString

Time zone for the Dunning Communication Delay feature.

Returns:

  • (String)


318
319
320
# File 'lib/advanced_billing/models/create_subscription.rb', line 318

def dunning_communication_delay_time_zone
  @dunning_communication_delay_time_zone
end

#expiration_tracks_next_billing_changeString

(Optional, default false) When set to true, and when next_billing_at is present, if the subscription expires, the expires_at will be shifted by the same amount of time as the difference between the old and new “next billing” dates.

Returns:

  • (String)


226
227
228
# File 'lib/advanced_billing/models/create_subscription.rb', line 226

def expiration_tracks_next_billing_change
  @expiration_tracks_next_billing_change
end

#expires_atDateTime

Timestamp giving the expiration date of this subscription (if any). You may manually change the expiration date at any point during a subscription period.

Returns:

  • (DateTime)


219
220
221
# File 'lib/advanced_billing/models/create_subscription.rb', line 219

def expires_at
  @expires_at
end

#groupGroupSettings

The reference value (provided by your app) of an existing customer within Chargify. Required, unless a ‘customer_id` or a set of `customer_attributes` is given.

Returns:



189
190
191
# File 'lib/advanced_billing/models/create_subscription.rb', line 189

def group
  @group
end

#import_mrrTrueClass | FalseClass

Setting this attribute to true will cause the subscription’s MRR to be added to your MRR analytics immediately. For this value to be honored, a next_billing_at must be present and set to a future date. This key/value will not be returned in the subscription response body.

Returns:

  • (TrueClass | FalseClass)


285
286
287
# File 'lib/advanced_billing/models/create_subscription.rb', line 285

def import_mrr
  @import_mrr
end

#initial_billing_atDateTime

(Optional) Set this attribute to a future date/time to create a subscription in the Awaiting Signup state, rather than Active or Trialing. You can omit the initial_billing_at date to activate the subscription immediately. In the Awaiting Signup state, a subscription behaves like any other. It can be canceled, allocated to, or have its billing date changed. etc. When the initial_billing_at date hits, the subscription will transition to the expected state. If the product has a trial, the subscription will enter a trial, otherwise it will go active. Setup fees will be respected either before or after the trial, as configured on the price point. If the payment is due at the initial_billing_at and it fails the subscription will be immediately canceled. See the [subscription import](maxio.zendesk.com/hc/en-us/articles/24251489107213-Advance d-Billing-Subscription-Imports#date-format) documentation for more information about Date/Time Formats.

Returns:

  • (DateTime)


103
104
105
# File 'lib/advanced_billing/models/create_subscription.rb', line 103

def initial_billing_at
  @initial_billing_at
end

#metafieldsHash[String, String]

(Optional) A set of key/value pairs representing custom fields and their values. Metafields will be created “on-the-fly” in your site for a given key, if they have not been created yet.

Returns:

  • (Hash[String, String])


177
178
179
# File 'lib/advanced_billing/models/create_subscription.rb', line 177

def metafields
  @metafields
end

#net_termsString

(Optional) Default: null The number of days after renewal (on invoice billing) that a subscription is due. A value between 0 (due immediately) and 180.

Returns:

  • (String)


64
65
66
# File 'lib/advanced_billing/models/create_subscription.rb', line 64

def net_terms
  @net_terms
end

#next_billing_atDateTime

(Optional) Set this attribute to a future date/time to sync imported subscriptions to your existing renewal schedule. See the notes on “Date/Time Format” in our [subscription import documentation](maxio.zendesk.com/hc/en-us/articles/24251489107213- Advanced-Billing-Subscription-Imports#date-format). If you provide a next_billing_at timestamp that is in the future, no trial or initial charges will be applied when you create the subscription. In fact, no payment will be captured at all. The first payment will be captured, according to the prices defined by the product, near the time specified by next_billing_at. If you do not provide a value for next_billing_at, any trial and/or initial charges will be assessed and charged at the time of subscription creation. If the card cannot be successfully charged, the subscription will not be created. See further notes in the section on Importing Subscriptions.

Returns:

  • (DateTime)


86
87
88
# File 'lib/advanced_billing/models/create_subscription.rb', line 86

def next_billing_at
  @next_billing_at
end

#offer_idObject

Use in place of passing product and component information to set up the subscription with an existing offer. May be either the Chargify id of the offer or its handle prefixed with ‘handle:`.er

Returns:

  • (Object)


263
264
265
# File 'lib/advanced_billing/models/create_subscription.rb', line 263

def offer_id
  @offer_id
end

#payment_collection_methodCollectionMethod

The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - ‘invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`.

Returns:



53
54
55
# File 'lib/advanced_billing/models/create_subscription.rb', line 53

def payment_collection_method
  @payment_collection_method
end

#payment_profile_attributesPaymentProfileAttributes

alias to credit_card_attributes



150
151
152
# File 'lib/advanced_billing/models/create_subscription.rb', line 150

def payment_profile_attributes
  @payment_profile_attributes
end

#payment_profile_idInteger

The Payment Profile ID of an existing card or bank account, which belongs to an existing customer to use for payment for this subscription. If the card, bank account, or customer does not exist already, or if you want to use a new (unstored) card or bank account for the subscription, use ‘payment_profile_attributes` instead to create a new payment profile along with the subscription. (This value is available on an existing subscription via the API as `credit_card` > id or `bank_account` > id)

Returns:

  • (Integer)


138
139
140
# File 'lib/advanced_billing/models/create_subscription.rb', line 138

def payment_profile_id
  @payment_profile_id
end

#prepaid_configurationUpsertPrepaidConfiguration

Use in place of passing product and component information to set up the subscription with an existing offer. May be either the Chargify id of the offer or its handle prefixed with ‘handle:`.er



269
270
271
# File 'lib/advanced_billing/models/create_subscription.rb', line 269

def prepaid_configuration
  @prepaid_configuration
end

#previous_billing_atDateTime

Providing a previous_billing_at that is in the past will set the current_period_starts_at when the subscription is created. It will also set activated_at if not explicitly passed during the subscription import. Can only be used if next_billing_at is also passed. Using this option will allow you to set the period start for the subscription so mid period component allocations have the correct prorated amount.

Returns:

  • (DateTime)


278
279
280
# File 'lib/advanced_billing/models/create_subscription.rb', line 278

def previous_billing_at
  @previous_billing_at
end

#product_change_delayedTrueClass | FalseClass

(Optional) used only for Delayed Product Change When set to true, indicates that a changed value for product_handle should schedule the product change to the next subscription renewal.

Returns:

  • (TrueClass | FalseClass)


257
258
259
# File 'lib/advanced_billing/models/create_subscription.rb', line 257

def product_change_delayed
  @product_change_delayed
end

#product_handleString

The API Handle of the product for which you are creating a subscription. Required, unless a ‘product_id` is given instead.

Returns:

  • (String)


16
17
18
# File 'lib/advanced_billing/models/create_subscription.rb', line 16

def product_handle
  @product_handle
end

#product_idInteger

The Product ID of the product for which you are creating a subscription. The product ID is not currently published, so we recommend using the API Handle instead.

Returns:

  • (Integer)


22
23
24
# File 'lib/advanced_billing/models/create_subscription.rb', line 22

def product_id
  @product_id
end

#product_price_point_handleString

The user-friendly API handle of a product’s particular price point.

Returns:

  • (String)


26
27
28
# File 'lib/advanced_billing/models/create_subscription.rb', line 26

def product_price_point_handle
  @product_price_point_handle
end

#product_price_point_idInteger

The ID of the particular price point on the product.

Returns:

  • (Integer)


30
31
32
# File 'lib/advanced_billing/models/create_subscription.rb', line 30

def product_price_point_id
  @product_price_point_id
end

#reason_codeString

(Optional) Can be used when canceling a subscription (via the HTTP DELETE method) to indicate why a subscription was canceled.

Returns:

  • (String)


251
252
253
# File 'lib/advanced_billing/models/create_subscription.rb', line 251

def reason_code
  @reason_code
end

#receives_invoice_emailsString

(Optional) Default: True - Whether or not this subscription is set to receive emails related to this subscription.

Returns:

  • (String)


58
59
60
# File 'lib/advanced_billing/models/create_subscription.rb', line 58

def receives_invoice_emails
  @receives_invoice_emails
end

#refString

A valid referral code. (optional, see [Referrals](maxio.zendesk.com/hc/en-us/articles/24286981223693-Ref errals-Reference#how-to-obtain-referral-codes) for more details). If supplied, must be valid, or else subscription creation will fail.

Returns:

  • (String)


196
197
198
# File 'lib/advanced_billing/models/create_subscription.rb', line 196

def ref
  @ref
end

#referenceString

The reference value (provided by your app) for the subscription itself.

Returns:

  • (String)


142
143
144
# File 'lib/advanced_billing/models/create_subscription.rb', line 142

def reference
  @reference
end

#sales_rep_idInteger

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.

Returns:

  • (Integer)


128
129
130
# File 'lib/advanced_billing/models/create_subscription.rb', line 128

def sales_rep_id
  @sales_rep_id
end

#skip_billing_manifest_taxesTrueClass | FalseClass

Valid only for the Subscription Preview endpoint. When set to ‘true` it skips calculating taxes for the current and next billing manifests. Defaults to `false` when not provided.

Returns:

  • (TrueClass | FalseClass)


324
325
326
# File 'lib/advanced_billing/models/create_subscription.rb', line 324

def skip_billing_manifest_taxes
  @skip_billing_manifest_taxes
end

#stored_credential_transaction_idInteger

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.

Returns:

  • (Integer)


122
123
124
# File 'lib/advanced_billing/models/create_subscription.rb', line 122

def stored_credential_transaction_id
  @stored_credential_transaction_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
588
589
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
# File 'lib/advanced_billing/models/create_subscription.rb', line 562

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  product_handle =
    hash.key?('product_handle') ? hash['product_handle'] : SKIP
  product_id = hash.key?('product_id') ? hash['product_id'] : SKIP
  product_price_point_handle =
    hash.key?('product_price_point_handle') ? hash['product_price_point_handle'] : SKIP
  product_price_point_id =
    hash.key?('product_price_point_id') ? hash['product_price_point_id'] : SKIP
  custom_price = SubscriptionCustomPrice.from_hash(hash['custom_price']) if
    hash['custom_price']
  coupon_code = hash.key?('coupon_code') ? hash['coupon_code'] : SKIP
  coupon_codes = hash.key?('coupon_codes') ? hash['coupon_codes'] : SKIP
  payment_collection_method =
    hash.key?('payment_collection_method') ? hash['payment_collection_method'] : SKIP
  receives_invoice_emails =
    hash.key?('receives_invoice_emails') ? hash['receives_invoice_emails'] : SKIP
  net_terms = hash.key?('net_terms') ? hash['net_terms'] : SKIP
  customer_id = hash.key?('customer_id') ? hash['customer_id'] : SKIP
  next_billing_at = if hash.key?('next_billing_at')
                      (DateTimeHelper.from_rfc3339(hash['next_billing_at']) if hash['next_billing_at'])
                    else
                      SKIP
                    end
  initial_billing_at = if hash.key?('initial_billing_at')
                         (DateTimeHelper.from_rfc3339(hash['initial_billing_at']) if hash['initial_billing_at'])
                       else
                         SKIP
                       end
   = hash['defer_signup'] ||= false
  stored_credential_transaction_id =
    hash.key?('stored_credential_transaction_id') ? hash['stored_credential_transaction_id'] : SKIP
  sales_rep_id = hash.key?('sales_rep_id') ? hash['sales_rep_id'] : SKIP
  payment_profile_id =
    hash.key?('payment_profile_id') ? hash['payment_profile_id'] : SKIP
  reference = hash.key?('reference') ? hash['reference'] : SKIP
  customer_attributes = CustomerAttributes.from_hash(hash['customer_attributes']) if
    hash['customer_attributes']
  if hash['payment_profile_attributes']
    payment_profile_attributes = PaymentProfileAttributes.from_hash(hash['payment_profile_attributes'])
  end
  credit_card_attributes = PaymentProfileAttributes.from_hash(hash['credit_card_attributes']) if
    hash['credit_card_attributes']
   = BankAccountAttributes.from_hash(hash['bank_account_attributes']) if
    hash['bank_account_attributes']
  # Parameter is an array, so we need to iterate through it
  components = nil
  unless hash['components'].nil?
    components = []
    hash['components'].each do |structure|
      components << (CreateSubscriptionComponent.from_hash(structure) if structure)
    end
  end

  components = SKIP unless hash.key?('components')
  calendar_billing = CalendarBilling.from_hash(hash['calendar_billing']) if
    hash['calendar_billing']
  metafields = hash.key?('metafields') ? hash['metafields'] : SKIP
  customer_reference =
    hash.key?('customer_reference') ? hash['customer_reference'] : SKIP
  group = GroupSettings.from_hash(hash['group']) if hash['group']
  ref = hash.key?('ref') ? hash['ref'] : SKIP
  cancellation_message =
    hash.key?('cancellation_message') ? hash['cancellation_message'] : SKIP
  cancellation_method =
    hash.key?('cancellation_method') ? hash['cancellation_method'] : SKIP
  currency = hash.key?('currency') ? hash['currency'] : SKIP
  expires_at = if hash.key?('expires_at')
                 (DateTimeHelper.from_rfc3339(hash['expires_at']) if hash['expires_at'])
               else
                 SKIP
               end
  expiration_tracks_next_billing_change =
    hash.key?('expiration_tracks_next_billing_change') ? hash['expiration_tracks_next_billing_change'] : SKIP
  agreement_terms =
    hash.key?('agreement_terms') ? hash['agreement_terms'] : SKIP
  authorizer_first_name =
    hash.key?('authorizer_first_name') ? hash['authorizer_first_name'] : SKIP
  authorizer_last_name =
    hash.key?('authorizer_last_name') ? hash['authorizer_last_name'] : SKIP
  calendar_billing_first_charge =
    hash.key?('calendar_billing_first_charge') ? hash['calendar_billing_first_charge'] : SKIP
  reason_code = hash.key?('reason_code') ? hash['reason_code'] : SKIP
  product_change_delayed =
    hash.key?('product_change_delayed') ? hash['product_change_delayed'] : SKIP
  offer_id = hash.key?('offer_id') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:CreateSubscriptionOfferId), hash['offer_id']
  ) : SKIP
  prepaid_configuration = UpsertPrepaidConfiguration.from_hash(hash['prepaid_configuration']) if
    hash['prepaid_configuration']
  previous_billing_at = if hash.key?('previous_billing_at')
                          (DateTimeHelper.from_rfc3339(hash['previous_billing_at']) if hash['previous_billing_at'])
                        else
                          SKIP
                        end
  import_mrr = hash.key?('import_mrr') ? hash['import_mrr'] : SKIP
  canceled_at = if hash.key?('canceled_at')
                  (DateTimeHelper.from_rfc3339(hash['canceled_at']) if hash['canceled_at'])
                else
                  SKIP
                end
  activated_at = if hash.key?('activated_at')
                   (DateTimeHelper.from_rfc3339(hash['activated_at']) if hash['activated_at'])
                 else
                   SKIP
                 end
  agreement_acceptance = AgreementAcceptance.from_hash(hash['agreement_acceptance']) if
    hash['agreement_acceptance']
  ach_agreement = ACHAgreement.from_hash(hash['ach_agreement']) if hash['ach_agreement']
  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
  skip_billing_manifest_taxes =
    hash.key?('skip_billing_manifest_taxes') ? hash['skip_billing_manifest_taxes'] : SKIP

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  CreateSubscription.new(product_handle: product_handle,
                         product_id: product_id,
                         product_price_point_handle: product_price_point_handle,
                         product_price_point_id: product_price_point_id,
                         custom_price: custom_price,
                         coupon_code: coupon_code,
                         coupon_codes: coupon_codes,
                         payment_collection_method: payment_collection_method,
                         receives_invoice_emails: receives_invoice_emails,
                         net_terms: net_terms,
                         customer_id: customer_id,
                         next_billing_at: next_billing_at,
                         initial_billing_at: initial_billing_at,
                         defer_signup: ,
                         stored_credential_transaction_id: stored_credential_transaction_id,
                         sales_rep_id: sales_rep_id,
                         payment_profile_id: payment_profile_id,
                         reference: reference,
                         customer_attributes: customer_attributes,
                         payment_profile_attributes: payment_profile_attributes,
                         credit_card_attributes: credit_card_attributes,
                         bank_account_attributes: ,
                         components: components,
                         calendar_billing: calendar_billing,
                         metafields: metafields,
                         customer_reference: customer_reference,
                         group: group,
                         ref: ref,
                         cancellation_message: cancellation_message,
                         cancellation_method: cancellation_method,
                         currency: currency,
                         expires_at: expires_at,
                         expiration_tracks_next_billing_change: expiration_tracks_next_billing_change,
                         agreement_terms: agreement_terms,
                         authorizer_first_name: authorizer_first_name,
                         authorizer_last_name: authorizer_last_name,
                         calendar_billing_first_charge: calendar_billing_first_charge,
                         reason_code: reason_code,
                         product_change_delayed: product_change_delayed,
                         offer_id: offer_id,
                         prepaid_configuration: prepaid_configuration,
                         previous_billing_at: previous_billing_at,
                         import_mrr: import_mrr,
                         canceled_at: canceled_at,
                         activated_at: activated_at,
                         agreement_acceptance: agreement_acceptance,
                         ach_agreement: ach_agreement,
                         dunning_communication_delay_enabled: dunning_communication_delay_enabled,
                         dunning_communication_delay_time_zone: dunning_communication_delay_time_zone,
                         skip_billing_manifest_taxes: skip_billing_manifest_taxes,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
# File 'lib/advanced_billing/models/create_subscription.rb', line 327

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['product_handle'] = 'product_handle'
  @_hash['product_id'] = 'product_id'
  @_hash['product_price_point_handle'] = 'product_price_point_handle'
  @_hash['product_price_point_id'] = 'product_price_point_id'
  @_hash['custom_price'] = 'custom_price'
  @_hash['coupon_code'] = 'coupon_code'
  @_hash['coupon_codes'] = 'coupon_codes'
  @_hash['payment_collection_method'] = 'payment_collection_method'
  @_hash['receives_invoice_emails'] = 'receives_invoice_emails'
  @_hash['net_terms'] = 'net_terms'
  @_hash['customer_id'] = 'customer_id'
  @_hash['next_billing_at'] = 'next_billing_at'
  @_hash['initial_billing_at'] = 'initial_billing_at'
  @_hash['defer_signup'] = 'defer_signup'
  @_hash['stored_credential_transaction_id'] =
    'stored_credential_transaction_id'
  @_hash['sales_rep_id'] = 'sales_rep_id'
  @_hash['payment_profile_id'] = 'payment_profile_id'
  @_hash['reference'] = 'reference'
  @_hash['customer_attributes'] = 'customer_attributes'
  @_hash['payment_profile_attributes'] = 'payment_profile_attributes'
  @_hash['credit_card_attributes'] = 'credit_card_attributes'
  @_hash['bank_account_attributes'] = 'bank_account_attributes'
  @_hash['components'] = 'components'
  @_hash['calendar_billing'] = 'calendar_billing'
  @_hash['metafields'] = 'metafields'
  @_hash['customer_reference'] = 'customer_reference'
  @_hash['group'] = 'group'
  @_hash['ref'] = 'ref'
  @_hash['cancellation_message'] = 'cancellation_message'
  @_hash['cancellation_method'] = 'cancellation_method'
  @_hash['currency'] = 'currency'
  @_hash['expires_at'] = 'expires_at'
  @_hash['expiration_tracks_next_billing_change'] =
    'expiration_tracks_next_billing_change'
  @_hash['agreement_terms'] = 'agreement_terms'
  @_hash['authorizer_first_name'] = 'authorizer_first_name'
  @_hash['authorizer_last_name'] = 'authorizer_last_name'
  @_hash['calendar_billing_first_charge'] =
    'calendar_billing_first_charge'
  @_hash['reason_code'] = 'reason_code'
  @_hash['product_change_delayed'] = 'product_change_delayed'
  @_hash['offer_id'] = 'offer_id'
  @_hash['prepaid_configuration'] = 'prepaid_configuration'
  @_hash['previous_billing_at'] = 'previous_billing_at'
  @_hash['import_mrr'] = 'import_mrr'
  @_hash['canceled_at'] = 'canceled_at'
  @_hash['activated_at'] = 'activated_at'
  @_hash['agreement_acceptance'] = 'agreement_acceptance'
  @_hash['ach_agreement'] = 'ach_agreement'
  @_hash['dunning_communication_delay_enabled'] =
    'dunning_communication_delay_enabled'
  @_hash['dunning_communication_delay_time_zone'] =
    'dunning_communication_delay_time_zone'
  @_hash['skip_billing_manifest_taxes'] = 'skip_billing_manifest_taxes'
  @_hash
end

.nullablesObject

An array for nullable fields



444
445
446
447
448
# File 'lib/advanced_billing/models/create_subscription.rb', line 444

def self.nullables
  %w[
    dunning_communication_delay_time_zone
  ]
end

.optionalsObject

An array for optional fields



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
432
433
434
435
436
437
438
439
440
441
# File 'lib/advanced_billing/models/create_subscription.rb', line 388

def self.optionals
  %w[
    product_handle
    product_id
    product_price_point_handle
    product_price_point_id
    custom_price
    coupon_code
    coupon_codes
    payment_collection_method
    receives_invoice_emails
    net_terms
    customer_id
    next_billing_at
    initial_billing_at
    defer_signup
    stored_credential_transaction_id
    sales_rep_id
    payment_profile_id
    reference
    customer_attributes
    payment_profile_attributes
    credit_card_attributes
    bank_account_attributes
    components
    calendar_billing
    metafields
    customer_reference
    group
    ref
    cancellation_message
    cancellation_method
    currency
    expires_at
    expiration_tracks_next_billing_change
    agreement_terms
    authorizer_first_name
    authorizer_last_name
    calendar_billing_first_charge
    reason_code
    product_change_delayed
    offer_id
    prepaid_configuration
    previous_billing_at
    import_mrr
    canceled_at
    activated_at
    agreement_acceptance
    ach_agreement
    dunning_communication_delay_enabled
    dunning_communication_delay_time_zone
    skip_billing_manifest_taxes
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



763
764
765
766
767
768
769
# File 'lib/advanced_billing/models/create_subscription.rb', line 763

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
# File 'lib/advanced_billing/models/create_subscription.rb', line 805

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} product_handle: #{@product_handle.inspect}, product_id:"\
  " #{@product_id.inspect}, product_price_point_handle:"\
  " #{@product_price_point_handle.inspect}, product_price_point_id:"\
  " #{@product_price_point_id.inspect}, custom_price: #{@custom_price.inspect}, coupon_code:"\
  " #{@coupon_code.inspect}, coupon_codes: #{@coupon_codes.inspect},"\
  " payment_collection_method: #{@payment_collection_method.inspect}, receives_invoice_emails:"\
  " #{@receives_invoice_emails.inspect}, net_terms: #{@net_terms.inspect}, customer_id:"\
  " #{@customer_id.inspect}, next_billing_at: #{@next_billing_at.inspect}, initial_billing_at:"\
  " #{@initial_billing_at.inspect}, defer_signup: #{@defer_signup.inspect},"\
  " stored_credential_transaction_id: #{@stored_credential_transaction_id.inspect},"\
  " sales_rep_id: #{@sales_rep_id.inspect}, payment_profile_id:"\
  " #{@payment_profile_id.inspect}, reference: #{@reference.inspect}, customer_attributes:"\
  " #{@customer_attributes.inspect}, payment_profile_attributes:"\
  " #{@payment_profile_attributes.inspect}, credit_card_attributes:"\
  " #{@credit_card_attributes.inspect}, bank_account_attributes:"\
  " #{@bank_account_attributes.inspect}, components: #{@components.inspect}, calendar_billing:"\
  " #{@calendar_billing.inspect}, metafields: #{@metafields.inspect}, customer_reference:"\
  " #{@customer_reference.inspect}, group: #{@group.inspect}, ref: #{@ref.inspect},"\
  " cancellation_message: #{@cancellation_message.inspect}, cancellation_method:"\
  " #{@cancellation_method.inspect}, currency: #{@currency.inspect}, expires_at:"\
  " #{@expires_at.inspect}, expiration_tracks_next_billing_change:"\
  " #{@expiration_tracks_next_billing_change.inspect}, agreement_terms:"\
  " #{@agreement_terms.inspect}, authorizer_first_name: #{@authorizer_first_name.inspect},"\
  " authorizer_last_name: #{@authorizer_last_name.inspect}, calendar_billing_first_charge:"\
  " #{@calendar_billing_first_charge.inspect}, reason_code: #{@reason_code.inspect},"\
  " product_change_delayed: #{@product_change_delayed.inspect}, offer_id:"\
  " #{@offer_id.inspect}, prepaid_configuration: #{@prepaid_configuration.inspect},"\
  " previous_billing_at: #{@previous_billing_at.inspect}, import_mrr: #{@import_mrr.inspect},"\
  " canceled_at: #{@canceled_at.inspect}, activated_at: #{@activated_at.inspect},"\
  " agreement_acceptance: #{@agreement_acceptance.inspect}, ach_agreement:"\
  " #{@ach_agreement.inspect}, dunning_communication_delay_enabled:"\
  " #{@dunning_communication_delay_enabled.inspect}, dunning_communication_delay_time_zone:"\
  " #{@dunning_communication_delay_time_zone.inspect}, skip_billing_manifest_taxes:"\
  " #{@skip_billing_manifest_taxes.inspect}, additional_properties:"\
  " #{get_additional_properties}>"
end

#to_custom_activated_atObject



757
758
759
# File 'lib/advanced_billing/models/create_subscription.rb', line 757

def to_custom_activated_at
  DateTimeHelper.to_rfc3339(activated_at)
end

#to_custom_canceled_atObject



753
754
755
# File 'lib/advanced_billing/models/create_subscription.rb', line 753

def to_custom_canceled_at
  DateTimeHelper.to_rfc3339(canceled_at)
end

#to_custom_expires_atObject



745
746
747
# File 'lib/advanced_billing/models/create_subscription.rb', line 745

def to_custom_expires_at
  DateTimeHelper.to_rfc3339(expires_at)
end

#to_custom_initial_billing_atObject



741
742
743
# File 'lib/advanced_billing/models/create_subscription.rb', line 741

def to_custom_initial_billing_at
  DateTimeHelper.to_rfc3339(initial_billing_at)
end

#to_custom_next_billing_atObject



737
738
739
# File 'lib/advanced_billing/models/create_subscription.rb', line 737

def to_custom_next_billing_at
  DateTimeHelper.to_rfc3339(next_billing_at)
end

#to_custom_previous_billing_atObject



749
750
751
# File 'lib/advanced_billing/models/create_subscription.rb', line 749

def to_custom_previous_billing_at
  DateTimeHelper.to_rfc3339(previous_billing_at)
end

#to_sObject

Provides a human-readable string representation of the object.



772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
# File 'lib/advanced_billing/models/create_subscription.rb', line 772

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} product_handle: #{@product_handle}, product_id: #{@product_id},"\
  " product_price_point_handle: #{@product_price_point_handle}, product_price_point_id:"\
  " #{@product_price_point_id}, custom_price: #{@custom_price}, coupon_code: #{@coupon_code},"\
  " coupon_codes: #{@coupon_codes}, payment_collection_method: #{@payment_collection_method},"\
  " receives_invoice_emails: #{@receives_invoice_emails}, net_terms: #{@net_terms},"\
  " customer_id: #{@customer_id}, next_billing_at: #{@next_billing_at}, initial_billing_at:"\
  " #{@initial_billing_at}, defer_signup: #{@defer_signup}, stored_credential_transaction_id:"\
  " #{@stored_credential_transaction_id}, sales_rep_id: #{@sales_rep_id}, payment_profile_id:"\
  " #{@payment_profile_id}, reference: #{@reference}, customer_attributes:"\
  " #{@customer_attributes}, payment_profile_attributes: #{@payment_profile_attributes},"\
  " credit_card_attributes: #{@credit_card_attributes}, bank_account_attributes:"\
  " #{@bank_account_attributes}, components: #{@components}, calendar_billing:"\
  " #{@calendar_billing}, metafields: #{@metafields}, customer_reference:"\
  " #{@customer_reference}, group: #{@group}, ref: #{@ref}, cancellation_message:"\
  " #{@cancellation_message}, cancellation_method: #{@cancellation_method}, currency:"\
  " #{@currency}, expires_at: #{@expires_at}, expiration_tracks_next_billing_change:"\
  " #{@expiration_tracks_next_billing_change}, agreement_terms: #{@agreement_terms},"\
  " authorizer_first_name: #{@authorizer_first_name}, authorizer_last_name:"\
  " #{@authorizer_last_name}, calendar_billing_first_charge:"\
  " #{@calendar_billing_first_charge}, reason_code: #{@reason_code}, product_change_delayed:"\
  " #{@product_change_delayed}, offer_id: #{@offer_id}, prepaid_configuration:"\
  " #{@prepaid_configuration}, previous_billing_at: #{@previous_billing_at}, import_mrr:"\
  " #{@import_mrr}, canceled_at: #{@canceled_at}, activated_at: #{@activated_at},"\
  " agreement_acceptance: #{@agreement_acceptance}, ach_agreement: #{@ach_agreement},"\
  " dunning_communication_delay_enabled: #{@dunning_communication_delay_enabled},"\
  " dunning_communication_delay_time_zone: #{@dunning_communication_delay_time_zone},"\
  " skip_billing_manifest_taxes: #{@skip_billing_manifest_taxes}, additional_properties:"\
  " #{get_additional_properties}>"
end