Skip to Content
Paycose Docs
Checkouts

Checkouts

The checkout.session object

A checkout session is a Paycose-hosted payment page for one invoice, one payment intent, or a new subscription. Create one, send the payer to its url, and listen for the checkout.session.completed event. A session lasts 24 hours from creation and can no longer be retrieved after that or after it is expired.

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.

  • expires_attimestampRequired

    Time the session expires, 24 hours after it was created, in Unix seconds.

  • modestringRequired

    What the session collects.

    • payment

      Collects payment for an existing invoice or payment intent.

    • subscription

      Starts a subscription from line_items and collects its first invoice, or saves a card when the subscription starts with a trial. When a provider such as Stripe bills the subscription, the payer's card is saved first and the subscription is created with it when the session completes; without a trial its first invoice is charged to that card at once.

    • setup

      Starts a subscription and saves the payer's card without taking a payment now.

  • statusstringRequired

    Whether the session can still be paid.

    • open

      The session can be paid.

    • completed

      The payer paid, or finished setting up the subscription in a setup or trial session. For a subscription billed by a provider such as Stripe, the payer saved their card and the subscription was created with it; payment_status says whether its first invoice is paid.

    • expired

      The session was expired by you or ran out of time. Expired sessions are deleted, so this status is seen only in the expire response and the checkout.session.expired event. A subscription the session created that has not started (no trial) becomes incomplete_expired and its open first invoice is voided.

  • currencystringRequired

    Three-letter ISO 4217 currency code, in lowercase.

  • amountintegerRequired

    Amount the payer pays in this session, in the smallest currency unit (for example, 49900 is 499.00 THB): the invoice's remaining amount or the payment intent's amount, less any promotion discount; for a subscription billed by a provider such as Stripe, the first invoice it charges when the subscription is created. 0 for a setup session or a subscription that starts with a trial.

  • payment_statusstringRequired

    Whether the session's payment is done, as Stripe's payment_status: unpaid until it is paid, paid once it completed, and no_payment_required when it collects nothing now.

    • unpaid

      The session has not collected its amount yet, including a session that expired unpaid and a completed subscription session whose first invoice still needs the payer, for example to authenticate the card.

    • paid

      The session completed and collected its amount.

    • no_payment_required

      The session collects nothing now: a setup session, a subscription that starts with a trial, or an amount of 0 after discounts.

  • subtotalintegerRequired

    Total of the items before discounts and tax, in the smallest currency unit, taken from the invoice. 0 for a payment intent session until a promotion code is applied.

  • total_discountintegerRequired

    Total of all discounts, in the smallest currency unit: the invoice's own discounts plus promotion_discount.

  • allow_promotion_codesbooleanRequired

    Whether the payer can enter a promotion code on the hosted page.

  • promotion_codestring

    The promotion code on this session: the one you set when creating it, or one the payer entered on the hosted page. Omitted when there is none.

  • promotion_code_idstring

    ID of the applied promotion code. Omitted until a code has been validated and applied.

  • coupon_idstring

    ID of the coupon behind the applied promotion code. Omitted until a code has been applied.

  • coupon_namestring

    Name of the coupon behind the applied promotion code. Omitted until a code has been applied.

  • promotion_discountinteger

    Discount the applied promotion code gives, in the smallest currency unit, before tax as Stripe's discount amounts are: on an invoice that adds tax, amount also drops by the tax on it. Omitted when no code discount applies, including subscription sessions, where the code is applied to the subscription instead.

  • total_taxintegerRequired

    Total tax on the invoice, in the smallest currency unit. 0 for a payment intent session.

  • total_feeintegerRequired

    Total of the fees added to the invoice, in the smallest currency unit. 0 for a payment intent session.

  • amount_shippingintegerRequired

    Shipping amount on the invoice, in the smallest currency unit. 0 when there is none.

  • amount_withholdinginteger

    Thai withholding tax the payer deducts, in the smallest currency unit; amount is already net of it. Left out when there is none.

  • target_typestringRequired

    Kind of object the session collects. Empty on a session that expired before the subscription it created started, and on an open session for a subscription billed by a provider such as Stripe, which is created when it completes.

    • invoice

      The session collects an invoice.

    • payment_intent

      The session collects a payment intent.

    • subscription

      The session saves a payment method for a subscription without collecting an invoice now.

  • target_idstringRequired

    ID of the invoice, payment intent or subscription named by target_type. Empty when target_type is.

  • customer_idstring

    ID of the customer who pays: the invoice's, payment intent's or subscription's customer. Omitted for an guest payer.

  • line_itemsarray of objects

    The items shown to the payer. Taken from the invoice (fees excluded) or from the subscription's prices; omitted for a payment intent session.

    Show child attributes
    • line_items.namestringRequired

      Name of the product on the line, or the line's description when it has no product name.

    • line_items.amountintegerRequired

      Amount of the line before discounts and tax (unit price times quantity), in the smallest currency unit (for example, 49900 is 499.00 THB).

    • line_items.quantityintegerRequired

      Quantity of the product on the line.

    • line_items.imagestring

      URL of the product's picture. Omitted when the product has none; the hosted checkout page shows the merchant's logo in its place.

    • line_items.idstring

      Unique identifier for the object.

    • line_items.price_idstring

      ID of the price the line sells. Set on a session opened through a payment link.

    • line_items.product_idstring

      ID of the product the line sells. Set on a session opened through a payment link.

    • line_items.unit_amountinteger

      Price of one unit, in the smallest currency unit. Set on a session opened through a payment link.

    • line_items.adjustable_quantityobjectNullable

      Quantity range the payer can choose for the line, on a session opened through a payment link. Omitted when the quantity is fixed.

      Show child attributes
      • line_items.adjustable_quantity.enabledbooleanRequired

        Whether the buyer can change the quantity.

      • line_items.adjustable_quantity.minimumintegerRequired

        Lowest quantity the buyer can choose.

      • line_items.adjustable_quantity.maximumintegerRequired

        Highest quantity the buyer can choose.

    • line_items.intervalstring

      Billing interval of a subscription line. Omitted on a line that does not recur.

      • day

        Billed every day.

      • week

        Billed every week.

      • month

        Billed every month.

      • year

        Billed every year.

    • line_items.interval_countinteger

      Number of intervals between billings, for example 3 with month for every three months. Omitted on a line that does not recur.

    • line_items.period_starttimestampNullable

      Start of the service period the line covers, in Unix seconds. Omitted when the line has no period.

    • line_items.period_endtimestampNullable

      End of the service period the line covers, in Unix seconds. Omitted when the line has no period.

  • success_urlstring

    Where the hosted page sends the payer after a successful payment. Omitted when not set.

  • cancel_urlstring

    Where the hosted page sends the payer when they leave without paying. Omitted when not set.

  • subscription_idstring

    ID of the subscription a subscription or setup session created. Omitted otherwise, and once the session expired before that subscription started: it was ended with the session, as Stripe creates none until a session completes. A subscription billed by a provider such as Stripe is created only when the session completes, so it is omitted until then.

  • setup_intent_idstring

    ID of the setup intent that saves the payer's card for the subscription. Omitted when the session does not save a card, and, for a subscription billed by a provider such as Stripe, until a guest payer has entered their billing details and become a customer.

  • recurringobjectNullable

    The billing schedule of the subscription the session starts. Omitted for payment sessions.

    Show child attributes
    • recurring.intervalstringRequired

      Billing interval, taken from the session's first price.

      • day

        Billed every day.

      • week

        Billed every week.

      • month

        Billed every month.

      • year

        Billed every year.

    • recurring.interval_countintegerRequired

      Number of intervals between billings, for example 3 with month for every three months.

    • recurring.amount_per_periodintegerRequired

      Amount billed each period, before tax and discounts: the sum of each price's unit amount times its quantity, in the smallest currency unit (for example, 49900 is 499.00 THB).

    • recurring.trial_endtimestampNullable

      End of the subscription's trial, in Unix seconds. Omitted when the subscription has no trial.

    • recurring.next_billing_attimestampNullable

      Time of the subscription's next billing, in Unix seconds. Omitted when not known.

  • selected_method_typestring

    Payment method type the payer chose on their latest attempt, for example card. Omitted until they try to pay.

  • charge_idstring

    ID of the most recent charge made through this session. Set on each payment attempt, so it can belong to a charge that has not succeeded.

  • billing_detailsobjectNullable

    Billing details the payer entered on the hosted page. Omitted until they submit them.

    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

  • urlstring

    URL of the hosted payment page to send the payer to. Returned only in the response to creating the session.

  • sessionstring

    The one-time token in url that opens this session on the hosted page. Returned only in the response to creating the session.