Stripe for Beginners: Accept Payments in Your Web App
Taking payments sounds intimidating — cards, security, compliance, refunds — but Stripe handles the hard parts. You never touch the card number: Stripe's checkout or card form collects it securely, and you work only with
Taking payments sounds intimidating — cards, security, compliance, refunds — but Stripe handles the hard parts. You never touch the card number: Stripe's checkout or card form collects it securely, and you work only with tokens and payment IDs.
The simplest integration is Stripe Checkout. Your server creates a checkout session, and Stripe hosts the whole payment page:
import Stripe from 'stripe';
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);
const session = await stripe.checkout.sessions.create({
mode: 'payment',
line_items: [
{
price_data: {
currency: 'inr',
product_data: { name: 'eBook Bundle' },
unit_amount: 19900, // ₹199 in paise
},
quantity: 1,
},
],
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel',
});
Send the user to session.url, and Stripe handles the card form, UPI, wallets, and confirmation. When payment succeeds, Stripe sends a webhook to your server so you can unlock the product or send a receipt.
For a custom checkout inside your own page, Stripe Elements gives you pre-built card inputs that are PCI-compliant out of the box, and Stripe.js confirms the payment from the browser. Subscriptions work the same way — create a subscription, and Stripe handles recurring billing, retries, and invoices.
Stripe also gives you a test mode with test card numbers, so you can build the whole flow without spending a rupee. Switch to live keys only when you are ready, and keep the secret key on the server — never in frontend code.
Stripe is for developers who need to charge for something — a product, a subscription, or a service. Start with Checkout, use test mode until the flow works end to end, and let Stripe worry about the card details and compliance.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.