← back to Handbag Authentication

api/cross-listing-generator.js

434 lines

const crypto = require('crypto');

class CrossListingGenerator {
  constructor() {
    this.platformConfigs = {
      ebay: {
        name: 'eBay',
        sellerFeePercent: 13.25,
        listingFeeFlat: 0.35,
        paymentProcessingPercent: 3.49,
        paymentProcessingFlat: 0.49,
        avgShippingCost: 15,
        importDutyPercent: 5.5,
        notes: 'Best for authenticated luxury bags. Free promoted listings for 200 listings/month.'
      },
      poshmark: {
        name: 'Poshmark',
        sellerFeePercent: 20, // Over $15
        sellerFeeFlat: 2.95, // Under $15
        listingFeeFlat: 0,
        paymentProcessingPercent: 0, // Included in seller fee
        paymentProcessingFlat: 0,
        avgShippingCost: 7.67, // Flat rate up to 5 lbs
        importDutyPercent: 0, // Buyer pays
        notes: 'Social selling platform. Great for designer bags. Flat shipping $7.67 for seller.'
      },
      mercari: {
        name: 'Mercari',
        sellerFeePercent: 12.9,
        listingFeeFlat: 0,
        paymentProcessingPercent: 2.9,
        paymentProcessingFlat: 0.30,
        avgShippingCost: 12,
        importDutyPercent: 0,
        notes: 'Lower fees than Poshmark. Authentication available for $500+ bags.'
      },
      vestiaire: {
        name: 'Vestiaire Collective',
        sellerFeePercent: 18, // Variable based on price
        listingFeeFlat: 0,
        paymentProcessingPercent: 0, // Included
        paymentProcessingFlat: 0,
        avgShippingCost: 0, // They handle
        importDutyPercent: 0,
        notes: 'Premium platform. They authenticate and handle shipping. International reach.'
      },
      therealreal: {
        name: 'The RealReal',
        sellerFeePercent: 40, // Consignment model: 15-60% depending on price
        listingFeeFlat: 0,
        paymentProcessingPercent: 0,
        paymentProcessingFlat: 0,
        avgShippingCost: 0,
        importDutyPercent: 0,
        notes: 'Luxury consignment. They authenticate, photograph, and ship. Best for high-value items.'
      },
      fashionphile: {
        name: 'Fashionphile',
        sellerFeePercent: 30, // They buy outright or consign
        listingFeeFlat: 0,
        paymentProcessingPercent: 0,
        paymentProcessingFlat: 0,
        avgShippingCost: 0,
        importDutyPercent: 0,
        notes: 'Hermès/Chanel specialist. Instant payment option. They handle everything.'
      }
    };
  }

  generateSKU(brand, model, color, size) {
    const brandCode = (brand || 'UNK').substring(0, 3).toUpperCase();
    const modelCode = (model || 'UNK').replace(/\s+/g, '').substring(0, 6).toUpperCase();
    const colorCode = (color || 'UNK').substring(0, 3).toUpperCase();
    const sizeCode = (size || 'OS').replace(/\s+/g, '').toUpperCase();
    const random = crypto.randomBytes(3).toString('hex').toUpperCase();

    return `${brandCode}-${modelCode}-${colorCode}-${sizeCode}-${random}`;
  }

  calculatePlatformProfits(purchasePriceUSD, suggestedRetailUSD) {
    const results = {};

    for (const [platform, config] of Object.entries(this.platformConfigs)) {
      // Calculate total cost
      const totalCost = purchasePriceUSD +
                       (purchasePriceUSD * config.importDutyPercent / 100) +
                       config.avgShippingCost;

      // Calculate seller fees at suggested retail price
      let sellerFee = 0;
      if (suggestedRetailUSD < 15 && config.sellerFeeFlat > 0) {
        sellerFee = config.sellerFeeFlat;
      } else {
        sellerFee = (suggestedRetailUSD * config.sellerFeePercent / 100) + config.listingFeeFlat;
      }

      const paymentFee = (suggestedRetailUSD * config.paymentProcessingPercent / 100) +
                        config.paymentProcessingFlat;

      const totalFees = sellerFee + paymentFee;
      const netProfit = suggestedRetailUSD - totalCost - totalFees;
      const roiPercent = ((netProfit / totalCost) * 100).toFixed(1);

      results[platform] = {
        platform: config.name,
        suggestedPrice: suggestedRetailUSD,
        totalCost,
        sellerFee: sellerFee.toFixed(2),
        paymentFee: paymentFee.toFixed(2),
        totalFees: totalFees.toFixed(2),
        netProfit: netProfit.toFixed(2),
        roiPercent,
        profitMargin: ((netProfit / suggestedRetailUSD) * 100).toFixed(1),
        notes: config.notes
      };
    }

    return results;
  }

