Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement dynamic per-request prices #21

Open
philippgille opened this issue Sep 15, 2018 · 0 comments
Open

Implement dynamic per-request prices #21

philippgille opened this issue Sep 15, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@philippgille
Copy link
Owner

Currently you can only set different amounts for different endpoints, but this means that all requests to one endpoint cost the same.

This can be improved upon, for example when there's a translation API, a per-character-billing would be the most dynamic billing possible.

This could be achieved by having a new set of middleware factory functions, which don't take wall.InvoiceOptions as parameter, but a func (req http.Request) (int64, string), which can determine the cost according to the amount of characters (or whatever) in the request body or query params etc.

So not just the amount, but also the memo could be dynamic.

Attention though: Currently it's possible (and nice, and common in other LN paywall projects) to first send a request only to the URI, without body and without query params.

In order to prevent the client from cheating (send request with view characters first, then one with many more after the payment), something must be done like: Cache the price of the invoice after the first request, then recalculate the price after the second request, make sure the amounts match.

This also requires #16 to be fixed first.

@philippgille philippgille added the enhancement New feature or request label Sep 15, 2018
@philippgille philippgille changed the title Implement dynamic invoice amounts Implement dynamic per-request prices Sep 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant