mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-09 12:16:50 +00:00
Introduce Stripe integration for automatic payment ingestion and refund tracking. Adds new fields to the payment model for Stripe IDs and status, Stripe client driver, sync service, cron job, manual API endpoint, and public webhook handler for real-time updates. Includes tests and documentation. Manual cash entry remains supported.
55 lines
1 KiB
Go
55 lines
1 KiB
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"github.com/rjNemo/rentease/pkg/cron"
|
|
|
|
internalcron "github.com/rjNemo/rentease/internal/cron"
|
|
)
|
|
|
|
func main() {
|
|
scheduler := cron.New()
|
|
|
|
scheduler.AddJob(cron.Job{
|
|
Name: "Monthly Booking Report",
|
|
Schedule: "minute",
|
|
Action: internalcron.JobMonthlyBookingReport,
|
|
})
|
|
|
|
scheduler.AddJob(cron.Job{
|
|
Name: "Stripe Payment Sync",
|
|
Schedule: "daily",
|
|
Action: internalcron.JobStripePaymentSync,
|
|
})
|
|
|
|
go scheduler.Start()
|
|
|
|
go func() {
|
|
for {
|
|
select {
|
|
case err := <-scheduler.ErrChan:
|
|
if err != nil {
|
|
log.Println("Error:", err)
|
|
}
|
|
case msg := <-scheduler.SuccessChan:
|
|
log.Print(msg)
|
|
}
|
|
}
|
|
}()
|
|
|
|
// Capture termination signals for graceful shutdown
|
|
sigChan := make(chan os.Signal, 1)
|
|
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
|
|
|
|
// Wait for termination signal
|
|
<-sigChan
|
|
log.Println("Received termination signal, shutting down...")
|
|
|
|
// Stop the task manager and close channels
|
|
scheduler.Stop()
|
|
log.Println("All tasks stopped, exiting.")
|
|
}
|