Skip to Content
Paycose Docs
Subscriptions

Subscriptions

The subscription object

A subscription bills a customer for recurring prices every period, in advance. Paycose either runs the billing schedule itself and creates each period's invoice, or, when the subscription is routed to a provider that bills on its own side (such as Stripe), keeps this object in step with the provider's subscription and invoices.

Attributes

  • idstringRequired

    Unique identifier for the object.

  • objectstringRequired

    String naming the object's type.

  • livemodebooleanRequired

    true when the object exists in live mode, false in test mode.

  • createdtimestampRequired

    Time the object was created, in Unix seconds.

  • updatedtimestampRequired

    Time the object last changed, in Unix seconds.

  • numberstringRequired

    Sequential subscription number assigned when the subscription is created, for display on documents.

  • customer_idstringRequired

    ID of the customer being billed. Empty for a guest subscription created without a customer.

  • default_payment_method_idstringRequired

    ID of the saved payment method charged for each period. Empty when none is set, for example on a send_invoice subscription or one created with payment_behavior=default_incomplete before its first payment.

  • customer_namestringRequired

    Customer name copied onto the subscription when it was created, falling back to the billing details collected at checkout.

  • customer_emailstringRequired

    Customer email copied onto the subscription when it was created, falling back to the billing details collected at checkout.

  • customer_phonestringRequired

    Customer phone number copied onto the subscription when it was created, falling back to the billing details collected at checkout.

  • billing_detailsobjectNullable

    Billing details the payer entered when the subscription was started from a checkout session. Absent for subscriptions created through the API.

    Show child attributes
    • billing_details.namestring

      Payer's name, up to 255 characters. Omitted when not given.

      Max length 255

    • billing_details.emailstring

      Payer's email address. Omitted when not given.

      Max length 254 · Format email

    • billing_details.phonestring

      Payer's phone number, up to 64 characters. Omitted when not given.

      Max length 64

    • billing_details.addressobjectNullable

      Payer's billing address. Omitted when not given.

      Show child attributes
      • billing_details.address.line1string

        First line of the address, such as street and house number. Up to 255 characters.

        Max length 255

      • billing_details.address.line2string

        Second line of the address, such as building or unit. Up to 255 characters.

        Max length 255

      • billing_details.address.citystring

        City or district. Up to 255 characters.

        Max length 255

      • billing_details.address.statestring

        State, province or region. Up to 255 characters.

        Max length 255

      • billing_details.address.postal_codestring

        Postal code. Up to 32 characters.

        Max length 32

      • billing_details.address.countrystring

        Two-letter ISO 3166-1 country code, in uppercase.

        Pattern ^[A-Z]{2}$

    • billing_details.business_namestring

      Name of the payer's business, up to 255 characters. Omitted when not given.

      Max length 255

    • billing_details.tax_idobjectNullable

      Payer's tax ID. Omitted when not given.

      Show child attributes
      • billing_details.tax_id.typestringRequired

        Type of the tax ID, as a tax ID type code from GET /tax_id_types. Up to 64 characters.

        Max length 64

      • billing_details.tax_id.valuestringRequired

        The tax ID number. Up to 255 characters; checked against the type's format.

        Max length 255

  • line_itemsarray of objectsRequired

    The recurring items billed every period, followed by any fee lines added through default_fees.

    Show child attributes
    • line_items.idstringRequired

      Unique identifier for the object.

    • line_items.objectstringRequired

      String naming the object's type, line_item.

    • line_items.product_idstringRequired

      ID of the product billed on this line. Empty on fee lines.

    • line_items.product_price_idstringRequired

      ID of the price billed on this line. Empty on fee lines.

    • line_items.sort_orderintegerRequired

      Position of the line on the subscription, starting at 0.

    • line_items.typestringRequired

      Kind of line: product for a price you subscribed the customer to, fee for a fee line.

      • product

        A price you subscribed the customer to.

      • fee

        A fee line added through default_fees. Its metadata carries the fee's fee_id and fee_name.

    • line_items.descriptionstringRequired

      Text shown for the line, normally the product name.

    • line_items.product_namestringRequired

      Name of the product when the line was added, or the fee's name on a fee line.

    • line_items.product_descriptionstringRequired

      Description of the product when the line was added.

    • line_items.product_imagestringRequired

      URL of the product's image when the line was added. Empty when the product has none.

    • line_items.product_typestringRequired

      product on product lines and fee on fee lines.

      • product

        A product line.

      • fee

        A fee line.

    • line_items.unit_amountintegerRequired

      Price of one unit for one period, in the smallest currency unit.

    • line_items.quantityinteger

      Number of units billed each period. Absent on a metered line, which bills the usage reported during the period, as on a Stripe subscription item for a metered price; the upcoming invoice shows that usage.

    • line_items.amount_discountintegerRequired

      Discount applied to this line, in the smallest currency unit.

    • line_items.amount_subtotalintegerRequired

      unit_amount multiplied by quantity, before discount and tax, in the smallest currency unit.

    • line_items.amount_taxintegerRequired

      Tax on this line, in the smallest currency unit. Inclusive tax is counted here but is already part of amount_subtotal.

    • line_items.amount_totalintegerRequired

      Amount of the line after discount, with exclusive tax added, in the smallest currency unit (for example, 49900 is 499.00 THB).

    • line_items.currencystringRequired

      Three-letter ISO 4217 currency code, in lowercase.

    • line_items.discountablebooleanRequired

      true when a coupon may discount this line.

    • line_items.prorationbooleanRequired

      true when the line is a proration. Lines stored on a subscription are not prorations.

    • line_items.period_starttimestampRequiredNullable

      Start of the period this line currently covers, in Unix seconds. Set from the provider for a provider-billed subscription and on usage-based lines when retrieved; otherwise null.

    • line_items.period_endtimestampRequiredNullable

      End of the period this line currently covers, in Unix seconds. Set from the provider for a provider-billed subscription and on usage-based lines when retrieved; otherwise null.

    • line_items.reference_idstringRequired

      The provider's ID for this line (for example a Stripe subscription item ID) when the provider bills the subscription. Empty when Paycose bills it.

    • line_items.metadataobjectRequired

      Key-value pairs you attach to the object for your own use. Paycose never reads or changes them.

    • line_items.taxesarray of objectsRequired

      The tax rates applied to this line and the tax each one adds.

      Show child attributes
      • line_items.taxes.idstringRequired

        Unique identifier for the object.

      • line_items.taxes.tax_rate_idstringRequired

        ID of the tax rate applied.

      • line_items.taxes.taxable_amountintegerRequired

        Amount the rate was applied to, in the smallest currency unit. For an inclusive rate this is the line amount with the tax taken out.

      • line_items.taxes.tax_amountintegerRequired

        Tax this rate adds to the line, in the smallest currency unit.

      • line_items.taxes.inclusivebooleanRequired

        true when the tax is already included in the line amount, false when it is added on top.

  • discountsarray of objectsRequired

    The coupon applied to the subscription, as a list of at most one discount. Empty when no coupon is applied or the coupon's duration has run out.

    Show child attributes
    • discounts.reference_idstring

      The provider's ID for this discount when the provider bills the subscription. Absent when Paycose bills it.

    • discounts.coupon_idstringRequired

      ID of the coupon applied.

    • discounts.promotion_code_idstringRequired

      ID of the promotion code the coupon was applied through. Empty when the coupon was applied directly.

    • discounts.namestringRequired

      Name of the coupon.

    • discounts.amountintegerRequired

      Discount the coupon takes off one period, in the smallest currency unit.

    • discounts.durationstring

      How long the coupon applies. Absent only on discounts recorded before durations were stored.

      • forever

        The coupon applies to every invoice.

      • once

        The coupon applies to the first invoice only, then is removed.

      • repeating

        The coupon applies for duration_in_months months from started_at, then is removed.

    • discounts.duration_in_monthsinteger

      Number of months a repeating coupon applies. Absent for other durations.

    • discounts.percentagenumber

      Percentage the coupon takes off the discountable lines, e.g. 10 for 10%. Absent for a fixed-amount coupon.

    • discounts.fixed_amountinteger

      Amount the coupon takes off, in the smallest currency unit. Absent for a percentage coupon.

    • discounts.currencystring

      Currency of fixed_amount, in lowercase. Absent for a percentage coupon.

    • discounts.started_attimestampNullable

      Time the discount started, in Unix seconds.

    • discounts.ends_attimestampNullable

      Time a repeating discount stops applying, in Unix seconds. Absent for other durations.

    • discounts.applied_countinteger

      Number of invoices the discount has been applied to so far. Absent until it has been applied once.

    • discounts.applies_to_productsarray of strings
  • subtotalintegerRequired

    Sum of the line items' amounts before discount and tax for one period, in the smallest currency unit.

  • taxintegerRequired

    Total tax on the line items for one period, in the smallest currency unit. Inclusive tax is counted here but is already part of the line amounts.

  • totalintegerRequired

    Amount one period costs after discount, with exclusive tax added, in the smallest currency unit (for example, 49900 is 499.00 THB).

  • amount_discountintegerRequired

    Discount the current coupon takes off one period, in the smallest currency unit.

  • amount_dueintegerRequired

    Amount the latest invoice asks for, in the smallest currency unit; also updated when the line items change. 0 until the subscription's first invoice exists.

  • amount_paidintegerRequired

    Amount paid on the latest invoice, in the smallest currency unit, whichever provider bills the subscription.

  • currencystringRequired

    Three-letter ISO 4217 currency code, in lowercase.

  • scaling_factorintegerRequired

    Number of smallest currency units in one unit of currency (10 to the power of the currency's decimal places), e.g. 100 for THB. Divide an amount by it to get the value in major units.

  • transfer_dataobjectRequiredNullable

    Where the money collected by each period invoice settles: a destination and, optionally, a balance_id. Null when the subscription settles to your own balance.

    Show child attributes
    • transfer_data.destinationstringRequired

      ID of the connected account (acct_…) the document is for.

    • transfer_data.balance_idstringRequired

      ID of the balance the document's payments are booked to.

    • transfer_data.connectedbooleanRequired

      True when the destination is a connected account paid under Connect: what you owe it and your application fee are recorded on your ledger. False for a legacy destination.

  • statusenumRequired

    Where the subscription is in its lifecycle. For a provider-billed subscription the status follows the provider's. A subscription whose collection is paused stays active and carries pause_collection.

    • incomplete

      The first payment has not succeeded yet. A new subscription Paycose bills with charge_automatically starts here, as does one created with payment_behavior=default_incomplete. It becomes active when the first invoice is paid, or at once when that invoice has nothing to collect.

    • incomplete_expired

      The first invoice was not paid within 23 hours, or the checkout session that created the subscription expired first, so the subscription expired and its open first invoice was voided. Final.

    • trialing

      In a trial period. The first invoice is billed when the trial ends.

    • active

      Running and in good standing.

    • past_due

      The latest renewal payment failed or needs the customer to authenticate, or a send_invoice invoice passed its due date unpaid. An active or trialing subscription can move here. It returns to active when its latest invoice is paid.

    • unpaid

      Every payment retry for an invoice failed; only a past_due subscription moves here. The invoice stays open and can still be paid; renewal invoices are created but not collected automatically.

    • paused

      The provider paused the subscription itself, for example when a trial ended without a payment method. No invoices are created until it is resumed. A subscription whose collection you paused reads active with pause_collection.

    • canceled

      The subscription has ended. Final; create a new subscription to bill the customer again.

  • providerstringRequired

    Name of the payment provider the subscription is routed to, e.g. stripe. When that provider bills on its own side, it creates the invoices; otherwise Paycose runs the billing schedule and charges through it.

  • reference_idstringRequired

    The provider's ID for this subscription (for example a Stripe sub_ ID) when the provider bills it. Empty when Paycose bills it.

  • provider_connection_idstring

    ID of the provider account the subscription lives on, for a provider-billed subscription. Returned by retrieve and list only; absent when Paycose bills the subscription.

  • provider_connection_statusstring

    State of the provider account in provider_connection_id, so you can spot a subscription left on an account that was replaced. Returned with provider_connection_id; absent when that account's state could not be read.

    • staged

      The provider account is set up but not in use yet.

    • active

      The provider account is in use.

    • retired

      The provider account was replaced and no longer takes new payments.

    • purged

      The provider account's credentials were removed.

    • missing

      The provider account no longer exists.

  • collection_methodenumRequired

    How each period invoice is paid: charge_automatically charges the default payment method, send_invoice sends the invoice for the customer to pay.

    • charge_automatically

      Each invoice is charged to the default payment method.

    • send_invoice

      Each invoice is sent to the customer, who pays it by its due date.

  • payment_method_typesarray of strings

    Payment method types the payer may use to pay this subscription's invoices. Absent when there is no restriction.

  • payment_method_providersarray of strings

    Payment providers that may process payments for this subscription's invoices. Absent when there is no restriction.

  • auto_advancebooleanRequired

    The auto_advance value sent when the subscription was created or last updated. Renewal invoices that Paycose bills are finalized and collected automatically regardless, except while the subscription is unpaid.

  • due_datetimestampRequiredNullable

    Fixed due date sent with a send_invoice subscription, in Unix seconds. It applies to the first invoice only; later invoices fall due days_until_due days after they are finalized. Null when not set.

  • days_until_dueintegerRequiredNullable

    Number of days a send_invoice subscription gives the customer to pay each invoice. 30 unless you set it or a due_date; null for charge_automatically subscriptions.

  • descriptionstringRequired

    Your description of the subscription, up to 500 characters.

  • billing_thresholdsobjectRequiredNullable

    Invoices the subscription early once the period's amount due reaches amount_gte. Null when no threshold is set.

    Show child attributes
    • billing_thresholds.amount_gteintegerRequiredNullable

      Amount due, in the smallest currency unit, at which the subscription is invoiced early.

    • billing_thresholds.reset_billing_cycle_anchorbooleanRequired

      Whether a threshold invoice starts a new billing period. When false, the period's dates stay as they were.

  • failure_countintegerRequired

    Number of consecutive failed payments on the subscription's invoices. Reset to 0 when a payment succeeds.

  • billing_cycle_anchortimestampRequiredNullable

    Time the billing cycle is anchored to, in Unix seconds: periods start on this date and repeat at the price's interval.

  • current_period_starttimestampRequiredNullable

    Start of the current billing period, in Unix seconds.

  • current_period_endtimestampRequiredNullable

    End of the current billing period, in Unix seconds. The next renewal invoice is created at this time.

  • trial_starttimestampRequiredNullable

    Start of the trial, in Unix seconds. Null when the subscription had no trial.

  • trial_endtimestampRequiredNullable

    End of the trial, in Unix seconds; billing starts then. Null when the subscription had no trial.

  • cancel_at_period_endbooleanRequired

    true when the subscription is set to cancel at the end of the current period. Reactivating it, or canceling it at once, sets this back to false.

  • cancel_attimestampRequiredNullable

    Time a scheduled cancellation takes effect, in Unix seconds. Null when no cancellation is scheduled, and after a cancellation that took effect at once.

  • canceled_attimestampRequiredNullable

    Time the cancellation was requested, in Unix seconds. For a cancellation at period end, this is earlier than cancel_at; canceling at once after scheduling one keeps the time the scheduled one was requested. Null when the subscription has not been canceled.

  • ended_attimestampRequiredNullable

    Time the subscription ended, in Unix seconds. Null while it is still running.

  • pause_collectionobjectRequiredNullable

    Set while collection is paused through the pause endpoint: no invoice is collected until the subscription is resumed, and status stays active. Null when collection is not paused.

    Show child attributes
    • pause_collection.behaviorstringRequired

      How invoices are treated while collection is paused, as sent to the pause endpoint (void by default).

      • keep_as_draft

        Invoices created while paused stay as drafts.

      • mark_uncollectible

        Invoices created while paused are marked uncollectible.

      • void

        Invoices created while paused are voided.

    • pause_collection.resumes_attimestampRequiredNullable

      Time collection resumes, in Unix seconds, as sent to the pause endpoint. Null when no time was set; collection then resumes when you resume the subscription.

  • test_clock_idstring

    ID of the test clock the subscription runs on. Absent for subscriptions not attached to a test clock.

  • latest_invoicestring | objectExpandable

    ID of the most recent invoice billed for the subscription, or the invoice itself with expand[]=latest_invoice. Absent until the first invoice exists.

  • pending_setup_intentstring

    Reserved for the ID of a setup intent collecting a payment method for the subscription. Paycose does not set it today, so it is always absent.

  • cancellation_detailsobjectRequiredNullable

    Why the subscription was canceled, recorded when a cancellation is requested. Always returned; each member is null until recorded, and they are cleared when the subscription is reactivated.

    Show child attributes
    • cancellation_details.commentstringRequiredNullable

      The customer's free-text comment, as sent in cancellation_details.comment. Null when none was given.

    • cancellation_details.feedbackstringRequiredNullable

      The customer's feedback category, as sent in cancellation_details.feedback. Null when none was given.

      • customer_service

        The customer was unhappy with customer service.

      • low_quality

        The customer was unhappy with quality.

      • missing_features

        Features the customer needs are missing.

      • other

        Another reason.

      • switched_service

        The customer switched to another service.

      • too_complex

        The service was too complex to use.

      • too_expensive

        The service was too expensive.

      • unused

        The customer did not use the service enough.

    • cancellation_details.reasonstringRequiredNullable

      Why the subscription was canceled. Null until a cancellation is requested or the subscription ends.

      • cancellation_requested

        The cancellation was requested through the cancel endpoint.

      • payment_failed

        The last payment retry failed and the dunning setting canceled the subscription.

  • on_behalf_ofstring

    ID of the connected account each period invoice's payment is made on behalf of. The invoices' fee lines and tax are then the application fee. Absent when not set.

  • metadataobjectRequired

    Key-value pairs you attach to the object for your own use. Paycose never reads or changes them.

  • latest_next_actionarray of objects

    Actions the payer still has to take to pay the subscription's open invoice, such as authenticating a card payment or scanning a QR code. Returned by retrieve only, and only while that invoice has an unpaid charge that needs action.

    Show child attributes
    • latest_next_action.typestringRequired

      The kind of step. It decides which of url, client_secret, payment_method, qr_data and qr_image_url are set.

      • redirect

        Send the payer to url to finish the payment.

      • share_link

        Send the hosted payment link in url to the customer so they can complete authentication themselves.

      • confirm_inline

        Show the card form in your page and confirm the payment with client_secret.

      • show_qr

        Show qr_data as a QR code, or the image at qr_image_url, for the payer to scan.

      • qr

        Show qr_data as a QR code for the payer to scan.

      • otp

        Ask the payer for the one-time password their bank sent and submit it to confirm the payment.

    • latest_next_action.titlestringRequired

      Short heading for the step, in English, suitable to show the payer.

    • latest_next_action.descriptionstringRequired

      One-sentence explanation of the step, in English, suitable to show the payer.

    • latest_next_action.urlstring

      For redirect, the page to send the payer to: a 3-D Secure page, a wallet's approval page or a banking app link. For share_link, a hosted payment page you can send to the customer; the link is valid for 24 hours. Omitted for other types.

    • latest_next_action.client_secretstring

      For confirm_inline, the provider's client secret the card form uses to confirm or authenticate the payment. For otp, the provider's reference of the payment that the one-time password confirms. Omitted for other types.

    • latest_next_action.payment_methodstring

      For confirm_inline after a payment was refused off-session, the provider's payment method to authenticate. For show_qr, the QR payment method the code is for, such as alipay, wechat_pay or qr_cross_border. Omitted otherwise.

    • latest_next_action.qr_datastring

      For show_qr and qr, the raw QR payload to render as a QR code for the payer to scan. Omitted for other types.

    • latest_next_action.qr_image_urlstring

      For show_qr, a link to the provider's image of the QR code, for when the provider sends no raw payload (such as an Omise PromptPay charge): show the image for the payer to scan. Omitted when the provider sends none.

    • latest_next_action.cryptoobjectNullable
      Show child attributes
      • latest_next_action.crypto.networkstringRequired
      • latest_next_action.crypto.chain_idstringRequired
      • latest_next_action.crypto.testnetbooleanRequired
      • latest_next_action.crypto.deposit_addressstringRequired
      • latest_next_action.crypto.token_currencystringRequired
      • latest_next_action.crypto.token_contract_addressstringRequired
      • latest_next_action.crypto.token_amountstringRequired
      • latest_next_action.crypto.token_unitsintegerRequired
      • latest_next_action.crypto.token_decimalsintegerRequired
      • latest_next_action.crypto.exchange_ratestring
      • latest_next_action.crypto.explorer_urlstring
      • latest_next_action.crypto.expires_attimestampRequired

        Unix timestamp in seconds.

  • customerobject (customer)NullableExpandable

    The full customer object when you pass expand[]=customer; otherwise absent — use customer_id.

  • default_payment_methodobject (payment_method)NullableExpandable

    The full payment method object when you pass expand[]=default_payment_method; otherwise absent — use default_payment_method_id.