From f7df6b614c93132a9da28179fe6af37523340d36 Mon Sep 17 00:00:00 2001 From: John Mizerek Date: Tue, 13 Jan 2026 11:06:27 -0800 Subject: [PATCH] Include delivery fee in payment calculation createPaymentIntent.cfm now fetches the order's delivery fee and includes it in the total amount charged to the customer. Co-Authored-By: Claude Opus 4.5 --- api/stripe/createPaymentIntent.cfm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/api/stripe/createPaymentIntent.cfm b/api/stripe/createPaymentIntent.cfm index 45fc343..536384a 100644 --- a/api/stripe/createPaymentIntent.cfm +++ b/api/stripe/createPaymentIntent.cfm @@ -73,6 +73,18 @@ try { abort; } + // Get order's delivery fee (if delivery order) + qOrder = queryExecute(" + SELECT OrderDeliveryFee, OrderTypeID + FROM Orders + WHERE OrderID = :orderID + ", { orderID: orderID }, { datasource: "payfrit" }); + + deliveryFee = 0; + if (qOrder.recordCount > 0 && qOrder.OrderTypeID == 3) { + deliveryFee = val(qOrder.OrderDeliveryFee); + } + // For testing, allow orders even without Stripe Connect setup hasStripeConnect = qBusiness.BusinessStripeOnboardingComplete == 1 && len(trim(qBusiness.BusinessStripeAccountID)) > 0; @@ -86,7 +98,7 @@ try { payfritCustomerFee = subtotal * customerFeePercent; payfritBusinessFee = subtotal * businessFeePercent; - totalBeforeCardFee = subtotal + tax + tip + payfritCustomerFee; + totalBeforeCardFee = subtotal + tax + tip + deliveryFee + payfritCustomerFee; cardFee = (totalBeforeCardFee * cardFeePercent) + cardFeeFixed; totalCustomerPays = totalBeforeCardFee + cardFee; @@ -137,6 +149,7 @@ try { "SUBTOTAL": subtotal, "TAX": tax, "TIP": tip, + "DELIVERY_FEE": deliveryFee, "PAYFRIT_FEE": payfritCustomerFee, "CARD_FEE": cardFee, "TOTAL": totalCustomerPays