Stripe Agent Toolkit + Credian: Adding Trust to Agent Payments
Stripe lets your agent process payments. Credian tells you whether it should. Here is how to combine both for trust gated financial operations.
By Credian Team
The Problem
Stripe's Agent Toolkit lets AI agents create payment links, manage subscriptions, and interact with Stripe's full API. It is excellent at moving money. What it does not do is evaluate whether the agent should be moving money in the first place.
That is where Credian comes in. By combining Stripe for payment processing and Credian for trust evaluation, you get a system where agents can only execute financial operations that match their trust level.
Architecture
The integration pattern is straightforward:
- Agent requests a financial operation
- Your middleware queries Credian for the agent's trust score
- Based on the score and confidence level, you set transaction limits
- If the operation is within limits, you execute it via Stripe's Agent Toolkit
- After completion, you report the outcome to Credian
The key insight is that Credian and Stripe operate at different layers. Credian answers "should this agent be allowed to do this?" Stripe answers "how do we actually process the payment?" Neither replaces the other.
Implementation
import { Credian } from 'credian';
import Stripe from 'stripe';
const credian = new Credian({ apiKey: process.env.CREDIAN_API_KEY });
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
// Trust gated payment creation
async function createTrustedPayment(agentId: string, amount: number) {
// Step 1: Check agent trust score
const score = await credian.scores.get(agentId);
// Step 2: Determine transaction limit based on score
const limit = getTransactionLimit(score);
if (amount > limit) {
throw new Error(
`Amount ${amount} exceeds limit ${limit} for score ${score.overallScore}`
);
}
// Step 3: Create payment via Stripe
const paymentIntent = await stripe.paymentIntents.create({
amount, // in cents
currency: 'usd',
metadata: {
agentId,
trustScore: String(score.overallScore),
confidence: score.confidence,
},
});
// Step 4: Report the outcome to Credian
await credian.events.report({
type: 'payment.completed',
data: {
amount,
currency: 'usd',
stripePaymentId: paymentIntent.id,
},
});
return paymentIntent;
}
function getTransactionLimit(score: {
overallScore: number;
confidence: string;
}) {
// Low confidence agents get minimal limits regardless of score
if (score.confidence === 'low') return 1000; // $10
if (score.overallScore >= 800) return 10000000; // $100,000
if (score.overallScore >= 600) return 1000000; // $10,000
if (score.overallScore >= 400) return 100000; // $1,000
return 10000; // $100
}
With LangChain
If your agent uses LangChain, you can combine both toolkits in the same agent executor:
import { CredianTool } from 'credian/langchain';
// import { StripeAgentToolkit } from '@stripe/agent-toolkit/langchain';
const credianTool = new CredianTool({
apiKey: process.env.CREDIAN_API_KEY,
});
// Both tools available to the same agent
const tools = [
credianTool,
// ...stripe toolkit tools
];
const prompt = ChatPromptTemplate.fromMessages([
['system', `Before any Stripe operation, use the credian tool to check
your trust score. Only proceed with payments if your score is above
600 with at least medium confidence. After completing any payment,
report the outcome using the credian tool.`],
['human', '{input}'],
['placeholder', '{agent_scratchpad}'],
]);
The agent will naturally check its trust score before attempting Stripe operations and report outcomes afterward. The trust evaluation becomes part of the agent's reasoning process, not just an external check.
Webhook Integration
For production deployments, you can use Stripe webhooks to automatically report payment outcomes to Credian:
// Stripe webhook handler
app.post('/webhooks/stripe', async (req, res) => {
const event = stripe.webhooks.constructEvent(
req.body,
req.headers['stripe-signature'],
process.env.STRIPE_WEBHOOK_SECRET
);
const agentId = event.data.object.metadata?.agentId;
if (!agentId) return res.sendStatus(200);
switch (event.type) {
case 'payment_intent.succeeded':
await credian.events.report({
type: 'payment.completed',
data: {
amount: event.data.object.amount,
stripeEventId: event.id,
},
});
break;
case 'payment_intent.payment_failed':
await credian.events.report({
type: 'payment.failed',
data: {
amount: event.data.object.amount,
reason: event.data.object.last_payment_error?.message,
},
});
break;
}
res.sendStatus(200);
});
This approach is more reliable than reporting from the agent itself because Stripe webhooks are guaranteed to fire even if the agent process crashes after initiating a payment.
What You Get
By combining Stripe and Credian, your agent payment system has:
- Trust gated access — Agents cannot exceed their trust level
- Dynamic limits — As an agent builds trust, its transaction limits increase automatically
- Audit trail — Every payment is tied to a trust score at the time of execution
- Recovery path — A bad payment drops the score and limits, but the agent can recover by demonstrating reliable behavior
- Full Stripe capabilities — Payment processing, subscriptions, invoicing, and everything else Stripe offers
Get started: npm install credian stripe to add trust gated payments to your agent in minutes.