Skip to content

Stripe Integration

Payment processing and subscriptions.

Configuration

json
{
  "credentials": {
    "stripe": {
      "secretKey": "{{env.STRIPE_SECRET_KEY}}",
      "webhookSecret": "{{env.STRIPE_WEBHOOK_SECRET}}"
    }
  }
}

Endpoints

MethodEndpointDescription
POST/integrations/stripe/payment-intentsCreate payment
POST/integrations/stripe/customersCreate customer
POST/integrations/stripe/subscriptionsCreate subscription
GET/integrations/stripe/subscriptions/:idGet subscription

Actions (for workflows)

createPaymentIntent

json
{
  "integration": "stripe",
  "action": "createPaymentIntent",
  "params": {
    "amount": 2000,
    "currency": "usd",
    "customer": "cus_123"
  }
}

createCustomer

json
{
  "integration": "stripe",
  "action": "createCustomer",
  "params": {
    "email": "customer@example.com",
    "name": "John Doe"
  }
}

createSubscription

json
{
  "integration": "stripe",
  "action": "createSubscription",
  "params": {
    "customer": "cus_123",
    "priceId": "price_456"
  }
}

cancelSubscription

json
{
  "integration": "stripe",
  "action": "cancelSubscription",
  "params": {
    "subscriptionId": "sub_789",
    "immediately": false
  }
}

Examples

Create Payment Intent

bash
curl -X POST http://localhost:3000/integrations/stripe/payment-intents \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 2000,
    "currency": "usd",
    "customer": "cus_123"
  }'

Response:

json
{
  "id": "pi_123",
  "client_secret": "pi_123_secret_456",
  "amount": 2000,
  "currency": "usd",
  "status": "requires_payment_method"
}

Webhook Receiver

Handle Stripe webhooks:

json
{
  "webhooks": [{
    "name": "stripe-events",
    "path": "/webhooks/stripe",
    "provider": "stripe",
    "secret": "&#123;&#123;env.STRIPE_WEBHOOK_SECRET&#125;&#125;",
    "actions": [{
      "condition": "&#123;&#123;payload.type&#125;&#125; === 'payment_intent.succeeded'",
      "type": "database",
      "action": "insert",
      "params": {
        "table": "payments",
        "data": {
          "stripe_id": "&#123;&#123;payload.data.object.id&#125;&#125;",
          "amount": "&#123;&#123;payload.data.object.amount&#125;&#125;"
        }
      }
    }]
  }]
}

Workflow Example

json
{
  "id": "process-order",
  "steps": [
    {
      "id": "create-customer",
      "type": "integration",
      "integration": "stripe",
      "action": "createCustomer",
      "params": {
        "email": "&#123;&#123;input.email&#125;&#125;",
        "name": "&#123;&#123;input.name&#125;&#125;"
      }
    },
    {
      "id": "create-payment",
      "type": "integration",
      "integration": "stripe",
      "action": "createPaymentIntent",
      "params": {
        "customer": "&#123;&#123;steps.create-customer.result.id&#125;&#125;",
        "amount": "&#123;&#123;input.amount&#125;&#125;",
        "currency": "usd"
      }
    }
  ]
}

Released under the ISC License.