Skip to content

feat(MER-155): Open Payments webhook on the management API - #19

Merged
beniaminmunteanu merged 2 commits into
mainfrom
beniamin/mer-155-webhook
Nov 25, 2026
Merged

beniaminmunteanu merged 2 commits into
mainfrom
beniamin/mer-155-webhook

Conversation

@beniaminmunteanu

Copy link
Copy Markdown
Member

Summary

Adds the webhook that tells the Merchant API a card payment has completed. With the finalize endpoint (#17), the terminal approves, the Merchant API creates the outgoing payment, and this webhook is how the Merchant API learns that the money arrived.

sequenceDiagram
    participant POS
    participant MerchantAPI as Merchant API
    participant OP as Open Payments provider (Rhyza)
    POS->>MerchantAPI: POST /v1/transactions/{requestId}/finalize (approve)
    MerchantAPI->>OP: create outgoing payment
    OP-->>MerchantAPI: POST /v1/webhooks/open-payments (payment_intent.completed)
    MerchantAPI-->>POS: 200 completed
Loading
 merchant-api.yaml
 paths:
+  /v1/webhooks/open-payments:           # receiveOpenPaymentsWebhook, no auth (trusted network)
+    post: OpenPaymentsWebhook -> 204 | 400 | 409 | 500
 components:
   responses:
+    WebhookConflict                     # 409 payment-not-completable
   schemas:
+    OpenPaymentsWebhook { id, type, data }
+    OpenPaymentsWebhookData { id, metadata }

How the Merchant API answers:

on(notification)
  if type is not payment_intent.completed      -> 204, ignored
  if metadata.requestId has no transaction      -> 204, ignored
  if the transaction has a payment to complete  -> 204, completed (repeats too)
  else                                          -> 409 payment-not-completable

"A payment to complete" includes a transaction whose outgoing payment creation the Merchant API reported as failed: a timed-out create may still have made the payment.

Anything that isn't ours gets 204, because the provider does not retry a 4xx and its webhook URL may receive other events.

Evidence

  • Before: oapi-codegen on the admin spec generates no webhook operation (grep -c receiveOpenPaymentsWebhook admin/server.gen.go → 0).
    After: it generates ReceiveOpenPaymentsWebhook (28 matches), and the Merchant API implementation against it passes its suite (interledger/merchant-api PR, linked from there).

Merge Danger

Door: two-way

Additive: one new path, one response, two schemas. Nothing existing changes.

Blast Radius: none

No existing consumer calls this path. metadata is left untyped on purpose, because providers put arbitrary JSON there.

@beniaminmunteanu
beniaminmunteanu merged commit 9d837ba into main Nov 25, 2026
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants