Paid Downloads · Documentation
User guide
Set up Paid Downloads, connect a payment provider, list your first product and help buyers when something goes wrong.
Pre-release. This guide covers version 1.0 ahead of launch, so a few names on screen may still change.
Before you start
- A Statamic 6 or Craft CMS 5 site on PHP 8.2 or newer, with the
curl,json,hashandmbstringextensions. - A Stripe account, a PayPal business account, or both.
- Somewhere private to keep your files: a folder on your server outside the web root, or an S3-compatible bucket with public access turned off.
- Working email on your site. Buyers get their download links by email, so send yourself a test message first.
- A scheduled task, so update emails and renewal reminders go out. The exact line for each CMS is in the install steps.
Install
Statamic 6
- Add the addon with Composer,
composer require deadmachines/download-suite-statamic, then runphp artisan migrate. - Put your keys in
.env. Start withDOWNLOAD_SUITE_MODE=testand your Stripe test keys or PayPal sandbox keys. Every setting is listed inconfig/download-suite.php. - Open Downloads in the control panel and make a product.
- Add the buy form to a template:
{{ download_suite:buy product="prd_..." }}. - Add Laravel's scheduler to cron:
* * * * * php artisan schedule:run. It sends update emails every 5 minutes and renewal reminders once a day. - Run
php artisan download-suite:checkto check your keys, storage and mail.
Craft CMS 5
- Add the plugin with Composer,
composer require deadmachines/download-suite-craft, then runphp craft plugin/install download-suite. - Copy the plugin's
src/config.phptoconfig/download-suite.php. Keys go in.envonly. Start withDOWNLOAD_SUITE_MODE=testand your Stripe test keys or PayPal sandbox keys. - Open Downloads in the control panel and make a product. Give editors the Manage products, buyers and payments permission.
- Add the buy form to a template:
{{ craft.downloadSuite.buyForm('prd_...') }}. - Add two cron lines:
*/5 * * * * php craft download-suite/send/updatesand0 9 * * * php craft download-suite/send/reminders. - Run
php craft download-suite/checkto check your keys, storage and mail.
On both, buyers' download pages live under /downloads/.
Basic settings
- Signing key: a secret the plugin uses to sign download links. The plugin can generate a 64-character key for you. Keep it the same on every server that runs your site, or links made on one server won't work on another. Changing it stops file links already handed out, and the unsubscribe links in emails already sent. Buyers' download pages keep working.
- Site name: how your shop is named in buyer emails.
- Seller email and from address: where your notices go, and who buyer emails come from.
- Link lifetimes: file links last 1 hour by default (60 seconds at the least). Links into a storage bucket last 5 minutes by default (30 seconds at the least). Most sites never change these.
Choose storage
Pick one place for your files. Both keep files private: buyers only ever get a short-lived link.
A private folder on your server
- Put the folder outside the web root, so nobody can reach a file by guessing its address.
- Set the folder to
750(or700). The plugin makes new folders750and files640. - You never need
777. The self-test fails a folder anyone on the server can write to. - If PHP runs as a different user from your own account, make the PHP user the folder's owner rather than opening up the permissions.
- Files are sent to the buyer straight from the folder, through PHP.
An S3-compatible bucket
- Works with Amazon S3, Cloudflare R2 and other S3-compatible services.
- Turn off public access on the bucket. The self-test fails a bucket that serves files to anyone.
- Give the plugin an access key that can read, write and delete in that bucket.
- Buyers are sent to a signed bucket link that lasts a few minutes, so large files don't pass through your server.
- Uploads from the admin go to the bucket in one piece, up to 5 GB per file.
Connect Stripe
- In Stripe, copy your secret key (or a restricted key) into the plugin's Stripe settings. Use a test key until you've made a test purchase.
- In Stripe's webhook settings, add an endpoint at your site's address followed by
/!/download-suite/webhook/stripeon Statamic, or/download-suite/webhook/stripeon Craft. - Send these events to it:
checkout.session.completedcheckout.session.async_payment_succeededcheckout.session.async_payment_failedcheckout.session.expiredcharge.refunded
invoice.paid,invoice.payment_failed,customer.subscription.updatedandcustomer.subscription.deleted. - Copy the endpoint's signing secret into the plugin. Without it, purchases never unlock.
- Send a test event from Stripe, then run the self-test. The Stripe line should say when the last webhook arrived.
Connect PayPal
- In the PayPal developer dashboard, create an app and copy its client ID and secret into the plugin. Leave sandbox mode on until you've made a test purchase.
- Add a webhook to the app at your site's address followed by
/!/download-suite/webhook/paypalon Statamic, or/download-suite/webhook/paypalon Craft, and subscribe it to:CHECKOUT.ORDER.APPROVEDPAYMENT.CAPTURE.COMPLETEDPAYMENT.CAPTURE.DENIEDandPAYMENT.CAPTURE.DECLINEDPAYMENT.CAPTURE.REFUNDEDPAYMENT.CAPTURE.REVERSED
PAYMENT.SALE.COMPLETED,PAYMENT.SALE.REFUNDED,PAYMENT.SALE.REVERSEDand theBILLING.SUBSCRIPTION.*events. - Copy the webhook ID into the plugin. Without it, refunds and late payments are missed.
- Ask for the buyer's email on your buy form. PayPal's payment notice doesn't include it, so asking up front means access starts without a gap.
- Switch sandbox mode off when you go live, and swap in your live app's details.
Create a listing
- Create a product and choose single file or file group. A file group is one product with several files. Bundles of separate products aren't in 1.0.
- Give it a name and a price. For a subscription, see the next section.
- Attach the file, or several files for a group. You can also link a file that's already in your storage.
- Set its access limits (next section), then save.
Each upload is checked before it's stored:
- Size: 500 MB by default. Your server's own upload limit (
upload_max_filesize) still applies, so raise that too for big files. - File type: a broad list of digital-goods formats is allowed by default, and you can change it.
- Always blocked: files a web server could run or obey, like
.php,.phtml,.pharand.htaccess, even if you add them to the allowed list. A file with PHP code hidden inside an allowed type is refused too. - File names: the plugin makes its own storage path for each file, so a strange file name can't end up somewhere it shouldn't.
If an upload fails, the message says why in plain words. If storage fails partway through a new listing, the files already written are removed and the listing is kept as a hidden draft.
Sell a subscription
Any product can be sold as a subscription that renews automatically. Stripe or PayPal does the charging and any retries, and the plugin keeps the buyer's access in step.
- Choose subscription when you set the product's price, then pick how often it renews: yearly, every 1 to 12 months, or every 1 to 52 weeks.
- The product's price is the first period's price. Set a renewal price for every period after it, for example $89 for the first year and then $49 a year.
- Add the subscription events to your Stripe and PayPal webhooks (see the two sections above), and turn on Stripe's customer portal so buyers can change their card.
From then on:
- Paid: the first payment starts access, and each renewal extends it to the new period end plus 7 grace days. If the product has a download cap, the counts reset each period.
- Failed card: the buyer gets one email with a link to update their card, and keeps access through the grace days while Stripe or PayPal tries again.
- Renewal reminder: yearly subscribers get an email 15 days before they renew. You can turn reminders on for shorter plans too.
- Cancelled: buyers cancel from their download page, Stripe's customer portal or their PayPal account, and you can cancel from the buyer list. Renewals stop, the buyer keeps the time they paid for, and they get one confirmation email.
- Refunded: a full refund of any subscription payment ends access. The refund doesn't cancel the subscription at Stripe or PayPal, so cancel it there too if the buyer shouldn't be charged again.
Every one of these events is recorded in the buyer's activity log, with the provider's subscription ID. A discount code applies to the first period and can't make it free. The subscription sets the buyer's dates, so a product's "days after purchase" expiry doesn't apply to subscribers, while a fixed end date and download caps still do. Plan and price changes apply to new subscribers.
Stripe and PayPal can send their own reminder and failed-payment emails. Leave theirs off, or turn off the plugin's subscription emails, so buyers don't get two.
Set access limits
- Expiry: a number of days after purchase, a fixed date, or both.
- Download cap: per file, or across the whole purchase.
- No limits: leave both empty and access lasts until you revoke it or the buyer is refunded.
Whichever limit is reached first ends access. Each purchase keeps the limits it was sold with, so a later change only affects new buyers.
Publish a new version
- Replace the file on the product, and give the new version a number and a short summary of what changed.
- The update emails are queued for past buyers and sent in batches.
- The old file is deleted unless you choose to keep it, or another listing still uses it. Files you linked by hand are never deleted.
Adding a file to a group sends the same emails. New versions are free to buyers who still have access. Buyers whose access ended get a buy-again link instead. Refunded and revoked buyers get nothing.
Discount codes
- A percent or a fixed amount off.
- Optional end date, use limit and list of products it applies to.
- A use counts when the payment completes, not when checkout starts.
- A 100% code gives access straight away with no payment step.
Buyer emails
| Sent when | |
|---|---|
| Purchase | A payment is confirmed. Holds the download page link and any limits. |
| Resend | You resend a buyer's link. |
| Update, still has access | A new version ships. Holds a fresh link. |
| Update, access ended | A new version ships. Holds a buy-again link. |
| Test | The self-test runs. |
You can rewrite every email. Placeholders in double braces are filled in when it's sent, for example {{product_name}}, {{site_name}}, {{download_url}}, {{expires_on}} and {{download_limit}}. Update emails also have {{version}}, {{summary}} and {{unsubscribe_url}}, and the buy-again email uses {{buy_url}} in place of the download link.
Buyer-facing words go through your CMS's language files, so you can translate them.
Every update email has one-click unsubscribe. An opt-out covers all update emails from your site, and it's checked again just before each email is sent. Purchase emails always go out.
Helping a buyer
Each buyer row shows the email address and the download page link. From there:
- Resend: sends the download email again.
- Fix the email address: corrects it on the purchase and the order, and can resend to the new address. An opt-out on the old address carries over.
- Copy link: copies the buyer's own download page link to send by hand. The purchase's limits still apply, and you're warned if the buyer would find nothing to download.
- Renew: starts access again from today, even after it expired or the downloads ran out. By default it uses the product's current limits and resets the counts. You can pick other limits or keep the counts, issue a new link (old links stop working) and resend the email in the same step. A refunded or revoked purchase has to be restored first.
- Also: extend, change the download cap, reset counts, revoke and restore, or gift access.
Every action you take is kept in the buyer's activity log, with who did it.
Refunds
- Refund from your Stripe or PayPal dashboard. The plugin hears about it by webhook.
- A full refund, or a PayPal reversal, ends the buyer's access.
- A partial refund keeps access.
- An open dispute or chargeback leaves access as it is. You can revoke access yourself from the buyer list.
- Renewing never undoes a refund.
Self-test and support info
Run the self-test after setup and after any change to your server, storage or payment settings. It never changes your data. Each line is PASS, WARN, FAIL or SKIP, with what to do next.
"Copy support info" gives you a plain-text report: core and PHP versions, which payment providers are on, when their last webhooks arrived, your storage type, counts of products and buyers, and the self-test results. Secrets are never included, only whether each one is set. Paste it into any support request.
Troubleshooting
| The self-test says | What to do |
|---|---|
| Signing key works but is short. | Generate a new 64-character key. File links already handed out stop working. |
| Signed links did not verify correctly. | Make sure every server uses the same signing key. |
| The storage folder is inside the public web root. | Move the folder outside the web root, then update its path. |
| PHP cannot write to the storage folder. | Make the folder owned by the user PHP runs as. Don't use 777. |
| The bucket refused the keys (403). | Check the access key, secret and the bucket's permissions. |
| Bucket … lets anyone download its files without paying. | Turn off public access on the bucket. |
| Stripe keys are set but the webhook signing secret is missing. | Add the signing secret from your Stripe webhook endpoint. |
| PayPal keys are set but the webhook id is missing. | Add the webhook ID from your PayPal app. |
| … is set up, but no webhook has arrived yet. | Send a test event from the provider's dashboard and check the webhook address. |
A buyer paid but has no email
- Check the buyer list. If the purchase is there, resend, or fix the address if it was mistyped.
- If there's no purchase, run the self-test and check the payment line. A missing webhook secret or ID is the usual cause.
- If an order shows as held for review, the amount paid didn't match the order. Check it in your payment dashboard before you give access.
Update emails aren't going out
Check that your site's queue or scheduled task is running, and that the test email in the self-test arrives.