-
Notifications
You must be signed in to change notification settings - Fork 82
custom payment methods #382
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
Open
asmogo
wants to merge
5
commits into
cashubtc:main
Choose a base branch
from
asmogo:generic-payment-method
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2ed6709
Add generic payment method support
asmogo 6ade8b4
feat(nut04/05): widen common quote structs for custom payment methods
robwoodgate 491d3c3
Merge pull request #1 from robwoodgate/feat/382-custom-base-structs
asmogo 3d98925
Merge branch 'main' into generic-payment-method
asmogo b984b1f
fix: prettier
asmogo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,6 +101,35 @@ The mint then responds with: | |
|
|
||
| where `signatures` is an array of blind signatures on the outputs. | ||
|
|
||
| ## Custom Payment Methods | ||
|
|
||
| Payment methods not specified in a dedicated NUT can be supported as custom payment methods. A custom payment method is identified by a lowercase string `{method}` (e.g., `paypal`, `stripe`, `onchain-payment-processor`). The `{method}` string **MUST** contain only ASCII alphanumeric characters, hyphens (`-`), and underscores (`_`), and **MUST** be non-empty. | ||
|
|
||
| ### Mint Quote | ||
|
|
||
| For a custom `{method}`, the wallet sends a request following the common mint quote request format (see [General Flow](#general-flow)). Method-specific fields (e.g., an `amount` of tokens to mint, a `description`, or a `pubkey` for [NUT-20][20] locks) are defined by the method-specific NUT. | ||
|
|
||
| The mint responds with the common mint quote response format. The `request` field contains the method-specific payment request (e.g., a payment URL, an on-chain address, an account identifier). Additional method-specific fields (such as `amount` or `expiry`) are defined by the method-specific NUT. | ||
|
|
||
|
|
||
| ### Method-Specific Fields | ||
|
|
||
| Custom payment methods **MAY** include additional fields in requests and responses. Implementations **MUST** ignore unrecognized fields to preserve forward compatibility. When a custom method gains widespread adoption, its fields **MAY** be formalized in a dedicated NUT. | ||
|
|
||
| Custom payment methods **MAY** include extra fields that the mint forwards to the payment processor without validation. | ||
|
|
||
| ### Websocket Notifications | ||
|
|
||
| Custom methods **MAY** support websocket subscriptions via [NUT-17][17] with kind `"{method}_mint_quote"`. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Related: #372 |
||
|
|
||
| ### Cached Responses | ||
|
|
||
| Custom method endpoints **MAY** support caching via [NUT-19][19] (e.g., `POST /v1/mint/{method}`). | ||
|
|
||
| ### Amount Precision | ||
|
|
||
| If an `amount` is provided, fiat-denominated units (e.g., `usd`, `eur`) **SHOULD** represent the value in the smallest currency unit (e.g., cents). For example, `"amount": 100` with `"unit": "usd"` represents $1.00 USD. | ||
|
|
||
| ## Adding New Payment Methods | ||
|
|
||
| To add a new payment method (e.g., BOLT12), implement the following: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,6 +203,24 @@ GET https://mint.host:3338/v1/melt/quote/bolt11/TRmjduhIsPxd... | |
| } | ||
| ``` | ||
|
|
||
| ## Custom Payment Methods | ||
|
|
||
| Payment methods not specified in a dedicated NUT can be supported as custom payment methods. See [NUT-04][04] for the custom method identifier definition and general conventions. | ||
|
|
||
| ### Melt Quote | ||
|
|
||
| For a custom `{method}`, the wallet sends a request following the common melt quote request format (see [General Flow](#general-flow)). The `request` field is the method-specific payment target (e.g., a bank account identifier, an on-chain address, a payment processor reference). `unit` is the unit the wallet would like to pay with. | ||
|
|
||
| The mint responds with the common melt quote response format. Method-specific fields are defined by the method-specific NUT. | ||
This comment was marked as resolved.
Sorry, something went wrong. |
||
|
|
||
| ### Websocket Notifications | ||
|
|
||
| Custom methods **MAY** support websocket subscriptions via [NUT-17][17] with kind `"{method}_melt_quote"`. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Related: #372 |
||
|
|
||
| ### Cached Responses | ||
|
|
||
| Custom method endpoints **MAY** support caching via [NUT-19][19] (e.g., `POST /v1/melt/{method}`). | ||
|
|
||
| ## Adding New Payment Methods | ||
|
|
||
| To add a new payment method (e.g., BOLT12), implement the following: | ||
|
|
@@ -257,6 +275,8 @@ The mint's settings for this NUT indicate the supported method-unit pairs for me | |
| [10]: 10.md | ||
| [11]: 11.md | ||
| [12]: 12.md | ||
| [17]: 17.md | ||
| [19]: 19.md | ||
| [23]: 23.md | ||
| [25]: 25.md | ||
| [30]: 30.md | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.