Adds digital product delivery to a Payload store. Products or variants carry downloadable files, a completed order creates access grants, and customers get signed links that expire, count uses and stop working when an order is refunded or cancelled. Requires Payload 3.88 or newer and the official ecommerce plugin; local storage works by default and other storage needs a file resolver.
Digital products for Payload ecommerce: signed expiring download links, per order access and download limits.
Installation
npm i payload-downloads1
Stars
0
Forks
0
Open Issues
2 weeks ago
Last Updated
26
Weekly Downloads
v1.0.2
npm Version
48.6 KB
Unpacked Size
0
Dependencies
10 since Sep 6
| Date | Stars |
|---|---|
| Dec 5, 2026 | 1 |
| Dec 4, 2026 | 1 |
| Dec 3, 2026 | 1 |
| Dec 2, 2026 | 1 |
| Dec 1, 2026 | 1 |
| Nov 30, 2026 | 1 |
| Nov 29, 2026 | 1 |
| Nov 28, 2026 | 1 |
| Nov 27, 2026 | 1 |
| Nov 26, 2026 | 1 |
| Nov 25, 2026 | 1 |
| Nov 24, 2026 | 1 |
| Nov 23, 2026 | 1 |
| Nov 22, 2026 | 1 |
| Nov 21, 2026 | 1 |
| Nov 20, 2026 | 1 |
| Nov 19, 2026 | 1 |
| Nov 18, 2026 | 1 |
| Nov 17, 2026 | 1 |
| Nov 16, 2026 | 1 |
| Nov 15, 2026 | 1 |
| Nov 14, 2026 | 1 |
| Nov 13, 2026 | 1 |
| Nov 12, 2026 | 1 |
| Nov 11, 2026 | 1 |
| Nov 10, 2026 | 1 |
| Nov 9, 2026 | 1 |
| Nov 8, 2026 | 1 |
| Nov 7, 2026 | 1 |
| Nov 6, 2026 | 1 |
| Nov 5, 2026 | 1 |
| Nov 4, 2026 | 1 |
| Nov 3, 2026 | 1 |
| Nov 2, 2026 | 1 |
| Nov 1, 2026 | 1 |
| Oct 31, 2026 | 1 |
| Oct 30, 2026 | 1 |
| Oct 29, 2026 | 1 |
| Oct 28, 2026 | 1 |
| Oct 27, 2026 | 1 |
| Oct 26, 2026 | 1 |
| Oct 25, 2026 | 1 |
| Oct 24, 2026 | 1 |
| Oct 23, 2026 | 1 |
| Oct 22, 2026 | 1 |
| Oct 21, 2026 | 1 |
| Oct 20, 2026 | 1 |
| Oct 19, 2026 | 1 |
| Oct 18, 2026 | 1 |
| Oct 17, 2026 | 1 |
| Oct 16, 2026 | 1 |
| Oct 15, 2026 | 1 |
| Oct 14, 2026 | 1 |
| Oct 13, 2026 | 1 |
| Oct 12, 2026 | 1 |
| Oct 11, 2026 | 1 |
| Oct 10, 2026 | 1 |
| Oct 9, 2026 | 1 |
| Oct 8, 2026 | 1 |
| Oct 7, 2026 | 1 |
| Oct 6, 2026 | 1 |
| Oct 5, 2026 | 1 |
| Oct 4, 2026 | 1 |
| Oct 3, 2026 | 1 |
| Oct 2, 2026 | 1 |
| Oct 1, 2026 | 1 |
| Sep 30, 2026 | 1 |
| Sep 29, 2026 | 1 |
| Sep 28, 2026 | 1 |
| Sep 27, 2026 | 1 |
| Sep 26, 2026 | 1 |
| Sep 25, 2026 | 1 |
| Sep 24, 2026 | 1 |
| Sep 23, 2026 | 1 |
| Sep 22, 2026 | 1 |
| Sep 21, 2026 | 1 |
| Sep 20, 2026 | 1 |
| Sep 19, 2026 | 1 |
| Sep 18, 2026 | 1 |
| Sep 17, 2026 | 1 |
| Sep 16, 2026 | 1 |
| Sep 15, 2026 | 1 |
| Sep 14, 2026 | 1 |
| Sep 13, 2026 | 1 |
| Sep 12, 2026 | 1 |
| Sep 11, 2026 | 1 |
| Sep 10, 2026 | 1 |
| Sep 9, 2026 | 1 |
| Sep 8, 2026 | 1 |
| Sep 7, 2026 | 1 |
| Sep 6, 2026 | 1 |
22+3 since Sep 6
| Date | Weekly downloads |
|---|---|
| Dec 5, 2026 | 22 |
| Dec 4, 2026 | 23 |
| Dec 3, 2026 | 25 |
| Dec 2, 2026 | 28 |
| Dec 1, 2026 | 26 |
| Nov 30, 2026 | 24 |
| Nov 29, 2026 | 22 |
| Nov 28, 2026 | 29 |
| Nov 27, 2026 | 36 |
| Nov 26, 2026 | 223 |
| Nov 25, 2026 | 218 |
| Nov 24, 2026 | 217 |
| Nov 23, 2026 | 218 |
| Nov 22, 2026 | 214 |
| Nov 21, 2026 | 204 |
| Nov 20, 2026 | 195 |
| Nov 19, 2026 | 8 |
| Nov 18, 2026 | 10 |
| Nov 17, 2026 | 9 |
| Nov 16, 2026 | 7 |
| Nov 15, 2026 | 7 |
| Nov 14, 2026 | 9 |
| Nov 13, 2026 | 8 |
| Nov 12, 2026 | 12 |
| Nov 11, 2026 | 10 |
| Nov 10, 2026 | 11 |
| Nov 9, 2026 | 11 |
| Nov 8, 2026 | 12 |
| Nov 7, 2026 | 12 |
| Nov 6, 2026 | 13 |
| Nov 5, 2026 | 9 |
| Nov 4, 2026 | 10 |
| Nov 3, 2026 | 9 |
| Nov 2, 2026 | 10 |
| Nov 1, 2026 | 7 |
| Oct 31, 2026 | 5 |
| Oct 30, 2026 | 4 |
| Oct 29, 2026 | 2 |
| Oct 28, 2026 | 1 |
| Oct 27, 2026 | 2 |
| Oct 26, 2026 | 2 |
| Oct 25, 2026 | 3 |
| Oct 24, 2026 | 3 |
| Oct 23, 2026 | 3 |
| Oct 22, 2026 | 7 |
| Oct 21, 2026 | 7 |
| Oct 20, 2026 | 7 |
| Oct 19, 2026 | 6 |
| Oct 18, 2026 | 5 |
| Oct 17, 2026 | 5 |
| Oct 16, 2026 | 5 |
| Oct 15, 2026 | 4 |
| Oct 14, 2026 | 5 |
| Oct 13, 2026 | 4 |
| Oct 12, 2026 | 4 |
| Oct 11, 2026 | 5 |
| Oct 10, 2026 | 7 |
| Oct 9, 2026 | 7 |
| Oct 8, 2026 | 5 |
| Oct 7, 2026 | 5 |
| Oct 6, 2026 | 10 |
| Oct 5, 2026 | 11 |
| Oct 4, 2026 | 13 |
| Oct 3, 2026 | 12 |
| Oct 2, 2026 | 17 |
| Oct 1, 2026 | 16 |
| Sep 30, 2026 | 16 |
| Sep 29, 2026 | 15 |
| Sep 28, 2026 | 14 |
| Sep 27, 2026 | 13 |
| Sep 26, 2026 | 16 |
| Sep 25, 2026 | 13 |
| Sep 24, 2026 | 13 |
| Sep 23, 2026 | 12 |
| Sep 22, 2026 | 11 |
| Sep 21, 2026 | 12 |
| Sep 20, 2026 | 13 |
| Sep 19, 2026 | 9 |
| Sep 18, 2026 | 7 |
| Sep 17, 2026 | 9 |
| Sep 16, 2026 | 11 |
| Sep 15, 2026 | 9 |
| Sep 14, 2026 | 9 |
| Sep 13, 2026 | 7 |
| Sep 12, 2026 | 10 |
| Sep 11, 2026 | 12 |
| Sep 10, 2026 | 10 |
| Sep 9, 2026 | 9 |
| Sep 8, 2026 | 9 |
| Sep 7, 2026 | 13 |
| Sep 6, 2026 | 19 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1340409911-root)<a href="https://payloaddirectory.dev/plugins/1340409911-root"><img src="https://payloaddirectory.dev/badge/1340409911-root.svg" alt="Payload Directory"></a>README
Sells digital products from a Payload store: a product or variant carries files, a paid order earns access to them, and the customer receives a signed link that expires, counts its uses and stops working the moment the order is refunded.
@payloadcms/plugin-ecommerce and with any collection that holds ordersnode:crypto HMAC-SHA256, no runtime dependenciesRequires 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-downloads
import { downloadsPlugin } from 'payload-downloads'
export default buildConfig({
plugins: [
downloadsPlugin({
downloadLimit: 5,
expiryDays: 30,
linkTtlSeconds: 300,
}),
],
})
Mark a product or variant downloadable, attach one or more files, and the plugin does the rest.
A signed in customer reads their own downloads from GET /api/downloads:
{
"downloads": [
{
"id": "6a85...",
"downloadCount": 1,
"downloadLimit": 5,
"expiresAt": "2026-09-18T10:00:00.000Z",
"file": { "id": "3", "filename": "guide.pdf", "filesize": 918273, "mimeType": "application/pdf" },
"remaining": 4,
"url": "/api/downloads/file?expires=1800000300&file=3&grant=12&order=8&signature=Xk3...",
"usable": true
}
]
}
To put the same links in your own order email, call downloadLinksForOrder on the server.
completed and not on processingRead from @payloadcms/[email protected]. The order status field is declared with defaultValue: 'processing', and confirmOrder writes status: 'processing' on every order it creates. processing is therefore the value an order carries because it exists, not because money settled: an order typed into the admin by hand, an import, or a second payment adapter all produce the same value without a payment having happened.
Handing over a file cannot be undone. The default grants on completed, which is a deliberate act by the shop. One line moves it earlier if that suits your trade:
downloadsPlugin({ grantOnStatuses: ['processing', 'completed'] })
Read from stripe/confirmOrder.ts, the order is written with
...(req.user ? { customer: req.user.id } : { customerEmail })
A logged in customer's order carries a customer and no customerEmail; a guest order carries an email and no customer. A grant records whichever the order has, and GET /api/downloads matches on both, so a customer who checked out as a guest and later registered with the same address still sees the download.
The link carries grant, order, file, expires and signature. The signature is
HMAC-SHA256( SHA256("payload-downloads:v1:" + secret), "v1\ngrant\norder\nfile\nexpires" )
base64url encoded, 43 characters. The key is derived from the secret rather than being the secret, so the same Payload secret used elsewhere is not the HMAC key. All four values are inside the signed message, separated by a character none of them may contain, so a signature cannot be moved to another file, another order, another grant or a later expiry. Verification compares with timingSafeEqual, and each of those five substitutions is refused by a test of its own.
A valid signature is not by itself permission to download. Before a byte is written the plugin also reloads the grant and refuses it if it is revoked, expired or at its limit, so a refund stops links that were already handed out, not only future ones.
| Option | Default | Meaning |
|---|---|---|
baseUrl | '' | Text placed before a generated link. Empty gives a root relative link |
customersSlug | 'users' | Slug of the customers collection |
disabled | false | Stops granting, revoking and serving but keeps the fields and the collection, so the database keeps its shape |
downloadableFieldName | 'downloadable' | Checkbox marking a product or variant as downloadable |
downloadLimit | 5 | Successful deliveries one grant allows. 0 means no limit |
enableVariants | true | Adds the fields to variants and the variant column to a grant |
endpointPath | '/downloads' | Path below the Payload API route |
expiryDays | 0 | Days a grant stays usable. 0 means no expiry |
filesFieldName | 'downloadFiles' | Upload field holding the files |
fileResolver | none | Reads the bytes when the upload collection does not use local storage |
grantOnStatuses | ['completed'] | Statuses that grant access on the way in |
grantsSlug | 'download-grants' | Collection holding one grant per order and file |
isAdmin | 'admin' in req.user.roles | Who may read every grant. Customers always read their own |
linkTtlSeconds | 300 | Seconds a signed link stays valid |
ordersSlug | 'orders' | Slug of the orders collection |
productsSlug | 'products' | Slug of the products collection |
revokeOnStatuses | ['refunded', 'cancelled'] | Statuses that revoke access on the way in. [] never revokes |
secret | the Payload secret | Key the signature is derived from |
uploadsSlug | 'media' | Upload collection holding the files |
variantsSlug | 'variants' | Slug of the variants collection |
A value that cannot be used is replaced by its default rather than being applied. A negative downloadLimit becomes 5, a linkTtlSeconds of 0 becomes 300, and 3.9 becomes 3. Nothing is silently reinterpreted: -5 never becomes 5. A status that appears in both lists revokes.
| Collection | Field | Type | Notes |
|---|---|---|---|
| your products collection | downloadable | checkbox | indexed, defaults to false |
| your products collection | downloadFiles | upload, hasMany | shown when downloadable is on |
| your variants collection | downloadable | checkbox | omitted when enableVariants is false |
| your variants collection | downloadFiles | upload, hasMany | a downloadable variant overrides its product |
download-grants | order | relationship | indexed, required |
download-grants | file | upload | indexed, required |
download-grants | product, variant | relationship | what the grant came from |
download-grants | customer | relationship | indexed, set for a signed in buyer |
download-grants | customerEmail | indexed, set for a guest buyer | |
download-grants | downloadCount | number | successful deliveries so far |
download-grants | downloadLimit | number | the limit in force when the grant was made |
download-grants | expiresAt | date | empty when expiryDays is 0 |
download-grants | lastDownloadedAt | date | |
download-grants | revoked | checkbox | indexed |
The grants collection refuses create, update and delete through the API; it is written only by the plugin. Read is allowed to a customer for their own rows and to whoever isAdmin accepts.
Two endpoints are added: GET /api/downloads and GET /api/downloads/file.
Exported for server side use: downloadsPlugin, createDownloadLink, downloadLinksForOrder, grantAccess, revokeAccess, downloadableFilesForOrder, grantState, decideTransition, signDownload, verifyDownloadSignature, parseClaim, resolveConfig.
Local storage works out of the box, a storage adapter needs six lines. Payload has no stable public API for reading the bytes behind an upload document when a cloud adapter owns them. Rather than guess at an internal one, the plugin reads from the collection's staticDir and, when that is not available, asks you:
downloadsPlugin({
fileResolver: async ({ filename }) => {
const object = await s3.send(new GetObjectCommand({ Bucket: 'files', Key: filename }))
return { body: object.Body as ReadableStream<Uint8Array>, size: object.ContentLength }
},
})
Without one, a request for a file the plugin cannot read returns 501 and logs. It never redirects to the storage, because a redirect is the storage path.
A signed link is a bearer token. Anyone holding the URL inside its lifetime can download. It is not bound to an IP address, a session or a browser. linkTtlSeconds defaults to 300 for that reason; the customer gets a fresh link from GET /api/downloads whenever they need one.
Rotating the Payload secret invalidates every outstanding link. Set secret explicitly if you need the two to move independently.
A delivery is counted when the response starts, not when it finishes. A customer whose connection drops halfway has still used one of their five. There is no way to know from the server that a stream completed.
The count is atomic where the adapter allows it. The increment is written with $inc through payload.db.updateOne, which was measured at 50 concurrent increments on both the PostgreSQL and MongoDB adapters with none lost. If that call fails the plugin falls back to a read and a write, and in that fallback a burst of simultaneous requests using the same link can exceed the limit by the size of the burst. If the delivery cannot be recorded at all the request is refused with 500 rather than served unmetered.
Range requests are ignored. The whole file is sent from the beginning every time. Resuming an interrupted download starts again and, in the worst case, costs another unit of the limit.
Orders completed before you install get nothing. Grants are created when an order crosses into a granting status. Existing completed orders stay without grants until they are saved again.
Files are matched per order, not per line. Buying the same product twice on one order produces one grant with one limit, not two.
MIT. Copyright George Vasiliades, https://github.com/Poseidonas
ecommerce
Ecommerce utilities for Payload with idempotent Stripe confirmation, orders, carts and inventory handling
10019.0k/wk46.1kv3 v4
payload ecommerce
Products, carts, orders and coupons for Payload 3 with server-side helpers and stock tracking
72537/wk2v3
payload tax eu
Calculates and records EU VAT on Payload orders, with reverse charge, VAT number checks and OSS reports
6811/wk1v3
payload plugin ecommerce digitaldownload
Digital download support for Payload ecommerce setups
4215/wk2v3
payload stock reservation
Validates variant stock and price at checkout and holds stock until payment settles or the hold expires
76152/wk1v3
payload coupons
Coupon codes with percentage and fixed discounts for Payload ecommerce, calculated in integer minor units
76144/wk2v3