1. Checkout
Documentation
  • Back to home
  • StripeKit
  • Installation
  • Getting Started
  • Choosing a Mode
  • Type Reference
  • Setup
    • Configuration
    • Timezones
    • Storage Adapter
    • Money and Currency
    • Error Handling
  • Stripe
    • Elements
  • Modules
    • Overview
    • Customers
      • Overview
      • List
      • Retrieve
      • Find or Create by Email
      • Create
      • Update
      • Sync
      • Delete
    • Payment Methods
      • Overview
      • Create Setup Intent
      • List
      • Attach
      • Detach
      • Set Default
      • Sync
    • Payments
      • Overview
      • Pay With Saved Method
      • Create
      • Retrieve
      • Confirm
      • Cancel
      • Sync
    • Checkout
      • Overview
      • Get
      • Create
      • Submit Fields
      • Apply Coupon
      • Mark Complete
    • Subscriptions
      • Overview
      • Create
      • Retrieve
      • Cancel
      • Resume
      • Toggle Collection Method
      • Update Fields
      • Apply Promotion Code
      • List By Customer
      • Find By Metadata
      • Sync
    • Invoices
      • Overview
      • Retrieve
      • List By Customer
      • List By Subscription
      • Pay With Saved Method
      • Void
      • Finalize
      • Sync
    • Coupons
      • Overview
      • Create
      • Validate
      • Apply To Subscription
      • List
      • Deactivate
    • Webhooks
      • Overview
      • Process
      • Events Reference
    • Sync
      • Overview
  1. Checkout

Create

$kit->checkout->create()#

Starts a new checkout session, either a one-off payment or a subscription, in whichever flow resolves from your configured mode (or flowOverride).

Signature#

Parameters#

FieldTypeRequiredDescription
mode'payment'|'subscription'YesWhat kind of checkout this is.
amountintRequired for payment mode; required for subscription mode in the elements flowMinor currency units, minimum 50.
currencystringNoDefaults to the currency configured on init.
priceIdstringRequired for subscription modeAn existing Stripe Price ID.
emailstringNoUsed to look up or create a customer if userId doesn't resolve one.
userIdstring|intNoLooked up via your storage adapter's findUserById() to resolve an existing Stripe customer.
descriptionstringNoLine item name (payment mode, api flow) or PaymentIntent description.
metadataarray<string,string>NoMerged with StripeKit's own tracking metadata, including a generated checkout_id.
customFieldslist<array>Nokey, label, required?, pattern?, patternHint? per field. See Custom fields below.
fieldValuesarray<string,string>NoPre-filled values for customFields, validated immediately if both are given together.
successUrl / cancelUrlstringNoOverride the values configured on init, for this call only.
couponCodestringNoApplied to the session if valid.
flowOverride'api'|'elements'NoOverrides the resolved flow for this call, equivalent to mode on $kit->payments->create().

Custom fields#

customFields describes a small form your frontend should render before the customer can pay, for example to collect a company name or a VAT number:
If you already know the values at creation time (for example, from a previous step in your own form), pass them as fieldValues and they are validated and stored immediately. Otherwise, leave fieldValues empty and collect them afterwards with submitFields().

Example request — subscription, api flow#

Example response#

Note amount is always 0 for a subscription checkout in the api flow, the price itself is defined by priceId on Stripe's side, and subscriptionId is only populated once the customer completes checkout (typically observed via your webhook handler).

Example request — one-off payment with custom fields, elements flow#

Example response#

requiresFields is true here because customFields were defined but no fieldValues were submitted yet. Render the form described by fieldSchema, then call submitFields().

Errors#

ExceptionWhen
ValidationErrormode is neither 'payment' nor 'subscription'; amount is missing or too low for a payment checkout; priceId is missing for a subscription checkout; the email is invalid; or submitted fieldValues fail schema validation (fieldErrors is set).
ConfigurationErrorA couponCode was passed but the coupons module isn't attached, which should never happen in normal use since StripeKit::init() wires this automatically.
StripeOperationErrorStripe rejects the underlying Checkout Session or PaymentIntent creation.

Notes#

Sessions expire after 1 day (expiresAtUtc). This is fixed and not currently configurable.
Every checkout session gets a unique checkout_id written into Stripe's metadata, so you can trace a Stripe object back to the checkout session that created it even without your own storage adapter.
Previous
Get
Next
Submit Fields
Built with