  generateEbayListingUrl(sku, title, price, category = 'Women\'s Bags & Handbags') {
    // eBay's "Sell Similar" URL pattern
    const params = new URLSearchParams({
      'siteid': '0',
      'mode': 'sell',
      'customid': sku,
      'title': title.substring(0, 80), // eBay 80 char limit
      'price': price,
      'category': '169291', // Women's Bags category
      'format': 'FixedPrice'
    });

    return `https://www.ebay.com/sl/sell?${params.toString()}`;
  }

  generatePoshmarkListingUrl(title, brand, price) {
    // Poshmark doesn't have URL prefill, but we can provide deep link
    return `https://poshmark.com/create-listing?department=Women&category=Bags&brand=${encodeURIComponent(brand)}&title=${encodeURIComponent(title.substring(0, 50))}&price=${price}`;
  }

  generateMercariListingUrl(title, price, category = 'Women/Bags') {
    return `https://www.mercari.com/sell/?title=${encodeURIComponent(title.substring(0, 40))}&price=${price}&category=${encodeURIComponent(category)}`;
  }

  generateCrossListingLinks(product, sku, suggestedPrice) {
    return {
      ebay: {
        url: this.generateEbayListingUrl(sku, product.title, suggestedPrice),
        quickStart: 'Click to prefill eBay listing with product details'
      },
      poshmark: {
        url: this.generatePoshmarkListingUrl(product.title, product.brand, suggestedPrice),
        quickStart: 'Click to open Poshmark app/web with pre-filled data'
      },
      mercari: {
        url: this.generateMercariListingUrl(product.title, suggestedPrice),
        quickStart: 'Click to create Mercari listing'
      },
      vestiaire: {
        url: 'https://www.vestiairecollective.com/sell/',
        quickStart: 'Manual listing - they authenticate and photograph'
      },
      therealreal: {
        url: 'https://www.therealreal.com/consign',
        quickStart: 'Submit for consignment - they handle everything'
      },
      fashionphile: {
        url: 'https://www.fashionphile.com/sell',
        quickStart: 'Request quote - instant payment option available'
      }
    };
  }

