var F=Object.defineProperty;var G=(z)=>z;function H(z,B){this[z]=G.bind(null,B)}var J=(z,B)=>{for(var D in B)F(z,D,{get:B[D],enumerable:!0,configurable:!0,set:H.bind(B,D)})};var K=(z,B)=>()=>(z&&(B=z(z=0)),B);import E from"@contractspec/lib.ui-link";import{ChevronRight as I}from"lucide-react";import{jsx as f,jsxs as q}from"react/jsx-runtime";function P(){return q("div",{className:"space-y-8",children:[q("div",{className:"space-y-4",children:[f("h1",{className:"font-bold text-4xl",children:"Stripe"}),f("p",{className:"text-muted-foreground",children:"The Stripe integration enables payment processing, subscription management, and invoicing in your ContractSpec applications. All Stripe operations are type-safe, policy-enforced, and automatically logged."})]}),q("div",{className:"space-y-4",children:[f("h2",{className:"font-bold text-2xl",children:"Setup"}),f("p",{className:"text-muted-foreground",children:"Add your Stripe credentials to your environment variables:"}),f("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:f("pre",{children:`# .env
STRIPE_SECRET_KEY=sk_test_...
STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...`})}),q("p",{className:"text-muted-foreground text-sm",children:["Get your API keys from the"," ",f("a",{href:"https://dashboard.stripe.com/apikeys",target:"_blank",rel:"noopener noreferrer",className:"text-violet-400 hover:text-violet-300",children:"Stripe Dashboard"}),"."]})]}),q("div",{className:"space-y-4",children:[f("h2",{className:"font-bold text-2xl",children:"Available capabilities"}),q("div",{className:"space-y-3",children:[f("h3",{className:"font-semibold text-lg",children:"Payment Intents"}),f("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:f("pre",{children:`capabilityId: stripe-create-payment-intent
provider:
  type: stripe
  operation: createPaymentIntent

inputs:
  amount:
    type: number
    description: "Amount in cents"
  currency:
    type: string
    default: "usd"
  customerId:
    type: string
    optional: true
  metadata:
    type: object
    optional: true

outputs:
  paymentIntentId:
    type: string
  clientSecret:
    type: string
  status:
    type: string`})})]}),q("div",{className:"space-y-3",children:[f("h3",{className:"font-semibold text-lg",children:"Customers"}),f("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:f("pre",{children:`capabilityId: stripe-create-customer
provider:
  type: stripe
  operation: createCustomer

inputs:
  email:
    type: string
  name:
    type: string
    optional: true
  metadata:
    type: object
    optional: true

outputs:
  customerId:
    type: string
  email:
    type: string`})})]}),q("div",{className:"space-y-3",children:[f("h3",{className:"font-semibold text-lg",children:"Subscriptions"}),f("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:f("pre",{children:`capabilityId: stripe-create-subscription
provider:
  type: stripe
  operation: createSubscription

inputs:
  customerId:
    type: string
  priceId:
    type: string
  trialDays:
    type: number
    optional: true

outputs:
  subscriptionId:
    type: string
  status:
    type: string
  currentPeriodEnd:
    type: timestamp`})})]})]}),q("div",{className:"space-y-4",children:[f("h2",{className:"font-bold text-2xl",children:"Webhooks"}),f("p",{className:"text-muted-foreground",children:"ContractSpec automatically handles Stripe webhooks. Configure your webhook endpoint in the Stripe Dashboard:"}),f("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:f("pre",{children:"https://your-app.com/api/webhooks/stripe"})}),f("p",{className:"text-muted-foreground",children:"Subscribe to these events:"}),q("ul",{className:"list-inside list-disc space-y-2 text-muted-foreground",children:[f("li",{children:f("code",{className:"rounded bg-background/50 px-2 py-1",children:"payment_intent.succeeded"})}),f("li",{children:f("code",{className:"rounded bg-background/50 px-2 py-1",children:"payment_intent.payment_failed"})}),f("li",{children:f("code",{className:"rounded bg-background/50 px-2 py-1",children:"customer.subscription.created"})}),f("li",{children:f("code",{className:"rounded bg-background/50 px-2 py-1",children:"customer.subscription.updated"})}),f("li",{children:f("code",{className:"rounded bg-background/50 px-2 py-1",children:"customer.subscription.deleted"})})]})]}),q("div",{className:"space-y-4",children:[f("h2",{className:"font-bold text-2xl",children:"Example workflow"}),f("p",{className:"text-muted-foreground",children:"Here's a complete payment workflow using Stripe:"}),f("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:f("pre",{children:`workflowId: process-payment
version: '1.0.0'.0.0

steps:
  - id: create-customer
    capability: stripe-create-customer
    inputs:
      email: \${input.customerEmail}
      name: \${input.customerName}
    onSuccess: create-payment-intent
    onFailure: notify-error

  - id: create-payment-intent
    capability: stripe-create-payment-intent
    inputs:
      amount: \${input.amount}
      currency: "usd"
      customerId: \${steps.create-customer.output.customerId}
    onSuccess: send-payment-link
    onFailure: notify-error

  - id: send-payment-link
    capability: send-email
    inputs:
      to: \${input.customerEmail}
      template: "payment-link"
      data:
        clientSecret: \${steps.create-payment-intent.output.clientSecret}
        amount: \${input.amount}

  - id: notify-error
    capability: send-email
    inputs:
      to: "admin@example.com"
      template: "payment-error"
      data:
        error: \${error.message}`})})]}),q("div",{className:"space-y-4",children:[f("h2",{className:"font-bold text-2xl",children:"Testing"}),f("p",{className:"text-muted-foreground",children:"Use Stripe's test cards for development:"}),f("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:q("table",{className:"w-full text-left text-sm",children:[f("thead",{className:"bg-card/50",children:q("tr",{className:"border-border/50 border-b",children:[f("th",{className:"px-4 py-3 font-semibold",children:"Card Number"}),f("th",{className:"px-4 py-3 font-semibold",children:"Scenario"})]})}),q("tbody",{className:"divide-y divide-border/50",children:[q("tr",{children:[f("td",{className:"px-4 py-3 font-mono",children:"4242 4242 4242 4242"}),f("td",{className:"px-4 py-3",children:"Successful payment"})]}),q("tr",{children:[f("td",{className:"px-4 py-3 font-mono",children:"4000 0000 0000 9995"}),f("td",{className:"px-4 py-3",children:"Insufficient funds"})]}),q("tr",{children:[f("td",{className:"px-4 py-3 font-mono",children:"4000 0000 0000 0002"}),f("td",{className:"px-4 py-3",children:"Card declined"})]})]})]})})]}),q("div",{className:"space-y-4",children:[f("h2",{className:"font-bold text-2xl",children:"Best practices"}),q("ul",{className:"list-inside list-disc space-y-2 text-muted-foreground",children:[f("li",{children:"Always use test mode during development"}),f("li",{children:"Verify webhook signatures to prevent fraud"}),f("li",{children:"Handle idempotency for payment operations"}),f("li",{children:"Store customer IDs for recurring payments"}),f("li",{children:"Use metadata to link Stripe objects to your application records"}),f("li",{children:"Monitor failed payments and retry logic"})]})]}),q("div",{className:"flex items-center gap-4 pt-4",children:[f(E,{href:"/docs/integrations",className:"btn-ghost",children:"Back to Integrations"}),q(E,{href:"/docs/integrations/postmark",className:"btn-primary",children:["Next: Postmark ",f(I,{size:16})]})]})]})}export{P as IntegrationsStripePage};
