Skip to content
Proud to collaborate with Microsoft for Startups

subscription.checkout ​

End-to-end subscription checkout with Stripe — validates plan/org, creates a Stripe Checkout Session, activates on payment webhook.

End-to-end subscription checkout via Stripe.

Uses context.session (SQLAlchemy session injected by the engine) to read and write subscription-domain models from ltinteg-workflow-business-library directly. No application-layer plugin or adapter is required — any project whose DB contains the standard LTINTEG subscription tables can use this workflow as-is.

States: initiated → validating → checkout_created → payment_received → activating → completed canceled | failed (terminal)

Required env var: STRIPE_SECRET_KEY

Overview ​

PropertyValue
Workflow typeLinear
LibraryApp-subscription
Version2.0

Triggers ​

SourceEndpoint / EventDescription
APIPOST /api/subscriptions/create-checkout-sessionUser initiates checkout
WEBHOOKcheckout.session.completedStripe webhook confirms payment

Input Schema ​

FieldTypeRequiredDefaultDescription
organization_uuiduuidYes—Organization UUID to subscribe
plan_uuiduuidYes—Plan UUID to subscribe to
user_uuiduuidNo—User initiating checkout
success_urlstringYes—Redirect URL after successful payment
cancel_urlstringYes—Redirect URL if user cancels
selected_price_refstringNo—Stripe price reference for a pre-selected billing cycle
user_seatsintegerNo—Initial paid user seat quantity for the Stripe subscription
key_seatsintegerNo—Initial paid agent/key seat quantity for the Stripe subscription
trace_refstringNo—Trace reference for request correlation

Output Schema ​

FieldTypeRequiredDefaultDescription
organization_uuiduuidNo——
plan_uuiduuidNo——
user_uuiduuidNo——
success_urlstringNo——
cancel_urlstringNo——
selected_price_refstringNo——
user_seatsintegerNo——
key_seatsintegerNo——
trace_refstringNo——
app_uuiduuidNo——
app_codestringNo——
plan_namestringNo——
stripe_product_refstringNo——
organization_emailstringNo——
stripe_customer_refstringNo——
regionstringNo——
billing_currencystringNo——
trial_period_daysintegerNo——
initiated_atstringNo——
initiated_bystringNo——
validated_atstringNo——
stripe_checkout_session_refstringNo——
checkout_urlstringNo——
stripe_price_refstringNo——
price_currencystringNo——
price_amountintegerNo——
checkout_created_atstringNo——
pending_subscription_uuiduuidNo——
stripe_subscription_refstringNo——
current_period_startstringNo——
current_period_endstringNo——
subscription_statusstringNo——
payment_received_atstringNo——
subscription_uuiduuidNo——
activated_atstringNo——
seat_items_persistedjsonNo——
billing_items_persistedlistNo——
completed_atstringNo——
canceled_atstringNo——
cancel_reasonstringNo——
failed_atstringNo——
failure_reasonstringNo——
failure_typestringNo——
failed_actionstringNo——
failed_at_statestringNo——
failed_stepstringNo——
failed_layerstringNo——
errorstringNo——
error_typestringNo——

States ​

StateInitialTerminalSuccessAuto-advanceDescription
initiatedYesNo—validate_checkoutCheckout request received
activatingNoNo—completeActivating subscription in database
checkout_createdNoNo——Stripe session created — awaiting payment webhook
payment_receivedNoNo—activate_subscriptionPayment confirmed by Stripe webhook
validatingNoNo—create_checkout_sessionValidating plan and organization
canceledNoYesNo—User canceled checkout
completedNoYesYes—Subscription activated successfully
failedNoYesNo—Checkout failed

State Diagram ​

Transitions ​

FromActionToDescription
initiatedvalidate_checkoutvalidatingValidate plan and org
validatingcreate_checkout_sessioncheckout_createdCreate Stripe session
checkout_createdpayment_receivedpayment_receivedPayment confirmed
payment_receivedactivate_subscriptionactivatingActivate subscription
activatingcompletecompletedMark complete
checkout_createdcancelcanceledUser canceled
* (any state)failfailedCatch-all failure handler

Outcomes ​

OutcomeTypeDescriptionState Data Keys
completedSUCCESSSubscription activated successfullysubscription_uuid, stripe_subscription_ref, completed_at
canceledFAILUREUser canceled checkoutcanceled_at, cancel_reason
failedFAILURECheckout failed — see failure_reasonfailed_at, failure_reason

Business Errors ​

CodeMessage Template
BILLING_AUTHORIZATION_REQUIRED
BILLING_ITEM_INPUT_ERROR
PLAN_NOT_FOUNDPlan {plan_uuid} not found or inactive
PLAN_NOT_LINKEDPlan {plan_uuid} not linked to a Stripe product
ORGANIZATION_NOT_FOUNDOrganization {organization_uuid} not found
EXISTING_SUBSCRIPTIONOrganization already has an active subscription for app
NO_PRICE_FOUNDNo active recurring price found for product reference {product_ref} in {currency} or USD
MIXED_CURRENCYSeat price {seat_price_ref} is in {seat_currency} but the base price for {product_ref} is in {base_currency}; Stripe cannot combine currencies in one checkout session

State Timeouts ​

StateTimeoutAction
checkout_created1440 minfail

Alarms ​

NameTypeStateSeverityDescription
checkout_failedstate_enteredfailedwarningSubscription checkout failed
checkout_pendingstate_timeoutcheckout_createdinfoCheckout session pending for over 1 hour

API Usage ​

bash
# Step 1: Start the workflow
POST /api/workflows/start
Content-Type: application/json

{
  "workflow_type": "subscription.checkout",
  "initial_data": {
    "organization_uuid": "value",
    "plan_uuid": "value",
    "success_url": "value",
    "cancel_url": "value"
  }
}

# Step 2: Webhook triggers transition (checkout.session.completed)
POST /api/workflows/{workflow_id}/transition
Content-Type: application/json

{ "action": "...", ... webhook payload ... }