Subscription represents the recurring items a customer has subscribed to. The recurring items can be - plan, addons. It may also contain the discount items like coupons.

Subscriptions are invoiced at the start of every term based on the recurring items and charged immediately against the customer's credit card if 'auto_collection' is turned 'on', otherwise the resulting invoice will be created as 'Payment Due'.

Sample subscription [ JSON ]

{ "activated_at": 1578727804, "auto_collection": "off", "billing_period": 1, "billing_period_unit": "month", "created_at": 1578727804, "currency_code": "USD", "current_term_end": 1581406204, "current_term_start": 1578727804, "customer_id": "__test__KyVnJjRnFcymP8oz", "deleted": false, "due_invoices_count": 1, "due_since": 1578727804, "has_scheduled_changes": false, "id": "__test__KyVnJjRnFcymP8oz", "mrr": 0, "next_billing_at": 1581406204, "object": "subscription", "plan_amount": 895, "plan_free_quantity": 0, "plan_id": "no_trial", "plan_quantity": 1, "plan_unit_price": 895, "resource_version": 1578727804000, "started_at": 1578727804, "status": "active", "total_dues": 895, "updated_at": 1578727804 }

Model Class

com.chargebee.models.Subscription
id
A unique identifier to identify the subscription. You will use this to perform all operations on this subscription.
string, max chars=50
customerId
Identifier of the customer with whom this subscription is associated.
string, max chars=50
currencyCode
The currency code (ISO 4217 format) of the subscription.
string, max chars=3
planId
Identifier of the plan for this subscription.
string, max chars=100
planQuantity
Represents the plan quantity for this subscription.
integer, default=1, min=1
planUnitPrice
Amount that will override the Plan's default price.
optional, in cents, min=0
setupFee
Amount that will override the default setup fee.
optional, in cents, min=0
planAmount

optional, in cents, min=0
billingPeriod
Defines billing frequency. Example: to bill customer every 3 months, provide "3" here.
optional, integer, min=1
billingPeriodUnit
Defines billing frequency in association with the billing period.
optional, enumerated string
Possible values are
DAYCharge based on day(s).WEEKCharge based on week(s).MONTHCharge based on month(s).YEARCharge based on year(s).
planFreeQuantity
The units of the item that will be free with this Plan.
optional, integer, min=0
status
Current state of the subscription.
enumerated string
Possible values are
FUTUREThe Subscription is scheduled to start in a future date.IN_TRIALThe subscription is in trial.ACTIVEThe subscription is in active state and will be charged at start of each term based on the recurring items(plan & addons etc.,).NON_RENEWINGThe subscription will be cancelled at end of the current term.PAUSEDThe subscription is paused. No new recurring actions will be allowed, but any pending payments will be collected.CANCELLEDThe subscription has been cancelled. No new recurring actions will take place, but any pending payments will be collected.
startDate
Applicable only for 'future' subscriptions. The scheduled start time of the 'future' subscription.
optional, timestamp(UTC) in seconds
trialStart
Start of the trial period for the subscription. Presence of this value for 'future' subscription implies the subscription will go into 'trial' state when it starts.
optional, timestamp(UTC) in seconds
trialEnd
End of the trial period for the subscription. Presence of this value for 'future' subscription implies the subscription will go into 'trial' state when it starts.
optional, timestamp(UTC) in seconds
currentTermStart
Start of the current billing term.
optional, timestamp(UTC) in seconds
currentTermEnd
End of the current billing term. Subscription is renewed immediately after this.
optional, timestamp(UTC) in seconds
nextBillingAt
Date on which the next billing happens.
optional, timestamp(UTC) in seconds
remainingBillingCycles
  • When the subscription is on a contract term: this value is the number of billing cycles remaining in the contract term after the current billing cycle.
  • When the subscription is not on a contract term: this value is the number of billing cycles remaining after the current cycle, at the end of which, the subscription cancels.
.
optional, integer, min=0
poNumber
Purchase Order Number for this subscription.
optional, string, max chars=100
createdAt
Subscription created time.
optional, timestamp(UTC) in seconds
startedAt
Time at which the subscription got started. Will be null for 'future' subscriptions as it is yet to be started.
optional, timestamp(UTC) in seconds
activatedAt
Time at which the subscription moved from in_trial state to active state.
optional, timestamp(UTC) in seconds
giftId
References the gift if it is a gifted subscription.
optional, string, max chars=150
contractTermBillingCycleOnRenewal
Number of billing cycles the new contract term should run for, on contract renewal. The default value is as specified in the site settings.
optional, integer, min=1, max=100
overrideRelationship
If true, ignores the hierarchy relationship and uses customer as payment and invoice owner.
optional, boolean
pauseDate
Date on which the subscription will be paused.
optional, timestamp(UTC) in seconds
resumeDate
Date on which the subscription will be resumed.
optional, timestamp(UTC) in seconds
cancelledAt
Time at which subscription was cancelled or is set to be cancelled.
optional, timestamp(UTC) in seconds
cancelReason
Possible reason the subscription might be cancelled.
optional, enumerated string
Possible values are
NOT_PAIDNot Paid.NO_CARDNo Card.FRAUD_REVIEW_FAILEDFraud Review Failed.NON_COMPLIANT_EU_CUSTOMERNon Compliant EU Customer.TAX_CALCULATION_FAILEDTax Calculation Failed.CURRENCY_INCOMPATIBLE_WITH_GATEWAYCurrency incompatible with Gateway.NON_COMPLIANT_CUSTOMERNon Compliant Customer.
affiliateToken
A unique tracking token.
optional, string, max chars=250
createdFromIp
The IP address of the user. Used primarly in refersion integration. Refersion uses this field to track/log affiliate subscription.
optional, string, max chars=50
resourceVersion
Version number of this resource. Each update of this resource results in incremental change of this number. This attribute will be present only if the resource has been updated after 2016-09-28.
optional, long
updatedAt
Timestamp indicating when this subscription was last updated. This attribute will be present only if the resource has been updated after 2016-09-28.
Note: This value does not change when the following attributes are changed: due_invoices_count, due_since, total_dues.
optional, timestamp(UTC) in seconds
hasScheduledChanges
If true, there are subscription changes scheduled on next renewal.
boolean, default=false
paymentSourceId
Payment source attached to this subscription. If present, customer's payment sources won't be used to collect any payment for this subscripiton.
optional, string, max chars=40
autoCollection
Defines whether payments need to be collected automatically for this subscription. Overrides customer's auto-collection property.
optional, enumerated string
Possible values are
ONWhenever an invoice is created for this subscription, an automatic charge will be attempted on the payment method available.OFFAutomatic collection of charges will not be made for this subscription. All payments must be recorded offline.
dueInvoicesCount
Total number of invoices that are due for payment.
Note: Not supported if consolidated invoicing is enabled or when the subscription is for the customer who is in hierarchy and the parent of this customer owns and pays for the invoices of the subscription.
optional, integer
dueSince
Time since this subscription has unpaid invoices.
Note: Not supported if consolidated invoicing is enabled or when the subscription is for the customer who is in hierarchy and the parent of this customer owns and pays for the invoices of the subscription.
optional, timestamp(UTC) in seconds
totalDues
Total invoice due amount for this subscription.
Note: Not supported if consolidated invoicing is enabled or when the subscription is for the customer who is in hierarchy and the parent of this customer owns and pays for the invoices of the subscription.
optional, in cents, min=0
mrr
Monthly recurring revenue for the subscription.
Note: This may not return accurate values since updated asynchronously.
optional, in cents, min=1
exchangeRate
Exchange rate used for base currency conversion.
optional, bigdecimal, min=1E-9, max=999999999.999999999
baseCurrencyCode
Base currency code (ISO 4217 format).
optional, string, max chars=3
invoiceNotes
Invoice Notes for this resource. Read More.
optional, string, max chars=2000
metaData
Additional data about this resource can be stored here in the JSON Format. Learn more.
optional, jsonobject
deleted
Indicates that this resource has been deleted.
boolean
cancelReasonCode
Reason code for canceling the subscription. Must be one from a list of reason codes set in the Chargebee app in Settings > Configure Chargebee > Reason Codes > Subscriptions > Subscription Cancellation. Must be passed if set as mandatory in the app. The codes are case-sensitive.
optional, string, max chars=100
List of addons for this subscription with quantity(if applicable).
optional, list of addon
Addon attributes
id
Identifier of the addon. Multiple addons can be passed.
string, max chars=100
quantity
Addon quantity. Applicable only for the quantity based addons. Should be passed with the same index as that of associated addon id.
optional, integer, default=1, min=1
unitPrice
Amount that will override the Addon's default price. The Plan's billing frequency will not be considered for overriding. E.g. If the Plan's billing frequency is every 3 months, and if the price override amount is $10, $10 will be used, and not $30 (i.e $10*3).
optional, in cents, min=0
amount

