Stripe Integration Guide

Accept Payments for Yard Sale Listings

Follow this complete guide to set up Stripe and start accepting $9.99 payments for 30-day yard sale listings. Choose between two easy methods!

RECOMMENDED

Option 1: Payment Links

Easiest method! No backend required. Just create a Payment Link in Stripe Dashboard and paste it into your code.

Setup time: 5 minutes
No server needed
Perfect for beginners
Get Started
ADVANCED

Option 2: Checkout API

More control. Use Stripe's API with your own backend. Collect custom data and automate processes.

Setup time: 30-60 minutes
Requires backend server
Full customization
View Guide
Advanced Method

Option 2: Stripe Checkout API

Use Stripe's API with your own backend for more control and automation

Prerequisites

This method requires:

  • A backend server (Node.js, Python, PHP, Ruby, etc.)
  • Basic programming knowledge
  • A hosting service (AWS, Heroku, Vercel, Netlify Functions, etc.)
  • Ability to handle API requests and webhooks

How It Works

User clicks "Pay"

Your server creates session

Stripe processes payment

Webhook confirms & creates listing

1

Get Your Stripe API Keys

  1. Log in to your Stripe Dashboard
  2. Click on "Developers" in the top right
  3. Click on "API keys"
  4. Copy your Publishable key and Secret key
  5. Store them securely in your backend environment variables

Security: NEVER expose your Secret key in frontend JavaScript! Always keep it on your server.

2

Install Stripe SDK

Choose your backend language:

Node.js / Express

npm install stripe express

Python / Flask

pip install stripe flask

PHP

composer require stripe/stripe-php
3

Create Checkout Session Endpoint

Example Node.js/Express endpoint:

const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);
const express = require('express');
const app = express();

app.use(express.json());

app.post('/api/create-checkout-session', async (req, res) => {
  try {
    const session = await stripe.checkout.sessions.create({
      payment_method_types: ['card'],
      line_items: [
        {
          price_data: {
            currency: 'usd',
            product_data: {
              name: '30-Day Yard Sale Listing',
              description: 'Premium listing with photos and map placement',
            },
            unit_amount: 999, // $9.99 in cents
          },
          quantity: 1,
        },
      ],
      mode: 'payment',
      success_url: `${req.headers.origin}/list-your-yard-sale?payment=success&session_id={CHECKOUT_SESSION_ID}`,
      cancel_url: `${req.headers.origin}/list-your-yard-sale?payment=cancel`,
      metadata: {
        // Store custom data about the listing
        userId: req.body.userId,
        listingData: JSON.stringify(req.body.listingData),
      },
    });

    res.json({ url: session.url });
  } catch (error) {
    res.status(500).json({ error: error.message });
  }
});

app.listen(3000, () => console.log('Server running on port 3000'));
4

Update Frontend Code

Tell your AI assistant to uncomment the "Option 2" code in the how-it-works page JavaScript and update the backend URL:

// Message to send to your AI assistant:

"Please update the how-it-works JavaScript file. Uncomment the 'Option 2' Checkout API code and replace 'https://your-backend.com' with my actual backend URL: https://myapi.example.com"

5

Set Up Webhooks (IMPORTANT!)

Webhooks ensure you're notified when payments succeed:

  1. In Stripe Dashboard, go to "Developers" → "Webhooks"
  2. Click "+ Add endpoint"
  3. Enter your webhook URL: https://yourapi.com/webhook
  4. Select event: checkout.session.completed
  5. Copy the webhook signing secret

Example webhook handler:

app.post('/webhook', express.raw({type: 'application/json'}), (req, res) => {
  const sig = req.headers['stripe-signature'];
  
  try {
    const event = stripe.webhooks.constructEvent(
      req.body, 
      sig, 
      process.env.STRIPE_WEBHOOK_SECRET
    );
    
    if (event.type === 'checkout.session.completed') {
      const session = event.data.object;
      
      // Create the yard sale listing in your database
      const listingData = JSON.parse(session.metadata.listingData);
      
      // TODO: Save listing to database
      // database.createListing(listingData);
      
      console.log('Payment successful! Creating listing...');
    }
    
    res.json({received: true});
  } catch (err) {
    res.status(400).send(`Webhook Error: ${err.message}`);
  }
});

Why Use the Checkout API?

Automatic Listing Creation

Automatically create listings in your database when payment succeeds

Custom Data Collection

Pass listing details directly through the payment flow

Real-time Notifications

Send confirmation emails and notifications automatically

Advanced Analytics

Track conversions, refunds, and customer behavior