feat: implement real-time rent payment tracker (#16)#68
Merged
elizabetheonoja-art merged 2 commits intoLeaseFlow-Protocol:mainfrom Mar 25, 2026
Merged
Conversation
- Add RentPaymentTrackerService that polls Stellar Horizon for incoming
payments to the LeaseFlow contract account
- Use cursor-based pagination (paging_token + order=asc) so each poll
only fetches genuinely new operations instead of re-scanning the same
200 records on every run
- Record every detected payment in a new payment_history table with full
deduplication via horizon_op_id unique constraint
- Auto-update lease payment_status and last_payment_at when a payment is
matched to an active lease by tenant Stellar account
- Add PaymentTrackerJob cron scheduler (default: every minute, override
via PAYMENT_TRACKER_CRON env var) started at server boot
- Expose three new API endpoints via paymentRoutes:
GET /api/leases/:leaseId/payments
GET /api/leases/:leaseId/payment-status
GET /api/tenants/:tenantAccountId/payments
- Fix getLeaseById to include payment_status, last_payment_at and
tenant_account_id columns (were missing, causing /payment-status to
return null for all payment fields)
- Add migration 002_add_payment_history.sql for the new schema columns
- Add 12 unit/integration tests covering poll logic, idempotency, lease
matching, and all AppDatabase payment methods
|
@chigozirim007 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RentPaymentTrackerService) monitors the LeaseFlow contract account for incomingpayment,path_payment_strict_send, andpath_payment_strict_receiveoperationspaging_token+order=asc— each poll only fetches new operations, not the same 200 records repeatedlyhorizon_op_idunique constraint — safe to re-run with no duplicate recordstenant_account_id, the leasepayment_statusandlast_payment_atare updated automaticallyPaymentTrackerJob) starts at server boot, configurable viaPAYMENT_TRACKER_CRONenv var (default: every minute)GET /api/leases/:leaseId/payments— full payment historyGET /api/leases/:leaseId/payment-status— current status + last payment timestampGET /api/tenants/:tenantAccountId/payments— all payments for a tenant Stellar accountgetLeaseByIdwas not selectingpayment_status,last_payment_at, ortenant_account_idcolumns —/payment-statuswould have returnednullfor all payment fields002_add_payment_history.sqladds thepayment_historytable and extendsleaseswith payment tracking columnsTest plan
node node_modules/jest/bin/jest.js tests/rentPaymentTracker.test.js --forceExit— all 12 tests passGET /api/leases/:leaseId/payment-statusreturnspayment_statusandlast_payment_atfields correctlyPaymentTrackerJoblogs appear on boot:[PaymentTracker] Scheduled payment pollingCloses #16