Each item can be configured to grant a role to the user who purchased it.
[ ] Users can choose whether to associate purchase with their account or get granted an accessKey
If a user chooses to use an accessKey, then an access key is generated and granted the role from the purchasable item when the purchase completes.
In such a case, the accessKey should be included in the redirect for the user.
[ ] accessKeys are inactive by default. Upon first use, it should ask the user if they want to activate their key.
[ ] Product records have the following data:
[ ] A unique name
[ ] A Stripe Purchase Link
[ ] A redirect URL
[ ] A role that is granted
[ ] markers
This might change in the future, but the gist is simple: there is a data structure that lets people store purchasable items in their records and that item contains a way to redirect the user to a product page, a role that is granted, and a URL that the user is redirected to.
[ ] os.requestPurchase(recordName, productName)
Requests that the current user purchase the product from the given record.
This should end up finding the purchasable item and redirect the user to the purchase link with additional information about the exact product that is being purchased.
Before redirecting to Stripe, CasualOS should record an invoice for the event. This invoice will be used to track the payment status of the purchase.
After purchase, CasualOS should ask the user if they want to use their account or get an access key ("I want this for myself" vs "I want a gift card").
Finally, CasualOS can grant the role to the user or accessKey depending on what the user chose.
CasualOS should react to Stripe webhooks to respond to events regarding payment status.
Each item can be configured to grant a role to the user who purchased it.
accessKey
, then an access key is generated and granted the role from the purchasable item when the purchase completes.os.requestPurchase(recordName, productName)
os.recordPurchasableItem(recordName, item)