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
idstringRequiredUnique identifier for the object.
objectstringRequiredString naming the object's type.
livemodebooleanRequiredtruewhen the object exists in live mode,falsein test mode.createdtimestampRequiredTime the object was created, in Unix seconds.
updatedtimestampRequiredTime the object last changed, in Unix seconds.
expires_attimestampRequiredTime the session expires, 24 hours after it was created, in Unix seconds.
modestringRequiredWhat the session collects.
paymentCollects payment for an existing invoice or payment intent.
subscriptionStarts a subscription from
line_itemsand 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.setupStarts a subscription and saves the payer's card without taking a payment now.
statusstringRequiredWhether the session can still be paid.
openThe session can be paid.
completedThe payer paid, or finished setting up the subscription in a
setupor 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_statussays whether its first invoice is paid.expiredThe 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.expiredevent. A subscription the session created that has not started (no trial) becomesincomplete_expiredand its open first invoice is voided.
currencystringRequiredThree-letter ISO 4217 currency code, in lowercase.
amountintegerRequiredAmount the payer pays in this session, in the smallest currency unit (for example,
49900is 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.0for asetupsession or a subscription that starts with a trial.payment_statusstringRequiredWhether the session's payment is done, as Stripe's
payment_status:unpaiduntil it is paid,paidonce it completed, andno_payment_requiredwhen it collects nothing now.unpaidThe session has not collected its
amountyet, including a session that expired unpaid and a completed subscription session whose first invoice still needs the payer, for example to authenticate the card.paidThe session completed and collected its
amount.no_payment_requiredThe session collects nothing now: a
setupsession, a subscription that starts with a trial, or anamountof0after discounts.
subtotalintegerRequiredTotal of the items before discounts and tax, in the smallest currency unit, taken from the invoice.
0for a payment intent session until a promotion code is applied.total_discountintegerRequiredTotal of all discounts, in the smallest currency unit: the invoice's own discounts plus
promotion_discount.allow_promotion_codesbooleanRequiredWhether the payer can enter a promotion code on the hosted page.
promotion_codestringThe 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_idstringID of the applied promotion code. Omitted until a code has been validated and applied.
coupon_idstringID of the coupon behind the applied promotion code. Omitted until a code has been applied.
coupon_namestringName of the coupon behind the applied promotion code. Omitted until a code has been applied.
promotion_discountintegerDiscount the applied promotion code gives, in the smallest currency unit, before tax as Stripe's discount amounts are: on an invoice that adds tax,
amountalso 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_taxintegerRequiredTotal tax on the invoice, in the smallest currency unit.
0for a payment intent session.total_feeintegerRequiredTotal of the fees added to the invoice, in the smallest currency unit.
0for a payment intent session.amount_shippingintegerRequiredShipping amount on the invoice, in the smallest currency unit.
0when there is none.amount_withholdingintegerThai withholding tax the payer deducts, in the smallest currency unit;
amountis already net of it. Left out when there is none.target_typestringRequiredKind 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.
invoiceThe session collects an invoice.
payment_intentThe session collects a payment intent.
subscriptionThe session saves a payment method for a subscription without collecting an invoice now.
target_idstringRequiredID of the invoice, payment intent or subscription named by
target_type. Empty whentarget_typeis.customer_idstringID of the customer who pays: the invoice's, payment intent's or subscription's customer. Omitted for an guest payer.
line_itemsarray of objectsThe 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.namestringRequiredName of the product on the line, or the line's description when it has no product name.
line_items.amountintegerRequiredAmount of the line before discounts and tax (unit price times quantity), in the smallest currency unit (for example,
49900is 499.00 THB).line_items.quantityintegerRequiredQuantity of the product on the line.
line_items.imagestringURL 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.idstringUnique identifier for the object.
line_items.price_idstringID of the price the line sells. Set on a session opened through a payment link.
line_items.product_idstringID of the product the line sells. Set on a session opened through a payment link.
line_items.unit_amountintegerPrice of one unit, in the smallest currency unit. Set on a session opened through a payment link.
line_items.adjustable_quantityobjectNullableQuantity 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.enabledbooleanRequiredWhether the buyer can change the quantity.
line_items.adjustable_quantity.minimumintegerRequiredLowest quantity the buyer can choose.
line_items.adjustable_quantity.maximumintegerRequiredHighest quantity the buyer can choose.
line_items.intervalstringBilling interval of a subscription line. Omitted on a line that does not recur.
dayBilled every day.
weekBilled every week.
monthBilled every month.
yearBilled every year.
line_items.interval_countintegerNumber of
intervals between billings, for example3withmonthfor every three months. Omitted on a line that does not recur.line_items.period_starttimestampNullableStart of the service period the line covers, in Unix seconds. Omitted when the line has no period.
line_items.period_endtimestampNullableEnd of the service period the line covers, in Unix seconds. Omitted when the line has no period.
success_urlstringWhere the hosted page sends the payer after a successful payment. Omitted when not set.
cancel_urlstringWhere the hosted page sends the payer when they leave without paying. Omitted when not set.
subscription_idstringID of the subscription a
subscriptionorsetupsession 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_idstringID 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.
recurringobjectNullableThe billing schedule of the subscription the session starts. Omitted for
paymentsessions.Show child attributes
recurring.intervalstringRequiredBilling interval, taken from the session's first price.
dayBilled every day.
weekBilled every week.
monthBilled every month.
yearBilled every year.
recurring.interval_countintegerRequiredNumber of
intervals between billings, for example3withmonthfor every three months.recurring.amount_per_periodintegerRequiredAmount 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,
49900is 499.00 THB).recurring.trial_endtimestampNullableEnd of the subscription's trial, in Unix seconds. Omitted when the subscription has no trial.
recurring.next_billing_attimestampNullableTime of the subscription's next billing, in Unix seconds. Omitted when not known.
selected_method_typestringPayment method type the payer chose on their latest attempt, for example
card. Omitted until they try to pay.charge_idstringID 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_detailsobjectNullableBilling details the payer entered on the hosted page. Omitted until they submit them.
Show child attributes
billing_details.namestringPayer's name, up to 255 characters. Omitted when not given.
Max length 255
billing_details.emailstringPayer's email address. Omitted when not given.
Max length 254 · Format
emailbilling_details.phonestringPayer's phone number, up to 64 characters. Omitted when not given.
Max length 64
billing_details.addressobjectNullablePayer's billing address. Omitted when not given.
Show child attributes
billing_details.address.line1stringFirst line of the address, such as street and house number. Up to 255 characters.
Max length 255
billing_details.address.line2stringSecond line of the address, such as building or unit. Up to 255 characters.
Max length 255
billing_details.address.citystringCity or district. Up to 255 characters.
Max length 255
billing_details.address.statestringState, province or region. Up to 255 characters.
Max length 255
billing_details.address.postal_codestringPostal code. Up to 32 characters.
Max length 32
billing_details.address.countrystringTwo-letter ISO 3166-1 country code, in uppercase.
Pattern
^[A-Z]{2}$
billing_details.business_namestringName of the payer's business, up to 255 characters. Omitted when not given.
Max length 255
billing_details.tax_idobjectNullablePayer's tax ID. Omitted when not given.
Show child attributes
billing_details.tax_id.typestringRequiredType 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.valuestringRequiredThe tax ID number. Up to 255 characters; checked against the type's format.
Max length 255
payment_linkstringID of the payment link the session was opened through. Omitted otherwise.
urlstringURL of the hosted payment page to send the payer to. Returned only in the response to creating the session.
sessionstringThe one-time token in
urlthat opens this session on the hosted page. Returned only in the response to creating the session.