feat(payments): add gift card system v2 with management, expiry, inventory, audit log
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -248,7 +248,7 @@ func CreateTerminalPayment(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// Deduct directly from card remaining amount
|
||||
_, err = tx.Exec(r.Context(), "UPDATE gift_cards SET amount_remaining = amount_remaining - $1 WHERE id = $2", amountPounds, cleanCardID)
|
||||
_, err = tx.Exec(r.Context(), "UPDATE gift_cards SET amount_remaining = amount_remaining - $1, last_used_at = NOW() WHERE id = $2", amountPounds, cleanCardID)
|
||||
if err != nil {
|
||||
log.Printf("Failed to deduct gift card amount: %v", err)
|
||||
http.Error(w, "Internal server error", http.StatusInternalServerError)
|
||||
@@ -366,7 +366,7 @@ func GetCheckoutStatus(w http.ResponseWriter, r *http.Request) {
|
||||
UpdatedAt: time.Now(),
|
||||
}
|
||||
|
||||
paymentID, err := service.CreatePaymentRecord(r.Context(), record)
|
||||
paymentID, err := service.CreatePaymentRecord(r.Context(), record, nil)
|
||||
if err != nil {
|
||||
log.Printf("Failed to create payment record: %v", err)
|
||||
http.Error(w, "Internal server error", http.StatusInternalServerError)
|
||||
@@ -540,7 +540,7 @@ func CreateBookingPayment(w http.ResponseWriter, r *http.Request) {
|
||||
CreatedBy: &userID,
|
||||
}
|
||||
|
||||
paymentID, err := service.CreatePaymentRecord(r.Context(), record)
|
||||
paymentID, err := service.CreatePaymentRecord(r.Context(), record, nil)
|
||||
if err != nil {
|
||||
log.Printf("Failed to create payment record: %v", err)
|
||||
http.Error(w, "Internal server error", http.StatusInternalServerError)
|
||||
@@ -879,7 +879,7 @@ func CreateTipPayment(w http.ResponseWriter, r *http.Request) {
|
||||
CreatedBy: &userID,
|
||||
}
|
||||
|
||||
paymentID, err := service.CreatePaymentRecord(r.Context(), record)
|
||||
paymentID, err := service.CreatePaymentRecord(r.Context(), record, nil)
|
||||
if err != nil {
|
||||
log.Printf("Failed to create payment record: %v", err)
|
||||
http.Error(w, "Internal server error", http.StatusInternalServerError)
|
||||
|
||||
Reference in New Issue
Block a user