File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Reference
2+
3+ - [ REST API] ( rest-api.md )
4+ - [ Configuration] ( configuration.md )
5+ - [ Webhook Handler] ( webhook.md )
6+ - [ Java Client] ( client.md )
Original file line number Diff line number Diff line change 1+ # Java Client
2+
3+ The ` cashu-gateway-client ` module offers REST clients for interacting with the service.
4+
5+ ## Common Methods
6+
7+ Available on all client classes.
8+
9+ | Method | Inputs | Response |
10+ | --------| --------| ----------|
11+ | ` get(Long id) ` | Numeric identifier | Returns the entity with the given id or ` null ` . |
12+ | ` getByEntityId(String entityId) ` | External id (` paymentId ` or ` quoteId ` ) | Returns the matching entity or ` null ` . |
13+ | ` create(T entity) ` | Entity instance | Persists the entity and returns the created object. |
14+ | ` delete(Long id) ` | Numeric identifier | Deletes the entity, response is empty. |
15+
16+ ## PaymentClient
17+
18+ | Method | Inputs | Response | Description |
19+ | --------| --------| ----------| -------------|
20+ | ` getByQuoteId(String quoteId) ` | Quote id | ` GatewayPayment ` linked to the quote. |
21+ | ` updatePayment(GatewayPayment payment) ` | Updated payment | ` GatewayPayment ` after update. |
22+
23+ ## QuoteClient
24+
25+ | Method | Inputs | Response | Description |
26+ | --------| --------| ----------| -------------|
27+ | ` getByInvoiceId(String invoiceId) ` | Lightning invoice id | Matching ` GatewayQuote ` . |
Original file line number Diff line number Diff line change @@ -59,4 +59,4 @@ This document lists configuration properties and environment variables available
5959
6060| Property | Default | Description |
6161| --- | --- | --- |
62- | ` A1b2C3d4.wid ` | ` phoenixd ` | Webhook identifier expected by validator. |
62+ | ` A1b2C3d4.wid ` | ` phoenixd ` | Webhook identifier expected by validator. |
Original file line number Diff line number Diff line change 1+ # REST API
2+
3+ The REST service exposes endpoints for managing quotes and payments. Base URL defaults to ` http://localhost:8080 ` .
4+
5+ ## Quote Endpoints
6+
7+ - ` GET /quote ` – list quotes
8+ - ` POST /quote ` – create a quote
9+ - ` GET /quote/{id} ` – fetch a quote by numeric id
10+ - ` GET /quote/search/findByQuoteId?quoteId=... ` – fetch by external quote id
11+ - ` GET /quote/search/findByInvoiceId?invoiceId=... ` – fetch by Lightning invoice id
12+
13+ ## Payment Endpoints
14+
15+ - ` GET /payment ` – list payments
16+ - ` POST /payment ` – create a payment
17+ - ` GET /payment/{id} ` – fetch a payment by numeric id
18+ - ` GET /payment/search/findByPaymentId?paymentId=... `
19+ - ` GET /payment/search/findByQuoteId?quoteId=... `
Original file line number Diff line number Diff line change 1+ # Webhook Handler
2+
3+ ` cashu-gateway-webhook ` exposes a servlet at ` /webhook ` for processing payment notifications.
4+
5+ ## Request Parameters
6+
7+ | Name | Required | Description |
8+ | ------| ----------| -------------|
9+ | ` wid ` | Yes | Identifies the webhook source (` phoenixd ` or ` dummy ` ). If absent in the request, the system property ` wid ` is used. |
10+ | ` type ` | Yes (phoenixd) | Expected value ` payment_received ` . |
11+ | ` amountSat ` | Yes (phoenixd) | Payment amount in satoshis. |
12+ | ` paymentHash ` | Yes (phoenixd) | Lightning payment hash. |
13+ | ` externalId ` | Yes (phoenixd) | Lightning invoice identifier used to look up the quote. |
14+
15+ The webhook expects parameters in an ` application/x-www-form-urlencoded ` payload.
16+
17+ ### Example
18+
19+ ```
20+ POST /webhook
21+ wid=phoenixd&type=payment_received&amountSat=1000&paymentHash=<hash>&externalId=<invoice>
22+ ```
23+
24+ ## Validation Rules
25+
26+ Requests with ` wid=phoenixd ` are validated as follows:
27+
28+ 1 . Retrieve the quote by ` externalId ` and ensure it exists and has direction ` RECEIVE ` .
29+ 2 . Load the payment linked to the quote.
30+ 3 . Confirm ` paymentHash ` and ` amountSat ` match the stored payment.
31+ 4 . Verify the payment state is ` PAID ` and the webhook ` type ` is ` payment_received ` .
32+
33+ If validation succeeds, the payment is marked ` CONFIRMED ` and a ` 201 Created ` response is returned. Any failure results in ` 401 Unauthorized ` .
34+
35+ The ` dummy ` webhook id is provided for testing and creates a placeholder payment without validation.
You can’t perform that action at this time.
0 commit comments