Skip to content

Latest commit

 

History

History
162 lines (114 loc) · 4.95 KB

File metadata and controls

162 lines (114 loc) · 4.95 KB

Ad Boost Feature Implementation

This document outlines the complete implementation of the ad boost feature for the classified ads platform, following the PRD requirements and jiji.ng benchmark functionality.

Overview

The ad boost feature allows users to pay to promote their ads for increased visibility and priority placement in listings. Boosted ads appear first in search results and have visual indicators to distinguish them from regular ads.

Pricing Structure (As per PRD)

  • 7 days: ₦1,000
  • 14 days: ₦1,800
  • 30 days: ₦3,500

Backend Implementation

1. Database Schema

The boost functionality uses existing database tables:

  • ads table: Contains is_boosted (boolean) and boost_expires_at (timestamp) columns
  • payments table: Tracks all boost payments with polymorphic relationship

2. API Endpoints

AdController enhanced with boost functionality:

// Get boost pricing options
GET /api/ads/boost/pricing

// Initiate boost payment (requires auth)
POST /api/ads/{id}/boost
Parameters: boost_days (7,14,30), email

// Verify boost payment (requires auth)  
POST /api/ads/boost/verify
Parameters: reference

// Check boost expiry (admin/cron)
POST /api/ads/boost/check-expiry

3. PaystackService

Created app/Services/PaystackService.php for payment integration:

  • Initialize payments
  • Verify payments
  • List transactions

4. Boost Logic

  • Priority Listing: Boosted ads appear first using ORDER BY is_boosted DESC, boost_expires_at DESC
  • Expiry Management: checkBoostExpiry() method to deactivate expired boosts
  • Payment Flow: Initialize → Redirect to Paystack → Verify → Activate boost

Frontend Implementation

1. Enhanced Components

BoostAd Component (src/components/BoostAd.jsx):

  • Modern UI with pricing cards
  • Package selection (7, 14, 30 days)
  • Email input for payment receipt
  • Integration with Paystack payment flow

PaymentCallback Component (src/pages/PaymentCallback.jsx):

  • Handles payment verification after Paystack redirect
  • Shows success/error states
  • Navigation back to ad or dashboard

2. Dashboard Integration

Dashboard Component enhanced with:

  • Boost status column in ads table
  • Boost action buttons for eligible ads
  • Visual indicators for boosted ads
  • Real-time boost status updates

3. Ad Listings Display

AdList Component enhanced with:

  • Visual boost indicators (star icons, colored borders)
  • "Featured" badges for boosted ads
  • Priority positioning for boosted ads
  • Gradient overlay for boosted ad cards

4. Visual Indicators

Boosted ads display:

  • Primary colored borders
  • Star icons
  • "Boosted" and "Featured" chips
  • Gradient overlay bars
  • Enhanced hover effects

Configuration

Backend Configuration

Add to .env:

PAYSTACK_PUBLIC_KEY=pk_test_xxxxxxxxxx
PAYSTACK_SECRET_KEY=sk_test_xxxxxxxxxx
PAYSTACK_PAYMENT_URL=https://api.paystack.co

Frontend Routes

Added payment callback route:

<Route path="/payment/callback" element={<PaymentCallback />} />

User Flow

  1. Boost Initiation: User clicks boost button on ad
  2. Package Selection: User selects boost duration (7, 14, or 30 days)
  3. Payment: Redirects to Paystack for secure payment
  4. Verification: Returns to app, payment is verified
  5. Activation: Ad boost is activated with expiry date
  6. Display: Ad appears with boost indicators and priority placement

Security Features

  • Authentication Required: All boost operations require user authentication
  • Ownership Validation: Users can only boost their own ads
  • Payment Verification: Server-side payment verification with Paystack
  • Secure References: Unique payment references prevent replay attacks

Benefits

  • Increased Visibility: Boosted ads appear first in listings
  • Visual Distinction: Multiple visual indicators highlight boosted ads
  • Revenue Generation: Monetization through ad boost payments
  • User Experience: Smooth payment flow with clear feedback

Monitoring & Maintenance

  • Expiry Checks: Automated system to deactivate expired boosts
  • Payment Tracking: Complete audit trail of all boost payments
  • Analytics Ready: Boost data available for reporting and analytics

Future Enhancements

  • Auto-renewal: Option for users to auto-renew boost
  • Bulk Boost: Allow boosting multiple ads simultaneously
  • Dynamic Pricing: Adjust pricing based on demand
  • Geographic Boost: Location-specific boost options

Testing

To test the boost feature:

  1. Ensure Paystack test keys are configured
  2. Create an ad through the platform
  3. Navigate to Dashboard and click boost button on the ad
  4. Select a package and complete payment flow
  5. Verify ad appears with boost indicators in listings
  6. Check payment record in admin panel

The implementation follows the PRD specifications and provides a complete, production-ready ad boost feature with secure payment processing and comprehensive user experience.