@prood/payment-stripe
Stripe provider using Checkout Sessions with the embedded Payment Element.
@prood/payment-stripe implements the PaymentProvider interface for Stripe, using the Checkout Sessions API with the embedded Payment Element.
Installation
Workspace package. Available from the source repo for now.
Usage
import { StripePaymentProvider } from '@prood/payment-stripe'
const provider = new StripePaymentProvider({
secretKey: config.secretKey,
webhookSecret: config.webhookSecret,
publishableKey: config.publishableKey,
})Via commerce factory (preferred in apps):
import { getTenantPaymentProvider } from '@prood/commerce'
const { provider } = await getTenantPaymentProvider(orgId, 'stripe')Configuration
| Field | Required | Description |
|---|---|---|
secretKey | Yes | Server-side secret key |
webhookSecret | Webhooks | Signing secret |
publishableKey | Client UI | Publishable key for Payment Element |
Each store enters these under Integrations in the dashboard. There is no environment fallback.
Payment flow
createSession()→ creates a Checkout Session- Client renders the Payment Element with its
clientSecret - Customer submits → Stripe handles 3DS if required
confirmSession()→ reads the Checkout Session's status- Webhook
checkout.session.completed→ the source of truth
Webhook events
| Event | Action |
|---|---|
checkout.session.completed | payment.captured when paid, otherwise payment.authorized |
checkout.session.async_payment_succeeded | payment.captured |
checkout.session.async_payment_failed | payment.failed |
checkout.session.expired | payment.cancelled |
charge.refunded | Record a refund, including one made in the Stripe dashboard. Stripe's refunded totals decide between refunded and partially_refunded |
Webhook URL: https://checkout.example.com/api/webhooks/stripe/{orgId}
Refunds
await provider.refund({
sessionId: 'cs_xxx', // the Checkout Session on the order
amount: 50, // partial refund in major units
reason: 'requested_by_customer',
})refund() resolves when Stripe accepts the refund and reads nothing back. Stripe honours idempotencyKey, so a retry can't send the money twice.
Test mode
Use Stripe test keys (sk_test_..., pk_test_...):
| Card | Result |
|---|---|
4242 4242 4242 4242 | Success |
4000 0000 0000 3220 | 3DS required |
4000 0000 0000 9995 | Declined |