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

Micropay endpoint #1

Open
agravitis opened this issue Sep 5, 2023 · 1 comment
Open

Micropay endpoint #1

agravitis opened this issue Sep 5, 2023 · 1 comment
Assignees

Comments

@agravitis
Copy link
Contributor

agravitis commented Sep 5, 2023

Class constructor signature should be TwinClient({url: "https://blah.blah.biz.todaq.net/", apiKey: "xyz"}).

Create an info() method that calls that endpoint without auth.

The method should be micropay(url, tokenTypeHash, amount) . The method should:

  • spin up another TwinClient for the provided url and call info() on it.
  • get the destinationAddress from there; also verify that tokenTypeHash and amountmakes sense, otherwise error intelligently using a custom error of type TwinMicropayError , subclassed from TwinError. The custom errors can be subclassed further into TwinMicropayAmountMismatchError and TwinMicropayTokenMismatchError.
  • Then attempt to perform the payment and proxying. Stream results back to the user. Convert any errors we don't know about into TwinErrors.
@sfertman
Copy link
Contributor

sfertman commented Sep 6, 2023

The method should be micropay(url, tokenTypeHash, amount) . ...

Enterprise server can accept any http method + body if required by the paywall server. micropay(url, tokenTypeHash, amount) signature doesn't allow for anything but a request with a predetermined method (GET?) and no body.

Alternatively we could add optional request config like micropay(url, tokenTypeHash, amount, { method?, body?})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants