Commerce API
Digital products
Sell files, licences and downloads. Delivered the moment payment clears.
A digital product needs no stock, no shipping and no fulfilment step. When the payment clears, entitlements are granted inside the same transaction that records it — so there is no window where money has been taken and nothing is owed.
const result = await mercestack.checkout({ email });
if (result.library) {
const library = await mercestack.getLibrary(result.library.accessToken);
for (const item of library.items) {
item.name; // "Handbook.pdf"
item.version; // "2026 edition"
item.licenseKey; // "MSTK-A3F9-K2MN-7PQR", or null
item.downloadsRemaining; // null means unlimited
item.available; // one flag, decided server-side
item.unavailableReason; // why not, when not
}
const { url, expiresIn } = await mercestack.getDownloadUrl(
result.library.accessToken,
library.items[0].entitlementId,
);
}How delivery is protected
- A download link is single use and lives for ten minutes. Forwarded to a group chat, it is dead before anyone else clicks it.
- The download count is spent when the link is *followed*, not when it is created — a link your customer never clicked costs them nothing.
- Files are never served from a permanent storage URL. There is nothing to leak that keeps working.
- Refunding an order withdraws access, and the customer is told why rather than meeting a silent failure.