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 <noreply@anthropic.com>
This commit is contained in:
parent
bd1e4110f6
commit
f7df6b614c
1 changed files with 14 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue