From ed001fd0b051d283c12751f03ab6ceb85b999fd8 Mon Sep 17 00:00:00 2001 From: John Mizerek Date: Thu, 19 Feb 2026 11:16:41 -0800 Subject: [PATCH] Remove hardcoded 5% fee fallback, require Businesses.PayfritFee If PayfritFee is not configured for a business, the payment intent creation now errors instead of silently using 5%. This ensures fees are always explicitly set per business. Co-Authored-By: Claude Opus 4.5 --- api/stripe/createPaymentIntent.cfm | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/api/stripe/createPaymentIntent.cfm b/api/stripe/createPaymentIntent.cfm index 4fc9ccb..41f8cf2 100644 --- a/api/stripe/createPaymentIntent.cfm +++ b/api/stripe/createPaymentIntent.cfm @@ -7,9 +7,10 @@ * Create Payment Intent for Order (v2 - with Payfrit fee structure) * * Fee Structure: - * - Customer pays: Subtotal + tax + tip + 5% Payfrit fee + card processing (2.9% + $0.30) - * - Restaurant receives: Subtotal - 5% Payfrit fee + tax + tip - * - Payfrit receives: 10% of subtotal (5% from customer + 5% from restaurant) + * - Fee rate read from Businesses.PayfritFee column (e.g., 0.065 = 6.5%) + * - Customer pays: Subtotal + tax + tip + PayfritFee% + card processing (2.9% + $0.30) + * - Restaurant receives: Subtotal - PayfritFee% + tax + tip + * - Payfrit receives: 2x PayfritFee% of subtotal (from customer + business) * * POST: { * BusinessID: int, @@ -109,10 +110,14 @@ try { hasStripeConnect = qBusiness.StripeOnboardingComplete == 1 && len(trim(qBusiness.StripeAccountID)) > 0; // ============================================================ - // FEE CALCULATION + // FEE CALCULATION (from Businesses.PayfritFee) // ============================================================ - // Customer fee from database (PayfritFee), default 5% if not set - customerFeePercent = isNumeric(qBusiness.PayfritFee) && qBusiness.PayfritFee > 0 ? qBusiness.PayfritFee : 0.05; + if (!isNumeric(qBusiness.PayfritFee) || qBusiness.PayfritFee <= 0) { + response["ERROR"] = "Business PayfritFee not configured"; + writeOutput(serializeJSON(response)); + abort; + } + customerFeePercent = qBusiness.PayfritFee; businessFeePercent = customerFeePercent; // Business fee mirrors customer fee cardFeePercent = 0.029; // 2.9% Stripe fee cardFeeFixed = 0.30; // $0.30 Stripe fixed fee