mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-10 04:36: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.
45 lines
920 B
Go
45 lines
920 B
Go
package booking
|
|
|
|
import (
|
|
"log"
|
|
|
|
"github.com/rjNemo/rentease/internal/config"
|
|
)
|
|
|
|
func (bs Service) OnePayment(id int) *Payment {
|
|
p, err := bs.store.GetPayment(id)
|
|
if err != nil {
|
|
log.Println(err)
|
|
}
|
|
return p
|
|
}
|
|
|
|
func (bs Service) CreatePayment(bid int, amount float64, paymentMethod string) (*Payment, error) {
|
|
p, err := bs.store.CreatePayment(&Payment{
|
|
BookingID: uint(bid),
|
|
Amount: amount,
|
|
PaymentMethod: config.PaymentMethod(paymentMethod),
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return p, nil
|
|
}
|
|
|
|
func (bs Service) UpdatePayment(id int, amount float64, paymentMethod string) *Payment {
|
|
p, err := bs.store.UpdatePayment(id, amount, paymentMethod)
|
|
if err != nil {
|
|
log.Println(err)
|
|
}
|
|
return p
|
|
}
|
|
|
|
func (bs Service) UpsertStripePayment(p *Payment) (*Payment, error) {
|
|
sp, err := bs.store.UpsertStripePayment(p)
|
|
if err != nil {
|
|
log.Println(err)
|
|
return nil, err
|
|
}
|
|
return sp, nil
|
|
}
|