Remove hardcoded 5% fee fallback, require Businesses.PayfritFee
If PayfritFee is not configured for a business, the payment intent creation now errors instead of silently using 5%. This ensures fees are always explicitly set per business. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c17f624787
commit
ed001fd0b0
1 changed files with 11 additions and 6 deletions
|
|
@ -7,9 +7,10 @@
|
||||||
* Create Payment Intent for Order (v2 - with Payfrit fee structure)
|
* Create Payment Intent for Order (v2 - with Payfrit fee structure)
|
||||||
*
|
*
|
||||||
* Fee Structure:
|
* Fee Structure:
|
||||||
* - Customer pays: Subtotal + tax + tip + 5% Payfrit fee + card processing (2.9% + $0.30)
|
* - Fee rate read from Businesses.PayfritFee column (e.g., 0.065 = 6.5%)
|
||||||
* - Restaurant receives: Subtotal - 5% Payfrit fee + tax + tip
|
* - Customer pays: Subtotal + tax + tip + PayfritFee% + card processing (2.9% + $0.30)
|
||||||
* - Payfrit receives: 10% of subtotal (5% from customer + 5% from restaurant)
|
* - Restaurant receives: Subtotal - PayfritFee% + tax + tip
|
||||||
|
* - Payfrit receives: 2x PayfritFee% of subtotal (from customer + business)
|
||||||
*
|
*
|
||||||
* POST: {
|
* POST: {
|
||||||
* BusinessID: int,
|
* BusinessID: int,
|
||||||
|
|
@ -109,10 +110,14 @@ try {
|
||||||
hasStripeConnect = qBusiness.StripeOnboardingComplete == 1 && len(trim(qBusiness.StripeAccountID)) > 0;
|
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
|
if (!isNumeric(qBusiness.PayfritFee) || qBusiness.PayfritFee <= 0) {
|
||||||
customerFeePercent = isNumeric(qBusiness.PayfritFee) && qBusiness.PayfritFee > 0 ? qBusiness.PayfritFee : 0.05;
|
response["ERROR"] = "Business PayfritFee not configured";
|
||||||
|
writeOutput(serializeJSON(response));
|
||||||
|
abort;
|
||||||
|
}
|
||||||
|
customerFeePercent = qBusiness.PayfritFee;
|
||||||
businessFeePercent = customerFeePercent; // Business fee mirrors customer fee
|
businessFeePercent = customerFeePercent; // Business fee mirrors customer fee
|
||||||
cardFeePercent = 0.029; // 2.9% Stripe fee
|
cardFeePercent = 0.029; // 2.9% Stripe fee
|
||||||
cardFeeFixed = 0.30; // $0.30 Stripe fixed fee
|
cardFeeFixed = 0.30; // $0.30 Stripe fixed fee
|
||||||
|
|
|
||||||
Reference in a new issue