On this page:
make-webhook-endpoint
webhook-endpoint?
handle-webhook-post
handle-claim-post
handle-readyz
serve-webhook-endpoint

11 HTTP edge and claim portal🔗ℹ

 (require commerce/server) package: commerce

Server processes explicitly require commerce/server. The edge binds webhook authentication, active order verification, journal acceptance, and the one-time claim portal behind one small HTTP surface; it is a thin adapter, and the journal’s idempotence decides every acknowledgement.

procedure

(make-webhook-endpoint #:keyring keyring 
  #:environment environment 
  #:merchant-client merchant-client 
  #:binding-lookup binding-lookup 
  #:storage storage) 
 → webhook-endpoint?
  keyring : pancake-webhook-keyring?
  environment : (or/c 'test 'production)
  merchant-client : pancake-merchant-client?
  binding-lookup : procedure?
  storage : commerce-storage?
Binds one Pancake channel to its keyring, merchant client, binding lookup, and storage.

procedure

(webhook-endpoint? value) → boolean?

  value : any/c
Recognizes one bound Pancake webhook endpoint.

procedure

(handle-webhook-post endpoint 
  raw-body 
  signature-header) 
 → 
exact-nonnegative-integer? jsexpr?
  endpoint : webhook-endpoint?
  raw-body : bytes?
  signature-header : string?
Pure webhook handling: exact body bytes plus the signature header in, HTTP status and JSON body out. The order is deliberate: signature first, then binding resolution, then active verification, then journal acceptance.

procedure

(handle-claim-post endpoint token)

 → 
exact-nonnegative-integer? jsexpr?
  endpoint : webhook-endpoint?
  token : string?
Fulfills a one-time claim token. Unknown claims answer 404, reused claims 409, expired claims 410, and other refusals 422 — a fulfilled claim returns the exact signed Permit envelope as JSON, once.

procedure

(handle-readyz endpoint) → 
exact-nonnegative-integer? jsexpr?
  endpoint : webhook-endpoint?
Renders the storage readiness snapshot for the load balancer.

procedure

(serve-webhook-endpoint endpoint    
  #:port port    
  [#:listen-ip listen-ip]) → (-> void?)
  endpoint : webhook-endpoint?
  port : exact-nonnegative-integer?
  listen-ip : string? = "127.0.0.1"
Binds the endpoint to an HTTP port and returns a zero-argument shutdown procedure. The servlet exposes exactly three routes — /webhooks/pancake, /claims, and /readyz; anything else is 404.