Short answer
HubSpot's KB: discount codes reduce price by a fixed amount or percentage at payment link checkout. They're only for payment links, not invoices, quotes or subscriptions, and can't be used with automated sales tax. Inactive codes can't be applied.
1. Payment links
Payment links in my demo portal.

2. Other discounts
For quote discounts, see quotes.