home / skills / shipshitdev / library / stripe-implementer

stripe-implementer skill

/bundles/payments/skills/stripe-implementer

This skill helps you implement Stripe payments, subscriptions, webhooks, and customer management in Next.js and NestJS with best practices.

npx playbooks add skill shipshitdev/library --skill stripe-implementer

Review the files below or copy the command above to add this skill to your agents.

Files (3)
SKILL.md
1.5 KB
---
name: stripe-implementer
description: Implement Stripe payment processing, subscription management, webhook handling, and customer management in Next.js and NestJS applications
---

# Stripe Implementer

Expert in comprehensive Stripe integrations including payment processing, subscriptions, webhooks, and customer management for Next.js and NestJS.

## When to Use This Skill

Use when you're:

- Integrating Stripe payments
- Implementing subscription billing
- Setting up Stripe webhooks
- Managing Stripe customers
- Handling payment intents or checkout sessions
- Implementing Stripe Connect or marketplace features

## Quick Setup

```bash
npm install stripe @stripe/stripe-js
```

```env
STRIPE_SECRET_KEY=sk_test_...
STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
```

## Key Flows

### Payment Methods

- **Checkout Sessions**: Recommended for one-time payments
- **Payment Intents**: For custom payment flows
- **Subscriptions**: For recurring billing

### Webhook Events

- `payment_intent.succeeded` / `payment_intent.payment_failed`
- `customer.subscription.created/updated/deleted`
- `invoice.payment_succeeded/failed`

## Best Practices

- Never expose secret keys client-side
- Always verify webhook signatures
- Use idempotency keys for critical operations
- Test with Stripe CLI: `stripe listen --forward-to localhost:3000/api/webhooks/stripe`

## References

- [Full guide: Setup, payments, subscriptions, webhooks, NestJS](references/full-guide.md)

Overview

This skill implements Stripe payment processing, subscription billing, webhook handling, and customer management for Next.js and NestJS applications. It provides practical code patterns, configuration guidance, and recommended flows to get secure payments and recurring billing running quickly. The focus is on production-safe defaults like webhook signature verification and idempotency handling.

How this skill works

The skill supplies integration patterns for Checkout Sessions, Payment Intents, and Subscription management, plus examples for creating and updating customers. It shows where to store and use secret and publishable keys, how to verify webhook signatures, and how to forward events into your business logic. Implementation notes cover both frontend Next.js usage (stripe-js) and backend NestJS routes/services using the Stripe server SDK.

When to use it

  • Adding one-time payments with Stripe Checkout in Next.js
  • Building recurring subscriptions and billing logic in NestJS
  • Receiving and verifying Stripe webhooks for asynchronous events
  • Managing customers, payment methods, and invoices programmatically
  • Implementing marketplace payouts with Stripe Connect
  • Protecting critical operations with idempotency and secret management

Best practices

  • Keep secret keys server-side and use publishable keys only in the client
  • Always verify webhook signatures using STRIPE_WEBHOOK_SECRET
  • Use idempotency keys for retries on payment and subscription creation
  • Test flows locally with the Stripe CLI and test API keys
  • Record and reconcile webhook events to prevent double-processing

Example use cases

  • Create a Next.js API route that initiates a Checkout Session and redirects the client
  • Implement a NestJS webhook controller that verifies signatures and updates subscription status
  • Build a billing portal that lists customer payment methods and invoices
  • Automate upgrades/downgrades of subscription tiers and prorations
  • Set up Stripe Connect flows for a marketplace with connected accounts

FAQ

Do I need to store Stripe secret keys in environment variables?

Yes. Store secret keys in server-side environment variables and never expose them in client code or public repositories.

How do I test webhooks locally?

Use the Stripe CLI to forward events to your local endpoint (stripe listen --forward-to localhost:3000/api/webhooks/stripe) and verify signature handling with your webhook secret.