Stripe Payment Setup
Payment System:
LogoAIpro uses Stripe for secure credit purchases. Stripe handles payment processing, checkout sessions, and webhooks for credit allocation.
Why Stripe?
Stripe is a complete payment solution that provides:
- Secure Payments: PCI-compliant payment processing
- Checkout Sessions: Easy-to-use checkout flow
- Webhooks: Real-time payment event notifications
- Multi-Currency: Support for multiple currencies
- Easy Integration: Simple Next.js integration
Step-by-Step Setup
Step 1: Create Stripe Account
- Go to stripe.com
- Click "Sign Up" or "Start Now"
- Sign up with your email address
- Verify your email address
- Complete the onboarding process
Step 2: Get API Keys
- After signing in, navigate to Developers → API Keys
- You'll see two keys:
- Publishable Key: Starts with
pk_test_(for test) orpk_live_(for production) - Secret Key: Starts with
sk_test_(for test) orsk_live_(for production)
- Publishable Key: Starts with
- Copy both keys
- Add them to your
.env.localfile:NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_xxxxxxxxxxxxx STRIPE_SECRET_KEY=sk_test_xxxxxxxxxxxxx
Security Note:
Never share your secret key or commit it to version control. The secret key should only be used server-side.
Step 3: Create Credit Products
LogoAIpro uses one-time payments for credit packages. Create products in Stripe:
- Navigate to Products in the sidebar
- Click "Add Product"
- Create three products for your credit packages:
- Basic Pack: One-time payment, $9.99 (50 credits)
- Pro Pack: One-time payment, $24.99 (150 credits)
- Enterprise Pack: One-time payment, $79.99 (500 credits)
- For each product:
- Enter product name (e.g., "Basic Pack")
- Enter description
- Set price (one-time payment)
- Save the product
- Copy the Price ID for each product (starts with
price_)
Step 4: Configure Credit Packages in Code
Update credit packages in your pricing configuration file:
export const creditPackages = [
{
name: "Basic Pack",
credits: 50,
price: "$9.99",
pricePerCredit: "$0.20 per credit",
description: "Perfect for testing and small projects.",
ctaLabel: "Buy Basic Pack",
ctaHref: "/api/checkout/credits?plan=basic",
},
{
name: "Pro Pack",
credits: 150,
price: "$24.99",
pricePerCredit: "$0.17 per credit",
description: "Best value for regular users and creators.",
highlight: true,
ctaLabel: "Buy Pro Pack",
ctaHref: "/api/checkout/credits?plan=pro",
},
{
name: "Enterprise Pack",
credits: 500,
price: "$79.99",
pricePerCredit: "$0.16 per credit",
description: "For businesses and heavy users.",
ctaLabel: "Buy Enterprise Pack",
ctaHref: "/api/checkout/credits?plan=enterprise",
},
];Step 5: Configure Checkout API
Update checkout route in app/api/checkout/credits/route.ts to map plans to Stripe Price IDs:
const PLAN_PRICE_MAP: Record = {
'basic': process.env.STRIPE_PRICE_BASIC || 'price_xxxxxxxxxxxxx',
'pro': process.env.STRIPE_PRICE_PRO || 'price_xxxxxxxxxxxxx',
'enterprise': process.env.STRIPE_PRICE_ENTERPRISE || 'price_xxxxxxxxxxxxx',
}; Add these Price IDs to your .env.local:
STRIPE_PRICE_BASIC=price_xxxxxxxxxxxxx
STRIPE_PRICE_PRO=price_xxxxxxxxxxxxx
STRIPE_PRICE_ENTERPRISE=price_xxxxxxxxxxxxxStep 6: Set Up Webhooks
Webhooks are essential for automatically adding credits to user accounts after payment.
- Navigate to Developers → Webhooks in Stripe Dashboard
- Click "Add Endpoint"
- Configure the webhook:
- Endpoint URL:
# Development (use ngrok for local testing) https://your-ngrok-url.ngrok.io/api/webhooks/stripe # Production https://yourdomain.com/api/webhooks/stripe - Events to Listen For: Select these events:
-
checkout.session.completed- Payment successful -
payment_intent.succeeded- Payment completed -
payment_intent.payment_failed- Payment failed
-
- Endpoint URL:
- Click "Add Endpoint"
- Copy the Signing Secret (starts with
whsec_) - Add it to your
.env.local:STRIPE_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxx
Webhook Testing (Local Development):
- Use ngrok to expose your local server
- Run:
ngrok http 3000 - Use the ngrok URL as your webhook endpoint
- Update the webhook URL in Stripe dashboard
Step 7: Configure Application URLs
- Navigate to Settings → Branding in Stripe Dashboard
- Configure your application details:
- Business name: LogoAIpro
- Support email: Your support email
- Support phone: Your support phone (optional)
- Configure redirect URLs in your checkout API route:
success_url: `${process.env.NEXT_PUBLIC_APP_URL}/dashboard/credits?session_id={CHECKOUT_SESSION_ID}&success=true`, cancel_url: `${process.env.NEXT_PUBLIC_APP_URL}/dashboard/credits?canceled=true`,
Step 8: Test Payment Flow
- Ensure all environment variables are set in
.env.local - Start your development server:
npm run dev - Navigate to Dashboard → Credits
- Click "Buy Credits" on any package
- Use Stripe test card:
4242 4242 4242 4242 - Use any future expiry date and any 3-digit CVC
- Complete the payment
- Verify credits are added to your account
Production Setup
Switching to Production Keys
- In Stripe Dashboard, toggle from "Test" to "Live" mode
- Get your production API keys
- Create production products and prices
- Update environment variables on your production server:
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_xxxxxxxxxxxxx STRIPE_SECRET_KEY=sk_live_xxxxxxxxxxxxx STRIPE_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxx STRIPE_PRICE_BASIC=price_xxxxxxxxxxxxx STRIPE_PRICE_PRO=price_xxxxxxxxxxxxx STRIPE_PRICE_ENTERPRISE=price_xxxxxxxxxxxxx - Update webhook URL to your production domain
- Test payment in production with a real card
Testing with Stripe Test Cards
Stripe provides test cards for testing different scenarios:
| Card Number | Scenario |
|---|---|
4242 4242 4242 4242 |
Successful payment |
4000 0000 0000 0002 |
Card declined |
4000 0000 0000 9995 |
Insufficient funds |
Use any future expiry date (e.g., 12/25) and any 3-digit CVC (e.g., 123).
Verification Checklist
Ensure you have:
- Stripe account created
- API keys added to
.env.local - Credit products created in Stripe
- Price IDs configured in code
- Webhook configured and secret added
- Checkout API route configured
- Test payment completed successfully
- Credits added to test account
Next Steps:
After Stripe is configured: