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