  generatePlatformGuide() {
    return {
      ebay: {
        setupSteps: [
          '1. Go to ebay.com and click "Register"',
          '2. Choose "Business Account" if planning 40+ sales/month',
          '3. Verify email and phone number',
          '4. Link PayPal or set up Managed Payments (required)',
          '5. Set up seller preferences in My eBay > Account > Site Preferences',
          '6. CRITICAL: Get eBay Authenticate service for bags $500+ (free authentication)',
          '7. Enable "Best Offer" to negotiate with buyers',
          '8. Use eBay\'s promoted listings (first 200 free/month)'
        ],
        fees: {
          sellingFee: '13.25% final value fee',
          insertionFee: '$0.35 per listing (first 250 free/month)',
          payment: '3.49% + $0.49 payment processing',
          promotion: 'Optional 1-20% ad rate'
        },
        tips: [
          'Use "Good Till Cancelled" 30-day listings for luxury items',
          'Offer free returns to boost buyer confidence',
          'Get eBay Authenticate badge for designer bags',
          'Cross-post to eBay Motors for vintage/rare pieces',
          'Use eBay\'s International Shipping Program for global reach'
        ]
      },
      poshmark: {
        setupSteps: [
          '1. Download Poshmark app or go to poshmark.com',
          '2. Sign up with email (use business email if bulk selling)',
          '3. Complete profile with professional photo and bio',
          '4. Enable "Posh Authenticate" for bags $500+ (automatic)',
          '5. Join relevant "Posh Parties" for your brands',
          '6. Share your listings 3-5x per day for visibility',
          '7. Follow other sellers in luxury category',
          '8. Set up direct deposit for payouts'
        ],
        fees: {
          under15: '$2.95 flat fee',
          over15: '20% commission',
          shipping: '$7.67 flat rate (paid by buyer for up to 5 lbs)',
          authentication: 'Free for items $500+'
        },
        tips: [
          'List at 20% above target price (buyers expect to negotiate)',
          'Use "Offer to Likers" feature to convert interest',
          'Share to parties for maximum exposure',
          'Poshmark authenticates designer bags $500+ automatically',
          'Fast shipping (< 3 days) improves seller rating'
        ]
      },
      mercari: {
        setupSteps: [
          '1. Download Mercari app (mobile-first platform)',
          '2. Sign up and verify phone number',
          '3. Link bank account or debit card for deposits',
          '4. Enable "Mercari Authenticate" for luxury items',
          '5. Set up shipping preferences',
          '6. Create detailed listings with 12 photos max',
          '7. Use promoted listings for high-value items'
        ],
        fees: {
          sellingFee: '12.9% (lower than Poshmark)',
          payment: '2.9% + $0.30 processing',
          shipping: 'Prepaid labels or charge buyer',
          authentication: '$5 for items $500-$2000, $10 for $2000+'
        },
        tips: [
          'Lower fees than Poshmark = more profit',
          'Use "Smart Pricing" for automated offers',
          'Mercari Authenticate required for designer bags $500+',
          'List same item on Mercari + Poshmark simultaneously',
          'Respond to messages within 24hrs for best results'
        ]
      },
      vestiaire: {
        setupSteps: [
          '1. Go to vestiairecollective.com/sell',
          '2. Create seller account (they manually approve)',
          '3. Submit photos and details of items',
          '4. Vestiaire reviews and authenticates',
          '5. They photograph professionally and list',
          '6. Ship item when sold (they provide label)',
          '7. Receive payment 2-3 days after buyer receives'
        ],
        fees: {
          commission: '18% for most items',
          returnFee: 'Free if item is authentic',
          shipping: 'Buyer pays',
          photography: 'Free professional photos'
        },
        tips: [
          'Best for international sales (Europe/Asia)',
          'They handle authentication and photography',
          'Higher end buyers = can charge more',
          'Approval process takes 24-48 hours',
          'Great for limited edition and vintage pieces'
        ]
      },
      therealreal: {
        setupSteps: [
          '1. Go to therealreal.com/consign',
          '2. Request a free appointment or shipping kit',
          '3. They evaluate items (in-home or at store)',
          '4. Accept consignment terms (15-60% commission based on price)',
          '5. They photograph, authenticate, list',
          '6. Get paid when item sells',
          '7. Option for instant payout at discounted rate'
        ],
        fees: {
          commission: '15-60% sliding scale (higher for lower prices)',
          instantPayout: 'Available at 50% of estimated value',
          authentication: 'Free',
          shipping: 'Free kit provided'
        },
        tips: [
          'Best for Hermès Birkin/Kelly (they specialize)',
          'Free in-home evaluation for high-value collections',
          'Instant payout option if you need cash now',
          'They have retail stores for in-person drop-off',
          'Best for items $1000+'
        ]
      },
      fashionphile: {
        setupSteps: [
          '1. Go to fashionphile.com/sell',
          '2. Submit photos and details for quote',
          '3. Receive instant quote (usually within 24 hours)',
          '4. Choose: Instant payment (lower) or consignment (higher)',
          '5. Ship item with free prepaid label',
          '6. They authenticate on receipt',
          '7. Get paid immediately (instant) or when sold (consignment)'
        ],
        fees: {
          instantBuy: 'They buy at ~60-70% of market value',
          consignment: '~30% commission',
          authentication: 'Free',
          shipping: 'Free prepaid labels'
        },
        tips: [
          'Hermès and Chanel specialists (best prices)',
          'Instant payment option = quick cash',
          'Consignment = higher payout but slower',
          'They have retail stores in LA, NYC, SF for in-person',
          'Best for authenticated luxury bags only'
        ]
      }
    };
  }

