Docs / integrations / call-stripe-api

call-stripe-api

recipesince 0.2.8

Operate on the OWNER's Stripe account (revenue dashboards, customer lookups, invoice ops) from a built app

Plane: http_integration · Requires: capability external_integration

Steps: 1. useAgent — With capabilities ['external_integration','data_access'], prompt the agent to call the built-in stripe integration's endpoints (list_charges, list_customers, …) and UPSERT results into payment_events in the declared doc_schema shape. 2. useCollection — Read payment_events reactively ({ layer: 'shared' }, refreshOnAgentComplete: true) for the dashboard UI.

Writes payment_events (layer shared, writer agent) — required: event_id, kind, amount_cents, currency, created_at.

Examples

End-to-end example
import { useAgent, useCollection } from '@flowstack/sdk';

export function RevenuePanel() {
  const { query, isStreaming } = useAgent(undefined, {
    capabilities: ['external_integration', 'data_access'],
  });
  const { documents: events } = useCollection('payment_events', {
    layer: 'shared',
    sort: { created_at: -1 },
    limit: 100,
    refreshOnAgentComplete: true,
  });
  const totalCents = events.reduce((s, e) => s + (e.amount_cents ?? 0), 0);

  return (
    <>
      <button
        disabled={isStreaming}
        onClick={() =>
          query(
            'Call the stripe integration: list the latest charges and upsert them into ' +
            'payment_events (dedupe on event_id), matching its doc schema. No card data.'
          )
        }
      >
        Refresh revenue
      </button>
      <h2>${(totalCents / 100).toFixed(2)}</h2>
    </>
  );
}
WarningFor CHARGING USERS OF THE APP use the platform paywall (paywall-app recipe / setMonetization) — NOT raw Stripe calls.
WarningThis recipe reads/operates the OWNER'S Stripe account via the owner-registered integration.
WarningNever persist card numbers, emails, or full customer objects; store opaque ids + amounts only.

See also

paywall-app · call-http-integration · register-custom-api · useAgent · useCollection

Source: sync-recipes.mjs ← https://sage-api.flowstack.fun/recipes.json · Also available in llms-full.txt and registry.json.