On this page:
verify-pancake-webhook
pancake-webhook-keyring
verify-pancake-refund-webhook
pancake-refund
pancake-refund-payment-event
strict-display-amount->minor
3.1 Pancake active one-time order verification
pancake-order-facts
pancake-order-binding
make-pancake-merchant-client
read-pancake-onetime-order
pancake-order-binding?
pancake-merchant-client?
verify-pancake-onetime-order

3 Pancake webhook authentication🔗ℹ

 (require commerce/pancake) package: commerce

Server processes explicitly require commerce/pancake. This module authenticates provider-native evidence and is not re-exported by the default facade.

procedure

(verify-pancake-webhook 
  raw-body 
  signature-header 
  #:environment environment 
  [#:keyring keyring 
  #:now-ms now-ms 
  #:past-tolerance-ms past-tolerance-ms 
  #:future-tolerance-ms future-tolerance-ms]) 
 → pancake-webhook?
  raw-body : bytes?
  signature-header : string?
  environment : (or/c 'test 'production)
  keyring : pancake-webhook-keyring?
   = (default-pancake-webhook-keyring)
  now-ms : exact-nonnegative-integer?
   = (current-inexact-milliseconds)
  past-tolerance-ms : exact-nonnegative-integer? = 2700000
  future-tolerance-ms : exact-nonnegative-integer? = 60000
Verifies the X-Waffo-Signature RSA-SHA256 signature over the decimal millisecond timestamp, one period byte, and the exact copied request bytes. The default window accepts up to 45 minutes of retry age and one minute of future clock skew. JSON parsing happens only after verification. The signed payload’s mode must match the explicitly selected environment, and duplicate top-level fields are rejected.

The returned value exposes environment, envelope identifiers, event and store metadata, data, immutable raw bytes, their SHA-256 digest, and the signature timestamp through the pancake-webhook-* accessors. It is provider-native evidence and is not yet a canonical payment-event.

procedure

(pancake-webhook-keyring test-public-key 
  production-public-key) 
 → pancake-webhook-keyring?
  test-public-key : non-empty-string?
  production-public-key : non-empty-string?
An explicit keyring supports controlled provider key rotation. Test and production keys must be non-empty and distinct. Authentication and payload failures raise redacted exn:fail:commerce values; raw bodies, signatures, and key contents are never included. Codes distinguish missing or malformed signature headers, invalid or out-of-window timestamps, invalid signatures, invalid configured public keys, invalid payloads, and environment mismatch.

procedure

(verify-pancake-refund-webhook raw-body 
  signature-header 
  #:environment environment 
  [#:keyring keyring]) 
 → 
pancake-webhook? pancake-refund?
  raw-body : bytes?
  signature-header : string?
  environment : (or/c 'test 'production)
  keyring : pancake-webhook-keyring?
   = (default-pancake-webhook-keyring)
Authenticates a signed refund webhook and extracts the refund record. Refund handling is operator-facing: a refund never magically revokes an offline credential.

struct

(struct pancake-refund (order-id
    event-id
    currency
    refunded-minor
    original-charged-minor
    external-id
    occurred-at
    raw-body
    payload-digest))
  order-id : string?
  event-id : string?
  currency : string?
  refunded-minor : exact-nonnegative-integer?
  original-charged-minor : exact-nonnegative-integer?
  external-id : string?
  occurred-at : exact-nonnegative-integer?
  raw-body : bytes?
  payload-digest : string?
One authenticated provider-native refund record.

procedure

(pancake-refund-payment-event webhook 
  refund 
  [#:occurred-at occurred-at]) 
 → payment-event?
  webhook : pancake-webhook?
  refund : pancake-refund?
  occurred-at : exact-nonnegative-integer? = (current-seconds)
Derives the canonical refund event from authenticated refund evidence.

procedure

(strict-display-amount->minor display-amount    
  currency    
  currency-exponent) → money?
  display-amount : string?
  currency : string?
  currency-exponent : (integer-in 0 4)
Converts a provider’s decimal display amount directly to configured minor units without floating point.

3.1 Pancake active one-time order verification🔗ℹ

struct

(struct pancake-order-facts (order-id
    status
    test-mode
    payment-id
    payment-status
    currency
    minor-units))
  order-id : string?
  status : string?
  test-mode : boolean?
  payment-id : string?
  payment-status : string?
  currency : string?
  minor-units : exact-nonnegative-integer?
The actively read provider order facts.

procedure

(pancake-order-binding merchant-external-id 
  product-id 
  offer-id 
  subject-id 
  amount 
  currency-exponent) 
 → pancake-order-binding?
  merchant-external-id : string?
  product-id : string?
  offer-id : string?
  subject-id : string?
  amount : money?
  currency-exponent : (integer-in 0 4)
Records the server-side expectation created with checkout. The merchant external id is a random correlation reference of at most 128 characters. It maps locally to one provider product, stable Offer, opaque stable subject, expected money value, and explicit ISO 4217 exponent from zero through four. It must not contain or substitute for the subject identity.

procedure

(make-pancake-merchant-client 
  merchant-id 
  private-key-pem 
  #:environment environment 
  [#:connect-timeout-seconds connect-timeout 
  #:request-timeout-seconds request-timeout 
  #:transport transport 
  #:clock clock]) 
 → pancake-merchant-client?
  merchant-id : string?
  private-key-pem : string?
  environment : (or/c 'test 'production)
  connect-timeout : exact-positive-integer? = 5
  request-timeout : exact-positive-integer? = 10
  transport : (or/c procedure? #f) = #f
  clock : (or/c procedure? #f) = #f
Creates an opaque server-side client. The RSA private key is parsed once and is not exposed by accessors. The client signs one POST /v1/graphql merchant read with RSA-SHA256/PKCS#1 v1.5. Both environments use https://api.waffo.ai/v1/graphql; the explicit environment is verified against the returned order’s testMode. Defaults are five seconds to connect and ten seconds for response headers and body. Reads follow no redirects, carry no idempotency key, and make no implicit retry.

procedure

(read-pancake-onetime-order client    
  order-id) → pancake-order-facts?
  client : pancake-merchant-client?
  order-id : string?
Actively reads one one-time order. Transport failure and HTTP 408/429/5xx raise retryable pancake-order-unavailable.

procedure

(pancake-order-binding? value) → boolean?

  value : any/c
Recognizes one recorded server-side checkout expectation.

procedure

(pancake-merchant-client? value) → boolean?

  value : any/c
Recognizes an opaque server-side Pancake merchant client; its private key is never exposed by an accessor.

procedure

(verify-pancake-onetime-order client    
  webhook    
  binding) → payment-event?
  client : pancake-merchant-client?
  webhook : pancake-webhook?
  binding : pancake-order-binding?
Requires an authenticated order.completed webhook, actively reads its one-time order, and checks order id, completed status, environment, store, merchant external id, product, the webhook payment id and succeeded status, currency, and exact payment total. Only a complete match constructs the canonical event. Merchant authentication, GraphQL rejection, missing or malformed orders, and each semantic mismatch have separate typed, redacted codes. The optional transport and clock arguments on make-pancake-merchant-client exist for deterministic integration testing; production callers normally leave them at their secure defaults.