frydigital

payload plugin shipstation

by frydigital
Stores & catalogs
v3
^3.0.0
MIT

Overview

Summary generated from the README

Integrates ShipStation's V1 API into Payload ecommerce projects to calculate shipping rates, validate addresses and handle multi-package shipments. It extends products, variants and orders with shipping details and adds shipping settings and zones. It is meant to be added after the ecommerce plugin and needs ShipStation API credentials and a warehouse ID.

Features

  • Real-time shipping rate calculation through the ShipStation API
  • Canadian provincial flat rates and custom zones with postal code patterns
  • Free shipping thresholds with eligibility rules and shipping class modifiers
  • Multi-package shipments with automatic splitting by weight and dimensions
  • Address validation and correction endpoint
  • Rate caching with Redis and in-memory fallback, plus tracking webhooks that update orders

Use cases

  • Show live carrier rates at checkout in a Payload-based store
  • Offer flat provincial or postal-code zone shipping with free shipping above a threshold
  • Update order tracking and delivery status automatically from ShipStation webhooks

From the author

ShipStation integration plugin for Payload CMS ecommerce

Installation

npm i @frydigital/payload-plugin-shipstation

2

Stars

1

Forks

3

Open Issues

9 months ago

Last Updated

25

Weekly Downloads

v1.0.0

npm Version

195.0 KB

Unpacked Size

2

Dependencies

GitHub stars

20 since Sep 6

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 20262
Dec 4, 20262
Dec 3, 20262
Dec 2, 20262
Dec 1, 20262
Nov 30, 20262
Nov 29, 20262
Nov 28, 20262
Nov 27, 20262
Nov 26, 20262
Nov 25, 20262
Nov 24, 20262
Nov 23, 20262
Nov 22, 20262
Nov 21, 20262
Nov 20, 20262
Nov 19, 20262
Nov 18, 20262
Nov 17, 20262
Nov 16, 20262
Nov 15, 20262
Nov 14, 20262
Nov 13, 20262
Nov 12, 20262
Nov 11, 20262
Nov 10, 20262
Nov 9, 20262
Nov 8, 20262
Nov 7, 20262
Nov 6, 20262
Nov 5, 20262
Nov 4, 20262
Nov 3, 20262
Nov 2, 20262
Nov 1, 20262
Oct 31, 20262
Oct 30, 20262
Oct 29, 20262
Oct 28, 20262
Oct 27, 20262
Oct 26, 20262
Oct 25, 20262
Oct 24, 20262
Oct 23, 20262
Oct 22, 20262
Oct 21, 20262
Oct 20, 20262
Oct 19, 20262
Oct 18, 20262
Oct 17, 20262
Oct 16, 20262
Oct 15, 20262
Oct 14, 20262
Oct 13, 20262
Oct 12, 20262
Oct 11, 20262
Oct 10, 20262
Oct 9, 20262
Oct 8, 20262
Oct 7, 20262
Oct 6, 20262
Oct 5, 20262
Oct 4, 20262
Oct 3, 20262
Oct 2, 20262
Oct 1, 20262
Sep 30, 20262
Sep 29, 20262
Sep 28, 20262
Sep 27, 20262
Sep 26, 20262
Sep 25, 20262
Sep 24, 20262
Sep 23, 20262
Sep 22, 20262
Sep 21, 20262
Sep 20, 20262
Sep 19, 20262
Sep 18, 20262
Sep 17, 20262
Sep 16, 20262
Sep 15, 20262
Sep 14, 20262
Sep 13, 20262
Sep 12, 20262
Sep 11, 20262
Sep 10, 20262
Sep 9, 20262
Sep 8, 20262
Sep 7, 20262
Sep 6, 20262
npm weekly downloads

