feat: implement recurring payment scheduler (#214)#305
Open
TEEZY234 wants to merge 7 commits intoceejaylaboratory:mainfrom
Open
feat: implement recurring payment scheduler (#214)#305TEEZY234 wants to merge 7 commits intoceejaylaboratory:mainfrom
TEEZY234 wants to merge 7 commits intoceejaylaboratory:mainfrom
Conversation
- Add Prisma models for RecurringPaymentSchedule and RecurringPaymentRun - Create RecurringPaymentsService with CRUD operations and schedule processing - Add authenticated API routes for managing recurring payment schedules - Implement cron-based worker to process due schedules automatically - Add environment variables for worker configuration - Include Jest tests for service and routes - Resolve merge conflicts in auth.service.ts and webhook.service.ts - Add dependencies: node-cron, cron-parser, @types/node-cron
|
@TEEZY234 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! 🚀 |
- Modified check-migrations.js to handle missing database gracefully - Skip drift check if SQLite database file doesn't exist (expected in CI) - Prevents P1003 error when ci.db hasn't been created yet
- Modified checkDestructiveChanges to skip if database file doesn't exist - Prevents missing migration_lock.toml error in CI environments - Both drift and destructive changes checks now handle missing databases gracefully
- Change from migrate dev to migrate deploy to apply existing migrations - Prevents conflicts when tables already exist from previous migrations - migrate deploy is the correct command for applying migrations in production/CI
- Add node-cron, cron-parser, @types/node-cron to lock file - Fixes npm ci error in CI due to package-lock.json being out of sync
- Regenerate package-lock.json after pulling latest main changes - Includes new dependencies from recurring payments feature
- Remove duplicate uuid entry from root node_modules - Keep main branch's version which has uuid in backend/node_modules only
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.
Pull Request: Implement Recurring Payment Scheduler
Closes #214
Summary
This PR implements a backend service for scheduling recurring Stellar payments (e.g., monthly subscriptions) with a cron-based worker to execute these automatically.
Changes Made
Database Schema
RecurringPaymentSchedulemodel with fields for destination, asset code, amount, cron expression, status, and next run timeRecurringPaymentRunmodel to track individual payment execution attempts with status, error tracking, and Stellar transaction IDService Layer
RecurringPaymentsServicewith:processDueSchedules()method to find and execute due paymentsBatchPaymentServicefor Stellar transactionsAPI Layer
recurring-payments.controller.tswith request handlersrecurring-payments.route.tswith authenticated endpoints:POST /api/recurring-payments- Create new scheduleGET /api/recurring-payments- List user's schedulesGET /api/recurring-payments/:id- Get specific schedulePATCH /api/recurring-payments/:id- Update scheduleDELETE /api/recurring-payments/:id- Delete schedule/api/recurring-paymentsWorker
recurring-payments.worker.tsusing node-cronRECURRING_PAYMENTS_WORKER_CRONenvironment variable (default:*/1 * * * *)Configuration
RECURRING_PAYMENTS_WORKER_CRON- Worker execution scheduleSTELLAR_HORIZON_URL- Stellar Horizon server URLSTELLAR_NETWORK_PASSPHRASE- Network passphraseSTELLAR_DISTRIBUTION_SECRET- Distribution account secret keyDependencies
node-cronfor schedulingcron-parserfor cron expression parsing@types/node-cronfor TypeScript supportstart:worker:recurring-paymentsTests
RecurringPaymentsServiceBug Fixes
auth.service.ts(combined tracing and configService)webhook.service.ts(combined imports and fixed deliver method)Usage
Start the worker
API Example
Notes
BatchPaymentServicefor Stellar transaction submission, ensuring consistency with the payment flow