Poseidonas

payload fulfillment

by Poseidonas
Stores & catalogs
v3
>=3.88 <4
MIT

Overview

Summary generated from the README

Extends the orders collection created by the official Payload ecommerce plugin with additional statuses, an append-only status history, internal notes, and tracking number and carrier fields. It adds a single beforeChange hook and no new collections or admin components. It must be listed after the plugin that defines the orders collection and requires Payload 3.88 or newer.

Features

  • Merges extra states such as pending-payment, on-hold, shipped and failed into the existing status field
  • Records every status change in a read-only history array closed to the API
  • Optional transition guard that rejects disallowed status changes with HTTP 400
  • Internal notes field with access control that hides it from the order customer
  • Tracking number and carrier fields shown only in configurable states
  • Configurable field names, states, transitions and carrier list

Use cases

  • Add shipped and on-hold stages between payment and delivery in a Payload shop
  • Keep an audit trail of who changed an order status and when
  • Let staff leave private notes and tracking details on orders

From the author

Extra order states, transition history, internal notes and tracking for Payload ecommerce orders.

Installation

npm i payload-fulfillment

1

Stars

0

Forks

0

Open Issues

2 weeks ago

Last Updated

35

Weekly Downloads

v1.0.2

npm Version

33.5 KB

Unpacked Size

0

Dependencies

GitHub stars

10 since Sep 6

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

32+11 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 202632
Dec 4, 202635
Dec 3, 202631
Dec 2, 202636
Dec 1, 202640
Nov 30, 202654
Nov 29, 202686
Nov 28, 2026109
Nov 27, 2026116
Nov 26, 2026292
Nov 25, 2026284
Nov 24, 2026277
Nov 23, 2026262
Nov 22, 2026228
Nov 21, 2026201
Nov 20, 2026191
Nov 19, 20268
Nov 18, 20269
Nov 17, 202610
Nov 16, 202614
Nov 15, 202611
Nov 14, 202611
Nov 13, 202614
Nov 12, 202615
Nov 11, 202614
Nov 10, 202613
Nov 9, 202611
Nov 8, 202614
Nov 7, 202616
Nov 6, 202613
Nov 5, 202613
Nov 4, 202614
Nov 3, 202615
Nov 2, 202615
Nov 1, 202612
Oct 31, 202612
Oct 30, 202611
Oct 29, 20268
Oct 28, 20267
Oct 27, 20267
Oct 26, 20266
Oct 25, 20265
Oct 24, 20265
Oct 23, 20265
Oct 22, 20268
Oct 21, 20268
Oct 20, 20269
Oct 19, 202610
Oct 18, 202610
Oct 17, 20269
Oct 16, 20269
Oct 15, 20269
Oct 14, 202611
Oct 13, 202610
Oct 12, 20267
Oct 11, 20269
Oct 10, 20269
Oct 9, 20269
Oct 8, 20267
Oct 7, 20266
Oct 6, 202610
Oct 5, 202611
Oct 4, 202611
Oct 3, 202610
Oct 2, 202614
Oct 1, 202613
Sep 30, 202612
Sep 29, 202611
Sep 28, 202610
Sep 27, 202610
Sep 26, 202615
Sep 25, 202611
Sep 24, 202611
Sep 23, 202612
Sep 22, 202610
Sep 21, 202612
Sep 20, 202612
Sep 19, 20268
Sep 18, 20268
Sep 17, 20269
Sep 16, 202611
Sep 15, 20269
Sep 14, 20268
Sep 13, 20268
Sep 12, 202610
Sep 11, 202612
Sep 10, 202612
Sep 9, 202610
Sep 8, 202612
Sep 7, 202615
Sep 6, 202621

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

Health Score