140 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 202614
Dec 4, 202615
Dec 3, 202614
Dec 2, 202614
Dec 1, 20268
Nov 30, 20268
Nov 29, 202613
Nov 28, 202614
Nov 27, 202614
Nov 26, 202612
Nov 25, 202612
Nov 24, 202613
Nov 23, 202613
Nov 22, 202610
Nov 21, 20268
Nov 20, 20267
Nov 19, 20269
Nov 18, 202616
Nov 17, 202613
Nov 16, 202613
Nov 15, 20269
Nov 14, 202613
Nov 13, 202613
Nov 12, 202611
Nov 11, 20264
Nov 10, 202610
Nov 9, 202610
Nov 8, 202610
Nov 7, 202612
Nov 6, 202615
Nov 5, 202616
Nov 4, 202616
Nov 3, 202612
Nov 2, 202612
Nov 1, 202612
Oct 31, 20266
Oct 30, 20263
Oct 29, 20262
Oct 28, 20262
Oct 27, 20261
Oct 26, 20262
Oct 25, 20263
Oct 24, 20263
Oct 23, 20263
Oct 22, 20266
Oct 21, 20266
Oct 20, 20265
Oct 19, 20264
Oct 18, 20263
Oct 17, 20263
Oct 16, 20264
Oct 15, 20261
Oct 14, 20261
Oct 13, 20261
Oct 12, 20261
Oct 11, 20262
Oct 10, 20262
Oct 9, 20261
Oct 8, 20261
Oct 7, 20266
Oct 6, 20266
Oct 5, 20267
Oct 4, 20269
Oct 3, 202615
Oct 2, 202615
Oct 1, 202615
Sep 30, 202610
Sep 29, 202610
Sep 28, 20269
Sep 27, 20266
Sep 26, 20266
Sep 25, 20268
Sep 24, 20268
Sep 23, 20268
Sep 22, 20269
Sep 21, 202615
Sep 20, 202615
Sep 19, 20269
Sep 18, 20267
Sep 17, 20267
Sep 16, 20268
Sep 15, 20268
Sep 14, 20262
Sep 13, 20263
Sep 12, 20264
Sep 11, 202610
Sep 10, 202610
Sep 9, 202612
Sep 8, 202614
Sep 7, 202615
Sep 6, 202614

Each point is npm's rolling 7-day download count.

Health Score