  generateUsResaleGuide() {
    return {
      authentication: {
        title: 'Authentication is CRITICAL for US Sales',
        services: [
          {
            name: 'Entrupy',
            cost: '$60-$80 per bag',
            method: 'AI-powered microscope analysis',
            url: 'https://www.entrupy.com',
            notes: 'Gold standard. Provides certificate. Required by many platforms.'
          },
          {
            name: 'Authenticate First',
            cost: '$10-$50',
            method: 'Expert photo review',
            url: 'https://authenticatefirst.com',
            notes: 'Fast 24-48 hour turnaround. Good for eBay listings.'
          },
          {
            name: 'Real Authentication',
            cost: '$25-$100',
            method: 'Expert authentication',
            url: 'https://realauthentication.com',
            notes: 'Specializes in Hermès and Chanel.'
          }
        ],
        platformAuth: {
          ebay: 'Free eBay Authenticate for items $500+',
          poshmark: 'Free Posh Authenticate for items $500+',
          mercari: 'Required Mercari Authenticate for designer bags $500+'
        }
      },
      importDuties: {
        title: 'Importing from Japan to USA',
        overview: 'You MUST pay customs duties when importing commercial goods',
        handbagDuty: '5.3-8.5% depending on material',
        calculationMethod: 'Duty = (Item Price + Shipping) × Duty Rate',
        thresholds: {
          personal: '$800 - duty-free if for personal use (risky for resale)',
          commercial: '$0 - all commercial imports subject to duty'
        },
        tips: [
          'Declare true value - customs fraud = serious penalties',
          'Use shipping services that handle customs (Buyee, FromJapan)',
          'Keep all receipts for tax deductions',
          'Consider Import Bond if importing >$2500 regularly'
        ]
      },
      taxConsiderations: {
        title: 'US Tax Requirements for Resellers',
        requirements: [
          'Get EIN (Employer ID Number) from IRS - free at irs.gov',
          'Register for sales tax permit in your state',
          'Collect sales tax on in-state sales',
          'File Schedule C with personal tax return for business income',
          'Keep detailed records of all purchases and sales',
          'Consider LLC formation if doing >$50k/year sales'
        ],
        deductions: [
          'Cost of goods sold (purchase price + shipping + duties)',
          'Platform fees (eBay, Poshmark, etc.)',
          'Authentication costs',
          'Shipping supplies',
          'Photography equipment',
          'Home office (if dedicated space)',
          'Mileage for business errands'
        ]
      },
      shippingBestPractices: {
        title: 'Shipping Luxury Bags in USA',
        carriers: [
          {
            name: 'USPS Priority Mail',
            cost: '$8-$15 for most bags',
            insurance: '$100 included, up to $5000 available',
            speed: '2-3 days',
            notes: 'Cheapest for items under $500'
          },
          {
            name: 'UPS Ground',
            cost: '$12-$25',
            insurance: '$100 included, up to $50k available',
            speed: '3-5 days',
            notes: 'Best for items $500-$2000. Better tracking.'
          },
          {
            name: 'FedEx',
            cost: '$15-$30',
            insurance: 'Up to $100k available',
            speed: '2-5 days',
            notes: 'Best for items $2000+. Signature required.'
          }
        ],
        packagingTips: [
          'Use brand-appropriate packaging (designer bags = luxury packaging)',
          'Double box high-value items ($1000+)',
          'Include dust bag if available',
          'Add tissue paper and thank you note',
          'Take photos before sealing box',
          'Require signature on delivery for items $500+',
          'Insure for FULL value, not just cost'
        ]
      }
    };
  }
}

module.exports = CrossListingGenerator;