polar
polar copied to clipboard
docs: Handling expirations with one-time product
trafficstars
$200
write a guide that talks about how to use license keys to enforce expiration on a one-time product purchase
context
in cases where someone sells a one time pruchase product but wants to make sure that the purchase say last for a certain period, then they can:
attach the license key benefit to the product for that much period (i.e. expiry) and then use the webhooks to automatically sync the state of the license key via the benefit_grant.created and benefit_grant.revoked webhooks:
- show the benefit creation steps (set up a license key benefit that expires in 3 days)
- show the product creation steps
- show the webhooks setup (single screenshot of the URL, events selected)
- show a simple endpoint (in JS) with pseudo code of how the event will be parsed (use the guide) and then the grant/revoke will be handled in a database (say redis, use Upstash.com)
- perform a purchase but show a customer portal view of someone purchased with the email in the view (can use temp-mail)
- show the webhook events firing on grant and revoke
- show the database changed entry