optional, in cents, min=0
trialEnd
The time at which the trial ends for the addon. This value can only be set for subscriptions that start with an active or non-renewing status. Once set, the value can't be changed. (Addon trial periods must be enabled by Chargebee Support.).
optional, timestamp(UTC) in seconds
remainingBillingCycles
The number of billing cycles this addon will be attached to subscription.
optional, integer, min=0
eventBasedAddons
Show attributes[+]
List of non-recurring addons that will be charged on the occurrence of specified event.
optional, list of event_based_addon
Event based addon attributes
id
A unique 'id' used to identify the addon.
string, max chars=100
quantity
Addon quantity. Applicable only for the quantity based addons. Should be passed with the same index as that of associated addon id.
integer, min=1
unitPrice
Amount that will override the Addon's default price.
in cents, min=0
onEvent
Event on which this addon will be charged.
enumerated string
Possible values are
SUBSCRIPTION_CREATIONAddon will be charged on subscription creation.SUBSCRIPTION_TRIAL_STARTAddon will be charged when the trial period starts.PLAN_ACTIVATIONAddon will be charged on plan activation.SUBSCRIPTION_ACTIVATIONAddon will be charged on subscription activation.CONTRACT_TERMINATIONAddon will be charged on contract termination.
chargeOnce
If enabled, the addon will be charged only at the first occurrence of the event. Applicable only for non-recurring add-ons.
boolean, default=true
chargedEventBasedAddons
Show attributes[+]
List of event_based_addons that have already been charged.
optional, list of charged_event_based_addon
Charged event based addon attributes
id
Addon id.
string, max chars=100
lastChargedAt
Timestamp indicating when this add-on was last charged for this subscription.
timestamp(UTC) in seconds
List of coupons for this subscription.
optional, list of coupon
Coupon attributes
couponId
Used to uniquely identify the coupon.
string, max chars=50
applyTill
The date till the coupon is to be applied. Applicable for "limited months" coupons.
optional, timestamp(UTC) in seconds
appliedCount
Number of times this coupon has been applied for this subscription.
integer, default=0
couponCode
The coupon code used to redeem the coupon. Will be present only when associated code for a coupon is used.
optional, string, max chars=50
shippingAddress
Show attributes[+]
Shipping address for the subscription.
optional, shipping_address
Shipping addres attributes
firstName
First name.
optional, string, max chars=150
lastName
Last name.
optional, string, max chars=150
email
Email.
optional, string, max chars=70
company
Company name.
optional, string, max chars=250
phone
Phone number.
optional, string, max chars=50
line1
Address line 1.
optional, string, max chars=180
line2
Address line 2.
optional, string, max chars=150
line3
Address line 3.
optional, string, max chars=150
city
City.
optional, string, max chars=50
stateCode
The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set the state_code as AZ (not US-AZ). or, for Tamil Nadu (India), set the state_code as TN (not IN-TN). or, for British Columbia (Canada), set the state_code as BC (not CA-BC).
Note: If the 'state_code' is specified, the 'state' attribute should not be provided as Chargebee will set the value automatically (for US, Canada, India).
optional, string, max chars=50
state
The state/province name.
optional, string, max chars=50
country
2-letter ISO 3166 alpha-2 country code.
optional, string, max chars=50
zip
Zip or Postal code.
optional, string, max chars=20
validationStatus
The address verification status.
optional, enumerated string, default=not_validated
Possible values are
NOT_VALIDATEDAddress is not yet validated.VALIDAddress was validated successfully.PARTIALLY_VALIDAddress is verified but only partially.INVALIDAddress is invalid.
referralInfo
Show attributes[+]
Referral details if exists for the subscription.
optional, referral_info
Referral info attributes
referralCode
Referral code if available for the subscription.
optional, string, max chars=50
couponCode
Referral coupon code if available for the subscription.
optional, string, max chars=50
referrerId
Referrer id if available for the subscription.
optional, string, max chars=19
externalReferenceId
External reference id in referral system for the subscription.
optional, string, max chars=50
rewardStatus
Reward status for the referral subscription.
optional, enumerated string, default=pending
Possible values are
PENDINGPending.PAIDPaid.INVALIDInvalid.
referralSystem
Source referral system for the referral subscription.
optional, enumerated string
Possible values are
REFERRAL_CANDYReferral Candy.REFERRAL_SAASQUATCHReferral Saasquatch.FRIENDBUYFriendbuy.
accountId
Referral account id.
string, max chars=50
campaignId
Referral campaign id.
string, max chars=50
externalCampaignId
Referral external campaign id.
optional, string, max chars=100
friendOfferType
Friend offer type for the referral camapign.
optional, enumerated string
Possible values are
NONENone.COUPONCoupon.COUPON_CODECoupon Code.
referrerRewardType
Referrer reward type for the referral campaign.
optional, enumerated string
Possible values are
NONENone.REFERRAL_DIRECT_REWARDReferral Direct Reward.CUSTOM_PROMOTIONAL_CREDITCustom Promotional Credit.CUSTOM_REVENUE_PERCENT_BASEDCustom Revenue Percent Based.
notifyReferralSystem
Whether or not to notify the referral purchases to the referral system.
optional, enumerated string
Possible values are
NONENone.FIRST_PAID_CONVERSIONFirst Paid Conversion.ALL_INVOICESAll Invoices.
destinationUrl
Destination url for the referral campaign.
optional, string, max chars=250
postPurchaseWidgetEnabled
Whether post purchase widget is enabled for this campaign.
boolean, default=true
contractTerm
Show attributes[+]
Contract terms for this subscription.
optional, contract_term
Contract term attributes
id
Id that uniquely identifies the contract term in the site.
string, max chars=50
status
Current status of contract.
enumerated string
Possible values are
ACTIVEAn actively running contract term.COMPLETEDThe contract term has run its full duration.CANCELLEDThe contract term was ended because: .TERMINATEDThe contract term was terminated ahead of completion.
contractStart
The start date of the contract term.
timestamp(UTC) in seconds
contractEnd
The end date of the contract term.
timestamp(UTC) in seconds
billingCycle
The number of billing cycles of the subscription that the contract term is for.
integer, min=0
actionAtTermEnd
Action to be taken when the contract term completes.
enumerated string, default=renew
Possible values are
RENEW
  • Contract term completes and a new contract term is started for the number of billing cycles specified in contract_billing_cycle_on_renewal.
  • The action_at_term_end for the new contract term is set to renew.
  • .
    EVERGREENContract term completes and the subscription renews.CANCELContract term completes and subscription is canceled.RENEW_ONCEUsed when you want to renew the contract term just once. Does the following:
  • Contract term completes and a new contract term is started for the number of billing cycles specified in contract_billing_cycle_on_renewal.
  • The action_at_term_end for the new contract term is set to cancel.
  • .
    totalContractValue
    The sum of the totals of all the invoices raised as part of the contract term. For active contract terms, this includes the invoices raised thus far and estimated invoice totals till the end of the contract term. If the subscription was imported with the contract term, then this value includes the value passed for total_amount_raised.
    in cents, default=0, min=0
    cancellationCutoffPeriod
    The number of days before contract_end, during which the customer is barred from canceling the contract term. The customer is allowed to cancel the contract term via the Self-Serve Portal only before this period. This allows you to have sufficient time for processing the contract term closure.
    optional, integer
    createdAt
    The date when the contract term was created.
    timestamp(UTC) in seconds
    subscriptionId
    The Id of the subscription that this contract term is for.
    string, max chars=50
    remainingBillingCycles
    The number of subscription billing cycles remaining after the current one for the contract term. This attribute is only returned for active contract terms.
    optional, integer, min=0
    This operation supports 3DS verification flow. To acheive the same, create the Payment Intent and pass it as input parameter to this API.

    Creates a new subscription along with the customer. You can attach a plan, plan quantity, one or more addons and coupon while creating this subscription.

    Future Subscriptions

    If the start_date is specified, the subscription will be created in 'future' state (.ie, instead of starting immediately it will be scheduled to start at the specified 'start_date'). Besides if 'trial' is specified (plan configuration or specified explictly using trial_end), the subscription will go into 'trial' state when it starts. Otherwise it will directly become 'active' when it starts.

    Trial Period

    If the plan has trial period or if the trial_end is specified explicitly, the subscription will be created in 'in_trial' state.

    If the card details are passed, it is not charged until the end of the trial period. Incase you need to verify the card you could enable the 'card verification option' in the gateway settings.

    Invoice

    If the plan does not have a trial period and if any of the recurring items has charges, then a invoice would be raised immediately. If 'auto_collection' is turned 'on', then card attributes are mandatory and subscription will be created only if the payment was successful.

    Card details

    Passing card details to this API involves PCI liability at your end as sensitive card information passes through your servers. If you wish to avoid that, you can use one of the following integration methodologies if applicable

    • If you are using Stripe gateway, you can use Stripe.js with your checkout form. Please refer this tutorial for more details.
    • If you are using Braintree gateway, you can use Braintree.js with your checkout form. Please refer this tutorial for more details.
    • If you are using Authorize.Net gateway, you use Accept.js with your checkout form.
    • In case you are using the Adyen gateway, you will have to use the Adyen’s Client Side Encryption to encrypt sensitive cardholder data. Once the cardholder data is encrypted, pass the value in adyen.encrypted.data as temp token in this API.
    You can also use our Hosted Pages based integration.

    Billing Address

    The Billing Address is significant especially when EU VAT taxes are involved, for tax calculations will be based on this address. For customers without Billing Address, EU VAT taxes will not be included. Thus ensure to set this properly if you have configured EU VAT Tax.

    Note: For the sites created before 1st Mar 2014, customer's billing address and 'vat_number' will be replaced automatically whenever the associated card gets updated. i.e existing values for billing address and 'vat_number' will be cleared and the new values will be set. This behaviour is changed now - The VAT number should always be passed along billing address and not with card address. Both the addresses have to be dealt separately.

    Billing Address attributes shall be explicitly passed for customers paying offline(Cash, Check, Bank Transfer etc).

    Related Tutorials

    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    /* 
        creates a subscription with customer information and billing details.
    */
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.create()
    	.planId("no_trial")
    	.autoCollection(AutoCollection.OFF)
    	.customerFirstName("John")
    	.customerLastName("Doe")
    	.customerEmail("john@user.com")
    	.billingAddressFirstName("John")
    	.billingAddressLastName("Doe")
    	.billingAddressLine1("PO Box 9999")
    	.billingAddressCity("Walnut")
    	.billingAddressState("California")
    	.billingAddressZip("91789")
    	.billingAddressCountry("US")
    	.request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
    Invoice invoice = result.invoice();
    List<UnbilledCharge> unbilledCharges = result.unbilledCharges();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet

    Sample Result [ JSON ]

    Method

    Subscription.create()
    
    id(val)
    Id for the new subscription. If not given, this will be auto-generated.
    optional, string, max chars=50
    planId(val)
    Identifier of the plan for this subscription.
    required, string, max chars=100
    planQuantity(val)
    Plan quantity for this subscription.
    optional, integer, default=1, min=1
    planUnitPrice(val)
    Amount that will override the Plan's default price.
    optional, in cents, min=0
    setupFee(val)
    Amount that will override the default setup fee.
    optional, in cents, min=0
    trialEnd(val)
    The time at which the trial ends for this subscription. Can be specified to override the default trial period.If '0' is passed, the subscription will be activated immediately.
    optional, timestamp(UTC) in seconds
    billingCycles(val)
    Number of cycles(plan interval) this subscription should be charged. After the billing cycles exhausted, the subscription will be cancelled.
    optional, integer, min=0
    mandatoryAddonsToRemove(val)
    List of addons IDs that are mandatory to the plan and has to be removed from the subscription.
    optional, list of string
    startDate(val)
    Allows you to specify a future date or a past date on which the subscription starts.Past dates can be entered in case the subscription has already started. Any past date entered must be within the current billing cycle/plan term. The subscription will start immediately if this parameter is not passed.
    optional, timestamp(UTC) in seconds
    autoCollection(val)
    Defines whether payments need to be collected automatically for this subscription. Overrides customer's auto-collection property.
    optional, enumerated string
    Possible values are
    ONWhenever an invoice is created for this subscription, an automatic charge will be attempted on the payment method available.OFFAutomatic collection of charges will not be made for this subscription. All payments must be recorded offline.
    termsToCharge(val)
    The number of future renewals for which advance invoicing is done. However, if a new term gets started in this operation, the specified terms_to_charge will be inclusive of this new term.
    optional, integer, min=1
    billingAlignmentMode(val)
    Applicable when calendar billing is enabled and subscription is getting created in active / non_renewing states. Unless specified the configured default value will be used.
    optional, enumerated string
    Possible values are
    IMMEDIATESubscription period will be aligned with the configured billing date immediately.DELAYEDSubscription period will be aligned with the configured billing date at a later date (subsequent renewals).
    poNumber(val)
    Purchase Order Number for this subscription.
    optional, string, max chars=100
    couponIds(val)
    Identifier of the coupon as a List. Coupon Codes can also be passed.
    optional, list of string
    tokenId(val)
    Token generated by Chargebee JS representing payment method details.
    optional, string, max chars=40
    affiliateToken(val)
    A unique tracking token.
    optional, string, max chars=250
    invoiceNotes(val)
    Invoice Notes for this resource. Read More.
    optional, string, max chars=2000
    metaData(val)
    Additional data about this resource can be stored here in the JSON Format. Learn more.
    optional, jsonobject
    invoiceImmediately(val)
    Applicable when charges are added during this operation. If specified as false, these charges will be added to unbilled charges. The default value for this parameter will be as per your site settings.
    optional, boolean
    contractTermBillingCycleOnRenewal(val)
    Number of billing cycles the new contract term should run for, on contract renewal. The default value is as specified in the site settings.
    optional, integer, min=1, max=100
    clientProfileId(val)
    Indicates the Client profile id for the customer. This is applicable only if you use Chargebee’s AvaTax for Communications integration.
    optional, string, max chars=50
    +
    customer
    Parameters for customer
    methods are prefixed like customer<param name>(val)
    customerId(val)
    Id for the new customer. If not given, this will be same as the subscription id.
    optional, string, max chars=50
    customerEmail(val)
    Email of the customer. Configured email notifications will be sent to this email.
    optional, string, max chars=70
    customerFirstName(val)
    First name of the customer.
    optional, string, max chars=150
    customerLastName(val)
    Last name of the customer.
    optional, string, max chars=150
    customerCompany(val)
    Company name of the customer.
    optional, string, max chars=250
    customerTaxability(val)
    Specifies if the customer is liable for tax.
    optional, enumerated string, default=taxable
    Possible values are
    TAXABLECustomer is taxable.EXEMPT
    • Customer is exempted from tax
    • Optionally, specify entity_code or exempt_number attributes if you use Chargebee’s AvaTax for Sales or specify exemption_details attribute if you use Chargebee’s AvaTax for Communications integration. Tax may still be applied by Avalara for certain values of entity_code/exempt_number/exemption_details based on the state/region/province of the taxable address.
    .
    customerLocale(val)
    Determines which region-specific language Chargebee uses to communicate with the customer. In the absence of the locale attribute, Chargebee will use your site's default language for customer communication.
    optional, string, max chars=50
    customerEntityCode(val)
    The exemption category of the customer, for USA and Canada. Applicable if you use Chargebee's AvaTax for Sales integration.
    optional, enumerated string
    Possible values are
    AFederal government.BState government.CTribe/Status Indian/Indian Band.DForeign diplomat.
    ECharitable or benevolent organization.FReligious organization.GResale.HCommercial agricultural production.IIndustrial production/manufacturer.JDirect pay permit.KDirect mail.LOther or custom.MEducational organization.NLocal government.PCommercial aquaculture.QCommercial Fishery.RNon-resident.MED1US Medical Device Excise Tax with exempt sales tax.MED2US Medical Device Excise Tax with taxable sales tax.
    Show all values[+]
    customerExemptNumber(val)
    Any string value that will cause the sale to be exempted. Use this if your finance team manually verifies and tracks exemption certificates. Applicable if you use Chargebee's AvaTax for Sales integration.
    optional, string, max chars=100
    customerNetTermDays(val)
    The number of days within which the customer has to make payment for the invoice.
    optional, integer, default=0
    customerTaxjarExemptionCategory(val)
    Indicates the exemption type of the customer. This is applicable only if you use Chargebee’s TaxJar integration.
    optional, enumerated string
    Possible values are
    WHOLESALEWhole-sale.GOVERNMENTGovernment.OTHEROther.
    customerPhone(val)
    Phone number of the customer.
    optional, string, max chars=50
    customerAutoCollection(val)
    Whether payments needs to be collected automatically for this customer.
    optional, enumerated string, default=on
    Possible values are
    ONWhenever an invoice is created, an automatic attempt to charge the customer's payment method is made.OFFAutomatic collection of charges will not be made. All payments must be recorded offline.
    customerAllowDirectDebit(val)
    Whether the customer can pay via Direct Debit.
    optional, boolean, default=false
    customerConsolidatedInvoicing(val)
    Applicable when consolidated invoicing is enabled. Indicates whether invoice consolidation should happen during subscription renewals. Needs to be set only if this value is different from the defaults configured.
    optional, boolean
    customerVatNumber(val)
    VAT/ Tax registration number of the customer. Learn more.
    optional, string, max chars=20
    customerRegisteredForGst(val)
    Confirms that a customer is registered under GST. This field is available for Australia only.
    optional, boolean
    customerBusinessCustomerWithoutVatNumber(val)
    Confirms that a customer is a valid business without VAT number.
    optional, boolean
    customerExemptionDetails(val)
    Indicates the exemption information. You can customize customer exemption based on specific Location, Tax level (Federal, State, County and Local), Category of Tax or specific Tax Name. This is applicable only if you use Chargebee’s AvaTax for Communications integration.
    To know more about what values you need to provide, refer to this Avalara’s API document.
    optional, jsonarray
    customerCustomerType(val)
    Indicates the type of the customer. This is applicable only if you use Chargebee’s AvaTax for Communications integration.
    optional, enumerated string
    Possible values are
    RESIDENTIALWhen the purchase is made by a customer for home use.BUSINESSWhen the purchase is made at a place of business.SENIOR_CITIZENWhen the purchase is made by a customer who meets the jurisdiction requirements to be considered a senior citizen and qualifies for senior citizen tax breaks.INDUSTRIALWhen the purchase is made by an industrial business.
    +
    card
    Parameters for card
    methods are prefixed like card<param name>(val)
    cardGatewayAccountId(val)
    The gateway account in which this payment source is stored.
    optional, string, max chars=50
    cardFirstName(val)
    Cardholder's first name.
    optional, string, max chars=50
    cardLastName(val)
    Cardholder's last name.
    optional, string, max chars=50
    cardNumber(val)
    The credit card number without any format. If you are using Braintree.js, you can specify the Braintree encrypted card number here.
    required if card provided, string, max chars=1500
    cardExpiryMonth(val)
    Card expiry month.
    required if card provided, integer, min=1, max=12
    cardExpiryYear(val)
    Card expiry year.
    required if card provided, integer
    cardCvv(val)
    The card verification value. If you are using Braintree.js, you can specify the Braintree encrypted cvv here.
    optional, string, max chars=520
    cardBillingAddr1(val)
    Address line 1, as available in card billing address.
    optional, string, max chars=150
    cardBillingAddr2(val)
    Address line 2, as available in card billing address.
    optional, string, max chars=150
    cardBillingCity(val)
    City, as available in card billing address.
    optional, string, max chars=50
    cardBillingStateCode(val)
    The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set the state_code as AZ (not US-AZ). or, for Tamil Nadu (India), set the state_code as TN (not IN-TN). or, for British Columbia (Canada), set the state_code as BC (not CA-BC).
    Note: If the 'state_code' is specified, the 'state' attribute should not be provided as Chargebee will set the value automatically (for US, Canada, India).
    optional, string, max chars=50
    cardBillingState(val)
    The state/province name. Use this to pass the state/province information for cases where 'state_code' is not supported or cannot be passed.
    optional, string, max chars=50
    cardBillingZip(val)
    Postal or Zip code, as available in card billing address.
    optional, string, max chars=20
    cardBillingCountry(val)
    2-letter ISO 3166 alpha-2 country code.
    optional, string, max chars=50
    +
    bankAccount
    Parameters for bankAccount
    methods are prefixed like bankAccount<param name>(val)
    bankAccountGatewayAccountId(val)
    The gateway account in which this payment source is stored.
    optional, string, max chars=50
    bankAccountIban(val)
    Account holder’s International Bank Account Number.
    optional, string, min chars=10, max chars=50
    bankAccountFirstName(val)
    Account holder’s first name as per bank account. If not passed, details from customer details will be considered.
    optional, string, max chars=150
    bankAccountLastName(val)
    Account holder’s last name as per bank account. If not passed, details from customer details will be considered.
    optional, string, max chars=150
    bankAccountCompany(val)
    Account holder’s company name as per bank account. If not passed, details from customer details will be considered.
    optional, string, max chars=250
    bankAccountEmail(val)
    Account holder’s email address. If not passed, details from customer details will be considered. All Direct Debit compliant emails will be sent to this email address.
    optional, string, max chars=70
    bankAccountBankName(val)
    Name of account holder’s bank.
    optional, string, max chars=100
    bankAccountAccountNumber(val)
    Account holder’s bank account number.
    optional, string, min chars=4, max chars=17
    bankAccountRoutingNumber(val)
    Bank account routing number.
    optional, string, min chars=3, max chars=9
    bankAccountBankCode(val)
    Indicates the bank code.
    optional, string, max chars=20
    bankAccountAccountType(val)
    For Authorize.net ACH users only. Indicates the type of account.
    optional, enumerated string
    Possible values are
    CHECKINGChecking Account.SAVINGSSavings Account.BUSINESS_CHECKINGBusiness Checking Account.
    bankAccountAccountHolderType(val)
    For Stripe ACH users only. Indicates the account holder type.
    optional, enumerated string
    Possible values are
    INDIVIDUALIndividual.COMPANYCompany.
    bankAccountEcheckType(val)
    For Authorize.net ACH users only. Indicates the type of eCheck.
    optional, enumerated string
    Possible values are
    WEBPayment Authorization obtained from the customer via the internet.PPDPayment Authorization is prearranged between the customer and the merchant.CCDPayment Authorization agreement from the corporate customer is required. Applicable for business_checking account_type.
    bankAccountIssuingCountry(val)
    2-letter(alpha2) ISO country code. Required when local bank details are provided, and not IBAN.
    optional, string, max chars=50
    bankAccountSwedishIdentityNumber(val)
    For GoCardless Autogiro users only. The civic/company number (personnummer, samordningsnummer, or organisationsnummer) of the customer. Must be supplied if the customer’s bank account is denominated in Swedish krona (SEK). This field cannot be changed once it has been set.
    optional, string, min chars=10, max chars=12
    +
    paymentMethod
    Parameters for paymentMethod
    methods are prefixed like paymentMethod<param name>(val)
    paymentMethodType(val)
    The type of payment method. For more details refer Update payment method for a customer API under Customer resource.
    optional, enumerated string
    Possible values are
    CARDCard based payment including credit cards and debit cards. Details about the card can be obtained from the card resource.PAYPAL_EXPRESS_CHECKOUTPayments made via PayPal Express Checkout.AMAZON_PAYMENTSPayments made via Amazon Payments.DIRECT_DEBITRepresents bank account for which the direct debit or ACH agreement/mandate is created.
    GENERICGeneric Payment Method.ALIPAYAlipay Payments.UNIONPAYUnionPay Payments.APPLE_PAYApple Pay Payments.WECHAT_PAYWeChat Pay Payments.IDEALiDEAL Payments.GOOGLE_PAYGoogle Pay Payments.SOFORTSofort Payments.BANCONTACTBancontact Card Payments.
    Show all values[+]
    paymentMethodGatewayAccountId(val)
    The gateway account in which this payment source is stored.
    optional, string, max chars=50
    paymentMethodReferenceId(val)
    The reference id. In the case of Amazon and PayPal this will be the billing agreement id. For GoCardless direct debit this will be 'mandate id'. In the case of card this will be the identifier provided by the gateway/card vault for the specific payment method resource. Note: This is not the one-time temporary token provided by gateways like Stripe.
    For more details refer Update payment method for a customer API under Customer resource.
    optional, string, max chars=200
    paymentMethodTmpToken(val)
    Single-use token created by payment gateways. In Stripe, a single-use token is created for Apple Pay Wallet or card details. In Braintree, a nonce is created for Apple Pay Wallet, PayPal, or card details. In Authorize.Net, a nonce is created for card details. In Adyen, an encrypted data is created from the card details.
    required if reference_id not provided, string, max chars=65k
    paymentMethodIssuingCountry(val)
    2-letter (alpha2) ISO country code. Indicates your customer's payment method country of issuance. Applicable for PayPal via Braintree.
    optional, string, max chars=50
    +
    paymentIntent
    Parameters for paymentIntent
    methods are prefixed like paymentIntent<param name>(val)
    paymentIntentId(val)
    Identifier for PaymentIntent generated by Chargebee.js. Applicable only when you are using Chargebee.js for completing the 3DS flow. The PaymentIntent should be in 'authorized' state while passing it here. You need not pass other PaymentIntent parameters if this is passed.
    optional, string, max chars=150
    paymentIntentGatewayAccountId(val)
    The gateway account used for performing the 3DS flow.
    required if payment intent token provided, string, max chars=50
    paymentIntentGwToken(val)
    Identifier for 3DS transaction/verification object at the gateway. Can be passed only after successfully completing the 3DS flow. Refer 3DS implementation in Chargebee to find out the gateway-specific gw_token format. Applicable when you are using gateway APIs directly for completing the 3DS flow.
    optional, string, max chars=65k
    paymentIntentReferenceId(val)
    Identifier for Braintree permanent token. Applicable when you are using Braintree APIs for completing the 3DS flow.
    optional, string, max chars=65k
    +
    billingAddress
    Parameters for billingAddress
    methods are prefixed like billingAddress<param name>(val)
    billingAddressFirstName(val)
    First name.
    optional, string, max chars=150
    billingAddressLastName(val)
    Last name.
    optional, string, max chars=150
    billingAddressEmail(val)
    Email.
    optional, string, max chars=70
    billingAddressCompany(val)
    Company name.
    optional, string, max chars=250
    billingAddressPhone(val)
    Phone number.
    optional, string, max chars=50
    billingAddressLine1(val)
    Address line 1.
    optional, string, max chars=150
    billingAddressLine2(val)
    Address line 2.
    optional, string, max chars=150
    billingAddressLine3(val)
    Address line 3.
    optional, string, max chars=150
    billingAddressCity(val)
    City.
    optional, string, max chars=50
    billingAddressStateCode(val)
    The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set the state_code as AZ (not US-AZ). or, for Tamil Nadu (India), set the state_code as TN (not IN-TN). or, for British Columbia (Canada), set the state_code as BC (not CA-BC).
    Note: If the 'state_code' is specified, the 'state' attribute should not be provided as Chargebee will set the value automatically (for US, Canada, India).
    optional, string, max chars=50
    billingAddressState(val)
    The state/province name. Use this to pass the state/province information for cases where 'state_code' is not supported or cannot be passed.
    optional, string, max chars=50
    billingAddressZip(val)
    Zip or Postal code.
    optional, string, max chars=20
    billingAddressCountry(val)
    2-letter ISO 3166 alpha-2 country code.
    optional, string, max chars=50
    billingAddressValidationStatus(val)
    The address verification status.
    optional, enumerated string, default=not_validated
    Possible values are
    NOT_VALIDATEDAddress is not yet validated.VALIDAddress was validated successfully.PARTIALLY_VALIDAddress is verified but only partially.INVALIDAddress is invalid.
    +
    shippingAddress
    Parameters for shippingAddress
    methods are prefixed like shippingAddress<param name>(val)
    shippingAddressFirstName(val)
    First name.
    optional, string, max chars=150
    shippingAddressLastName(val)
    Last name.
    optional, string, max chars=150
    shippingAddressEmail(val)
    Email.
    optional, string, max chars=70
    shippingAddressCompany(val)
    Company name.
    optional, string, max chars=250
    shippingAddressPhone(val)
    Phone number.
    optional, string, max chars=50
    shippingAddressLine1(val)
    Address line 1.
    optional, string, max chars=180
    shippingAddressLine2(val)
    Address line 2.
    optional, string, max chars=150
    shippingAddressLine3(val)
    Address line 3.
    optional, string, max chars=150
    shippingAddressCity(val)
    City.
    optional, string, max chars=50
    shippingAddressStateCode(val)
    The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set the state_code as AZ (not US-AZ). or, for Tamil Nadu (India), set the state_code as TN (not IN-TN). or, for British Columbia (Canada), set the state_code as BC (not CA-BC).
    Note: If the 'state_code' is specified, the 'state' attribute should not be provided as Chargebee will set the value automatically (for US, Canada, India).
    optional, string, max chars=50
    shippingAddressState(val)
    The state/province name. Use this to pass the state/province information for cases where 'state_code' is not supported or cannot be passed.
    optional, string, max chars=50
    shippingAddressZip(val)
    Zip or Postal code.
    optional, string, max chars=20
    shippingAddressCountry(val)
    2-letter ISO 3166 alpha-2 country code.
    optional, string, max chars=50
    shippingAddressValidationStatus(val)
    The address verification status.
    optional, enumerated string, default=not_validated
    Possible values are
    NOT_VALIDATEDAddress is not yet validated.VALIDAddress was validated successfully.PARTIALLY_VALIDAddress is verified but only partially.INVALIDAddress is invalid.
    +
    contractTerm
    Parameters for contractTerm
    methods are prefixed like contractTerm<param name>(val)
    contractTermActionAtTermEnd(val)
    Action to be taken when the contract term completes.
    optional, enumerated string, default=cancel
    Possible values are
    RENEW
  • Contract term completes and a new contract term is started for the number of billing cycles specified in contract_billing_cycle_on_renewal.
  • The action_at_term_end for the new contract term is set to renew.
  • .
    EVERGREENContract term completes and the subscription renews.CANCELContract term completes and subscription is canceled.
    contractTermCancellationCutoffPeriod(val)
    The number of days before contract_end, during which the customer is barred from canceling the contract term. The customer is allowed to cancel the contract term via the Self-Serve Portal only before this period. This allows you to have sufficient time for processing the contract term closure.
    optional, integer, default=0
    +
    addons
    Parameters for addons. Multiple addons can be passed by specifying unique indices.
    methods are prefixed like addons<param name>(idx,val)
    addonId(idx,val)
    Identifier of the addon. Multiple addons can be passed.
    optional, string, max chars=100
    addonQuantity(idx,val)
    Addon quantity. Applicable only for the quantity based addons. Should be passed with the same index as that of associated addon id.
    optional, integer, default=1, min=1
    addonUnitPrice(idx,val)
    Amount that will override the Addon's default price. The Plan's billing frequency will not be considered for overriding. E.g. If the Plan's billing frequency is every 3 months, and if the price override amount is $10, $10 will be used, and not $30 (i.e $10*3).
    optional, in cents, min=0
    addonBillingCycles(idx,val)
    Number of billing cycles the addon will be charged for. When not set, the addon is attached to the subscription for an indefinite number of billing cycles. While updating a subscription to a plan with a different billing period, set this parameter again or its value will be lost. And so, the addon will be attached indefinitely.
    optional, integer, min=1
    addonTrialEnd(idx,val)
    The time at which the trial ends for the addon. This value can only be set for subscriptions that start with an active or non-renewing status. Once set, the value can't be changed. (Addon trial periods must be enabled by Chargebee Support.).
    optional, timestamp(UTC) in seconds
    +
    eventBasedAddons
    Parameters for eventBasedAddons. Multiple eventBasedAddons can be passed by specifying unique indices.
    methods are prefixed like eventBasedAddons<param name>(idx,val)
    eventBasedAddonId(idx,val)
    A unique 'id' used to identify the addon.
    optional, string, max chars=100
    eventBasedAddonQuantity(idx,val)
    Addon quantity. Applicable only for the quantity based addons. Should be passed with the same index as that of associated addon id.
    optional, integer, min=1
    eventBasedAddonUnitPrice(idx,val)
    Amount that will override the Addon's default price.
    optional, in cents, min=0
    eventBasedAddonServicePeriodInDays(idx,val)
    Defines service period of the addon in days from the day of charge.
    optional, integer, min=1, max=730
    eventBasedAddonOnEvent(idx,val)
    Event on which this addon will be charged.
    optional, enumerated string
    Possible values are
    SUBSCRIPTION_CREATIONAddon will be charged on subscription creation.SUBSCRIPTION_TRIAL_STARTAddon will be charged when the trial period starts.PLAN_ACTIVATIONAddon will be charged on plan activation.SUBSCRIPTION_ACTIVATIONAddon will be charged on subscription activation.CONTRACT_TERMINATIONAddon will be charged on contract termination.
    eventBasedAddonChargeOnce(idx,val)
    If enabled, the addon will be charged only at the first occurrence of the event. Applicable only for non-recurring add-ons.
    optional, boolean, default=true
    eventBasedAddonChargeOn(idx,val)
    Indicates when the non-recurring addon will be charged.
    optional, enumerated string
    Possible values are
    IMMEDIATELYCharges for the addon will be applied immediately.ON_EVENTCharge for the addon will be applied on the occurrence of a specified event.
    Resource object representing subscription.
    always returned
    Resource object representing customer.
    always returned
    Resource object representing card.
    optional
    Resource object representing invoice.
    optional
    Resource object representing unbilled_charge.
    optional
    This operation supports 3DS verification flow. To acheive the same, create the Payment Intent and pass it as input parameter to this API.

    Creates a new subscription for an existing customer. You can attach a plan, plan quantity, one or more addons and coupon while creating this subscription.

    If the plan does not have a trial period and if any of the recurring-item has charges, then the customer is charged immediately if auto_collection is turned 'on'. In that case, subscription is created only if the customer has a payment method on file and attempted payment is successful.

    Notes

    If an invoice gets generated during this operation, available Credits and Excess Payments will be automatically applied.
    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.createForCustomer("__test__KyVnJjRnFd1vn8pd")
    	.planId("no_trial")
    	.shippingAddressFirstName("Mark")
    	.shippingAddressLastName("Henry")
    	.shippingAddressCompany("chargebee")
    	.startDate(1578727816)
    	.request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
    Invoice invoice = result.invoice();
    List<UnbilledCharge> unbilledCharges = result.unbilledCharges();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet

    Sample Result [ JSON ]

    Method

    Subscription.createForCustomer(<customer_id>)
    
    id(val)
    Id for the new subscription. If not given, this will be auto-generated.
    optional, string, max chars=50
    planId(val)
    Identifier of the plan for this subscription.
    required, string, max chars=100
    planQuantity(val)
    Plan quantity for this subscription.
    optional, integer, default=1, min=1
    planUnitPrice(val)
    Amount that will override the Plan's default price.
    optional, in cents, min=0
    setupFee(val)
    Amount that will override the default setup fee.
    optional, in cents, min=0
    trialEnd(val)
    The time at which the trial ends for this subscription. Can be specified to override the default trial period.If '0' is passed, the subscription will be activated immediately.
    optional, timestamp(UTC) in seconds
    billingCycles(val)
    Number of cycles(plan interval) this subscription should be charged. After the billing cycles exhausted, the subscription will be cancelled.
    optional, integer, min=0
    mandatoryAddonsToRemove(val)
    List of addons IDs that are mandatory to the plan and has to be removed from the subscription.
    optional, list of string
    startDate(val)
    Allows you to specify a future date or a past date on which the subscription starts.Past dates can be entered in case the subscription has already started. Any past date entered must be within the current billing cycle/plan term. The subscription will start immediately if this parameter is not passed.
    optional, timestamp(UTC) in seconds
    autoCollection(val)
    Defines whether payments need to be collected automatically for this subscription. Overrides customer's auto-collection property.
    optional, enumerated string
    Possible values are
    ONWhenever an invoice is created for this subscription, an automatic charge will be attempted on the payment method available.OFFAutomatic collection of charges will not be made for this subscription. All payments must be recorded offline.
    termsToCharge(val)
    The number of future renewals for which advance invoicing is done. However, if a new term gets started in this operation, the specified terms_to_charge will be inclusive of this new term.
    optional, integer, min=1
    billingAlignmentMode(val)
    Applicable when calendar billing is enabled and subscription is getting created in active / non_renewing states. Unless specified the configured default value will be used.
    optional, enumerated string
    Possible values are
    IMMEDIATESubscription period will be aligned with the configured billing date immediately.DELAYEDSubscription period will be aligned with the configured billing date at a later date (subsequent renewals).
    poNumber(val)
    Purchase Order Number for this subscription.
    optional, string, max chars=100
    couponIds(val)
    Identifier of the coupon as a List. Coupon Codes can also be passed.
    optional, list of string
    paymentSourceId(val)
    Unique identifier of the payment source to be attached to this subscription.
    optional, string, max chars=40
    overrideRelationship(val)
    If true, ignores the hierarchy relationship and uses customer as payment and invoice owner.
    optional, boolean
    invoiceNotes(val)
    Invoice Notes for this resource. Read More.
    optional, string, max chars=2000
    metaData(val)
    Additional data about this resource can be stored here in the JSON Format. Learn more.
    optional, jsonobject
    invoiceImmediately(val)
    Applicable when charges are added during this operation. If specified as false, these charges will be added to unbilled charges. The default value for this parameter will be as per your site settings.
    optional, boolean
    contractTermBillingCycleOnRenewal(val)
    Number of billing cycles the new contract term should run for, on contract renewal. The default value is as specified in the site settings.
    optional, integer, min=1, max=100
    +
    shippingAddress
    Parameters for shippingAddress
    methods are prefixed like shippingAddress<param name>(val)
    shippingAddressFirstName(val)
    First name.
    optional, string, max chars=150
    shippingAddressLastName(val)
    Last name.
    optional, string, max chars=150
    shippingAddressEmail(val)
    Email.
    optional, string, max chars=70
    shippingAddressCompany(val)
    Company name.
    optional, string, max chars=250
    shippingAddressPhone(val)
    Phone number.
    optional, string, max chars=50
    shippingAddressLine1(val)
    Address line 1.
    optional, string, max chars=180
    shippingAddressLine2(val)
    Address line 2.
    optional, string, max chars=150
    shippingAddressLine3(val)
    Address line 3.
    optional, string, max chars=150
    shippingAddressCity(val)
    City.
    optional, string, max chars=50
    shippingAddressStateCode(val)
    The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set the state_code as AZ (not US-AZ). or, for Tamil Nadu (India), set the state_code as TN (not IN-TN). or, for British Columbia (Canada), set the state_code as BC (not CA-BC).
    Note: If the 'state_code' is specified, the 'state' attribute should not be provided as Chargebee will set the value automatically (for US, Canada, India).
    optional, string, max chars=50
    shippingAddressState(val)
    The state/province name. Use this to pass the state/province information for cases where 'state_code' is not supported or cannot be passed.
    optional, string, max chars=50
    shippingAddressZip(val)
    Zip or Postal code.
    optional, string, max chars=20
    shippingAddressCountry(val)
    2-letter ISO 3166 alpha-2 country code.
    optional, string, max chars=50
    shippingAddressValidationStatus(val)
    The address verification status.
    optional, enumerated string, default=not_validated
    Possible values are
    NOT_VALIDATEDAddress is not yet validated.VALIDAddress was validated successfully.PARTIALLY_VALIDAddress is verified but only partially.INVALIDAddress is invalid.
    +
    paymentIntent
    Parameters for paymentIntent
    methods are prefixed like paymentIntent<param name>(val)
    paymentIntentId(val)
    Identifier for PaymentIntent generated by Chargebee.js. Applicable only when you are using Chargebee.js for completing the 3DS flow. The PaymentIntent should be in 'authorized' state while passing it here. You need not pass other PaymentIntent parameters if this is passed.
    optional, string, max chars=150
    paymentIntentGatewayAccountId(val)
    The gateway account used for performing the 3DS flow.
    required if payment intent token provided, string, max chars=50
    paymentIntentGwToken(val)
    Identifier for 3DS transaction/verification object at the gateway. Can be passed only after successfully completing the 3DS flow. Refer 3DS implementation in Chargebee to find out the gateway-specific gw_token format. Applicable when you are using gateway APIs directly for completing the 3DS flow.
    optional, string, max chars=65k
    paymentIntentReferenceId(val)
    Identifier for Braintree permanent token. Applicable when you are using Braintree APIs for completing the 3DS flow.
    optional, string, max chars=65k
    +
    contractTerm
    Parameters for contractTerm
    methods are prefixed like contractTerm<param name>(val)
    contractTermActionAtTermEnd(val)
    Action to be taken when the contract term completes.
    optional, enumerated string, default=cancel
    Possible values are
    RENEW
  • Contract term completes and a new contract term is started for the number of billing cycles specified in contract_billing_cycle_on_renewal.
  • The action_at_term_end for the new contract term is set to renew.
  • .
    EVERGREENContract term completes and the subscription renews.CANCELContract term completes and subscription is canceled.
    contractTermCancellationCutoffPeriod(val)
    The number of days before contract_end, during which the customer is barred from canceling the contract term. The customer is allowed to cancel the contract term via the Self-Serve Portal only before this period. This allows you to have sufficient time for processing the contract term closure.
    optional, integer, default=0
    +
    addons
    Parameters for addons. Multiple addons can be passed by specifying unique indices.
    methods are prefixed like addons<param name>(idx,val)
    addonId(idx,val)
    Identifier of the addon. Multiple addons can be passed.
    optional, string, max chars=100
    addonQuantity(idx,val)
    Addon quantity. Applicable only for the quantity based addons. Should be passed with the same index as that of associated addon id.
    optional, integer, default=1, min=1
    addonUnitPrice(idx,val)
    Amount that will override the Addon's default price. The Plan's billing frequency will not be considered for overriding. E.g. If the Plan's billing frequency is every 3 months, and if the price override amount is $10, $10 will be used, and not $30 (i.e $10*3).
    optional, in cents, min=0
    addonBillingCycles(idx,val)
    Number of billing cycles the addon will be charged for. When not set, the addon is attached to the subscription for an indefinite number of billing cycles. While updating a subscription to a plan with a different billing period, set this parameter again or its value will be lost. And so, the addon will be attached indefinitely.
    optional, integer, min=1
    addonTrialEnd(idx,val)
    The time at which the trial ends for the addon. This value can only be set for subscriptions that start with an active or non-renewing status. Once set, the value can't be changed. (Addon trial periods must be enabled by Chargebee Support.).
    optional, timestamp(UTC) in seconds
    +
    eventBasedAddons
    Parameters for eventBasedAddons. Multiple eventBasedAddons can be passed by specifying unique indices.
    methods are prefixed like eventBasedAddons<param name>(idx,val)
    eventBasedAddonId(idx,val)
    A unique 'id' used to identify the addon.
    optional, string, max chars=100
    eventBasedAddonQuantity(idx,val)
    Addon quantity. Applicable only for the quantity based addons. Should be passed with the same index as that of associated addon id.
    optional, integer, min=1
    eventBasedAddonUnitPrice(idx,val)
    Amount that will override the Addon's default price.
    optional, in cents, min=0
    eventBasedAddonServicePeriodInDays(idx,val)
    Defines service period of the addon in days from the day of charge.
    optional, integer, min=1, max=730
    eventBasedAddonOnEvent(idx,val)
    Event on which this addon will be charged.
    optional, enumerated string
    Possible values are
    SUBSCRIPTION_CREATIONAddon will be charged on subscription creation.SUBSCRIPTION_TRIAL_STARTAddon will be charged when the trial period starts.PLAN_ACTIVATIONAddon will be charged on plan activation.SUBSCRIPTION_ACTIVATIONAddon will be charged on subscription activation.CONTRACT_TERMINATIONAddon will be charged on contract termination.
    eventBasedAddonChargeOnce(idx,val)
    If enabled, the addon will be charged only at the first occurrence of the event. Applicable only for non-recurring add-ons.
    optional, boolean, default=true
    eventBasedAddonChargeOn(idx,val)
    Indicates when the non-recurring addon will be charged.
    optional, enumerated string
    Possible values are
    IMMEDIATELYCharges for the addon will be applied immediately.ON_EVENTCharge for the addon will be applied on the occurrence of a specified event.
    Resource object representing subscription.
    always returned
    Resource object representing customer.
    always returned
    Resource object representing card.
    optional
    Resource object representing invoice.
    optional
    Resource object representing unbilled_charge.
    optional
    Retrieves the list of subscriptions.
    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    
    Environment.configure("{site}","{site_api_key}");
    ListResult result = Subscription.list()
    	.limit(2)
    	.planId().in("basic","no_trial")
    	.request();
    for(ListResult.Entry entry:result) {
    	Subscription subscription = entry.subscription();
    	Customer customer = entry.customer();
    	Card card = entry.card();
    }
        System.out.println(result);
      }
    }
    copy full code
    copy snippet
    
    Environment.configure("{site}","{site_api_key}");
    ListResult result = Subscription.list()
    	.limit(2)
    	.planId().in("basic","no_trial")
    	.request();
    for(ListResult.Entry entry:result) {
    	Subscription subscription = entry.subscription();
    	Customer customer = entry.customer();
    	Card card = entry.card();
    }

    Sample Result [ JSON ]

    Show more...
    { "list": [ { "customer": { "allow_direct_debit": false, "auto_collection": "on", "billing_address": { "city": "Walnut", "country": "US", "first_name": "John", "last_name": "Doe", "line1": "PO Box 9999", "object": "billing_address", "state": "California", "state_code": "CA", "validation_status": "not_validated", "zip": "91789" }, "card_status": "no_card", "created_at": 1578727804, "deleted": false, "email": "john@user.com", "excess_payments": 0, "first_name": "John", "id": "__test__KyVnJjRnFcymP8oz", "last_name": "Doe", "net_term_days": 0, "object": "customer", "pii_cleared": "active", "preferred_currency_code": "USD", "promotional_credits": 0, "refundable_credits": 0, "resource_version": 1578727804000, "taxability": "taxable", "unbilled_charges": 0, "updated_at": 1578727804 }, "subscription": { "activated_at": 1578727804, "auto_collection": "off", "billing_period": 1, "billing_period_unit": "month", "created_at": 1578727804, "currency_code": "USD", "current_term_end": 1581406204, "current_term_start": 1578727804, "customer_id": "__test__KyVnJjRnFcymP8oz", "deleted": false, "due_invoices_count": 1, "due_since": 1578727804, "has_scheduled_changes": false, "id": "__test__KyVnJjRnFcymP8oz", "mrr": 0, "next_billing_at": 1581406204, "object": "subscription", "plan_amount": 895, "plan_free_quantity": 0, "plan_id": "no_trial", "plan_quantity": 1, "plan_unit_price": 895, "resource_version": 1578727804000, "started_at": 1578727804, "status": "active", "total_dues": 895, "updated_at": 1578727804 } }, {..} ], "next_offset": "[\"1517470226000\",\"195000001593\"]" }

    Method

    Subscription.list()
    
    limit(val)
    Limits the number of resources to be returned.
    optional, integer, default=10, min=1, max=100
    offset(val)
    Allows you to fetch the next set of resources. The value used for this parameter must be the value returned for next_offset parameter in the previous API call.
    optional, string, max chars=1000
    includeDeleted(val)
    If set to true, includes the deleted resources in the response. For the deleted resources in the response, the 'deleted' attribute will be 'true'.
    optional, boolean, default=false
    sortBy<Attribute>(<sort-order>)
    Sorts based on the specified attribute.
    Supported attributes : createdAt, updatedAt
    Supported sort-orders : SortOrder.ASC, SortOrder.DESC

    Example sortByCreatedAt(SortOrder.asc)
    This will sort the result based on the 'createdAt' attribute in ascending(earliest first) order.
    optional, string filter
    Filter Params
    For operator usages, see the Pagination and Filtering section.
    id().<operator>(val)
    To filter based on Subscription Id.
    Supported operators : is, isNot, startsWith, in, notIn

    Example id().is(8gsnbYfsMLds)
    optional, string filter
    customerId().<operator>(val)
    To filter based on Subscription Customer Id.
    Supported operators : is, isNot, startsWith, in, notIn

    Example customerId().isNot(8gsnbYfsMLds)
    optional, string filter
    planId().<operator>(val)
    To filter based on Subscription Plan Id.
    Supported operators : is, isNot, startsWith, in, notIn

    Example planId().is(basic)
    optional, string filter
    status().<operator>(val)
    To filter based on Subscription State. Possible values are : FUTURE, IN_TRIAL, ACTIVE, NON_RENEWING, PAUSED, CANCELLED.
    Supported operators : is, isNot, in, notIn

    Example status().is(active)
    optional, enumerated string filter
    cancelReason().<operator>(val)
    To filter based on Subscription Cancel Reason. Possible values are : NOT_PAID, NO_CARD, FRAUD_REVIEW_FAILED, NON_COMPLIANT_EU_CUSTOMER, TAX_CALCULATION_FAILED, CURRENCY_INCOMPATIBLE_WITH_GATEWAY, NON_COMPLIANT_CUSTOMER.
    Supported operators : is, isNot, in, notIn, isPresent

    Example cancelReason().is(not_paid)
    optional, enumerated string filter
    cancelReasonCode().<operator>(val)
    To filter based on Cancel Reason Code.
    Supported operators : is, isNot, startsWith, in, notIn

    Example cancelReasonCode().is(Not Paid)
    optional, string filter
    remainingBillingCycles().<operator>(val)
    To filter based on Subscription Remaining Billing Cycles.
    Supported operators : is, isNot, lt, lte, gt, gte, between, isPresent

    Example remainingBillingCycles().lte(3)
    optional, integer filter
    createdAt().<operator>(val)
    To filter based on Subscription Created At.
    Supported operators : after, before, on, between

    Example createdAt().after(timestampVal)
    optional, timestampVal as java.sql.Timestamp object, timestamp filter
    activatedAt().<operator>(val)
    To filter based on Subscription Activated At.
    Supported operators : after, before, on, between, isPresent

    Example activatedAt().after(timestampVal)
    optional, timestampVal as java.sql.Timestamp object, timestamp filter
    nextBillingAt().<operator>(val)
    To filter based on Subscription Next Billing At.
    Supported operators : after, before, on, between

    Example nextBillingAt().after(timestampVal)
    optional, timestampVal as java.sql.Timestamp object, timestamp filter
    cancelledAt().<operator>(val)
    To filter based on Subscription Cancelled At.
    Supported operators : after, before, on, between

    Example cancelledAt().on(timestampVal)
    optional, timestampVal as java.sql.Timestamp object, timestamp filter
    hasScheduledChanges().<operator>(val)
    To filter based on Subscription Has Scheduled Changes. Possible values are : True, False
    Supported operators : is

    Example hasScheduledChanges().is(true)
    optional, boolean filter
    updatedAt().<operator>(val)
    To filter based on updated_at. This attribute will be present only if the resource has been updated after 2016-09-28. It is advisable when using this filter, to pass the sort_by input parameter as updated_at for a faster response.
    Supported operators : after, before, on, between

    Example updatedAt().after(timestampVal)
    optional, timestampVal as java.sql.Timestamp object, timestamp filter
    overrideRelationship().<operator>(val)
    To filter based on Subscription Override Relationship. Possible values are : True, False
    Supported operators : is

    Example overrideRelationship().is(false)
    optional, boolean filter
    Resource object representing subscription.
    always returned
    Resource object representing customer.
    always returned
    Resource object representing card.
    optional
    next_offset
    This attribute is returned only if more resources are present. To fetch the next set of resources use this value for the input parameter “offset”.
    optional, string, max chars=1000
    Retrieves a list of contract term resources for the subscription specified in the path.
    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    
    Environment.configure("{site}","{site_api_key}");
    ListResult result = Subscription.contractTermsForSubscription("__test__3Nl7o66Rt41d6R73").request();
    for(ListResult.Entry entry:result) {
    	ContractTerm contractTerm = entry.contractTerm();
    }
        System.out.println(result);
      }
    }
    copy full code
    copy snippet

    Sample Result [ JSON ]

    Method

    Subscription.contractTermsForSubscription(<subscription_id>)
    
    limit(val)
    Limits the number of resources to be returned.
    optional, integer, default=10, min=1, max=100
    offset(val)
    Allows you to fetch the next set of resources. The value used for this parameter must be the value returned for next_offset parameter in the previous API call.
    optional, string, max chars=1000
    Resource object representing contract_term.
    always returned
    next_offset
    This attribute is returned only if more resources are present. To fetch the next set of resources use this value for the input parameter “offset”.
    optional, string, max chars=1000
    Retrieves the subscription identified by the 'subscription id' specified in the url.
    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.retrieve("__test__KyVnJjRnFYi7x5wE").request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.retrieve("__test__KyVnJjRnFYi7x5wE").request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();

    Sample Result [ JSON ]

    Show more...
    { "customer": { "allow_direct_debit": false, "auto_collection": "off", "card_status": "no_card", "created_at": 1517469187, "deleted": false, "excess_payments": 0, "id": "__test__KyVnJjRnFYi7x5wE", "net_term_days": 0, "object": "customer", "pii_cleared": "active", "preferred_currency_code": "USD", "promotional_credits": 0, "refundable_credits": 0, "resource_version": 1517469187000, "taxability": "taxable", "unbilled_charges": 0, "updated_at": 1517469187 }, "subscription": { "activated_at": 1517469187, "billing_period": 1, "billing_period_unit": "month", "created_at": 1517469187, "currency_code": "USD", "current_term_end": 1519888387, "current_term_start": 1517469187, "customer_id": "__test__KyVnJjRnFYi7x5wE", "deleted": false, "due_invoices_count": 1, "due_since": 1517469187, "has_scheduled_changes": false, "id": "__test__KyVnJjRnFYi7x5wE", "mrr": 0, "next_billing_at": 1519888387, "object": "subscription", "plan_amount": 895, "plan_free_quantity": 0, "plan_id": "no_trial", "plan_quantity": 1, "plan_unit_price": 895, "resource_version": 1517469187000, "started_at": 1517469187, "status": "active", "total_dues": 895, "updated_at": 1517469187 } }

    Method

    Subscription.retrieve(<subscription_id>)
    
    Resource object representing subscription.
    always returned
    Resource object representing customer.
    always returned
    Resource object representing card.
    optional

    Retrieves a subscription with the scheduled changes applied.
    Note: Only the following attributes are changed

    • plan_id
    • plan_quantity
    • plan_unit_price
    • setup_fee
    • billing_period
    • billing_period_unit
    • plan_free_quantity
    • remaining_billing_cycles
    • addons
    • coupons
    Other attributes such as status, next_billing_at are not changed and will reflect the current subscription values.

    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.retrieveWithScheduledChanges("__test__KyVnJjRnFYiC95wL").request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.retrieveWithScheduledChanges("__test__KyVnJjRnFYiC95wL").request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();

    Sample Result [ JSON ]

    Show more...
    { "card": { "card_type": "visa", "created_at": 1517469187, "customer_id": "__test__KyVnJjRnFYiC95wL", "expiry_month": 12, "expiry_year": 2022, "funding_type": "credit", "gateway": "chargebee", "gateway_account_id": "gw___test__KyVnLVRnFYfVN5i", "iin": "411111", "last4": "1111", "masked_number": "************1111", "object": "card", "payment_source_id": "pm___test__KyVnJjRnFYiCU5wN", "resource_version": 1517469187000, "status": "valid", "updated_at": 1517469187 }, "customer": { "allow_direct_debit": false, "auto_collection": "on", "card_status": "valid", "created_at": 1517469187, "deleted": false, "excess_payments": 0, "id": "__test__KyVnJjRnFYiC95wL", "net_term_days": 0, "object": "customer", "payment_method": { "gateway": "chargebee", "gateway_account_id": "gw___test__KyVnLVRnFYfVN5i", "object": "payment_method", "reference_id": "tok___test__KyVnJjRnFYiCQ5wM", "status": "valid", "type": "card" }, "pii_cleared": "active", "preferred_currency_code": "USD", "primary_payment_source_id": "pm___test__KyVnJjRnFYiCU5wN", "promotional_credits": 0, "refundable_credits": 0, "resource_version": 1517469187000, "taxability": "taxable", "unbilled_charges": 0, "updated_at": 1517469187 }, "subscription": { "activated_at": 1517469187, "billing_period": 1, "billing_period_unit": "month", "created_at": 1517469187, "currency_code": "USD", "current_term_end": 1519888387, "current_term_start": 1517469187, "customer_id": "__test__KyVnJjRnFYiC95wL", "deleted": false, "due_invoices_count": 0, "has_scheduled_changes": true, "id": "__test__KyVnJjRnFYiC95wL", "mrr": 0, "next_billing_at": 1519888387, "object": "subscription", "plan_amount": 895, "plan_free_quantity": 0, "plan_id": "sub_free", "plan_quantity": 1, "plan_unit_price": 0, "resource_version": 1517469187000, "started_at": 1517469187, "status": "active", "updated_at": 1517469187 } }

    Method

    Subscription.retrieveWithScheduledChanges(<subscription_id>)
    
    Resource object representing subscription.
    always returned
    Resource object representing customer.
    always returned
    Resource object representing card.
    optional
    Removes the subscription changes scheduled on next renewal. Advance charges, if any, will be refunded as credits and a new invoice will be generated on renewal.
    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.removeScheduledChanges("__test__KyVnJjRnFYhb75vO").request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
    List<CreditNote> creditNotes = result.creditNotes();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.removeScheduledChanges("__test__KyVnJjRnFYhb75vO").request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
    List<CreditNote> creditNotes = result.creditNotes();

    Sample Result [ JSON ]

    Show more...
    { "card": { "card_type": "visa", "created_at": 1517469185, "customer_id": "__test__KyVnJjRnFYhb75vO", "expiry_month": 12, "expiry_year": 2022, "funding_type": "credit", "gateway": "chargebee", "gateway_account_id": "gw___test__KyVnLVRnFYfVN5i", "iin": "411111", "last4": "1111", "masked_number": "************1111", "object": "card", "payment_source_id": "pm___test__KyVnJjRnFYhbQ5vQ", "resource_version": 1517469185000, "status": "valid", "updated_at": 1517469185 }, "customer": { "allow_direct_debit": false, "auto_collection": "on", "card_status": "valid", "created_at": 1517469185, "deleted": false, "excess_payments": 0, "id": "__test__KyVnJjRnFYhb75vO", "net_term_days": 0, "object": "customer", "payment_method": { "gateway": "chargebee", "gateway_account_id": "gw___test__KyVnLVRnFYfVN5i", "object": "payment_method", "reference_id": "tok___test__KyVnJjRnFYhbN5vP", "status": "valid", "type": "card" }, "pii_cleared": "active", "preferred_currency_code": "USD", "primary_payment_source_id": "pm___test__KyVnJjRnFYhbQ5vQ", "promotional_credits": 0, "refundable_credits": 0, "resource_version": 1517469185000, "taxability": "taxable", "unbilled_charges": 0, "updated_at": 1517469185 }, "subscription": { "activated_at": 1517469185, "billing_period": 1, "billing_period_unit": "month", "created_at": 1517469185, "currency_code": "USD", "current_term_end": 1519888385, "current_term_start": 1517469185, "customer_id": "__test__KyVnJjRnFYhb75vO", "deleted": false, "due_invoices_count": 0, "has_scheduled_changes": false, "id": "__test__KyVnJjRnFYhb75vO", "mrr": 0, "next_billing_at": 1519888385, "object": "subscription", "plan_amount": 895, "plan_free_quantity": 0, "plan_id": "no_trial", "plan_quantity": 1, "plan_unit_price": 895, "resource_version": 1517469185000, "started_at": 1517469185, "status": "active", "updated_at": 1517469185 } }

    Method

    Subscription.removeScheduledChanges(<subscription_id>)
    
    Resource object representing subscription.
    always returned
    Resource object representing customer.
    always returned
    Resource object representing card.
    optional
    Resource object representing credit_note.
    optional

    Note: Cannot be called when the subscription is on a contract term. (That is, when the contract_term.status attribute is active.)

    If the subscription is in Non Renewing or In Trial state and is also scheduled to cancel at the end of current term, then this API can be used to remove the scheduled cancellation. When a scheduled cancellation is removed, the subscription will revert to Active or In Trial state, whichever is the state before cancellation was scheduled.

    While removing the scheduled cancellation, you may specify the number of billing cycles. If the billing cycle is not specified, the default billing cycle from the plan will be applied on the subscription.

    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.removeScheduledCancellation("__test__KyVnJjRnFYhVX5vF").request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.removeScheduledCancellation("__test__KyVnJjRnFYhVX5vF").request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();

    Sample Result [ JSON ]

    Show more...
    { "customer": { "allow_direct_debit": false, "auto_collection": "off", "card_status": "no_card", "created_at": 1517469184, "deleted": false, "excess_payments": 0, "id": "__test__KyVnJjRnFYhVX5vF", "net_term_days": 0, "object": "customer", "pii_cleared": "active", "preferred_currency_code": "USD", "promotional_credits": 0, "refundable_credits": 0, "resource_version": 1517469184000, "taxability": "taxable", "unbilled_charges": 0, "updated_at": 1517469184 }, "subscription": { "activated_at": 1517469184, "billing_period": 1, "billing_period_unit": "month", "created_at": 1517469184, "currency_code": "USD", "current_term_end": 1519888384, "current_term_start": 1517469184, "customer_id": "__test__KyVnJjRnFYhVX5vF", "deleted": false, "due_invoices_count": 1, "due_since": 1517469184, "has_scheduled_changes": false, "id": "__test__KyVnJjRnFYhVX5vF", "mrr": 0, "next_billing_at": 1519888384, "object": "subscription", "plan_amount": 895, "plan_free_quantity": 0, "plan_id": "no_trial", "plan_quantity": 1, "plan_unit_price": 895, "resource_version": 1517469185000, "started_at": 1517469184, "status": "active", "total_dues": 895, "updated_at": 1517469185 } }

    Method

    Subscription.removeScheduledCancellation(<subscription_id>)
    
    billingCycles(val)
    Number of cycles(plan interval) this subscription should be charged. After the billing cycles exhausted, the subscription will be cancelled.
    optional, integer, min=0
    Resource object representing subscription.
    always returned
    Resource object representing customer.
    always returned
    Resource object representing card.
    optional
    Removes Coupons associated with the Subscription. If the param 'coupon_ids' is not specified, all the Coupons linked to the Subscription will be removed.
    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    /* 
        removes the listed coupons associated with the subscription.
    */
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.removeCoupons("__test__KyVnJjRnFYhMK5ux")
    	.couponIds("plan_only_coupon")
    	.request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet

    Sample Result [ JSON ]

    Method

    Subscription.removeCoupons(<subscription_id>)
    
    couponIds(val)
    Identifier of the coupon as a List. Coupon Codes can also be passed.
    optional, list of string
    Resource object representing subscription.
    always returned
    Resource object representing customer.
    always returned
    Resource object representing card.
    optional
    This operation supports 3DS verification flow. To acheive the same, create the Payment Intent and pass it as input parameter to this API.

    You can modify the plan, plan quantity and add or remove addons for the subscription. By default the changes are applied immediately and the charges (/credits) are prorated and adjusted with the next billing term. You may also choose to effect the changes at the end of the current term by passing end_of_term as "true". In this case proration will not be done.

    Only the parameters that are passed are modified for the subscription. Rest will reflect the existing values.

    By default, the addons passed are appended to the existing list of addons for this subscription. In case a passed addon already exists for this subscription, quantity value is replaced. If you want to completely replace the addons for this subscription, pass replace_addon_list as "true".

    Card and 'vat_number' attributes can also be passed during subscription update. If they are passed, corresponding Billing Info attributes - the Billing Address and 'vat_number' - will be replaced automatically.

    Passing credit card details to this API involves PCI liability at your end as sensitive card info passes through your servers. If you wish to avoid that, you can use one of the following integration methodologies if applicable

    • If you are using Stripe gateway, you can use Stripe.js with your checkout form. Please refer this tutorial for more details.
    • If you are using Braintree gateway, you can use Braintree.js with your checkout form. Please refer this tutorial for more details.
    • If you are using Authorize.Net gateway, you use Accept.js with your checkout form.
    • If you are using the Adyen gateway, you will have to use the Adyen’s Client Side Encryption to encrypt sensitive cardholder data. Once the cardholder data is encrypted, pass the value in adyen.encrypted.data as temp token in this API.
    • You can also use our Hosted Pages based integration.

    Notes

    Proration Scenario: A customer changes from a $15 plan to $30 plan after 15 days of a monthly term. He will be charged for $7.50 immediately. The following Credit Note and Invoice will be generated

    Credit Note
    Prorated credits for Old Plan $7.50
    Invoice
    Prorated charges for New Plan $15.00
    Total $15.00
    Credits ($7.50)
    Amount Due $7.50

    Meanwhile downgrading will result in net credits being created which will be applied when the subscription is charged on start of the next term. Learn more about our proration scenarios here.

    Billing Cycle: The billing period for a subscription does not change if the plans intervals of both old and new are same. However, if a customer changes to a plan that has different billing interval(say monthly to yearly), the billing period is reset. Customer is charged immediately for the modified subscription after applying credit for the unused period for the old subscription.

    Card and VAT number Input: If they are passed, corresponding Billing Address attributes and vat_number will be replaced. i.e existing values for Billing Address and 'vat_number' will be cleared and the new values will be set.

    If an invoice gets generated during this operation, available Credits and Excess Payments will be automatically applied.

    Advance charges, if any, will be refunded as credits and a new invoice will be generated on renewal.

    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    /* 
        updates the subscription's plan and replaces the addons associated with it .The changes made will be effective from current end of term.
    */
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.update("__test__KyVnJjRnFYiIx5wa")
    	.planId("plan1")
    	.addonId(0,"sub_ssl")
    	.addonId(1,"sub_monitor")
    	.addonQuantity(1,2)
    	.endOfTerm(true)
    	.request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
    Invoice invoice = result.invoice();
    List<UnbilledCharge> unbilledCharges = result.unbilledCharges();
    List<CreditNote> creditNotes = result.creditNotes();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet

    Sample Result [ JSON ]

    Method

    Subscription.update(<subscription_id>)
    
    planId(val)
    Identifier of the plan for this subscription.
    optional, string, max chars=100
    planQuantity(val)
    Represents the plan quantity for this subscription.
    optional, integer, min=1
    planUnitPrice(val)
    Amount that will override the Plan's default price.
    optional, in cents, min=0
    setupFee(val)
    Amount that will override the default setup fee.
    optional, in cents, min=0
    replaceAddonList(val)
    Should be true if the existing addons should be replaced with the ones that are being passed.
    optional, boolean
    mandatoryAddonsToRemove(val)
    List of addons IDs that are mandatory to the plan and has to be removed from the subscription.
    optional, list of string
    startDate(val)
    Applicable only for 'future' subscriptions. The new start date of the 'future' subscription.
    optional, timestamp(UTC) in seconds
    trialEnd(val)
    The time at which the trial should end for this subscription. Can be specified to override the default trial period defined in plan. If '0' is passed, the subscription will be activated immediately.
    optional, timestamp(UTC) in seconds
    billingCycles(val)
    Number of cycles(plan interval) this subscription should be charged. After the billing cycles exhausted, the subscription will be cancelled.
    optional, integer, min=0
    termsToCharge(val)
    The number of future renewals for which advance invoicing is done. However, if a new term gets started in this operation, the specified terms_to_charge will be inclusive of this new term.
    optional, integer, min=1
    reactivateFrom(val)
    The time from which this subscription should be reactivated.
    optional, timestamp(UTC) in seconds
    billingAlignmentMode(val)
    Applicable when calendar billing is enabled and a new term gets started during this operation. Unless specified the configured default value will be used.
    optional, enumerated string
    Possible values are
    IMMEDIATESubscription period will be aligned with the configured billing date immediately.DELAYEDSubscription period will be aligned with the configured billing date at a later date (subsequent renewals).
    poNumber(val)
    Purchase Order Number for this subscription.
    optional, string, max chars=100
    couponIds(val)
    Identifier of the coupon as a List. Coupon Codes can also be passed.
    optional, list of string
    replaceCouponList(val)
    Should be true if the existing coupons should be replaced with the ones that are being passed.
    optional, boolean
    prorate(val)
    Add Prorated Credits and Charges, if applicable, while updating the subscription. If this parameter is not passed, the default value set in the Site Settings will be used. Else, it will be assumed as true.
    optional, boolean
    endOfTerm(val)
    You can specify when you want to update the subscription.
    optional, boolean
    forceTermReset(val)
    Applicable for 'Active' & 'Non Renewing' states alone. Generally, subscription's term will be reset (i.e current term is ended and a new term starts immediately) when a new plan having different billing frequency is specified in the input. For all the other cases, the subscription's term will remain intact. Now for this later scenario, if you want to force a term reset you can specify this param as 'true'.
    Note: Specifying this value as 'false' has no impact on the default behaviour.
    optional, boolean, default=false
    reactivate(val)
    Applicable only for cancelled subscriptions. Once this is passed as true, cancelled subscription will become active; otherwise subscription changes will be made but the the subscription state will remain cancelled. If not passed, subscription will be activated only if there is any change in subscription data.
    optional, boolean
    tokenId(val)
    Token generated by Chargebee JS representing payment method details.
    optional, string, max chars=40
    invoiceNotes(val)
    Invoice Notes for this resource. Read More.
    optional, string, max chars=2000
    metaData(val)
    Additional data about this resource can be stored here in the JSON Format. Learn more.
    optional, jsonobject
    invoiceImmediately(val)
    Applicable when charges are added during this operation. If specified as false, these charges will be added to unbilled charges. The default value for this parameter will be as per your site settings.
    optional, boolean
    overrideRelationship(val)
    If true, ignores the hierarchy relationship and uses customer as payment and invoice owner.
    optional, boolean
    contractTermBillingCycleOnRenewal(val)
    Number of billing cycles the new contract term should run for, on contract renewal. The default value is as specified in the site settings.
    optional, integer, min=1, max=100
    +
    card
    Parameters for card
    methods are prefixed like card<param name>(val)
    cardGatewayAccountId(val)
    The gateway account in which this payment source is stored.
    optional, string, max chars=50
    cardFirstName(val)
    Cardholder's first name.
    optional, string, max chars=50
    cardLastName(val)
    Cardholder's last name.
    optional, string, max chars=50
    cardNumber(val)
    The credit card number without any format. If you are using Braintree.js, you can specify the Braintree encrypted card number here.
    required if card provided, string, max chars=1500
    cardExpiryMonth(val)
    Card expiry month.
    required if card provided, integer, min=1, max=12
    cardExpiryYear(val)
    Card expiry year.
    required if card provided, integer
    cardCvv(val)
    The card verification value. If you are using Braintree.js, you can specify the Braintree encrypted cvv here.
    optional, string, max chars=520
    cardBillingAddr1(val)
    Address line 1, as available in card billing address.
    optional, string, max chars=150
    cardBillingAddr2(val)
    Address line 2, as available in card billing address.
    optional, string, max chars=150
    cardBillingCity(val)
    City, as available in card billing address.
    optional, string, max chars=50
    cardBillingStateCode(val)
    The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set the state_code as AZ (not US-AZ). or, for Tamil Nadu (India), set the state_code as TN (not IN-TN). or, for British Columbia (Canada), set the state_code as BC (not CA-BC).
    Note: If the 'state_code' is specified, the 'state' attribute should not be provided as Chargebee will set the value automatically (for US, Canada, India).
    optional, string, max chars=50
    cardBillingState(val)
    The state/province name. Use this to pass the state/province information for cases where 'state_code' is not supported or cannot be passed.
    optional, string, max chars=50
    cardBillingZip(val)
    Postal or Zip code, as available in card billing address.
    optional, string, max chars=20
    cardBillingCountry(val)
    2-letter ISO 3166 alpha-2 country code.
    optional, string, max chars=50
    +
    paymentMethod
    Parameters for paymentMethod
    methods are prefixed like paymentMethod<param name>(val)
    paymentMethodType(val)
    The type of payment method. For more details refer Update payment method for a customer API under Customer resource.
    optional, enumerated string
    Possible values are
    CARDCard based payment including credit cards and debit cards. Details about the card can be obtained from the card resource.PAYPAL_EXPRESS_CHECKOUTPayments made via PayPal Express Checkout.AMAZON_PAYMENTSPayments made via Amazon Payments.DIRECT_DEBITRepresents bank account for which the direct debit or ACH agreement/mandate is created.
    GENERICGeneric Payment Method.ALIPAYAlipay Payments.UNIONPAYUnionPay Payments.APPLE_PAYApple Pay Payments.WECHAT_PAYWeChat Pay Payments.IDEALiDEAL Payments.GOOGLE_PAYGoogle Pay Payments.SOFORTSofort Payments.BANCONTACTBancontact Card Payments.
    Show all values[+]
    paymentMethodGatewayAccountId(val)
    The gateway account in which this payment source is stored.
    optional, string, max chars=50
    paymentMethodReferenceId(val)
    The reference id. In the case of Amazon and PayPal this will be the billing agreement id. For GoCardless direct debit this will be 'mandate id'. In the case of card this will be the identifier provided by the gateway/card vault for the specific payment method resource. Note: This is not the one-time temporary token provided by gateways like Stripe.
    For more details refer Update payment method for a customer API under Customer resource.
    optional, string, max chars=200
    paymentMethodTmpToken(val)
    Single-use tokens created by payment gateways. In Stripe, a single-use token is created for Apple Pay Wallet, card details or direct debit. In Braintree, a nonce is created for Apple Pay Wallet, PayPal, or card details. In Authorize.Net, a nonce is created for card details. In Adyen, an encrypted data is created from the card details.
    required if reference_id not provided, string, max chars=65k
    paymentMethodIssuingCountry(val)
    2-letter (alpha2) ISO country code. Indicates your customer's payment method country of issuance. Applicable for PayPal via Braintree.
    optional, string, max chars=50
    +
    paymentIntent
    Parameters for paymentIntent
    methods are prefixed like paymentIntent<param name>(val)
    paymentIntentId(val)
    Identifier for PaymentIntent generated by Chargebee.js. Applicable only when you are using Chargebee.js for completing the 3DS flow. The PaymentIntent should be in 'authorized' state while passing it here. You need not pass other PaymentIntent parameters if this is passed.
    optional, string, max chars=150
    paymentIntentGatewayAccountId(val)
    The gateway account used for performing the 3DS flow.
    required if payment intent token provided, string, max chars=50
    paymentIntentGwToken(val)
    Identifier for 3DS transaction/verification object at the gateway. Can be passed only after successfully completing the 3DS flow. Refer 3DS implementation in Chargebee to find out the gateway-specific gw_token format. Applicable when you are using gateway APIs directly for completing the 3DS flow.
    optional, string, max chars=65k
    paymentIntentReferenceId(val)
    Identifier for Braintree permanent token. Applicable when you are using Braintree APIs for completing the 3DS flow.
    optional, string, max chars=65k
    +
    billingAddress
    Parameters for billingAddress
    methods are prefixed like billingAddress<param name>(val)
    billingAddressFirstName(val)
    First name.
    optional, string, max chars=150
    billingAddressLastName(val)
    Last name.
    optional, string, max chars=150
    billingAddressEmail(val)
    Email.
    optional, string, max chars=70
    billingAddressCompany(val)
    Company name.
    optional, string, max chars=250
    billingAddressPhone(val)
    Phone number.
    optional, string, max chars=50
    billingAddressLine1(val)
    Address line 1.
    optional, string, max chars=150
    billingAddressLine2(val)
    Address line 2.
    optional, string, max chars=150
    billingAddressLine3(val)
    Address line 3.
    optional, string, max chars=150
    billingAddressCity(val)
    City.
    optional, string, max chars=50
    billingAddressStateCode(val)
    The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set the state_code as AZ (not US-AZ). or, for Tamil Nadu (India), set the state_code as TN (not IN-TN). or, for British Columbia (Canada), set the state_code as BC (not CA-BC).
    Note: If the 'state_code' is specified, the 'state' attribute should not be provided as Chargebee will set the value automatically (for US, Canada, India).
    optional, string, max chars=50
    billingAddressState(val)
    The state/province name. Use this to pass the state/province information for cases where 'state_code' is not supported or cannot be passed.
    optional, string, max chars=50
    billingAddressZip(val)
    Zip or Postal code.
    optional, string, max chars=20
    billingAddressCountry(val)
    2-letter ISO 3166 alpha-2 country code.
    optional, string, max chars=50
    billingAddressValidationStatus(val)
    The address verification status.
    optional, enumerated string
    Possible values are
    NOT_VALIDATEDAddress is not yet validated.VALIDAddress was validated successfully.PARTIALLY_VALIDAddress is verified but only partially.INVALIDAddress is invalid.
    +
    shippingAddress
    Parameters for shippingAddress
    methods are prefixed like shippingAddress<param name>(val)
    shippingAddressFirstName(val)
    First name.
    optional, string, max chars=150
    shippingAddressLastName(val)
    Last name.
    optional, string, max chars=150
    shippingAddressEmail(val)
    Email.
    optional, string, max chars=70
    shippingAddressCompany(val)
    Company name.
    optional, string, max chars=250
    shippingAddressPhone(val)
    Phone number.
    optional, string, max chars=50
    shippingAddressLine1(val)
    Address line 1.
    optional, string, max chars=180
    shippingAddressLine2(val)
    Address line 2.
    optional, string, max chars=150
    shippingAddressLine3(val)
    Address line 3.
    optional, string, max chars=150
    shippingAddressCity(val)
    City.
    optional, string, max chars=50
    shippingAddressStateCode(val)
    The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set the state_code as AZ (not US-AZ). or, for Tamil Nadu (India), set the state_code as TN (not IN-TN). or, for British Columbia (Canada), set the state_code as BC (not CA-BC).
    Note: If the 'state_code' is specified, the 'state' attribute should not be provided as Chargebee will set the value automatically (for US, Canada, India).
    optional, string, max chars=50
    shippingAddressState(val)
    The state/province name. Use this to pass the state/province information for cases where 'state_code' is not supported or cannot be passed.
    optional, string, max chars=50
    shippingAddressZip(val)
    Zip or Postal code.
    optional, string, max chars=20
    shippingAddressCountry(val)
    2-letter ISO 3166 alpha-2 country code.
    optional, string, max chars=50
    shippingAddressValidationStatus(val)
    The address verification status.
    optional, enumerated string
    Possible values are
    NOT_VALIDATEDAddress is not yet validated.VALIDAddress was validated successfully.PARTIALLY_VALIDAddress is verified but only partially.INVALIDAddress is invalid.
    +
    customer
    Parameters for customer
    methods are prefixed like customer<param name>(val)
    customerVatNumber(val)
    VAT/ Tax registration number of the customer. Learn more.
    optional, string, max chars=20
    customerBusinessCustomerWithoutVatNumber(val)
    Confirms that a customer is a valid business without VAT number.
    optional, boolean
    customerRegisteredForGst(val)
    Confirms that a customer is registered under GST. This field is available for Australia only.
    optional, boolean
    +
    contractTerm
    Parameters for contractTerm
    methods are prefixed like contractTerm<param name>(val)
    contractTermActionAtTermEnd(val)
    Action to be taken when the contract term completes.
    optional, enumerated string
    Possible values are
    RENEW
  • Contract term completes and a new contract term is started for the number of billing cycles specified in contract_billing_cycle_on_renewal.
  • The action_at_term_end for the new contract term is set to renew.
  • .
    EVERGREENContract term completes and the subscription renews.CANCELContract term completes and subscription is canceled.RENEW_ONCEUsed when you want to renew the contract term just once. Does the following:
  • Contract term completes and a new contract term is started for the number of billing cycles specified in contract_billing_cycle_on_renewal.
  • The action_at_term_end for the new contract term is set to cancel.
  • .
    contractTermCancellationCutoffPeriod(val)
    The number of days before contract_end, during which the customer is barred from canceling the contract term. The customer is allowed to cancel the contract term via the Self-Serve Portal only before this period. This allows you to have sufficient time for processing the contract term closure.
    optional, integer
    +
    addons
    Parameters for addons. Multiple addons can be passed by specifying unique indices.
    methods are prefixed like addons<param name>(idx,val)
    addonId(idx,val)
    Identifier of the addon. Multiple addons can be passed.
    optional, string, max chars=100
    addonQuantity(idx,val)
    Addon quantity. Applicable only for the quantity based addons. Should be passed with the same index as that of associated addon id.
    optional, integer, min=1
    addonUnitPrice(idx,val)
    Amount that will override the Addon's default price. The Plan's billing frequency will not be considered for overriding. E.g. If the Plan's billing frequency is every 3 months, and if the price override amount is $10, $10 will be used, and not $30 (i.e $10*3).
    optional, in cents, min=0
    addonBillingCycles(idx,val)
    Number of billing cycles the addon will be charged for. When not set, the addon is attached to the subscription for an indefinite number of billing cycles. While updating a subscription to a plan with a different billing period, set this parameter again or its value will be lost. And so, the addon will be attached indefinitely.
    optional, integer, min=1
    addonTrialEnd(idx,val)
    The time at which the trial ends for the addon. To update this value, redo the complete addon set using replace_addon_list. (Addon trial periods must be enabled by Chargebee Support.).
    optional, timestamp(UTC) in seconds
    +
    eventBasedAddons
    Parameters for eventBasedAddons. Multiple eventBasedAddons can be passed by specifying unique indices.
    methods are prefixed like eventBasedAddons<param name>(idx,val)
    eventBasedAddonId(idx,val)
    A unique 'id' used to identify the addon.
    optional, string, max chars=100
    eventBasedAddonQuantity(idx,val)
    Addon quantity. Applicable only for the quantity based addons. Should be passed with the same index as that of associated addon id.
    optional, integer, min=1
    eventBasedAddonUnitPrice(idx,val)
    Amount that will override the Addon's default price.
    optional, in cents, min=0
    eventBasedAddonServicePeriodInDays(idx,val)
    Defines service period of the addon in days from the day of charge.
    optional, integer, min=1, max=730
    eventBasedAddonChargeOn(idx,val)
    Indicates when the non-recurring addon will be charged.
    optional, enumerated string
    Possible values are
    IMMEDIATELYCharges for the addon will be applied immediately.ON_EVENTCharge for the addon will be applied on the occurrence of a specified event.
    eventBasedAddonOnEvent(idx,val)
    Event on which this addon will be charged.
    optional, enumerated string
    Possible values are
    SUBSCRIPTION_CREATIONAddon will be charged on subscription creation.SUBSCRIPTION_TRIAL_STARTAddon will be charged when the trial period starts.PLAN_ACTIVATIONAddon will be charged on plan activation.SUBSCRIPTION_ACTIVATIONAddon will be charged on subscription activation.CONTRACT_TERMINATIONAddon will be charged on contract termination.
    eventBasedAddonChargeOnce(idx,val)
    If enabled, the addon will be charged only at the first occurrence of the event. Applicable only for non-recurring add-ons.
    optional, boolean
    Resource object representing subscription.
    always returned
    Resource object representing customer.
    always returned
    Resource object representing card.
    optional
    Resource object representing invoice.
    optional
    Resource object representing unbilled_charge.
    optional
    Resource object representing credit_note.
    optional

    Changes the subscription's current term end date. Depending on the "status" of the subscription, "term end date" has different effects.

    • If the Subscription is in trial, it affects trial end date.
    • If the Subscription is active, it affects the next billing date.
    • If the Subscription's status is non_renewing, this affects the upcoming cancellation date.

    Tip: To cycle through a couple of billing cycles and test webhooks, you may use this API.

    Notes

    • When changing the term_end for active / non_renewing subscriptions, by default no additional charges (when term gets extended) will be added or credits (when term gets reduced) will be issued. However you can specify prorate param as true for adding prorated charges / issuing prorated credits. Further for the charges that got added, you can specify invoice_immediately as false to add them to unbilled charges and invoice them later.
    • Advance charges, if any will be credited back during this operation.
    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.changeTermEnd("__test__KyVnJjRnFcwjb8oM")
    	.termEndsAt(1579285800)
    	.request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
    Invoice invoice = result.invoice();
    List<UnbilledCharge> unbilledCharges = result.unbilledCharges();
    List<CreditNote> creditNotes = result.creditNotes();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.changeTermEnd("__test__KyVnJjRnFcwjb8oM")
    	.termEndsAt(1579285800)
    	.request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
    Invoice invoice = result.invoice();
    List<UnbilledCharge> unbilledCharges = result.unbilledCharges();
    List<CreditNote> creditNotes = result.creditNotes();

    Sample Result [ JSON ]

    Show more...
    { "customer": { "allow_direct_debit": false, "auto_collection": "off", "card_status": "no_card", "created_at": 1517470196, "deleted": false, "excess_payments": 0, "id": "__test__KyVnJjRnFcwjb8oM", "net_term_days": 0, "object": "customer", "pii_cleared": "active", "preferred_currency_code": "USD", "promotional_credits": 0, "refundable_credits": 0, "resource_version": 1517470196000, "taxability": "taxable", "unbilled_charges": 0, "updated_at": 1517470196 }, "subscription": { "activated_at": 1517470196, "billing_period": 1, "billing_period_unit": "month", "created_at": 1517470196, "currency_code": "USD", "current_term_end": 1579285800, "current_term_start": 1517470196, "customer_id": "__test__KyVnJjRnFcwjb8oM", "deleted": false, "due_invoices_count": 1, "due_since": 1517470196, "has_scheduled_changes": false, "id": "__test__KyVnJjRnFcwjb8oM", "mrr": 0, "next_billing_at": 1579285800, "object": "subscription", "plan_amount": 895, "plan_free_quantity": 0, "plan_id": "no_trial", "plan_quantity": 1, "plan_unit_price": 895, "resource_version": 1517470197000, "started_at": 1517470196, "status": "active", "total_dues": 895, "updated_at": 1517470197 } }

    Method

    Subscription.changeTermEnd(<subscription_id>)
    
    termEndsAt(val)
    The time at which the current term should end for this subscription.
    required, timestamp(UTC) in seconds
    prorate(val)
    Applicable for active / non_renewing subscriptions. If specified as true prorated charges / credits will be added during this operation.
    optional, boolean
    invoiceImmediately(val)
    Applicable when charges are added during this operation. If specified as false, these charges will be added to unbilled charges. The default value for this parameter will be as per your site settings.
    optional, boolean
    Resource object representing subscription.
    always returned
    Resource object representing customer.
    always returned
    Resource object representing card.
    optional
    Resource object representing invoice.
    optional
    Resource object representing unbilled_charge.
    optional
    Resource object representing credit_note.
    optional
    This operation supports 3DS verification flow. To acheive the same, create the Payment Intent and pass it as input parameter to this API.

    This API is used to reactivate a cancelled subscription. You may also optionally specify a trial end date, to move the subscription to In Trial state. If trial end is not specified, the subscription will be activated and any applicable charges will be initiated.

    Unless the billing cycle is specified, it will be set to plan's default billing cycle.

    During an in-term reactivation++, unless the billing cycle is specified, the subscription's remaining billing cycles will be restored. If a trial end date is specified, then the plan's default billing cycle is used.

    ++What is an "in-term reactivation"?
    An "in-term reactivation" happens when the billing term of the subscription is retained upon cancellation and reactivation is initiated within that term.

    When is the ‘billing term’ retained for a cancelled subscription?
    When dunning (payment failure retry settings) is configured with the last retry configured as

    • cancel subscription and mark invoice as ‘Not Paid’, or
    • cancel subscription and mark the invoice as ‘Voided’ and the case if any of the current term invoices is partially or fully paid, the invoice is not voided but instead Chargebee marks the invoices as ‘Not Paid’.

    Note : In both cases, the billing term is retained and upon reactivation the subscription will be moved to active state (if the plan does not have a trial period) and no invoice will be generated. Ensure that you collect any unpaid invoices.

    Example : A Subscription was billed from 1st to 31st of a month and it was cancelled on the 20th due to one of the above cases (billing term is not reset). If the reactivation happens on 25th then it is considered an in-term reactivation.

    Notes

    Reactivation of a subscription in non_renewing state has been deprecated. To remove a scheduled cancellation of a non_renewing Subscription, use Remove Scheduled Cancellation API.

    However, if you use reactivate API to remove scheduled cancellation for a non_renewing Subscription, then the status will be set to active and the billing cycle will be set to forever. If any value is passed for trial_end or billing cycle, an error will be thrown.

    If an invoice gets generated during this operation, available Credits and Excess Payments will be automatically applied.

    Additional Error Scenarios: If there is a need to create an immediate charge and the collection fails, an error will be thrown.

    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.reactivate("__test__KyVnJjRnFYhF75uk")
    	.invoiceImmediately(true)
    	.billingCycles(4)
    	.request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
    Invoice invoice = result.invoice();
    List<UnbilledCharge> unbilledCharges = result.unbilledCharges();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.reactivate("__test__KyVnJjRnFYhF75uk")
    	.invoiceImmediately(true)
    	.billingCycles(4)
    	.request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
    Invoice invoice = result.invoice();
    List<UnbilledCharge> unbilledCharges = result.unbilledCharges();

    Sample Result [ JSON ]

    Show more...
    { "customer": { "allow_direct_debit": false, "auto_collection": "off", "card_status": "no_card", "created_at": 1517469183, "deleted": false, "excess_payments": 0, "id": "__test__KyVnJjRnFYhF75uk", "net_term_days": 0, "object": "customer", "pii_cleared": "active", "preferred_currency_code": "USD", "promotional_credits": 0, "refundable_credits": 0, "resource_version": 1517469183000, "taxability": "taxable", "unbilled_charges": 0, "updated_at": 1517469183 }, "invoice": { "adjustment_credit_notes": [], "amount_adjusted": 0, "amount_due": 895, "amount_paid": 0, "amount_to_collect": 895, "applied_credits": [], "base_currency_code": "USD", "credits_applied": 0, "currency_code": "USD", "customer_id": "__test__KyVnJjRnFYhF75uk", "date": 1517469184, "deleted": false, "due_date": 1517469184, "dunning_attempts": [], "exchange_rate": 1, "first_invoice": false, "has_advance_charges": false, "id": "__demo_inv__19", "is_gifted": false, "issued_credit_notes": [], "line_items": [ { "amount": 895, "customer_id": "__test__KyVnJjRnFYhF75uk", "date_from": 1517469184, "date_to": 1519888384, "description": "No Trial", "discount_amount": 0, "entity_id": "no_trial", "entity_type": "plan", "id": "li___test__KyVnJjRnFYhJO5ut", "is_taxed": false, "item_level_discount_amount": 0, "object": "line_item", "pricing_model": "per_unit", "quantity": 1, "subscription_id": "__test__KyVnJjRnFYhF75uk", "tax_amount": 0, "tax_exempt_reason": "tax_not_configured", "unit_amount": 895 }, {..} ], "linked_orders": [], "linked_payments": [], "net_term_days": 0, "object": "invoice", "price_type": "tax_exclusive", "recurring": true, "resource_version": 1517469184000, "round_off_amount": 0, "status": "payment_due", "sub_total": 895, "subscription_id": "__test__KyVnJjRnFYhF75uk", "tax": 0, "term_finalized": true, "total": 895, "updated_at": 1517469184, "write_off_amount": 0 }, "subscription": { "activated_at": 1517469184, "billing_period": 1, "billing_period_unit": "month", "created_at": 1517469183, "currency_code": "USD", "current_term_end": 1519888384, "current_term_start": 1517469184, "customer_id": "__test__KyVnJjRnFYhF75uk", "deleted": false, "due_invoices_count": 2, "due_since": 1517469183, "has_scheduled_changes": false, "id": "__test__KyVnJjRnFYhF75uk", "mrr": 0, "next_billing_at": 1519888384, "object": "subscription", "plan_amount": 895, "plan_free_quantity": 0, "plan_id": "no_trial", "plan_quantity": 1, "plan_unit_price": 895, "remaining_billing_cycles": 3, "resource_version": 1517469184000, "started_at": 1517469183, "status": "active", "total_dues": 1790, "updated_at": 1517469184 } }

    Method

    Subscription.reactivate(<subscription_id>)
    
    trialEnd(val)
    The time at which the trial should end for this subscription.
    optional, timestamp(UTC) in seconds
    billingCycles(val)
    Number of cycles(plan interval) this subscription should be charged. After the billing cycles exhausted, the subscription will be cancelled.
    optional, integer, min=0
    reactivateFrom(val)
    The time from which this subscription should be reactivated.
    optional, timestamp(UTC) in seconds
    invoiceImmediately(val)
    Applicable when charges are added during this operation. If specified as false, these charges will be added to unbilled charges. The default value for this parameter will be as per your site settings.
    optional, boolean
    billingAlignmentMode(val)
    Applicable when calendar billing is enabled and a new active term gets started during this operation. Unless specified the configured default value will be used.
    optional, enumerated string
    Possible values are
    IMMEDIATESubscription period will be aligned with the configured billing date immediately.DELAYEDSubscription period will be aligned with the configured billing date at a later date (subsequent renewals).
    termsToCharge(val)
    The number of future renewals for which advance invoicing is done. However, if a new term gets started in this operation, the specified terms_to_charge will be inclusive of this new term.
    optional, integer, min=1
    contractTermBillingCycleOnRenewal(val)
    Number of billing cycles the new contract term should run for, on contract renewal. The default value is as specified in the site settings.
    optional, integer, min=1, max=100
    +
    contractTerm
    Parameters for contractTerm
    methods are prefixed like contractTerm<param name>(val)
    contractTermActionAtTermEnd(val)
    Action to be taken when the contract term completes.
    optional, enumerated string, default=cancel
    Possible values are
    RENEW
  • Contract term completes and a new contract term is started for the number of billing cycles specified in contract_billing_cycle_on_renewal.
  • The action_at_term_end for the new contract term is set to renew.
  • .
    EVERGREENContract term completes and the subscription renews.CANCELContract term completes and subscription is canceled.
    contractTermCancellationCutoffPeriod(val)
    The number of days before contract_end, during which the customer is barred from canceling the contract term. The customer is allowed to cancel the contract term via the Self-Serve Portal only before this period. This allows you to have sufficient time for processing the contract term closure.
    optional, integer, default=0
    +
    paymentIntent
    Parameters for paymentIntent
    methods are prefixed like paymentIntent<param name>(val)
    paymentIntentId(val)
    Identifier for PaymentIntent generated by Chargebee.js. Applicable only when you are using Chargebee.js for completing the 3DS flow. The PaymentIntent should be in 'authorized' state while passing it here. You need not pass other PaymentIntent parameters if this is passed.
    optional, string, max chars=150
    paymentIntentGatewayAccountId(val)
    The gateway account used for performing the 3DS flow.
    required if payment intent token provided, string, max chars=50
    paymentIntentGwToken(val)
    Identifier for 3DS transaction/verification object at the gateway. Can be passed only after successfully completing the 3DS flow. Refer 3DS implementation in Chargebee to find out the gateway-specific gw_token format. Applicable when you are using gateway APIs directly for completing the 3DS flow.
    optional, string, max chars=65k
    paymentIntentReferenceId(val)
    Identifier for Braintree permanent token. Applicable when you are using Braintree APIs for completing the 3DS flow.
    optional, string, max chars=65k
    Resource object representing subscription.
    always returned
    Resource object representing customer.
    always returned
    Resource object representing card.
    optional
    Resource object representing invoice.
    optional
    Resource object representing unbilled_charge.
    optional

    Adds a one time charge to the subscription which will be added to the invoice generated at the end of the current term. If there are any applicable coupons in the subscription, an appropriate discount will be applied.

    To collect a charge immediately, use this API.

    Notes

    If any subscription changes happen before the end of the current term, these charges will be collected along with it.

    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.addChargeAtTermEnd("__test__KyVnJjRnFcujS8nn")
    	.amount(300)
    	.description("Service Charge")
    	.request();
    Estimate estimate = result.estimate();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.addChargeAtTermEnd("__test__KyVnJjRnFcujS8nn")
    	.amount(300)
    	.description("Service Charge")
    	.request();
    Estimate estimate = result.estimate();

    Sample Result [ JSON ]

    Show more...
    {"estimate": { "created_at": 1517470189, "invoice_estimate": { "amount_due": 1195, "amount_paid": 0, "credits_applied": 0, "currency_code": "USD", "customer_id": "__test__KyVnJjRnFcujS8nn", "line_item_discounts": [], "line_item_taxes": [], "line_items": [ { "amount": 300, "customer_id": "__test__KyVnJjRnFcujS8nn", "date_from": 1517470189, "date_to": 1517470189, "description": "Service Charge", "discount_amount": 0, "entity_type": "adhoc", "id": "li___test__KyVnJjRnFcunk8nu", "is_taxed": false, "item_level_discount_amount": 0, "object": "line_item", "pricing_model": "flat_fee", "quantity": 1, "subscription_id": "__test__KyVnJjRnFcujS8nn", "tax_amount": 0, "unit_amount": 300 }, {..} ], "object": "invoice_estimate", "price_type": "tax_exclusive", "recurring": true, "round_off_amount": 0, "sub_total": 1195, "taxes": [], "total": 1195 }, "object": "estimate", "subscription_estimate": { "currency_code": "USD", "id": "__test__KyVnJjRnFcujS8nn", "next_billing_at": 1519889389, "object": "subscription_estimate", "status": "active" } }}

    Method

    Subscription.addChargeAtTermEnd(<subscription_id>)
    
    amount(val)
    The amount to be charged.
    required, in cents, min=1
    description(val)
    Description for this charge.
    required, string, max chars=250
    avalaraSaleType(val)
    Indicates the type of sale carried out. This is applicable only if you use Chargebee’s AvaTax for Communications integration.
    optional, enumerated string
    Possible values are
    WHOLESALETransaction is a sale to another company that will resell your product or service to another consumer.RETAILTransaction is a sale to an end user.CONSUMEDTransaction is for an item that is consumed directly.VENDOR_USETransaction is for an item that is subject to vendor use tax.
    avalaraTransactionType(val)
    Indicates the type of product to be taxed. Values for this field can be taken from Avalara. This is applicable only if you use Chargebee’s AvaTax for Communications integration.
    optional, integer
    avalaraServiceType(val)
    Indicates the type of service for the product to be taxed. Values for this field can be taken from Avalara. This is applicable only if you use Chargebee’s AvaTax for Communications integration.
    optional, integer
    dateFrom(val)
    The time when the service period for the charge starts.
    optional, timestamp(UTC) in seconds
    dateTo(val)
    The time when the service period for the charge ends.
    optional, timestamp(UTC) in seconds
    Resource object representing estimate.
    always returned

    Adds a "non-recurring addon" charge to a subscription which will be added to the invoice generated at the end of the current term. If there are any applicable coupons in the subscription, an appropriate discount will be applied.

    To collect the charges for the non-recurring addon immediately, use this API.

    Notes

    If any subscription changes happen before the end of the current term, these charges will be collected along with it.

    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.chargeAddonAtTermEnd("__test__KyVnJjRnFcxOf8oU")
    	.addonId("non_recurring_addon")
    	.addonQuantity(3)
    	.addonUnitPrice(100)
    	.request();
    Estimate estimate = result.estimate();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.chargeAddonAtTermEnd("__test__KyVnJjRnFcxOf8oU")
    	.addonId("non_recurring_addon")
    	.addonQuantity(3)
    	.addonUnitPrice(100)
    	.request();
    Estimate estimate = result.estimate();

    Sample Result [ JSON ]

    Show more...
    {"estimate": { "created_at": 1578727799, "invoice_estimate": { "amount_due": 1195, "amount_paid": 0, "credits_applied": 0, "currency_code": "USD", "customer_id": "__test__KyVnJjRnFcxOf8oU", "line_item_discounts": [], "line_item_taxes": [], "line_items": [ { "amount": 300, "customer_id": "__test__KyVnJjRnFcxOf8oU", "date_from": 1578727799, "date_to": 1578727799, "description": "non_recurring_addon", "discount_amount": 0, "entity_id": "non_recurring_addon", "entity_type": "addon", "id": "li___test__KyVnJjRnFcxSq8ob", "is_taxed": false, "item_level_discount_amount": 0, "object": "line_item", "pricing_model": "per_unit", "quantity": 3, "subscription_id": "__test__KyVnJjRnFcxOf8oU", "tax_amount": 0, "unit_amount": 100 }, {..} ], "object": "invoice_estimate", "price_type": "tax_exclusive", "recurring": true, "round_off_amount": 0, "sub_total": 1195, "taxes": [], "total": 1195 }, "object": "estimate", "subscription_estimate": { "currency_code": "USD", "id": "__test__KyVnJjRnFcxOf8oU", "next_billing_at": 1519889399, "object": "subscription_estimate", "status": "active" } }}

    Method

    Subscription.chargeAddonAtTermEnd(<subscription_id>)
    
    addonId(val)
    The ID of the non-recurring addon to be charged.
    required, string, max chars=100
    addonQuantity(val)
    The number of addon units to be charged. Mandatory for quantity based addons.
    optional, integer, min=1
    addonUnitPrice(val)
    Amount that will override the Addon's default price.
    optional, in cents, default=addon amount, min=0
    dateFrom(val)
    The time when the service period for the addon starts.
    optional, timestamp(UTC) in seconds
    dateTo(val)
    The time when the service period for the addon ends.
    optional, timestamp(UTC) in seconds
    Resource object representing estimate.
    always returned

    Use this API to create an advance invoice for the future renewals of a subscription. This operation will charge your customer if they have a payment method and Auto Collection is turned on. Any changes scheduled for the subscription will be considered while generating an advance invoice. Read More.

    Notes

    This operation is not supported for non-renewing and cancelled subscriptions.

    This operation is not supported if an advance invoice is already present. You could void/delete that invoice and try creating another advance invoice.

    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.chargeFutureRenewals("__test__KyVnJjRnFcy3b8of").request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
    Invoice invoice = result.invoice();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.chargeFutureRenewals("__test__KyVnJjRnFcy3b8of").request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
    Invoice invoice = result.invoice();

    Sample Result [ JSON ]

    Show more...
    { "card": { "card_type": "american_express", "created_at": 1517470201, "customer_id": "__test__KyVnJjRnFcy3b8of", "expiry_month": 12, "expiry_year": 2022, "funding_type": "not_known", "gateway": "chargebee", "gateway_account_id": "gw___test__KyVnHuRnFcucX27", "iin": "378282", "last4": "0005", "masked_number": "***********0005", "object": "card", "payment_source_id": "pm___test__KyVnJjRnFcy4A8oh", "resource_version": 1517470201000, "status": "valid", "updated_at": 1517470201 }, "customer": { "allow_direct_debit": false, "auto_collection": "on", "card_status": "valid", "created_at": 1517470201, "deleted": false, "excess_payments": 0, "id": "__test__KyVnJjRnFcy3b8of", "net_term_days": 0, "object": "customer", "payment_method": { "gateway": "chargebee", "gateway_account_id": "gw___test__KyVnHuRnFcucX27", "object": "payment_method", "reference_id": "tok___test__KyVnJjRnFcy468og", "status": "valid", "type": "card" }, "pii_cleared": "active", "preferred_currency_code": "USD", "primary_payment_source_id": "pm___test__KyVnJjRnFcy4A8oh", "promotional_credits": 0, "refundable_credits": 0, "resource_version": 1517470201000, "taxability": "taxable", "unbilled_charges": 0, "updated_at": 1517470201 }, "invoice": { "adjustment_credit_notes": [], "amount_adjusted": 0, "amount_due": 0, "amount_paid": 895, "amount_to_collect": 0, "applied_credits": [], "base_currency_code": "USD", "credits_applied": 0, "currency_code": "USD", "customer_id": "__test__KyVnJjRnFcy3b8of", "date": 1517470202, "deleted": false, "due_date": 1517470202, "dunning_attempts": [], "exchange_rate": 1, "first_invoice": false, "has_advance_charges": true, "id": "__demo_inv__7", "is_gifted": false, "issued_credit_notes": [], "line_items": [ { "amount": 895, "customer_id": "__test__KyVnJjRnFcy3b8of", "date_from": 1519889401, "date_to": 1522567801, "description": "No Trial", "discount_amount": 0, "entity_id": "no_trial", "entity_type": "plan", "id": "li___test__KyVnJjRnFcy8J8ot", "is_taxed": false, "item_level_discount_amount": 0, "object": "line_item", "pricing_model": "per_unit", "quantity": 1, "subscription_id": "__test__KyVnJjRnFcy3b8of", "tax_amount": 0, "tax_exempt_reason": "tax_not_configured", "unit_amount": 895 }, {..} ], "linked_orders": [], "linked_payments": [ { "applied_amount": 895, "applied_at": 1517470202, "txn_amount": 895, "txn_date": 1517470202, "txn_id": "txn___test__KyVnJjRnFcy8s8ou", "txn_status": "success" }, {..} ], "net_term_days": 0, "object": "invoice", "paid_at": 1517470202, "price_type": "tax_exclusive", "recurring": true, "resource_version": 1517470202000, "round_off_amount": 0, "status": "paid", "sub_total": 895, "subscription_id": "__test__KyVnJjRnFcy3b8of", "tax": 0, "term_finalized": true, "total": 895, "updated_at": 1517470202, "write_off_amount": 0 }, "subscription": { "activated_at": 1517470201, "billing_period": 1, "billing_period_unit": "month", "created_at": 1517470201, "currency_code": "USD", "current_term_end": 1519889401, "current_term_start": 1517470201, "customer_id": "__test__KyVnJjRnFcy3b8of", "deleted": false, "due_invoices_count": 0, "has_scheduled_changes": false, "id": "__test__KyVnJjRnFcy3b8of", "mrr": 0, "next_billing_at": 1522567801, "object": "subscription", "plan_amount": 895, "plan_free_quantity": 0, "plan_id": "no_trial", "plan_quantity": 1, "plan_unit_price": 895, "resource_version": 1517470202000, "started_at": 1517470201, "status": "active", "updated_at": 1517470202 } }

    Method

    Subscription.chargeFutureRenewals(<subscription_id>)
    
    termsToCharge(val)
    The number of future renewals for which the advance invoicing is done.
    optional, integer, default=1, min=1
    Resource object representing subscription.
    always returned
    Resource object representing customer.
    always returned
    Resource object representing card.
    optional
    Resource object representing invoice.
    always returned
    This API is not enabled for live sites by default. Please contact support@chargebee.com to get this enabled.
    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.importSubscription()
    	.planId("no_trial")
    	.status(Status.ACTIVE)
    	.currentTermEnd(1587925800)
    	.billingCycles(4)
    	.customerFirstName("John")
    	.customerLastName("Doe")
    	.customerLocale("fr-CA")
    	.customerPhone("+1-949-999-9999")
    	.billingAddressFirstName("John")
    	.billingAddressLastName("Doe")
    	.billingAddressLine1("PO Box 9999")
    	.billingAddressCity("Walnut")
    	.billingAddressState("California")
    	.billingAddressZip("91789")
    	.billingAddressCountry("US")
    	.addonId(0,"ssl")
    	.contractTermActionAtTermEnd(ActionAtTermEnd.RENEW)
    	.contractTermBillingCycleOnRenewal(3)
    	.contractTermContractStart(1509511210)
    	.contractTermCancellationCutoffPeriod(3)
    	.contractTermCreatedAt(1509511210)
    	.contractTermTotalAmountRaised(900)
    	.contractTermBillingCycles("5")
    	.request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
    Invoice invoice = result.invoice();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.importSubscription()
    	.planId("no_trial")
    	.status(Status.ACTIVE)
    	.currentTermEnd(1587925800)
    	.billingCycles(4)
    	.customerFirstName("John")
    	.customerLastName("Doe")
    	.customerLocale("fr-CA")
    	.customerPhone("+1-949-999-9999")
    	.billingAddressFirstName("John")
    	.billingAddressLastName("Doe")
    	.billingAddressLine1("PO Box 9999")
    	.billingAddressCity("Walnut")
    	.billingAddressState("California")
    	.billingAddressZip("91789")
    	.billingAddressCountry("US")
    	.addonId(0,"ssl")
    	.contractTermActionAtTermEnd(ActionAtTermEnd.RENEW)
    	.contractTermBillingCycleOnRenewal(3)
    	.contractTermContractStart(1509511210)
    	.contractTermCancellationCutoffPeriod(3)
    	.contractTermCreatedAt(1509511210)
    	.contractTermTotalAmountRaised(900)
    	.contractTermBillingCycles("5")
    	.request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
    Invoice invoice = result.invoice();

    Sample Result [ JSON ]

    Show more...
    { "customer": { "allow_direct_debit": false, "auto_collection": "on", "billing_address": { "city": "Walnut", "country": "US", "first_name": "John", "last_name": "Doe", "line1": "PO Box 9999", "object": "billing_address", "state": "California", "state_code": "CA", "validation_status": "not_validated", "zip": "91789" }, "card_status": "no_card", "created_at": 1517482723, "deleted": false, "excess_payments": 0, "first_name": "John", "id": "__test__XpbTotFRw2GNtjJ", "last_name": "Doe", "locale": "fr-CA", "net_term_days": 0, "object": "customer", "phone": "+1-949-999-9999", "pii_cleared": "active", "preferred_currency_code": "USD", "promotional_credits": 0, "refundable_credits": 0, "resource_version": 1517482723000, "taxability": "taxable", "unbilled_charges": 0, "updated_at": 1517482723 }, "subscription": { "activated_at": 1517482722, "addons": [ { "amount": 495, "id": "ssl", "object": "addon", "quantity": 1, "unit_price": 495 }, {..} ], "billing_period": 1, "billing_period_unit": "month", "contract_term": { "action_at_term_end": "renew", "billing_cycle": 4, "cancellation_cutoff_period": 3, "contract_end": 1598466600, "contract_start": 1509511210, "created_at": 1509511210, "id": "__test__XpbTotFRw2GNtoK", "object": "contract_term", "remaining_billing_cycles": 3, "status": "active", "total_contract_value": 5070 }, "contract_term_billing_cycle_on_renewal": 3, "created_at": 1517482723, "currency_code": "USD", "current_term_end": 1587925800, "current_term_start": 1517482722, "customer_id": "__test__XpbTotFRw2GNtjJ", "deleted": false, "due_invoices_count": 0, "has_scheduled_changes": false, "id": "__test__XpbTotFRw2GNtjJ", "mrr": 0, "next_billing_at": 1587925800, "object": "subscription", "plan_amount": 895, "plan_free_quantity": 0, "plan_id": "no_trial", "plan_quantity": 1, "plan_unit_price": 895, "remaining_billing_cycles": 3, "resource_version": 1517482724000, "started_at": 1517482722, "status": "active", "updated_at": 1517482724 } }

    Method

    Subscription.importSubscription()
    
    id(val)
    Id for the new subscription. If not given, this will be auto-generated.
    optional, string, max chars=50
    clientProfileId(val)
    Indicates the Client profile id for the customer. This is applicable only if you use Chargebee’s AvaTax for Communications integration.
    optional, string, max chars=50
    planId(val)
    Identifier of the plan for this subscription.
    required, string, max chars=100
    planQuantity(val)
    Plan quantity for this subscription.
    optional, integer, default=1, min=1
    planUnitPrice(val)
    Amount that will override the Plan's default price.
    optional, in cents, min=0
    setupFee(val)
    Amount that will override the default setup fee.
    optional, in cents, min=0
    trialEnd(val)
    The time at which the trial ends for this subscription. Can be specified to override the default trial period.If '0' is passed, the subscription will be activated immediately.
    optional, timestamp(UTC) in seconds
    billingCycles(val)
    Number of cycles(plan interval) this subscription should be charged. After the billing cycles exhausted, the subscription will be cancelled.
    optional, integer, min=0
    startDate(val)
    Allows you to specify a future date or a past date on which the subscription starts.Past dates can be entered in case the subscription has already started. Any past date entered must be within the current billing cycle/plan term. The subscription will start immediately if this parameter is not passed.
    optional, timestamp(UTC) in seconds
    autoCollection(val)
    Defines whether payments need to be collected automatically for this subscription. Overrides customer's auto-collection property.
    optional, enumerated string
    Possible values are
    ONWhenever an invoice is created for this subscription, an automatic charge will be attempted on the payment method available.OFFAutomatic collection of charges will not be made for this subscription. All payments must be recorded offline.
    poNumber(val)
    Purchase Order Number for this subscription.
    optional, string, max chars=100
    couponIds(val)
    Identifier of the coupon as a List. Coupon Codes can also be passed.
    optional, list of string
    contractTermBillingCycleOnRenewal(val)
    Number of billing cycles the new contract term should run for, on contract renewal. The default value is as specified in the site settings.
    optional, integer, min=1, max=100
    status(val)
    Current state of the subscription.
    required, enumerated string
    Possible values are
    FUTUREThe Subscription is scheduled to start in a future date.IN_TRIALThe subscription is in trial.ACTIVEThe subscription is in active state and will be charged at start of each term based on the recurring items(plan & addons etc.,).NON_RENEWINGThe subscription will be cancelled at end of the current term.PAUSEDThe subscription is paused. No new recurring actions will be allowed, but any pending payments will be collected.CANCELLEDThe subscription has been cancelled. No new recurring actions will take place, but any pending payments will be collected.
    currentTermEnd(val)
    End of the current billing term. Subscription is renewed immediately after this. If not given, this will be calculated based on plan billing cycle.
    optional, timestamp(UTC) in seconds
    currentTermStart(val)
    Start of the current billing term.
    optional, timestamp(UTC) in seconds
    trialStart(val)
    Start of the trial period for the subscription. Presence of this value for 'future' subscription implies the subscription will go into 'trial' state when it starts.
    optional, timestamp(UTC) in seconds
    cancelledAt(val)
    Time at which subscription was cancelled or is set to be cancelled.
    optional, timestamp(UTC) in seconds
    startedAt(val)
    Time at which the subscription got started. Will be null for 'future' subscriptions as it is yet to be started.
    optional, timestamp(UTC) in seconds
    pauseDate(val)
    Date on which the subscription will be paused.
    optional, timestamp(UTC) in seconds
    resumeDate(val)
    Date on which the subscription will be resumed.
    optional, timestamp(UTC) in seconds
    createCurrentTermInvoice(val)
    Set as TRUE if you want Chargebee to create an invoice for the subscription.
    • Invoice will be created for subscriptions with ACTIVE or NON_RENEWING status only.
    • Invoice will be created for the period mentioned in the current_term_start and current_term_end attributes.
    • Invoice will not be generated if subscription amount is zero dollars (for that period) and 'Hide Zero Value Line Items' option is enabled in Settings.
    • Invoice will not be generated if the given quantity is not greater than free quantity (If free quantity is configured in the plan/addon).
      optional, boolean, default=false
    affiliateToken(val)
    A unique tracking token.
    optional, string, max chars=250
    invoiceNotes(val)
    Invoice Notes for this resource. Read More.
    optional, string, max chars=2000
    metaData(val)
    Additional data about this resource can be stored here in the JSON Format. Learn more.
    optional, jsonobject
    +
    customer
    Parameters for customer
    methods are prefixed like customer<param name>(val)
    customerId(val)
    Id for the new customer. If not given, this will be same as the subscription id.
    optional, string, max chars=50
    customerEmail(val)
    Email of the customer. Configured email notifications will be sent to this email.
    optional, string, max chars=70
    customerFirstName(val)
    First name of the customer.
    optional, string, max chars=150
    customerLastName(val)
    Last name of the customer.
    optional, string, max chars=150
    customerCompany(val)
    Company name of the customer.
    optional, string, max chars=250
    customerTaxability(val)
    Specifies if the customer is liable for tax.
    optional, enumerated string, default=taxable
    Possible values are
    TAXABLECustomer is taxable.EXEMPT
    • Customer is exempted from tax
    • Optionally, specify entity_code or exempt_number attributes if you use Chargebee’s AvaTax for Sales or specify exemption_details attribute if you use Chargebee’s AvaTax for Communications integration. Tax may still be applied by Avalara for certain values of entity_code/exempt_number/exemption_details based on the state/region/province of the taxable address.
    .
    customerLocale(val)
    Determines which region-specific language Chargebee uses to communicate with the customer. In the absence of the locale attribute, Chargebee will use your site's default language for customer communication.
    optional, string, max chars=50
    customerEntityCode(val)
    The exemption category of the customer, for USA and Canada. Applicable if you use Chargebee's AvaTax for Sales integration.
    optional, enumerated string
    Possible values are
    AFederal government.BState government.CTribe/Status Indian/Indian Band.DForeign diplomat.
    ECharitable or benevolent organization.FReligious organization.GResale.HCommercial agricultural production.IIndustrial production/manufacturer.JDirect pay permit.KDirect mail.LOther or custom.MEducational organization.NLocal government.PCommercial aquaculture.QCommercial Fishery.RNon-resident.MED1US Medical Device Excise Tax with exempt sales tax.MED2US Medical Device Excise Tax with taxable sales tax.
    Show all values[+]
    customerExemptNumber(val)
    Any string value that will cause the sale to be exempted. Use this if your finance team manually verifies and tracks exemption certificates. Applicable if you use Chargebee's AvaTax for Sales integration.
    optional, string, max chars=100
    customerNetTermDays(val)
    The number of days within which the customer has to make payment for the invoice.
    optional, integer, default=0
    customerTaxjarExemptionCategory(val)
    Indicates the exemption type of the customer. This is applicable only if you use Chargebee’s TaxJar integration.
    optional, enumerated string
    Possible values are
    WHOLESALEWhole-sale.GOVERNMENTGovernment.OTHEROther.
    customerPhone(val)
    Phone number of the customer.
    optional, string, max chars=50
    customerCustomerType(val)
    Indicates the type of the customer. This is applicable only if you use Chargebee’s AvaTax for Communications integration.
    optional, enumerated string
    Possible values are
    RESIDENTIALWhen the purchase is made by a customer for home use.BUSINESSWhen the purchase is made at a place of business.SENIOR_CITIZENWhen the purchase is made by a customer who meets the jurisdiction requirements to be considered a senior citizen and qualifies for senior citizen tax breaks.INDUSTRIALWhen the purchase is made by an industrial business.
    customerAutoCollection(val)
    Whether payments needs to be collected automatically for this customer.
    optional, enumerated string, default=on
    Possible values are
    ONWhenever an invoice is created, an automatic attempt to charge the customer's payment method is made.OFFAutomatic collection of charges will not be made. All payments must be recorded offline.
    customerAllowDirectDebit(val)
    Whether the customer can pay via Direct Debit.
    optional, boolean, default=false
    customerVatNumber(val)
    VAT/ Tax registration number of the customer. Learn more.
    optional, string, max chars=20
    +
    contractTerm
    Parameters for contractTerm
    methods are prefixed like contractTerm<param name>(val)
    contractTermId(val)
    Id that uniquely identifies the contract term in the site.
    optional, string, max chars=50
    contractTermCreatedAt(val)
    The date when the contract term was created.
    optional, timestamp(UTC) in seconds
    contractTermContractStart(val)
    The start date of the contract term.
    optional, timestamp(UTC) in seconds
    contractTermTotalAmountRaised(val)
    The amount raised for the contract term up until the time of importing the subscription. This gets added to total_contract_value.
    optional, in cents, default=0, min=0
    contractTermBillingCycle(val)
    The number of billing cycles of the subscription that the contract term is for.
    optional, integer, min=0
    contractTermActionAtTermEnd(val)
    Action to be taken when the contract term completes.
    optional, enumerated string, default=cancel
    Possible values are
    RENEW
  • Contract term completes and a new contract term is started for the number of billing cycles specified in contract_billing_cycle_on_renewal.
  • The action_at_term_end for the new contract term is set to renew.
  • .
    RENEW_ONCEUsed when you want to renew the contract term just once. Does the following:
  • Contract term completes and a new contract term is started for the number of billing cycles specified in contract_billing_cycle_on_renewal.
  • The action_at_term_end for the new contract term is set to cancel.
  • .
    EVERGREENContract term completes and the subscription renews.CANCELContract term completes and subscription is canceled.
    contractTermCancellationCutoffPeriod(val)
    The number of days before contract_end, during which the customer is barred from canceling the contract term. The customer is allowed to cancel the contract term via the Self-Serve Portal only before this period. This allows you to have sufficient time for processing the contract term closure.
    optional, integer, default=0
    +
    card
    Parameters for card
    methods are prefixed like card<param name>(val)
    cardGatewayAccountId(val)
    The gateway account in which this payment source is stored.
    optional, string, max chars=50
    cardFirstName(val)
    Cardholder's first name.
    optional, string, max chars=50
    cardLastName(val)
    Cardholder's last name.
    optional, string, max chars=50
    cardNumber(val)
    The credit card number without any format. If you are using Braintree.js, you can specify the Braintree encrypted card number here.
    required if card provided, string, max chars=1500
    cardExpiryMonth(val)
    Card expiry month.
    required if card provided, integer, min=1, max=12
    cardExpiryYear(val)
    Card expiry year.
    required if card provided, integer
    cardCvv(val)
    The card verification value. If you are using Braintree.js, you can specify the Braintree encrypted cvv here.
    optional, string, max chars=520
    cardBillingAddr1(val)
    Address line 1, as available in card billing address.
    optional, string, max chars=150
    cardBillingAddr2(val)
    Address line 2, as available in card billing address.
    optional, string, max chars=150
    cardBillingCity(val)
    City, as available in card billing address.
    optional, string, max chars=50
    cardBillingStateCode(val)
    The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set the state_code as AZ (not US-AZ). or, for Tamil Nadu (India), set the state_code as TN (not IN-TN). or, for British Columbia (Canada), set the state_code as BC (not CA-BC).
    Note: If the 'state_code' is specified, the 'state' attribute should not be provided as Chargebee will set the value automatically (for US, Canada, India).
    optional, string, max chars=50
    cardBillingState(val)
    The state/province name. Use this to pass the state/province information for cases where 'state_code' is not supported or cannot be passed.
    optional, string, max chars=50
    cardBillingZip(val)
    Postal or Zip code, as available in card billing address.
    optional, string, max chars=20
    cardBillingCountry(val)
    2-letter ISO 3166 alpha-2 country code.
    optional, string, max chars=50
    +
    paymentMethod
    Parameters for paymentMethod
    methods are prefixed like paymentMethod<param name>(val)
    paymentMethodType(val)
    The type of payment method. For more details refer Update payment method for a customer API under Customer resource.
    optional, enumerated string
    Possible values are
    CARDCard based payment including credit cards and debit cards. Details about the card can be obtained from the card resource.PAYPAL_EXPRESS_CHECKOUTPayments made via PayPal Express Checkout.AMAZON_PAYMENTSPayments made via Amazon Payments.DIRECT_DEBITRepresents bank account for which the direct debit or ACH agreement/mandate is created.
    GENERICGeneric Payment Method.ALIPAYAlipay Payments.UNIONPAYUnionPay Payments.APPLE_PAYApple Pay Payments.WECHAT_PAYWeChat Pay Payments.IDEALiDEAL Payments.GOOGLE_PAYGoogle Pay Payments.SOFORTSofort Payments.BANCONTACTBancontact Card Payments.
    Show all values[+]
    paymentMethodGatewayAccountId(val)
    The gateway account in which this payment source is stored.
    optional, string, max chars=50
    paymentMethodReferenceId(val)
    The reference id. In the case of Amazon and PayPal this will be the billing agreement id. For GoCardless direct debit this will be 'mandate id'. In the case of card this will be the identifier provided by the gateway/card vault for the specific payment method resource. Note: This is not the one-time temporary token provided by gateways like Stripe.
    For more details refer Update payment method for a customer API under Customer resource.
    optional, string, max chars=200
    paymentMethodIssuingCountry(val)
    2-letter (alpha2) ISO country code. Indicates your customer's payment method country of issuance. Applicable for PayPal via Braintree.
    optional, string, max chars=50
    +
    billingAddress
    Parameters for billingAddress
    methods are prefixed like billingAddress<param name>(val)
    billingAddressFirstName(val)
    First name.
    optional, string, max chars=150
    billingAddressLastName(val)
    Last name.
    optional, string, max chars=150
    billingAddressEmail(val)
    Email.
    optional, string, max chars=70
    billingAddressCompany(val)
    Company name.
    optional, string, max chars=250
    billingAddressPhone(val)
    Phone number.
    optional, string, max chars=50
    billingAddressLine1(val)
    Address line 1.
    optional, string, max chars=150
    billingAddressLine2(val)
    Address line 2.
    optional, string, max chars=150
    billingAddressLine3(val)
    Address line 3.
    optional, string, max chars=150
    billingAddressCity(val)
    City.
    optional, string, max chars=50
    billingAddressStateCode(val)
    The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set the state_code as AZ (not US-AZ). or, for Tamil Nadu (India), set the state_code as TN (not IN-TN). or, for British Columbia (Canada), set the state_code as BC (not CA-BC).
    Note: If the 'state_code' is specified, the 'state' attribute should not be provided as Chargebee will set the value automatically (for US, Canada, India).
    optional, string, max chars=50
    billingAddressState(val)
    The state/province name. Use this to pass the state/province information for cases where 'state_code' is not supported or cannot be passed.
    optional, string, max chars=50
    billingAddressZip(val)
    Zip or Postal code.
    optional, string, max chars=20
    billingAddressCountry(val)
    2-letter ISO 3166 alpha-2 country code.
    optional, string, max chars=50
    billingAddressValidationStatus(val)
    The address verification status.
    optional, enumerated string, default=not_validated
    Possible values are
    NOT_VALIDATEDAddress is not yet validated.VALIDAddress was validated successfully.PARTIALLY_VALIDAddress is verified but only partially.INVALIDAddress is invalid.
    +
    shippingAddress
    Parameters for shippingAddress
    methods are prefixed like shippingAddress<param name>(val)
    shippingAddressFirstName(val)
    First name.
    optional, string, max chars=150
    shippingAddressLastName(val)
    Last name.
    optional, string, max chars=150
    shippingAddressEmail(val)
    Email.
    optional, string, max chars=70
    shippingAddressCompany(val)
    Company name.
    optional, string, max chars=250
    shippingAddressPhone(val)
    Phone number.
    optional, string, max chars=50
    shippingAddressLine1(val)
    Address line 1.
    optional, string, max chars=180
    shippingAddressLine2(val)
    Address line 2.
    optional, string, max chars=150
    shippingAddressLine3(val)
    Address line 3.
    optional, string, max chars=150
    shippingAddressCity(val)
    City.
    optional, string, max chars=50
    shippingAddressStateCode(val)
    The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set the state_code as AZ (not US-AZ). or, for Tamil Nadu (India), set the state_code as TN (not IN-TN). or, for British Columbia (Canada), set the state_code as BC (not CA-BC).
    Note: If the 'state_code' is specified, the 'state' attribute should not be provided as Chargebee will set the value automatically (for US, Canada, India).
    optional, string, max chars=50
    shippingAddressState(val)
    The state/province name. Use this to pass the state/province information for cases where 'state_code' is not supported or cannot be passed.
    optional, string, max chars=50
    shippingAddressZip(val)
    Zip or Postal code.
    optional, string, max chars=20
    shippingAddressCountry(val)
    2-letter ISO 3166 alpha-2 country code.
    optional, string, max chars=50
    shippingAddressValidationStatus(val)
    The address verification status.
    optional, enumerated string, default=not_validated
    Possible values are
    NOT_VALIDATEDAddress is not yet validated.VALIDAddress was validated successfully.PARTIALLY_VALIDAddress is verified but only partially.INVALIDAddress is invalid.
    +
    transaction
    Parameters for transaction
    methods are prefixed like transaction<param name>(val)
    transactionAmount(val)
    The payment transaction amount. This param should be passed only if the invoice is created for current term.
    optional, in cents, min=1
    transactionPaymentMethod(val)
    The Payment Method of this transaction. This param should be passed only if the invoice is created for current term.
    optional, enumerated string, default=card
    Possible values are
    CASHCash.CHECKCheck.
    BANK_TRANSFERBank Transfer.OTHERPayment Methods other than the above types.
    Show all values[+]
    transactionReferenceNumber(val)
    The reference number for this transaction. e.g check number in case of 'check' payment. This param should be passed only if the invoice is created for current term.
    optional, string, max chars=100
    transactionDate(val)
    Indicates when this transaction occurred. This param should be passed only if the invoice is created for current term.
    optional, timestamp(UTC) in seconds
    +
    addons
    Parameters for addons. Multiple addons can be passed by specifying unique indices.
    methods are prefixed like addons<param name>(idx,val)
    addonId(idx,val)
    Identifier of the addon. Multiple addons can be passed.
    optional, string, max chars=100
    addonQuantity(idx,val)
    Addon quantity. Applicable only for the quantity based addons. Should be passed with the same index as that of associated addon id.
    optional, integer, default=1, min=1
    addonUnitPrice(idx,val)
    Amount that will override the Addon's default price. The Plan's billing frequency will not be considered for overriding. E.g. If the Plan's billing frequency is every 3 months, and if the price override amount is $10, $10 will be used, and not $30 (i.e $10*3).
    optional, in cents, min=0
    addonBillingCycles(idx,val)
    Number of billing cycles the addon will be charged for. When not set, the addon is attached to the subscription for an indefinite number of billing cycles. While updating a subscription to a plan with a different billing period, set this parameter again or its value will be lost. And so, the addon will be attached indefinitely.
    optional, integer, min=1
    +
    eventBasedAddons
    Parameters for eventBasedAddons. Multiple eventBasedAddons can be passed by specifying unique indices.
    methods are prefixed like eventBasedAddons<param name>(idx,val)
    eventBasedAddonId(idx,val)
    A unique 'id' used to identify the addon.
    optional, string, max chars=100
    eventBasedAddonQuantity(idx,val)
    Addon quantity. Applicable only for the quantity based addons. Should be passed with the same index as that of associated addon id.
    optional, integer, min=1
    eventBasedAddonUnitPrice(idx,val)
    Amount that will override the Addon's default price.
    optional, in cents, min=0
    eventBasedAddonServicePeriodInDays(idx,val)
    Defines service period of the addon in days from the day of charge.
    optional, integer, min=1, max=730
    eventBasedAddonOnEvent(idx,val)
    Event on which this addon will be charged.
    optional, enumerated string
    Possible values are
    SUBSCRIPTION_CREATIONAddon will be charged on subscription creation.SUBSCRIPTION_TRIAL_STARTAddon will be charged when the trial period starts.PLAN_ACTIVATIONAddon will be charged on plan activation.SUBSCRIPTION_ACTIVATIONAddon will be charged on subscription activation.CONTRACT_TERMINATIONAddon will be charged on contract termination.
    eventBasedAddonChargeOnce(idx,val)
    If enabled, the addon will be charged only at the first occurrence of the event. Applicable only for non-recurring add-ons.
    optional, boolean, default=true
    +
    chargedEventBasedAddons
    Parameters for chargedEventBasedAddons. Multiple chargedEventBasedAddons can be passed by specifying unique indices.
    methods are prefixed like chargedEventBasedAddons<param name>(idx,val)
    chargedEventBasedAddonId(idx,val)
    Addon id.
    optional, string, max chars=100
    chargedEventBasedAddonLastChargedAt(idx,val)
    Timestamp indicating when this add-on was last charged for this subscription.
    optional, timestamp(UTC) in seconds
    Resource object representing subscription.
    always returned
    Resource object representing customer.
    always returned
    Resource object representing card.
    optional
    Resource object representing invoice.
    optional
    This API is not enabled for live sites by default. Please contact support@chargebee.com to get this enabled.
    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.importForCustomer("__test__XpbTotFRw2GOLPY")
    	.planId("no_trial")
    	.billingCycles(4)
    	.status(Status.IN_TRIAL)
    	.trialEnd(1587925800)
    	.addonId(0,"ssl")
    	.contractTermActionAtTermEnd(ActionAtTermEnd.RENEW)
    	.contractTermBillingCycleOnRenewal(3)
    	.contractTermContractStart(1509511210)
    	.contractTermCancellationCutoffPeriod(3)
    	.contractTermCreatedAt(1509511210)
    	.contractTermTotalAmountRaised(900)
    	.contractTermBillingCycles("5")
    	.request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
    Invoice invoice = result.invoice();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.importForCustomer("__test__XpbTotFRw2GOLPY")
    	.planId("no_trial")
    	.billingCycles(4)
    	.status(Status.IN_TRIAL)
    	.trialEnd(1587925800)
    	.addonId(0,"ssl")
    	.contractTermActionAtTermEnd(ActionAtTermEnd.RENEW)
    	.contractTermBillingCycleOnRenewal(3)
    	.contractTermContractStart(1509511210)
    	.contractTermCancellationCutoffPeriod(3)
    	.contractTermCreatedAt(1509511210)
    	.contractTermTotalAmountRaised(900)
    	.contractTermBillingCycles("5")
    	.request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
    Invoice invoice = result.invoice();

    Sample Result [ JSON ]

    Show more...
    { "customer": { "allow_direct_debit": false, "auto_collection": "off", "card_status": "no_card", "created_at": 1517482724, "deleted": false, "excess_payments": 0, "first_name": "Mark", "id": "__test__XpbTotFRw2GOLPY", "last_name": "Henry", "net_term_days": 0, "object": "customer", "pii_cleared": "active", "preferred_currency_code": "USD", "promotional_credits": 0, "refundable_credits": 0, "resource_version": 1517482724000, "taxability": "taxable", "unbilled_charges": 0, "updated_at": 1517482724 }, "subscription": { "addons": [ { "amount": 495, "id": "ssl", "object": "addon", "quantity": 1, "unit_price": 495 }, {..} ], "billing_period": 1, "billing_period_unit": "month", "contract_term": { "action_at_term_end": "renew", "billing_cycle": 4, "cancellation_cutoff_period": 3, "contract_end": 1598466600, "contract_start": 1509511210, "created_at": 1509511210, "id": "__test__XpbTotFRw2GOMLb", "object": "contract_term", "remaining_billing_cycles": 4, "status": "active", "total_contract_value": 6460 }, "contract_term_billing_cycle_on_renewal": 3, "created_at": 1517482724, "currency_code": "USD", "customer_id": "__test__XpbTotFRw2GOLPY", "deleted": false, "due_invoices_count": 0, "has_scheduled_changes": false, "id": "__test__XpbTotFRw2GOMGa", "next_billing_at": 1587925800, "object": "subscription", "plan_amount": 895, "plan_free_quantity": 0, "plan_id": "no_trial", "plan_quantity": 1, "plan_unit_price": 895, "remaining_billing_cycles": 4, "resource_version": 1517482724000, "started_at": 1517482724, "status": "in_trial", "trial_end": 1587925800, "trial_start": 1517482724, "updated_at": 1517482724 } }

    Method

    Subscription.importForCustomer(<customer_id>)
    
    id(val)
    Id for the new subscription. If not given, this will be auto-generated.
    optional, string, max chars=50
    planId(val)
    Identifier of the plan for this subscription.
    required, string, max chars=100
    planQuantity(val)
    Plan quantity for this subscription.
    optional, integer, default=1, min=1
    planUnitPrice(val)
    Amount that will override the Plan's default price.
    optional, in cents, min=0
    setupFee(val)
    Amount that will override the default setup fee.
    optional, in cents, min=0
    trialEnd(val)
    The time at which the trial ends for this subscription. Can be specified to override the default trial period.If '0' is passed, the subscription will be activated immediately.
    optional, timestamp(UTC) in seconds
    billingCycles(val)
    Number of cycles(plan interval) this subscription should be charged. After the billing cycles exhausted, the subscription will be cancelled.
    optional, integer, min=0
    startDate(val)
    Allows you to specify a future date or a past date on which the subscription starts.Past dates can be entered in case the subscription has already started. Any past date entered must be within the current billing cycle/plan term. The subscription will start immediately if this parameter is not passed.
    optional, timestamp(UTC) in seconds
    autoCollection(val)
    Defines whether payments need to be collected automatically for this subscription. Overrides customer's auto-collection property.
    optional, enumerated string
    Possible values are
    ONWhenever an invoice is created for this subscription, an automatic charge will be attempted on the payment method available.OFFAutomatic collection of charges will not be made for this subscription. All payments must be recorded offline.
    poNumber(val)
    Purchase Order Number for this subscription.
    optional, string, max chars=100
    couponIds(val)
    Identifier of the coupon as a List. Coupon Codes can also be passed.
    optional, list of string
    paymentSourceId(val)
    Unique identifier of the payment source to be attached to this subscription.
    optional, string, max chars=40
    status(val)
    Current state of the subscription.
    required, enumerated string
    Possible values are
    FUTUREThe Subscription is scheduled to start in a future date.IN_TRIALThe subscription is in trial.ACTIVEThe subscription is in active state and will be charged at start of each term based on the recurring items(plan & addons etc.,).NON_RENEWINGThe subscription will be cancelled at end of the current term.PAUSEDThe subscription is paused. No new recurring actions will be allowed, but any pending payments will be collected.CANCELLEDThe subscription has been cancelled. No new recurring actions will take place, but any pending payments will be collected.
    currentTermEnd(val)
    End of the current billing term. Subscription is renewed immediately after this. If not given, this will be calculated based on plan billing cycle.
    optional, timestamp(UTC) in seconds
    currentTermStart(val)
    Start of the current billing term.
    optional, timestamp(UTC) in seconds
    trialStart(val)
    Start of the trial period for the subscription. Presence of this value for 'future' subscription implies the subscription will go into 'trial' state when it starts.
    optional, timestamp(UTC) in seconds
    cancelledAt(val)
    Time at which subscription was cancelled or is set to be cancelled.
    optional, timestamp(UTC) in seconds
    startedAt(val)
    Time at which the subscription got started. Will be null for 'future' subscriptions as it is yet to be started.
    optional, timestamp(UTC) in seconds
    pauseDate(val)
    Date on which the subscription will be paused.
    optional, timestamp(UTC) in seconds
    resumeDate(val)
    Date on which the subscription will be resumed.
    optional, timestamp(UTC) in seconds
    contractTermBillingCycleOnRenewal(val)
    Number of billing cycles the new contract term should run for, on contract renewal. The default value is as specified in the site settings.
    optional, integer, min=1, max=100
    createCurrentTermInvoice(val)
    Set as TRUE if you want Chargebee to create an invoice for the subscription.
    • Invoice will be created for subscriptions with ACTIVE or NON_RENEWING status only.
    • Invoice will be created for the period mentioned in the current_term_start and current_term_end attributes.
    • Invoice will not be generated if subscription amount is zero dollars (for that period) and 'Hide Zero Value Line Items' option is enabled in Settings.
    • Invoice will not be generated if the given quantity is not greater than free quantity (If free quantity is configured in the plan/addon).
      optional, boolean, default=false
    invoiceNotes(val)
    Invoice Notes for this resource. Read More.
    optional, string, max chars=2000
    metaData(val)
    Additional data about this resource can be stored here in the JSON Format. Learn more.
    optional, jsonobject
    +
    contractTerm
    Parameters for contractTerm
    methods are prefixed like contractTerm<param name>(val)
    contractTermId(val)
    Id that uniquely identifies the contract term in the site.
    optional, string, max chars=50
    contractTermCreatedAt(val)
    The date when the contract term was created.
    optional, timestamp(UTC) in seconds
    contractTermContractStart(val)
    The start date of the contract term.
    optional, timestamp(UTC) in seconds
    contractTermTotalAmountRaised(val)
    The amount raised for the contract term up until the time of importing the subscription. This gets added to total_contract_value.
    optional, in cents, default=0, min=0
    contractTermBillingCycle(val)
    The number of billing cycles of the subscription that the contract term is for.
    optional, integer, min=0
    contractTermActionAtTermEnd(val)
    Action to be taken when the contract term completes.
    optional, enumerated string, default=cancel
    Possible values are
    RENEW
  • Contract term completes and a new contract term is started for the number of billing cycles specified in contract_billing_cycle_on_renewal.
  • The action_at_term_end for the new contract term is set to renew.
  • .
    RENEW_ONCEUsed when you want to renew the contract term just once. Does the following:
  • Contract term completes and a new contract term is started for the number of billing cycles specified in contract_billing_cycle_on_renewal.
  • The action_at_term_end for the new contract term is set to cancel.
  • .
    EVERGREENContract term completes and the subscription renews.CANCELContract term completes and subscription is canceled.
    contractTermCancellationCutoffPeriod(val)
    The number of days before contract_end, during which the customer is barred from canceling the contract term. The customer is allowed to cancel the contract term via the Self-Serve Portal only before this period. This allows you to have sufficient time for processing the contract term closure.
    optional, integer, default=0
    +
    transaction
    Parameters for transaction
    methods are prefixed like transaction<param name>(val)
    transactionAmount(val)
    The payment transaction amount. This param should be passed only if the invoice is created for current term.
    optional, in cents, min=1
    transactionPaymentMethod(val)
    The Payment Method of this transaction. This param should be passed only if the invoice is created for current term.
    optional, enumerated string, default=card
    Possible values are
    CASHCash.CHECKCheck.
    BANK_TRANSFERBank Transfer.OTHERPayment Methods other than the above types.
    Show all values[+]
    transactionReferenceNumber(val)
    The reference number for this transaction. e.g check number in case of 'check' payment. This param should be passed only if the invoice is created for current term.
    optional, string, max chars=100
    transactionDate(val)
    Indicates when this transaction occurred. This param should be passed only if the invoice is created for current term.
    optional, timestamp(UTC) in seconds
    +
    shippingAddress
    Parameters for shippingAddress
    methods are prefixed like shippingAddress<param name>(val)
    shippingAddressFirstName(val)
    First name.
    optional, string, max chars=150
    shippingAddressLastName(val)
    Last name.
    optional, string, max chars=150
    shippingAddressEmail(val)
    Email.
    optional, string, max chars=70
    shippingAddressCompany(val)
    Company name.
    optional, string, max chars=250
    shippingAddressPhone(val)
    Phone number.
    optional, string, max chars=50
    shippingAddressLine1(val)
    Address line 1.
    optional, string, max chars=180
    shippingAddressLine2(val)
    Address line 2.
    optional, string, max chars=150
    shippingAddressLine3(val)
    Address line 3.
    optional, string, max chars=150
    shippingAddressCity(val)
    City.
    optional, string, max chars=50
    shippingAddressStateCode(val)
    The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set the state_code as AZ (not US-AZ). or, for Tamil Nadu (India), set the state_code as TN (not IN-TN). or, for British Columbia (Canada), set the state_code as BC (not CA-BC).
    Note: If the 'state_code' is specified, the 'state' attribute should not be provided as Chargebee will set the value automatically (for US, Canada, India).
    optional, string, max chars=50
    shippingAddressState(val)
    The state/province name. Use this to pass the state/province information for cases where 'state_code' is not supported or cannot be passed.
    optional, string, max chars=50
    shippingAddressZip(val)
    Zip or Postal code.
    optional, string, max chars=20
    shippingAddressCountry(val)
    2-letter ISO 3166 alpha-2 country code.
    optional, string, max chars=50
    shippingAddressValidationStatus(val)
    The address verification status.
    optional, enumerated string, default=not_validated
    Possible values are
    NOT_VALIDATEDAddress is not yet validated.VALIDAddress was validated successfully.PARTIALLY_VALIDAddress is verified but only partially.INVALIDAddress is invalid.
    +
    addons
    Parameters for addons. Multiple addons can be passed by specifying unique indices.
    methods are prefixed like addons<param name>(idx,val)
    addonId(idx,val)
    Identifier of the addon. Multiple addons can be passed.
    optional, string, max chars=100
    addonQuantity(idx,val)
    Addon quantity. Applicable only for the quantity based addons. Should be passed with the same index as that of associated addon id.
    optional, integer, default=1, min=1
    addonUnitPrice(idx,val)
    Amount that will override the Addon's default price. The Plan's billing frequency will not be considered for overriding. E.g. If the Plan's billing frequency is every 3 months, and if the price override amount is $10, $10 will be used, and not $30 (i.e $10*3).
    optional, in cents, min=0
    addonBillingCycles(idx,val)
    Number of billing cycles the addon will be charged for. When not set, the addon is attached to the subscription for an indefinite number of billing cycles. While updating a subscription to a plan with a different billing period, set this parameter again or its value will be lost. And so, the addon will be attached indefinitely.
    optional, integer, min=1
    +
    eventBasedAddons
    Parameters for eventBasedAddons. Multiple eventBasedAddons can be passed by specifying unique indices.
    methods are prefixed like eventBasedAddons<param name>(idx,val)
    eventBasedAddonId(idx,val)
    A unique 'id' used to identify the addon.
    optional, string, max chars=100
    eventBasedAddonQuantity(idx,val)
    Addon quantity. Applicable only for the quantity based addons. Should be passed with the same index as that of associated addon id.
    optional, integer, min=1
    eventBasedAddonUnitPrice(idx,val)
    Amount that will override the Addon's default price.
    optional, in cents, min=0
    eventBasedAddonServicePeriodInDays(idx,val)
    Defines service period of the addon in days from the day of charge.
    optional, integer, min=1, max=730
    eventBasedAddonOnEvent(idx,val)
    Event on which this addon will be charged.
    optional, enumerated string
    Possible values are
    SUBSCRIPTION_CREATIONAddon will be charged on subscription creation.SUBSCRIPTION_TRIAL_STARTAddon will be charged when the trial period starts.PLAN_ACTIVATIONAddon will be charged on plan activation.SUBSCRIPTION_ACTIVATIONAddon will be charged on subscription activation.CONTRACT_TERMINATIONAddon will be charged on contract termination.
    eventBasedAddonChargeOnce(idx,val)
    If enabled, the addon will be charged only at the first occurrence of the event. Applicable only for non-recurring add-ons.
    optional, boolean, default=true
    +
    chargedEventBasedAddons
    Parameters for chargedEventBasedAddons. Multiple chargedEventBasedAddons can be passed by specifying unique indices.
    methods are prefixed like chargedEventBasedAddons<param name>(idx,val)
    chargedEventBasedAddonId(idx,val)
    Addon id.
    optional, string, max chars=100
    chargedEventBasedAddonLastChargedAt(idx,val)
    Timestamp indicating when this add-on was last charged for this subscription.
    optional, timestamp(UTC) in seconds
    Resource object representing subscription.
    always returned
    Resource object representing customer.
    always returned
    Resource object representing card.
    optional
    Resource object representing invoice.
    optional

    Assigns the payment source and sets auto collection state for the subscription.

    Notes

    When you don't pass any input param for this API, payment source and auto collection for the subscription will be the same as the customer's default settings.

    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.overrideBillingProfile("__test__KyVnJjRnFYgwY5u3")
    	.paymentSourceId("pm___test__KyVnJjRnFYgz15uA")
    	.autoCollection(AutoCollection.ON)
    	.request();
    Subscription subscription = result.subscription();
    PaymentSource paymentSource = result.paymentSource();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.overrideBillingProfile("__test__KyVnJjRnFYgwY5u3")
    	.paymentSourceId("pm___test__KyVnJjRnFYgz15uA")
    	.autoCollection(AutoCollection.ON)
    	.request();
    Subscription subscription = result.subscription();
    PaymentSource paymentSource = result.paymentSource();

    Sample Result [ JSON ]

    Show more...
    { "payment_source": { "card": { "brand": "american_express", "expiry_month": 12, "expiry_year": 2022, "funding_type": "not_known", "iin": "378282", "last4": "0005", "masked_number": "***********0005", "object": "card" }, "created_at": 1517469182, "customer_id": "__test__KyVnJjRnFYgvq5u1", "deleted": false, "gateway": "chargebee", "gateway_account_id": "gw___test__KyVnLVRnFYfVN5i", "id": "pm___test__KyVnJjRnFYgz15uA", "object": "payment_source", "reference_id": "tok___test__KyVnJjRnFYgyy5u9", "resource_version": 1517469182000, "status": "valid", "type": "card", "updated_at": 1517469182 }, "subscription": { "activated_at": 1517469182, "auto_collection": "on", "billing_period": 1, "billing_period_unit": "month", "created_at": 1517469182, "currency_code": "USD", "current_term_end": 1519888382, "current_term_start": 1517469182, "customer_id": "__test__KyVnJjRnFYgvq5u1", "deleted": false, "due_invoices_count": 0, "has_scheduled_changes": false, "id": "__test__KyVnJjRnFYgwY5u3", "mrr": 0, "next_billing_at": 1519888382, "object": "subscription", "payment_source_id": "pm___test__KyVnJjRnFYgz15uA", "plan_amount": 895, "plan_free_quantity": 0, "plan_id": "no_trial", "plan_quantity": 1, "plan_unit_price": 895, "resource_version": 1517469183000, "started_at": 1517469182, "status": "active", "updated_at": 1517469183 } }

    Method

    Subscription.overrideBillingProfile(<subscription_id>)
    
    paymentSourceId(val)
    Unique identifier of the payment source to be attached to this subscription.
    optional, string, max chars=40
    autoCollection(val)
    Defines whether payments need to be collected automatically for this subscription. Overrides customer's auto-collection property.
    optional, enumerated string
    Possible values are
    ONWhenever an invoice is created for this subscription, an automatic charge will be attempted on the payment method available.OFFAutomatic collection of charges will not be made for this subscription. All payments must be recorded offline.
    Resource object representing subscription.
    always returned
    Resource object representing payment_source.
    optional

    Deletes the subscription resource.

    Notes

    This operation is irreversible - all data related to the subscription, such as invoices, transactions, and reports, will be deleted.

    Note: This operation schedules the subscription resource for deletion. It will be deleted in a few minutes.

    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.delete("__test__KyVnJjRnFd3Ar8pu").request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.delete("__test__KyVnJjRnFd3Ar8pu").request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();

    Sample Result [ JSON ]

    Show more...
    { "card": { "card_type": "american_express", "created_at": 1517470221, "customer_id": "__test__KyVnJjRnFd3Ar8pu", "expiry_month": 12, "expiry_year": 2022, "funding_type": "not_known", "gateway": "chargebee", "gateway_account_id": "gw___test__KyVnHuRnFcucX27", "iin": "378282", "last4": "0005", "masked_number": "***********0005", "object": "card", "payment_source_id": "pm___test__KyVnJjRnFd3BV8pw", "resource_version": 1517470221000, "status": "valid", "updated_at": 1517470221 }, "customer": { "allow_direct_debit": false, "auto_collection": "on", "card_status": "valid", "created_at": 1517470221, "deleted": false, "excess_payments": 0, "id": "__test__KyVnJjRnFd3Ar8pu", "net_term_days": 0, "object": "customer", "payment_method": { "gateway": "chargebee", "gateway_account_id": "gw___test__KyVnHuRnFcucX27", "object": "payment_method", "reference_id": "tok___test__KyVnJjRnFd3BR8pv", "status": "valid", "type": "card" }, "pii_cleared": "active", "preferred_currency_code": "USD", "primary_payment_source_id": "pm___test__KyVnJjRnFd3BV8pw", "promotional_credits": 0, "refundable_credits": 0, "resource_version": 1517470221000, "taxability": "taxable", "unbilled_charges": 0, "updated_at": 1517470221 }, "subscription": { "activated_at": 1517470221, "billing_period": 1, "billing_period_unit": "month", "created_at": 1517470221, "currency_code": "USD", "current_term_end": 1519889421, "current_term_start": 1517470221, "customer_id": "__test__KyVnJjRnFd3Ar8pu", "deleted": false, "due_invoices_count": 0, "has_scheduled_changes": false, "id": "__test__KyVnJjRnFd3Ar8pu", "mrr": 0, "next_billing_at": 1519889421, "object": "subscription", "plan_amount": 895, "plan_free_quantity": 0, "plan_id": "no_trial", "plan_quantity": 1, "plan_unit_price": 895, "resource_version": 1517470221000, "started_at": 1517470221, "status": "active", "updated_at": 1517470221 } }

    Method

    Subscription.delete(<subscription_id>)
    
    Resource object representing subscription.
    always returned
    Resource object representing customer.
    always returned
    Resource object representing card.
    optional

    Pausing a subscription will move the subscription from its current state to Paused state, and will stop all recurring actions.

    You could schedule the pause by passing specific_date/end_of_term parameter in pause_option. If scheduled, the subscription will not be paused until the specific_date/end_of_term is reached.

    UNBILLED CHARGES

    Any unbilled charges present in the subscription can be invoiced by specifying invoice or no_action. If invoice is chosen, automatic charge will be attempted on the payment method available if the customer has enabled auto-collection. If payment collection fails or when auto-collection is not enabled, the invoice will be closed as unpaid.
    If no_action is chosen, charges will be added to the resumption invoice.

    INVOICE DUNNING HANDLING

    If invoice is in the dunning cycle, invoice_dunning_handing allows you to stop or continue dunning.

    Note:

    • Applicable only for active/non-renewing subscriptions.
    • For non-renewing subscriptions, pause_date and resume_date should be before the cancellation date. If paused indefinitely, the subscription will be cancelled on the cancelled_at date.
    • Advance charges, if any, will be refunded as credits.
    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    /* 
        pauses the subscription on end of term.
    */
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.pause("__test__KyVnJjRnFYh2x5uJ")
    	.pauseOption(PauseOption.END_OF_TERM)
    	.request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
    Invoice invoice = result.invoice();
    List<UnbilledCharge> unbilledCharges = result.unbilledCharges();
    List<CreditNote> creditNotes = result.creditNotes();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet

    Sample Result [ JSON ]

    Method

    Subscription.pause(<subscription_id>)
    
    pauseOption(val)
    List of options to pause the subscription.
    optional, enumerated string
    Possible values are
    IMMEDIATELYPause immediately.END_OF_TERMPause at the end of current term.SPECIFIC_DATEPause on a specific date.
    pauseDate(val)
    Date on which the subscription will be paused. Applicable when 'specific_date' option is chosen in the pause_option field.
    optional, timestamp(UTC) in seconds
    unbilledChargesHandling(val)
    Applicable when unbilled charges are present for the subscription and pause_option is set as 'immediately'. Note: On the invoice raised, an automatic charge will be attempted on the payment method available, if customer's auto-collection property is ‘ON’.
    optional, enumerated string
    Possible values are
    NO_ACTIONRetain as unbilled.INVOICEInvoice charges.
    invoiceDunningHandling(val)
    Handles dunning for invoices already in the dunning cycle, when subscription is paused. Applicable when pause_option is set as 'immediately'.
    optional, enumerated string
    Possible values are
    CONTINUEContinue dunning.STOPStop dunning.
    resumeDate(val)
    Date on which the subscription will be resumed.
    optional, timestamp(UTC) in seconds
    Resource object representing subscription.
    always returned
    Resource object representing customer.
    always returned
    Resource object representing card.
    optional
    Resource object representing invoice.
    optional
    Resource object representing unbilled_charge.
    optional
    Resource object representing credit_note.
    optional

    Cancelling a subscription will move the subscription from its current state to Cancelled, and will stop all recurring actions.

    You could schedule the cancellation by passing end_of_term parameter as true. If scheduled, the subscription status will be set to non_renewing if it is in active state, until the end of term, and then cancelled. A subscription's state will not change if it is in in_trial state. However, cancellation will be scheduled at the end of the trial.

    CREDIT OPTION

    On subscription cancellation, credits can be issued against current term charges of the subscription by using credit_option_for_current_term_charges. You can choose to either provide no credits, prorate credits for the unused period or issue full credits for the current term charges.

    UNBILLED CHARGES

    Any unbilled charges present in the subscription can either be invoiced or deleted by specifying unbilled_charges_option. Note that automatic charge will be attempted on the payment method available if the customer has enabled auto-collection. If not, the invoice will be closed as unpaid.

    ACCOUNT RECEIVABLES

    Specifying account_receivables_handling allows you to close invoices of the subscription which have amounts due. The invoices are chosen for payment collection or for writing off the due amount after applying the available credits and excess payments.

    If specified as schedule_payment_collection, payment collection for the amount due of past invoices will be attempted. The payment method available will be charged if auto-collection is enabled for the customer, and appropriate payment collection(payment succeeded or payment failed) events will be triggered. If the payment collection fails, no further retries will be made on the invoices. Note: If the invoices of the subscription are consolidated, and any of the subscriptions in the consolidated invoice are cancelled, these invoices will not be selected for collection.

    If specified as write_off, the amount due of past invoices will be written-off. Note: If the invoices of the subscription are consolidated, and any of the subscriptions in the consolidated invoice are still active(future, in-trial, active, and non-renewing), these invoices will not be selected for the write-off operation.

    ACCOUNT PAYABLES

    Specifying refundable_credits_handling allows you to provide refunds for refundable credits remaining, after they are applied to a subscription’s due invoices. The refund initiated will be asynchronous and the payment refunded event will be triggered on refund success. Note: Consolidated credit notes of the subscription will not be selected for refund.

    Canceling Contract Terms

    • Subscriptions with contract terms can only be cancelled by terminating the contract term.
    • When canceling a contract term, the default value for the following parameters is taken from the site settings for contract terms instead of the site settings for subscription cancellation.
      • credit_option_for_current_term_charges
      • unbilled_charges_option
      • account_receivables_handling
      • refundable_credits_handling
    • end_of_term or cancel_at should not be passed when using contract terms; use contract_term_cancel_option instead.
    • The event_based_addons parameter is used when canceling contract terms to override price or quantity for the termination fee. To use this parameter, the following two conditions must be met:
      • contract_term_cancel_option must be set to terminate_now.
      • the subscription must have an event-based addon with the on_event parameter set to contract_term_termination

    Notes

    Advance charges, if any, will be refunded as credits.

    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    /* 
        cancels the subscription after the term ends.
    */
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.cancel("__test__KyVnJjRnFcvOB8ny")
    	.endOfTerm(true)
    	.request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
    Invoice invoice = result.invoice();
    List<UnbilledCharge> unbilledCharges = result.unbilledCharges();
    List<CreditNote> creditNotes = result.creditNotes();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet

    Sample Result [ JSON ]

    Method

    Subscription.cancel(<subscription_id>)
    
    endOfTerm(val)
    Set this to true if you want to cancel the subscription at the end of the current subscription billing cycle.
    optional, boolean, default=false
    cancelAt(val)
    Specify the date at which you want to cancel the subscription. Do not pass if end_of_term is passed as true.
    optional, timestamp(UTC) in seconds
    creditOptionForCurrentTermCharges(val)
    Specify this if you want to issue credits against the current term charges. Not applicable when 'end_of_term' is true.
    optional, enumerated string
    Possible values are
    NONENo credits will be issued against current term charges.PRORATEProrated credits for the unused period will be issued against current term charges.FULLCredits will be issued for all the current term charges.
    unbilledChargesOption(val)
    Applicable when unbilled charges are present for this subscription. If specified as delete, these charges will be deleted instead of getting invoiced immediately. Note: On the invoice raised, an automatic charge will be attempted on the payment method available if customer's auto-collection property is ‘ON’. Not applicable when 'end_of_term' is true.
    optional, enumerated string
    Possible values are
    INVOICEUnbilled charges will be raised as an invoice. An attempt to collect payment will be made.DELETEUnbilled charges will be deleted.
    accountReceivablesHandling(val)
    Applicable when the subscription has past due invoices. Specify this if you want to close the due invoices of the subscription. If specified as schedule_payment_collection/write_off, the due invoices of the subscription will be qualified for the selected operation after the remaining refundable credits and excess payments are applied. Note: The payment collection attempt will be asynchronous. Not applicable when 'end_of_term' is true.
    optional, enumerated string
    Possible values are
    NO_ACTIONNo action is taken.SCHEDULE_PAYMENT_COLLECTIONAn automatic charge for the due amount of the past invoices will be attempted on the payment method available, if customer's auto-collection property is ‘ON’.WRITE_OFFThe amount due in the invoices will be written-off. Credit notes created due to write-off will not be sent in the response.
    refundableCreditsHandling(val)
    Applicable when the customer has remaining refundable credits(issued against online payments). If specified as schedule_refund, the refund will be initiated for these credits after they are applied against the subscription’s past due invoices if any. Note: The refunds initiated will be asynchronous. Not applicable when 'end_of_term' is true.
    optional, enumerated string
    Possible values are
    NO_ACTIONNo action is taken. .SCHEDULE_REFUNDInitiates refund of the remaining credits.
    contractTermCancelOption(val)
    Cancels the current contract term.
    • terminate_immediately immediately does the following:
    • end_of_contract_term Sets the contract_term[action_at_term_end] to cancel. In other words, the contract term is not renewed and the subscription is canceled at the end of the contract term.
    .
    optional, enumerated string
    Possible values are
    TERMINATE_IMMEDIATELYTerminate immediately.END_OF_CONTRACT_TERMEnd of contract term.
    cancelReasonCode(val)
    Reason code for canceling the subscription. Must be one from a list of reason codes set in the Chargebee app in Settings > Configure Chargebee > Reason Codes > Subscriptions > Subscription Cancellation. Must be passed if set as mandatory in the app. The codes are case-sensitive.
    optional, string, max chars=100
    +
    eventBasedAddons
    Parameters for eventBasedAddons. Multiple eventBasedAddons can be passed by specifying unique indices.
    methods are prefixed like eventBasedAddons<param name>(idx,val)
    eventBasedAddonId(idx,val)
    The unique id of the event-based addon that represents the termination fee.
    optional, string, max chars=100
    eventBasedAddonQuantity(idx,val)
    The quantity associated with the termination fee. Applicable only when the addon for the termination charge is quantity-based.
    optional, integer, min=1
    eventBasedAddonUnitPrice(idx,val)
    The termination fee. In case it is quantity-based, this is the fee per unit.
    optional, in cents, min=0
    eventBasedAddonServicePeriodInDays(idx,val)
    The service period of the termination fee—expressed in days—starting from the current date.
    optional, integer, min=1, max=730
    Resource object representing subscription.
    always returned
    Resource object representing customer.
    always returned
    Resource object representing card.
    optional
    Resource object representing invoice.
    optional
    Resource object representing unbilled_charge.
    optional
    Resource object representing credit_note.
    optional
    This operation supports 3DS verification flow. To acheive the same, create the Payment Intent and pass it as input parameter to this API.

    This API is used to resume a paused subscription. On resumption the subscription will be activated and any applicable charges will be initiated.

    You could schedule the resumption by passing specific_date parameter in resume_option. If scheduled, the subscription will be resumed on the specific_date and moved to Active state.

    For in-term resumption ++, unless there are scheduled changes, unbilled charges will not be charged.

    ++What is an "in-term resumption"?
    An “in-term resumption” is when the pause and resumption happens within the billing term of the subscription.

    Example : A subscription was billed from 1st to 31st of a month. It was paused on the 20th and resumed before 31st. This is an in-term resumption.

    UNPAID INVOICES

    Specifying unpaid_invoices allows you to close invoices of the subscription which have amounts due. The invoices are chosen for payment collection after applying the available credits and excess payments.

    If specified as schedule_payment_collection, payment collection for the amount due of past invoices will be attempted. The payment method available will be charged if auto-collection is enabled for the customer, and appropriate payment collection(payment succeeded or payment failed) events will be triggered. If the payment collection fails, no further retries will be made on the invoices.

    Note: If the invoices of the subscription are consolidated, and any of the subscriptions in the consolidated invoice are cancelled, these invoices will not be selected for collection.

    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    /* 
        resumes a subscription immediately by scheduling payment collection for unpaid invoices.
    */
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.resume("__test__KyVnJjRnFYhvT5vw")
    	.resumeOption(ResumeOption.IMMEDIATELY)
    	.unpaidInvoicesHandling(UnpaidInvoicesHandling.SCHEDULE_PAYMENT_COLLECTION)
    	.request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
    Invoice invoice = result.invoice();
    List<UnbilledCharge> unbilledCharges = result.unbilledCharges();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet

    Sample Result [ JSON ]

    Method

    Subscription.resume(<subscription_id>)
    
    resumeOption(val)
    List of options to resume the subscription.
    optional, enumerated string
    Possible values are
    IMMEDIATELYResume immediately.SPECIFIC_DATEResume on a specific date.
    resumeDate(val)
    Date on which the subscription will be resumed. Applicable when resume_option is set as 'specific_date'.
    optional, timestamp(UTC) in seconds
    chargesHandling(val)
    Applicable when charges get added during this operation and resume_option is set as 'immediately'. Allows to raise invoice immediately or add them to unbilled charges.
    optional, enumerated string
    Possible values are
    INVOICE_IMMEDIATELYInvoice immediately.ADD_TO_UNBILLED_CHARGESAdd to unbilled charges.
    unpaidInvoicesHandling(val)
    Applicable when the subscription has past due invoices and resume_option is set as 'immediately'. Allows to collect past due invoices or retain them as unpaid. If 'schedule_payment_collection' option is chosen in this field, remaining refundable credits and excess payments are applied. Note: The payment collection attempt will be asynchronous.
    optional, enumerated string
    Possible values are
    NO_ACTIONRetain as unpaid.SCHEDULE_PAYMENT_COLLECTIONCollect payment.
    +
    paymentIntent
    Parameters for paymentIntent
    methods are prefixed like paymentIntent<param name>(val)
    paymentIntentId(val)
    Identifier for PaymentIntent generated by Chargebee.js. Applicable only when you are using Chargebee.js for completing the 3DS flow. The PaymentIntent should be in 'authorized' state while passing it here. You need not pass other PaymentIntent parameters if this is passed.
    optional, string, max chars=150
    paymentIntentGatewayAccountId(val)
    The gateway account used for performing the 3DS flow.
    required if payment intent token provided, string, max chars=50
    paymentIntentGwToken(val)
    Identifier for 3DS transaction/verification object at the gateway. Can be passed only after successfully completing the 3DS flow. Refer 3DS implementation in Chargebee to find out the gateway-specific gw_token format. Applicable when you are using gateway APIs directly for completing the 3DS flow.
    optional, string, max chars=65k
    paymentIntentReferenceId(val)
    Identifier for Braintree permanent token. Applicable when you are using Braintree APIs for completing the 3DS flow.
    optional, string, max chars=65k
    Resource object representing subscription.
    always returned
    Resource object representing customer.
    always returned
    Resource object representing card.
    optional
    Resource object representing invoice.
    optional
    Resource object representing unbilled_charge.
    optional

    If the subscription is in Active or Non Renewing state and is also scheduled to pause at the end_of_term/specific_date, this API can be used to remove the scheduled pause.

    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.removeScheduledPause("__test__KyVnJjRnFYhj15ve").request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.removeScheduledPause("__test__KyVnJjRnFYhj15ve").request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();

    Sample Result [ JSON ]

    Show more...
    { "customer": { "allow_direct_debit": false, "auto_collection": "off", "card_status": "no_card", "created_at": 1517469185, "deleted": false, "excess_payments": 0, "id": "__test__KyVnJjRnFYhj15ve", "net_term_days": 0, "object": "customer", "pii_cleared": "active", "preferred_currency_code": "USD", "promotional_credits": 0, "refundable_credits": 0, "resource_version": 1517469185000, "taxability": "taxable", "unbilled_charges": 0, "updated_at": 1517469185 }, "subscription": { "activated_at": 1517469185, "billing_period": 1, "billing_period_unit": "month", "created_at": 1517469185, "currency_code": "USD", "current_term_end": 1519888385, "current_term_start": 1517469185, "customer_id": "__test__KyVnJjRnFYhj15ve", "deleted": false, "due_invoices_count": 1, "due_since": 1517469185, "has_scheduled_changes": false, "id": "__test__KyVnJjRnFYhj15ve", "mrr": 0, "next_billing_at": 1519888385, "object": "subscription", "plan_amount": 895, "plan_free_quantity": 0, "plan_id": "no_trial", "plan_quantity": 1, "plan_unit_price": 895, "resource_version": 1517469186000, "started_at": 1517469185, "status": "active", "total_dues": 895, "updated_at": 1517469186 } }

    Method

    Subscription.removeScheduledPause(<subscription_id>)
    
    Resource object representing subscription.
    always returned
    Resource object representing customer.
    always returned
    Resource object representing card.
    optional

    If the subscription is in Paused state and is scheduled to resume on a specific_date, this API can be used to remove the scheduled resumption. When the scheduled resumption is removed, the subscription will remain Paused.

    Sample Codes
    import java.io.IOException;
    import com.chargebee.*;
    import com.chargebee.models.*;
    import com.chargebee.models.enums.*;
    
    public class Sample{
      
      public static void main(String args[]) throws IOException{
        
        
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.removeScheduledResumption("__test__KyVnJjRnFYhot5vn").request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();
        System.out.println(result);
      }
    }
    copy full code
    copy snippet
    
    Environment.configure("{site}","{site_api_key}");
    Result result = Subscription.removeScheduledResumption("__test__KyVnJjRnFYhot5vn").request();
    Subscription subscription = result.subscription();
    Customer customer = result.customer();
    Card card = result.card();

    Sample Result [ JSON ]

    Show more...
    { "customer": { "allow_direct_debit": false, "auto_collection": "off", "card_status": "no_card", "created_at": 1517469186, "deleted": false, "excess_payments": 0, "id": "__test__KyVnJjRnFYhot5vn", "net_term_days": 0, "object": "customer", "pii_cleared": "active", "preferred_currency_code": "USD", "promotional_credits": 0, "refundable_credits": 0, "resource_version": 1517469186000, "taxability": "taxable", "unbilled_charges": 0, "updated_at": 1517469186 }, "subscription": { "activated_at": 1517469186, "billing_period": 1, "billing_period_unit": "month", "created_at": 1517469186, "currency_code": "USD", "current_term_end": 1519888386, "current_term_start": 1517469186, "customer_id": "__test__KyVnJjRnFYhot5vn", "deleted": false, "due_invoices_count": 1, "due_since": 1517469186, "has_scheduled_changes": false, "id": "__test__KyVnJjRnFYhot5vn", "mrr": 0, "object": "subscription", "pause_date": 1517469186, "plan_amount": 895, "plan_free_quantity": 0, "plan_id": "no_trial", "plan_quantity": 1, "plan_unit_price": 895, "resource_version": 1517469186000, "started_at": 1517469186, "status": "paused", "total_dues": 895, "updated_at": 1517469186 } }

    Method

    Subscription.removeScheduledResumption(<subscription_id>)
    
    Resource object representing subscription.
    always returned
    Resource object representing customer.
    always returned
    Resource object representing card.
    optional