PackagesPayment Providers
@prood/payment-stripe
Stripe Payment Element provider via PaymentIntents — the default payment gateway.
@prood/payment-stripe implements the PaymentProvider interface for Stripe, using the Payment Element and PaymentIntents API.
Installation
pnpm add @prood/payment-stripeUsage
import { StripePaymentProvider } from '@prood/payment-stripe'
const provider = new StripePaymentProvider({
secretKey: process.env.STRIPE_SECRET_KEY!,
webhookSecret: process.env.STRIPE_WEBHOOK_SECRET,
publishableKey: process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY,
})Via commerce factory (preferred in apps):
import { getPaymentProvider } from '@prood/commerce'
const provider = await getPaymentProvider('stripe', orgId)Configuration
| Field | Env fallback | Required | Description |
|---|---|---|---|
secretKey | STRIPE_SECRET_KEY | Yes | Server-side secret key |
webhookSecret | STRIPE_WEBHOOK_SECRET | Webhooks | Webhook signing secret |
publishableKey | NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY | Client UI | Publishable key for Payment Element |
Per-tenant overrides via dashboard Integrations → Stripe.
Payment flow
createSession()→ creates Stripe PaymentIntent- Client renders Payment Element with
clientSecret - Customer submits → Stripe handles 3DS if required
confirmSession()→ verifies PaymentIntent status- Webhook
payment_intent.succeeded→ async confirmation
Webhook events
| Event | Action |
|---|---|
payment_intent.succeeded | Mark order as confirmed |
payment_intent.payment_failed | Mark order as failed |
charge.refunded | Update order refund status |
Webhook URL: https://checkout.example.com/api/webhooks/stripe/{orgId}
Refunds
const result = await provider.refund({
sessionId: 'pi_xxx',
amount: 5000, // partial refund in minor units
reason: 'Customer request',
})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 |