diff --git a/src/subdomains/supporting/payment/entities/fee.entity.ts b/src/subdomains/supporting/payment/entities/fee.entity.ts index f02304b118..e151435a36 100644 --- a/src/subdomains/supporting/payment/entities/fee.entity.ts +++ b/src/subdomains/supporting/payment/entities/fee.entity.ts @@ -12,6 +12,7 @@ import { FeeRequest } from '../services/fee.service'; export enum FeeType { SPECIAL = 'Special', // Single use only, highest prio applies to all CUSTOM = 'Custom', // Single use only, second highest prio + CUSTOM_PARTNER = 'CustomPartner', // Single use only, second highest prio, can be combined with PartnerFee BASE = 'Base', // Single use only, absolute base fee DISCOUNT = 'Discount', // Single use only, absolute discount RELATIVE_DISCOUNT = 'RelativeDiscount', // Single use only, relative discount diff --git a/src/subdomains/supporting/payment/services/fee.service.ts b/src/subdomains/supporting/payment/services/fee.service.ts index 00a90dc45a..b272be72b2 100644 --- a/src/subdomains/supporting/payment/services/fee.service.ts +++ b/src/subdomains/supporting/payment/services/fee.service.ts @@ -331,13 +331,6 @@ export class FeeService { ]); const blockchainFee = fromFee + toFee; - // get partner fee - const partnerFee = Util.minObj( - fees.filter((fee) => fee.type === FeeType.PARTNER), - 'rate', - ); - const partnerFeeSpec = { rate: partnerFee?.rate ?? 0, fixed: partnerFee?.fixed ?? 0 }; - // get min special fee const specialFee = Util.minObj( fees.filter((fee) => fee.type === FeeType.SPECIAL), @@ -346,26 +339,33 @@ export class FeeService { if (specialFee) return { - fees: [specialFee, partnerFee].filter((e) => e != null), + fees: [specialFee], dfx: { rate: specialFee.rate, fixed: specialFee.fixed ?? 0 }, bank: { rate: 0, fixed: 0 }, - partner: partnerFeeSpec, + partner: { rate: 0, fixed: 0 }, payoutRefBonus: specialFee.payoutRefBonus, network: Math.min(specialFee.blockchainFactor * blockchainFee, Config.maxBlockchainFee), }; + // get partner fee + const partnerFee = Util.minObj( + fees.filter((fee) => fee.type === FeeType.PARTNER), + 'rate', + ); + const partnerFeeSpec = { rate: partnerFee?.rate ?? 0, fixed: partnerFee?.fixed ?? 0 }; + // get min custom fee const customFee = Util.minObj( - fees.filter((fee) => fee.type === FeeType.CUSTOM), + fees.filter((fee) => [FeeType.CUSTOM, FeeType.CUSTOM_PARTNER].includes(fee.type)), 'rate', ); if (customFee) return { - fees: [customFee, partnerFee].filter((e) => e != null), + fees: [customFee], dfx: { rate: customFee.rate, fixed: customFee.fixed ?? 0 }, bank: { rate: 0, fixed: 0 }, - partner: partnerFeeSpec, + partner: customFee.type === FeeType.CUSTOM_PARTNER ? partnerFeeSpec : { rate: 0, fixed: 0 }, network: Math.min(customFee.blockchainFactor * blockchainFee, Config.maxBlockchainFee), payoutRefBonus: customFee.payoutRefBonus, };