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