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": "{{env.STRIPE_WEBHOOK_SECRET}}",
    "actions": [{
      "condition": "{{payload.type}} === 'payment_intent.succeeded'",
      "type": "database",
      "action": "insert",
      "params": {
        "table": "payments",
        "data": {
          "stripe_id": "{{payload.data.object.id}}",
          "amount": "{{payload.data.object.amount}}"
        }
      }
    }]
  }]
}

Workflow Example

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

Backflow - Configuration-driven API framework