73/100Good

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/1340409988-root.svg)](https://payloaddirectory.dev/plugins/1340409988-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1340409988-root"><img src="https://payloaddirectory.dev/badge/1340409988-root.svg" alt="Payload Directory"></a>
Updated Nov 17, 2026Created Aug 20, 2026Published Nov 17, 2026

README

payload-fulfillment

npm node license payload

Gives a Payload order the states a real shop needs between payment and delivery, and a record of how it got there: extra statuses merged into the ones you already have, an append-only transition history, internal notes, and a tracking number with a carrier.

  • Extends @payloadcms/plugin-ecommerce and works on any collection that holds orders
  • Built against Payload 3.88 and @payloadcms/plugin-ecommerce 3.88.0
  • No runtime dependencies, and no runtime import of payload either
  • No admin components, so it survives minor releases

Install

Requires Payload 3.88 or newer and @payloadcms/plugin-ecommerce 3.88 or newer. Verified against Payload 3.88.0 with the official plugin installed.

pnpm add payload-fulfillment
import { ecommercePlugin } from '@payloadcms/plugin-ecommerce'
import { fulfillmentPlugin } from 'payload-fulfillment'

export default buildConfig({
  plugins: [
    ecommercePlugin({ /* ... */ }),
    fulfillmentPlugin({
      guardTransitions: true,
      carriers: ['DHL', 'UPS', 'ELTA Courier'],
    }),
  ],
})

fulfillmentPlugin must come after the plugin that defines the orders collection. It extends what it finds; if the orders collection is not there yet, it returns the config untouched.

What was measured

Read from the published sources of the exact versions, both of which are installed and can be checked line by line.

What the official plugin gives an order

@payloadcms/[email protected], dist/collections/orders/createOrdersCollection.js. The orders collection carries one status field:

PropertyValue
namestatus
typeselect
defaultValueprocessing
interfaceNameOrderStatus
optionsprocessing, completed, cancelled, refunded

Those four are the whole vocabulary. An order is created by the Stripe adapter with status: 'processing' already set (dist/payments/adapters/stripe/confirmOrder.js), so there is no state before payment, no on hold, no failed, and nothing between processing and completed. There is no transition history, no notes and no tracking anywhere on the collection.

This package adds the missing states to that same field. The four above are never removed, never renamed and never reordered, because a shop may already have orders sitting in them.

Why the history is a field on the order and not a collection

Payload 3.88.0, dist/collections/operations/utilities/update.js and dist/collections/operations/create.js, run their hooks in this order:

beforeValidate - Fields  ->  beforeValidate - Collection  ->  beforeChange - Collection  ->  beforeChange - Fields

Three things follow from that, and together they decide the design.

Field access is enforced before the collection hook runs. dist/fields/hooks/beforeValidate/promise.js deletes a field from the incoming payload when its create or update access returns false. That happens in the first step, so a field closed to the API is still writable by a hook in the third step. The history field is therefore declared create: false, update: false and written only by the plugin. No request can forge, edit or delete an entry.

The previous document is read with access overridden. originalDoc is built with overrideAccess: true and depth: 0. The hook can read the existing history even though the requester cannot, and the relationships come back as plain ids.

The write costs nothing extra. The entry is appended to the same document, in the same write, inside the request's own transaction. A separate collection would mean a second payload.create: with req it is an extra write per status change, and without req it is a second database connection held while the order's own transaction is still open, which exhausts the default pg pool of 10 at eleven concurrent requests. A history that only ever grows by a handful of rows per order, and that is always read together with the order, does not justify either cost.

The trade is stated under Honest limits.

The guard answers with 400, not 500

dist/utilities/routeError.js takes the HTTP status from err.status, and dist/utilities/isErrorPublic.js shows the message to the client when isPublic is true or the status is not 500. InvalidTransitionError carries both, so a refused transition comes back as a readable 400 without the package importing anything from payload at runtime.

The tracking fields hide, they do not disappear

admin.condition is read in dist/fields/hooks/beforeChange/promise.js, where it only decides whether validation is skipped, and it appears nowhere in the read pipeline. Hiding the tracking fields outside the shipping states changes what the admin panel draws, never what the database holds or what the API returns.

Tests

53 unit tests, pnpm test.

Options

OptionDefaultMeaning
carriers[]Options for the carrier field. Given any, it becomes a select instead of free text
disabledfalseStops the hook but keeps every field, so the database keeps its shape
guardTransitionsfalseRefuses a status change the transition map does not allow, with HTTP 400
historytrueRecords every status change on the order
historyFieldName'statusHistory'Name of the transition history field
internalAccesssee belowDecides who reads the history and reads or writes the notes
notestrueAdds internal notes to the order
notesFieldName'internalNotes'Name of the internal notes field
ordersSlug'orders'Slug of the orders collection
statespending-payment, on-hold, shipped, failedExtra states merged into the status field
statusFieldName'status'Name of the status field
trackingtrueAdds the tracking number and carrier fields
trackingCarrierFieldName'trackingCarrier'Name of the carrier field
trackingNumberFieldName'trackingNumber'Name of the tracking number field
trackingStates['shipped', 'completed']States in which the tracking fields are shown
transitionssee belowReplaces the built-in transition map
usersSlug'users'Collection the by and author relationships point at

A state may be written as a string or as { label, value }. A bare string becomes its own label, so 'awaiting-stock' is shown as Awaiting stock. A value that is empty, or that repeats one already listed, is dropped rather than applied. trackingStates: [] places no restriction at all and shows the tracking fields in every state.

The default states

ValueLabelFills the gap
pending-paymentPending paymentbefore the money arrives
on-holdOn holdstopped, waiting on the shop or the customer
shippedShippedbetween processing and completed
failedFailedpayment or fulfillment gave up

They are appended after the four official options, in that order. Passing states replaces the list; passing states: [] adds none.

The default transition map

Only read when guardTransitions is true.

FromMay become
pending-paymentprocessing, on-hold, cancelled, failed
processingon-hold, shipped, completed, cancelled, failed, refunded
on-holdprocessing, shipped, completed, cancelled, failed
shippedcompleted, cancelled, refunded
completedrefunded
cancelledrefunded
refundednothing
failedprocessing, cancelled

A state that is not a key of the map is never refused, so adding your own states does not lock the shop out. Passing transitions replaces the whole map.

import { InvalidTransitionError } from 'payload-fulfillment'

try {
  await payload.update({ collection: 'orders', id, data: { status: 'processing' } })
} catch (error) {
  if (error instanceof InvalidTransitionError) {
    console.log(error.from, error.to, error.allowed)
  }
}

The default internal access

denyOrderCustomer, exported so you can compose with it. It refuses an anonymous request, refuses the user named in the order's customer, and refuses a guest whose email matches the order's customerEmail. Everyone else who can already read the order sees the field, which under the official plugin's isAdmin OR isDocumentOwner read access means the shop and not the buyer.

If your orders collection names its customer differently, or lets strangers read orders, pass your own internalAccess.

What it adds to your database

FieldTypeNotes
statusselectthe existing field, with the extra options appended. Created in full if it is missing
trackingNumbertextindexed, sidebar, shown in trackingStates
trackingCarriertext or selectsidebar, shown in trackingStates
statusHistoryarrayread only, closed to the API
statusHistory.fromtextthe state left behind, empty on the first entry
statusHistory.totextthe state entered
statusHistory.atdateISO timestamp written by the hook
statusHistory.byrelationshipthe user, when they belong to usersSlug
statusHistory.byEmailtexttheir email, kept as a copy that survives a deleted user
internalNotesarraygated by internalAccess
internalNotes.notetextarearequired
internalNotes.atdatestamped once, on the write that created the note
internalNotes.authorrelationshipstamped once
internalNotes.authorEmailtextstamped once

No collections are added. The plugin appends one beforeChange hook to the orders collection and touches nothing else.

Honest limits

The plugin must run after the one that defines the orders collection. It extends a collection that already exists in the incoming config. Listed before ecommercePlugin, it finds no orders collection, returns the config untouched, and says nothing. If the fields do not appear, check the order of the plugins array first.

Two simultaneous writes to the same order can lose an entry. The history is rebuilt from originalDoc, which each request read inside its own transaction. Two admins changing the status of the same order in the same instant produce two arrays built from the same starting point, and the second write wins whole. The status itself behaves the same way, with or without this package. If you need an audit trail that survives that, it has to be a separate collection committing on its own, and that carries the connection cost described above.

Only writes that go through Payload are recorded. A status changed directly in the database, or through a payload.db call, leaves no entry. The hook is the only writer.

The guard is a rule, not a lock. It refuses through Payload's Local, REST and GraphQL APIs. It is off by default so that adopting the package cannot break an existing admin workflow, and it never refuses a transition out of a state its map does not mention.

Add states, do not remove them. Removing a state after orders have been saved in it leaves those orders holding a value the field no longer offers. Changing the options of a select field also changes the shape of the collection: generate and apply a Payload migration before deploying to a database that runs them.

Note text stays editable. author, authorEmail and at are stamped once and restored from the stored order on every later write, so they cannot be rewritten. The text of an existing note can still be changed by anyone internalAccess lets write notes. The history is the append-only record; the notes are a workspace.

No timeline widget. The history is a read-only array field and the notes are a plain array field, drawn by Payload's own inputs. That is deliberate: admin components are where third party Payload packages break on minor releases.

License

MIT. Copyright George Vasiliades, https://github.com/Poseidonas

Similar plugins