32/100Fair

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1100764656-root.svg)](https://payloaddirectory.dev/plugins/1100764656-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1100764656-root"><img src="https://payloaddirectory.dev/badge/1100764656-root.svg" alt="Payload Directory"></a>
Updated Mar 9, 2026Created Nov 20, 2025Published Dec 3, 2025

README

@frydigital/payload-plugin-shipstation

CI npm version License: MIT

A comprehensive ShipStation integration plugin for Payload CMS ecommerce projects. Provides real-time shipping rate calculation, address validation, multi-package handling, and webhook support for tracking updates.

Note: This plugin uses the ShipStation V1 API (ssapi.shipstation.com). See ShipStation API Documentation for full API reference.

Features

✅ Phase 1 (Available Now)

  • 🚚 Real-time shipping rate calculation via ShipStation API (v1)
  • 🍁 Canadian provincial flat rates (all 13 provinces/territories)
  • 📍 Custom shipping zones with postal code pattern matching
  • 🎁 Free shipping thresholds with rule-based eligibility
  • 📦 Multi-package shipment handling with auto-splitting
  • ✅ Address validation and correction
  • 🔔 Webhook support for shipment tracking updates
  • ⚡ Rate caching (Redis + in-memory fallback)
  • 🔐 Secure API credential management

🚧 Phase 2

  • 🌍 International shipping with customs forms
  • 💼 Multi-carrier account management
  • 📊 Shipping analytics and performance tracking

Installation

1. Install from GitHub Packages

pnpm add @frydigital/payload-plugin-shipstation
# or
npm install @frydigital/payload-plugin-shipstation
# or
yarn add @frydigital/payload-plugin-shipstation

2. Environment Variables

Add the following to your .env file (see .env.example for full template):

# ShipStation V1 API Configuration
# Get credentials from ShipStation: Settings > Account > API Settings

# Option 1: Combined format (API Key:Secret)
SHIPSTATION_API_KEY=your_api_key:your_api_secret

# Option 2: Separate variables
# SHIPSTATION_API_KEY=your_api_key
# SHIPSTATION_API_SECRET=your_api_secret

# Warehouse ID - numeric ID from ShipStation (Settings > Shipping > Ship From Locations)
SHIPSTATION_WAREHOUSE_ID=123456

# Optional: Webhook secret for signature verification
SHIPSTATION_WEBHOOK_SECRET=your_webhook_secret

# Optional: Redis for rate caching
REDIS_URL=redis://localhost:6379

3. Configure Plugin

Add the plugin to your Payload configuration:

// payload.config.ts
import { shipStationPlugin } from '@frydigital/payload-plugin-shipstation'

export default buildConfig({
  plugins: [
    // Add after ecommerce plugin
    shipStationPlugin({
      apiKey: process.env.SHIPSTATION_API_KEY!,
      warehouseId: process.env.SHIPSTATION_WAREHOUSE_ID!,
      
      // Enable features
      enabledFeatures: {
        addressValidation: true,
        multiPackage: true,
        autoCreateShipments: false,
        webhooks: true,
      },
      
      // Canadian provincial rates (in cents)
      provincialRates: [
        { province: 'BC', baseRate: 1200, enabled: true },
        { province: 'AB', baseRate: 1000, enabled: true },
        { province: 'SK', baseRate: 1500, enabled: true },
        { province: 'MB', baseRate: 1500, enabled: true },
        { province: 'ON', baseRate: 1000, enabled: true },
        { province: 'QC', baseRate: 1200, enabled: true },
        { province: 'NB', baseRate: 1500, enabled: true },
        { province: 'NS', baseRate: 1800, enabled: true },
        { province: 'PE', baseRate: 1800, enabled: true },
        { province: 'NL', baseRate: 2000, enabled: true },
        { province: 'YT', baseRate: 2500, enabled: true },
        { province: 'NT', baseRate: 3000, enabled: true },
        { province: 'NU', baseRate: 3500, enabled: true },
      ],
      
      // Free shipping configuration
      freeShippingConfig: {
        threshold: 10000, // $100.00 CAD
        eligibleCountries: ['CA'],
        excludedShippingClasses: ['oversized'],
      },
      
      // Shipping class rate modifiers
      shippingClassModifiers: {
        standard: 1.0,
        expedited: 1.5,
        fragile: 1.3,
        oversized: 2.0,
        custom: 1.0,
      },
      
      // Multi-package limits
      maxPackageWeight: { value: 70, unit: 'pound' },
      maxPackageDimensions: { length: 36, width: 24, height: 24, unit: 'inch' },
      
      // Cache configuration
      cache: {
        enableCache: true,
        cacheTTL: 300, // 5 minutes
        redisUrl: process.env.REDIS_URL,
        fallbackToMemory: true,
      },
      
      // Webhook configuration
      webhookSecret: process.env.SHIPSTATION_WEBHOOK_SECRET,
      enabledWebhookEvents: [
        'tracking.updated',
        'tracking.delivered',
      ],
    }),
  ],
})

Usage

Calculating Shipping Rates

From Frontend/API Route
// app/api/calculate-shipping/route.ts
import { NextRequest, NextResponse } from 'next/server'

export async function POST(req: NextRequest) {
  const { cartId, shippingAddress } = await req.json()
  
  const response = await fetch('/api/shipping/calculate-rates', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ cartId, shippingAddress }),
  })
  
  const { rates, freeShipping } = await response.json()
  
  return NextResponse.json({ rates, freeShipping })
}
Response Format
{
  "rates": [
    {
      "serviceName": "Canada Post Regular Parcel",
      "serviceCode": "canada_post_regular_parcel",
      "carrierCode": "canada_post",
      "shipmentCost": 12.50,
      "otherCost": 0,
      "deliveryDays": 3,
      "estimatedDeliveryDate": "2025-11-23T23:59:00Z"
    }
  ],
  "freeShipping": false,
  "appliedRule": "provincial_rate",
  "cacheHit": true
}

Address Validation

const response = await fetch('/api/shipping/validate-address', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    address: {
      street1: '123 Main Street',
      city: 'Toronto',
      state: 'ON',
      postalCode: 'M5H 2N2',
      country: 'CA',
    },
  }),
})

const { isValid, normalizedAddress, errors } = await response.json()

Product Shipping Configuration

Add shipping details to your products:

// When creating/updating products
await payload.create({
  collection: 'products',
  data: {
    title: 'Widget',
    // ... other product fields
    
    shippingDetails: {
      weight: { value: 2.5, unit: 'pound' },
      dimensions: { length: 12, width: 8, height: 4, unit: 'inch' },
      shippingClass: 'standard',
      requiresSignature: false,
      hazardousMaterials: false,
    },
  },
})

