Files
Crussell/backend/handlers/payments/refund_policy.go
T
popertotsandSisyphus 77317e4a45 fix: payments money-safety round-2 — webhook booking gate + M2 stranded-charge refund, sync-path status guards, gift-card cancel re-issue reconcile, till-sweep clawback lock, sweep VAT rescue, refund credit routing
- webhook payment.updated now re-reads the booking FOR UPDATE: non-payable booking -> payment failed + stranded-charge refund row + flood-capped alert; payable booking -> full completion side-effects; gift-card rows stay pending (C6 same-key retry); unknown events -> 503 so Square retries
- sync-path completion flips (saved-card, tip, online) guarded AND status='pending' + post-flip re-read; postChargeRecheck failed-mark guarded — no webhook-first double-processing, no phantom split rows
- CancelGiftCard resume reconciles ALL Square refunds (pending blocks re-issue; COMPLETED sum >= entitlement resolves+neutralizes; else re-issues only the difference under a fresh key) — closes double-refund
- sweep till_sales fail/clawback takes crussell:till:<key> lock + post-lock status re-read; recordUntrackedTillSalePayment applies VAT; rescue align clears VAT fields before re-apply (split-accurate VAT, tip rows stay VAT-free)
- refunds: chargeAggKey widened, redeemed-card refunds route to user_giftcard_balances, guest cash refunds recorded failed + notification
- handlers: tip split-records excluded from VAT loop, splitIdempotencyKey hashed, cross-booking key reuse 409, refunded payments excluded from existingCount, SCA-mint exemption for save_card, non-COMPLETED results routed

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)
2026-08-22 00:34:51 +01:00

31 lines
1.0 KiB
Go

package payments
import "time"
const (
FullRefundThreshold = 72 * time.Hour
PartialRefundThreshold = 24 * time.Hour
NoShowThreshold = 24 * time.Hour
DepositDeadlineWindow = 24 * time.Hour
DepositAdvanceWindow = 36 * time.Hour
FullRefundTier = "full_refund_72h"
PartialRefundTier = "partial_refund_24h_72h"
NoRefundTier = "no_refund_under_24h"
ProtectedDepositMaxPct = 0.50
RequiredDepositPct = 0.20
// depositPromotionMinPct is the share of the booking total a payment must
// cover before a pending_release booking is promoted back to 'confirmed'
// (A10) — the deposit-promotion threshold in the CreateBookingPayment
// deposit-promotion query. Named separately from RequiredDepositPct (the
// deposit REQUIRED at booking time, used by bookings.go): the promotion
// threshold is about already-paid money, not the amount to demand up front,
// even though both are 20% today.
depositPromotionMinPct = RequiredDepositPct
LoyaltyStampCost = 10
LoyaltyDiscountPercent = 10.0
)