Integrate Stripe payments with checkout and payment intents
✓Works with OpenClaudeYou are a backend payment integration engineer. The user wants to integrate Stripe payments with checkout flow and payment intents.
What to check first
- Run
npm list stripeto verify the Stripe Node.js library is installed (npm install stripe) - Confirm your Stripe API keys are set in environment variables:
STRIPE_SECRET_KEYandSTRIPE_PUBLISHABLE_KEY - Check your Node.js version supports async/await (v7.6+)
Steps
- Initialize the Stripe client with your secret key at the top of your payment module
- Create a Payment Intent before charging to handle asynchronous payment confirmation
- Implement the
/create-payment-intentendpoint that returns the client secret - Call
stripe.paymentIntents.create()with amount in cents, currency, and metadata - Return the
client_secretto your frontend for Stripe.js to confirm - Handle the confirmation response and check
payment_intent.statusfor success - Implement webhook listener for
payment_intent.succeededandpayment_intent.payment_failedevents - Verify webhook signatures using
stripe.webhooks.constructEvent()before processing
Code
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);
const express = require('express');
const app = express();
app.use(express.json());
// Create Payment Intent endpoint
app.post('/create-payment-intent', async (req, res) => {
const { amount, currency = 'usd', customerId, metadata = {} } = req.body;
try {
const paymentIntent = await stripe.paymentIntents.create({
amount: Math.round(amount * 100), // Convert dollars to cents
currency,
customer: customerId,
metadata,
automatic_payment_methods: {
enabled: true,
},
});
res.json({ clientSecret: paymentIntent.client_secret });
} catch (error) {
res.status(400).json({ error: error.message });
}
});
// Confirm payment from frontend, then verify on backend
app.post('/confirm-payment', async (req, res) => {
const { paymentIntentId } = req.body;
try {
const paymentIntent = await stripe.paymentIntents.retrieve(paymentIntentId);
if (paymentIntent.status === 'succeeded') {
res.json({ success: true, paymentIntent });
} else if (paymentIntent.status === 'requires_payment_method') {
res.status(400).json({ error: 'Payment method required' });
} else {
res.status(400).json({ error: `Payment status: ${paymentIntent.status}` });
}
} catch (error) {
res.status(400).json({ error: error.message });
}
});
// Webhook handler for async
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Payments Skills
Other Claude Code skills in the same category — free to download.
Stripe Subscriptions
Set up recurring subscription billing with Stripe
Stripe Webhooks
Handle Stripe webhook events with signature verification
PayPal Integration
Integrate PayPal payments and checkout
Payment Form
Build secure PCI-compliant payment forms
Invoice System
Build invoice generation and management system
Pricing Page
Build dynamic pricing page with plan comparison
Payment Testing
Set up payment testing with test cards and sandbox environments
Want a Payments skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.