rentease/internal/service/booking/payment.go
Ruidy 8384d85e3e
feat(stripe): add Stripe payment sync and webhook support
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.
2025-10-03 21:39:59 +02:00

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
}