accounts.js
Members
(constant) accounts#
Handles user specific accounts with **balance**s that increase with **deposit**s from receipt verified WebMonetization payments and are **deduct**ed when streaming media data to the client.
- Source:
#
paywallThresholdpaywallThreshold has two functions: 1. Speed up the inital load of media by allowing some content to be loaded before the wallet is ready to pay (this can take few seconds). 2. Create a "preview" mode where some content can be shown also to users that don't have wallet set up, while instructing them to set up a wallet once the initial balance has run out.
- Source:
Methods
(userId) โ {number}#
balanceGet users specific account balance. Creates and returns initial amount for new users ("paywallThreshold"), if user don't exist.
Parameters:
Name | Type | Description |
---|---|---|
userId | string |
- Source:
Returns:
users balance
- Type
- number
(userId, amount) โ {number}#
depositIncrements user specific account with given amount.
Parameters:
Name | Type | Description |
---|---|---|
userId | string | |
amount | number | amount to be deposited |
- Source:
Returns:
users balance after the deposit.
- Type
- number
(userId, amount) โ {boolean}#
spendDeducts given amount from users account, if the accounts balance is equal or larger to the given amount.
Parameters:
Name | Type | Description |
---|---|---|
userId | string | |
amount | number | to be spent |
- Source:
Returns:
true for succesfull action, false for failure.
- Type
- boolean