Pricing & Credits Configuration
Credit Packages Overview
LogoAIpro offers three credit packages with different quantities of credits. Each package provides credits for logo generation operations.
Package Structure
| Package | Credits | Price | Price/Credit | Value |
|---|---|---|---|---|
| Basic Pack | 50 | $9.99 | $0.20 | Entry Level |
| Pro Pack ⭐ | 150 | $24.99 | $0.17 | Best Value |
| Enterprise Pack | 500 | $79.99 | $0.16 | Professional |
Credit Costs per Operation
Each logo generation typically costs 1 credit per logo. This applies to all logo generation operations regardless of style, size, or quality settings.
Credit Costs
| Operation | Credits per Operation | Description |
|---|---|---|
| Logo Generation | 1 credit | Generate a single logo with any style, size, or quality |
| Logo Regeneration | 1 credit | Regenerate a logo with different parameters |
Configuration Files
1. Frontend Pricing Display
Credit packages are configured in your pricing configuration file for display on the frontend:
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, // This makes it the "Best Value" package
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",
},
];2. Backend Credit Configuration
Credit pricing and checkout is handled in app/api/checkout/credits/route.ts:
// Credit pricing plans (prices in cents for Stripe)
const CREDIT_PLANS = {
basic: { price: 999, credits: 50 }, // $9.99
pro: { price: 2499, credits: 150 }, // $24.99
enterprise: { price: 7999, credits: 500 }, // $79.99
} as const;Customizing Credit Packages
Step 1: Modify Credit Amounts
To change credit amounts, update both files:
- Frontend: Update your pricing configuration file with new credit amounts
- Backend: Update
app/api/checkout/credits/route.tswith matching credit amounts and prices (in cents) - Stripe: No changes needed in Stripe Dashboard since we use dynamic pricing
Step 2: Modify Package Prices
- Update prices in your frontend configuration (display price as string, e.g., "$9.99")
- Update prices in
app/api/checkout/credits/route.ts(in cents, e.g., 999 for $9.99) - Recalculate
pricePerCreditin frontend configuration
Step 3: Add a New Package
- Add new package to your pricing configuration array
- Add corresponding entry to
CREDIT_PLANSobject inapp/api/checkout/credits/route.ts - Update the
ctaHrefto match the new plan key (e.g.,plan=premium) - Test the checkout flow to ensure it works correctly
Stripe Integration
Checkout Process Flow
The checkout API route creates Stripe checkout sessions with dynamic pricing. Here's how it works:
- User clicks "Buy Credits" button on pricing page
- Frontend redirects to
/api/checkout/credits?plan=basic - Backend validates the plan and creates a Stripe checkout session
- User completes payment on Stripe checkout page
- Stripe webhook triggers and adds credits to user account
- User is redirected back to credits page with success message
Stripe Checkout Session Configuration
const session = await stripe.checkout.sessions.create({
allow_promotion_codes: true, // Allows coupon codes
metadata: {
userId, // User ID from Clerk
credits: plan.credits.toString(),
type: "user_credits", // Identifies this as a credit purchase
},
line_items: [
{
price_data: {
currency: "usd",
unit_amount: plan.price, // Price in cents
product_data: {
name: `${plan.credits.toLocaleString()} Credit Pack`,
description: `${plan.credits.toLocaleString()} credits for logo generation`,
},
},
quantity: 1,
},
],
mode: "payment", // One-time payment
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`,
});price_data) instead of predefined Stripe Price IDs. This allows easy price changes without updating Stripe Dashboard.
Modify Credit Costs per Operation
To change credit costs for logo generation, update the credit check in your API route:
// In API route (e.g., app/api/generate/route.ts)
import { checkAndDeductCredits } from "@/lib/utils/credits";
// Check and deduct credits (change 1 to your desired credit cost)
const creditCheck = await checkAndDeductCredits(1);
if (!creditCheck.success) {
return NextResponse.json(
{ error: creditCheck.error || "Insufficient credits" },
{ status: 400 }
);
}Credit Validation System
Credit Check Function
Credits are checked and deducted using your credit utility function:
export async function checkAndDeductCredits(
amount: number,
userId?: string
): Promise<{ success: boolean; error?: string }> {
// Implementation:
// 1. Checks user credit balance from database
// 2. Deducts credits if sufficient balance exists
// 3. Updates user credit balance in database
// 4. Returns success or error message
}Credit Balance Check
- Before Operation: System checks if user has enough credits
- During Operation: Credits are deducted immediately when operation starts
- After Operation: If operation fails, credits are not refunded (prevent abuse)
Webhook Integration
Stripe Webhook Handler
Credits are automatically added to user accounts via Stripe webhook when payment is completed:
// app/api/stripe-webhook/route.ts
if (event.type === 'checkout.session.completed') {
const session = event.data.object;
const userId = session.metadata.userId;
const credits = parseInt(session.metadata.credits);
// Validate this is a credit purchase
if (session.metadata.type === 'user_credits') {
// Add credits to user account in database
await addCreditsToUser(userId, credits);
}
}STRIPE_WEBHOOK_SECRET to ensure requests are from Stripe.
Pricing Strategy Recommendations
Current Pricing Tiers
- Basic Pack ($9.99): Perfect for testing the platform or occasional use
- Pro Pack ($24.99): Ideal for regular users and content creators
- Enterprise Pack ($79.99): Best for heavy users and businesses
Pricing Tips
- Lower cost per credit with larger packs incentivizes bulk purchases
- The Pro pack being highlighted as "Best Value" drives conversions
- Clear pricing per credit helps users understand value
- Free tier (10 credits) allows users to test before purchasing
Testing Credit System
Test Checklist
- Test credit purchase flow with Stripe test mode
- Verify credits are added correctly after payment
- Test credit deduction when generating logos
- Verify insufficient credits error message
- Test webhook handling for successful payments
- Verify credit balance displays correctly in dashboard