Skip to content

fix: query all Square locations for Lightning payment lookups#12

Open
gudnuf wants to merge 1 commit intomainfrom
fix/multi-location-square-lookups
Open

fix: query all Square locations for Lightning payment lookups#12
gudnuf wants to merge 1 commit intomainfrom
fix/multi-location-square-lookups

Conversation

@gudnuf
Copy link

@gudnuf gudnuf commented Feb 25, 2026

Summary

  • Fetch all active Square locations at startup via GET /v2/locations
  • Iterate over each location when checking for Lightning payments during melt validation
  • Fixes merchants with multiple locations (e.g. Pink Owl Coffee with 5 locations) where Lightning payments happen at a non-default location and are missed by the single-location query

Changes

  • types.rs — Added ListLocationsResponse and SquareLocation types
  • square_api.rs — Added list_locations(), added location_id param to list_payments(), updated has_lightning_payment_near_timestamp() and log_recent_lightning_payments() to iterate all locations
  • lib.rs (cdk-agicash) — Added location_ids field to ClosedLoopValidator::Square, threaded through validation
  • lib.rs (cdk-mintd) — Fetch locations at startup, pass to ClosedLoopPayment::new_square()

Test plan

  • cargo check -p cdk-agicash passes
  • cargo check -p cdk-mintd passes
  • cargo test -p cdk-agicash passes
  • Rebuild cdk-mintd image, deploy to prod
  • Verify startup log: "Discovered N active Square location(s)"
  • Test melt at Pink Owl — should find Lightning payments at non-default location

Merchants with multiple Square locations (e.g. Pink Owl Coffee with 5)
had melt failures because list_payments only checked the default
location. Now we fetch all active locations at startup via
GET /v2/locations and iterate over each during payment validation.
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.

1 participant