Shipping Zones

Enable custom shipping zones for advanced rate calculations based on postal codes:

  1. Enable in Shipping Settings global (Custom Zones tab)
  2. Create zones in the Shipping Zones collection
  3. Define postal code patterns using regex

Example: Greater Toronto Area Zone

{
  name: 'Greater Toronto Area',
  enabled: true,
  priority: 1,
  postalCodePatterns: ['^M[0-9][A-Z]'], // Toronto postal codes
  countries: ['CA'],
  provinces: ['ON'],
  rateType: 'flat',
  baseRate: 800, // $8.00
  freeShippingThreshold: 5000, // $50.00
}

Webhooks

Setup in ShipStation

  1. Go to Settings > API > Webhooks in ShipStation
  2. Add webhook URL: https://yourdomain.com/api/shipping/shipstation/webhook
  3. Select events: tracking.updated, tracking.delivered
  4. Add your webhook secret through a postman api request as a custom-key in the header.

Tracking Updates

The plugin automatically:

  • Updates order tracking numbers
  • Changes shipment status
  • Triggers customer notifications (order_shipped, order_delivered)
  • Stores tracking history

API Reference

Endpoints

EndpointMethodDescription
/api/shipping/calculate-ratesPOSTCalculate shipping rates for cart
/api/shipping/validate-addressPOSTValidate and correct address
/api/shipping/estimateGETQuick rate estimate
/api/shipping/shipstation/webhookPOSTShipStation webhook handler

Collections Extended

  • products - Adds shippingDetails group with weight, dimensions, shipping class
  • variants - Inherits/overrides product shipping details
  • orders - Adds shippingDetails with tracking info, costs, history

Globals Added

  • shipping-settings - Central shipping configuration
  • shipping-zones (optional) - Custom postal code-based zones

Development

Running Tests

cd packages/payload-plugin-shipstation
pnpm install
pnpm test

Building

pnpm build

Local Development

Link the plugin locally:

cd packages/payload-plugin-shipstation
pnpm link

cd ../../
pnpm link @frydigital/payload-plugin-shipstation

Troubleshooting

Rates Not Calculating

  1. Check ShipStation API key is valid
  2. Verify warehouse ID exists in ShipStation
  3. Check product weights are configured
  4. Review Payload logs for errors

Address Validation Failing

  1. Ensure address validation is enabled in settings
  2. Check validation mode (validate_only vs validate_and_clean)
  3. Verify address format matches ShipStation requirements

Cache Issues

  1. Check Redis connection if configured
  2. Verify cache TTL settings
  3. Clear cache: Delete Redis keys with pattern shipstation:rate:*

Webhook Not Working

  1. Verify webhook secret matches ShipStation
  2. Check webhook URL is publicly accessible
  3. Review webhook event logs in ShipStation
  4. Check Payload logs for webhook processing errors

Phase 2 Roadmap

International Shipping (Q1 2026)

  • Customs form generation
  • HS code management
  • Duty calculation integration
  • Country restrictions

Carrier Account Management (Q1 2026)

  • Multiple accounts per carrier
  • Load balancing strategies
  • Account-specific rate calculation
  • Warehouse-based account assignment

Shipping Analytics (Q1 2026)

  • Rate request tracking
  • Delivery performance metrics
  • Carrier comparison insights
  • Customer satisfaction tracking

Development

Running Tests

# Run tests once
pnpm test

# Run tests in watch mode
pnpm test:watch

# Run tests with coverage
pnpm test:coverage

# Run tests with UI
pnpm test:ui

Test Coverage

The plugin has comprehensive test coverage:

  • ShipStation API Client: 85.21%
  • Shipment Creation Utility: 98.46%
  • Orders Collection Hook: 95.62%
  • Endpoints: 84-100%
  • Overall: 73 tests passing

Building

# Build the plugin
pnpm build

# Watch mode for development
pnpm dev

# Clean build artifacts
pnpm clean

CI/CD

Tests run automatically on:

  • Pull request creation
  • Push to master/main branches
  • Node.js versions: 18.x, 20.x

Contributing

We welcome contributions! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass (pnpm test)
  5. Submit a pull request

License

MIT License - see LICENSE file for details

Support

Credits

Built with ❤️ for the Payload CMS community.

Similar plugins