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;
|
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
|
// For testing, allow orders even without Stripe Connect setup
|
||||||
hasStripeConnect = qBusiness.BusinessStripeOnboardingComplete == 1 && len(trim(qBusiness.BusinessStripeAccountID)) > 0;
|
hasStripeConnect = qBusiness.BusinessStripeOnboardingComplete == 1 && len(trim(qBusiness.BusinessStripeAccountID)) > 0;
|
||||||
|
|
||||||
|
|
@ -86,7 +98,7 @@ try {
|
||||||
|
|
||||||
payfritCustomerFee = subtotal * customerFeePercent;
|
payfritCustomerFee = subtotal * customerFeePercent;
|
||||||
payfritBusinessFee = subtotal * businessFeePercent;
|
payfritBusinessFee = subtotal * businessFeePercent;
|
||||||
totalBeforeCardFee = subtotal + tax + tip + payfritCustomerFee;
|
totalBeforeCardFee = subtotal + tax + tip + deliveryFee + payfritCustomerFee;
|
||||||
cardFee = (totalBeforeCardFee * cardFeePercent) + cardFeeFixed;
|
cardFee = (totalBeforeCardFee * cardFeePercent) + cardFeeFixed;
|
||||||
totalCustomerPays = totalBeforeCardFee + cardFee;
|
totalCustomerPays = totalBeforeCardFee + cardFee;
|
||||||
|
|
||||||
|
|
@ -137,6 +149,7 @@ try {
|
||||||
"SUBTOTAL": subtotal,
|
"SUBTOTAL": subtotal,
|
||||||
"TAX": tax,
|
"TAX": tax,
|
||||||
"TIP": tip,
|
"TIP": tip,
|
||||||
|
"DELIVERY_FEE": deliveryFee,
|
||||||
"PAYFRIT_FEE": payfritCustomerFee,
|
"PAYFRIT_FEE": payfritCustomerFee,
|
||||||
"CARD_FEE": cardFee,
|
"CARD_FEE": cardFee,
|
||||||
"TOTAL": totalCustomerPays
|
"TOTAL": totalCustomerPays
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue