Getting started with Stripe
Add invoice-backed enrichment to an existing Stripe request and confirm payment from signed Stripe webhook events.
On this page
Enrich the existing payment request
Carden validates the source invoice from a supported source and exact full unpaid payment, then automatically chooses enhanced or ordinary mode. Enhanced mode returns validated payment_details and amount_details. Ordinary mode returns no enhanced fields while allowing the same factual payment. Add the preparation reference to the one Stripe request your checkout already makes. Carden stores the immutable preparation; signed Stripe webhook deliveries supply payment evidence for the same payment.
| Flow | Use it when | Carden key scopes |
|---|---|---|
| Linked invoice source | The payment maps to one imported, fully unpaid invoice. | invoices:read + enrichment:write |
| Inline invoice | The backend already has a complete CanonicalInvoice v1. | enrichment:write |
| Reporting only | An existing integration optionally submits observations; these do not replace connected Stripe evidence. | payments:write |
Connect payment evidence and invoice data
- Configure the Stripe webhook endpoint in your Stripe Dashboard to send payment events to Carden.
- Connect an invoice source, complete its import, and review only factual exceptions.
- Link the invoice source to Stripe in the same merchant and environment if the connections are not already linked; linking requires authority over both integrations.
- Create a server-side Stripe-integration Carden key with invoices:read and enrichment:write.
Linking does not change existing keys. The webhook endpoint and enrichment key have different jobs: the webhook confirms actual Stripe activity; the key prepares fields for your existing payment request.
Use one source-trusted, fully unpaid invoice
Pass the known Carden invoice ID directly to preparation without retrieving the invoice first. Carden rechecks source freshness and eligibility. expectedRevision is optional when you need to reject changes since a reviewed revision.
- The invoice must be open, positive, fully unpaid, and unambiguous.
- The Stripe amount and currency must match the invoice total and balance.
- The source must be active, current, and free of pending refresh work.
- Partial payments, combined invoices, overpayments, and ambiguous allocations require another supported workflow.
Add the improvement directly to the Stripe call
stripe is the merchant's existing Stripe server client. existingPaymentIntentParams and existingStripeRequestOptions are the arguments already used by checkout, including its existing idempotency key and account routing. order.invoiceId identifies the invoice, and attempt.preparationIdempotencyKey is a stable key for this preparation. Modify that existing Stripe invocation as shown below rather than adding another payment call.
Enrichment and connected payment confirmation
The checkout adds prepared data; Carden receives signed payment events independently.
Prepare
Request invoice-backed fields
Carden validates the invoice and stores its immutable preparation.
Pay
Enrich the existing Stripe call
Include the fields and preparation reference in the same request.
Confirm
Receive signed Stripe events
Carden verifies delivery signatures and records actual captured and refunded amounts independently of preparation.
const response = await fetch(new URL("/api/v1/stripe/payment-preparations/from-invoice", cardenBaseUrl), {
method: "POST",
headers: { Authorization: `Bearer ${cardenApiKey}`, "Content-Type": "application/json" },
body: JSON.stringify({
invoiceId: order.invoiceId,
amountMinor: existingPaymentIntentParams.amount,
currency: existingPaymentIntentParams.currency,
idempotencyKey: attempt.preparationIdempotencyKey,
}),
signal: AbortSignal.timeout(5000),
});
const envelope = await response.json();
if (!response.ok || envelope?.object !== "stripe.payment_preparation" || envelope.api_version !== "v1") {
throw new Error(envelope?.error?.message ?? `Carden preparation failed: ${response.status}`);
}
const prepared = { ...envelope.data, preparation: envelope.preparation };
const { mode, enrichment, preparation } = prepared;
const { payment_details: existingPaymentDetails, ...paymentParams } = existingPaymentIntentParams;
const result = await stripe.paymentIntents.create({
...paymentParams,
...(mode === "enhanced" && enrichment ? {
...enrichment,
amount_details: {
...enrichment.amount_details,
line_items: [...enrichment.amount_details.line_items],
},
payment_details: { ...existingPaymentDetails, ...enrichment.payment_details },
} : {}),
amount: preparation.amountMinor,
currency: preparation.currency,
metadata: {
...existingPaymentIntentParams.metadata,
carden_preparation_id: preparation.id,
},
}, existingStripeRequestOptions);Keep identities separate
| Identifier | Purpose |
|---|---|
| Preparation idempotencyKey | Reuses identical preparation input while current source checks still pass. |
| preparation.id | Identifies the immutable invoice preparation; retain it as carden_preparation_id metadata. |
| x-carden-request-id | Diagnostic identity of one Carden request, not a payment or preparation ID. |
| Stripe idempotency key | Protects the merchant's existing Stripe payment operation. |
| Stripe charge / PaymentIntent / account IDs | Identify the actual connected-account payment evidence. |
Metadata supports traceability, not proof of commercial-data transmission or network qualification. A correlation mismatch in amount or currency requires review; preserve actual Stripe amounts instead of rewriting them to fit an invoice.
Confirm outcomes through Stripe webhooks
Review Connect Stripe payment events on the Setup tab. Delivery verified means a signed event arrived and its signature passed Carden verification. Captured payments confirmed counts actual captured payment evidence delivered by signed Stripe webhooks. Failed-payment, refund, and dispute deliveries can verify delivery without confirming capture. Webhook delivery is asynchronous, separate from settlement, and is not an instant checkout acknowledgment.
Carden retains Stripe webhook evidence and the immutable preparation even if the invoice changes or its source disconnects after payment. Payment confirmation from signed webhook deliveries does not depend on a merchant payment-report queue or the invoice source remaining connected. Webhook setup does not import historical charges or itemized fee reports. Connect a restricted read-only Stripe key on the Setup tab to sync balance transactions into settlement and fee evidence; that evidence is still only a processor-reported cost and not a qualification or verified-savings result.