Developer notes
How the fee is applied
Section titled “How the fee is applied”The add-on writes the fee into the core payment surcharge ($cart['payment_surcharge'], payment_surcharge_title) and lets CS-Cart tax, store (?:orders.payment_surcharge), split (Multi-Vendor sub-orders) and print it.
calculate_cart_post:Engine::apply()quotes the selected method (rules -> core a/p surcharge -> legal guard), writes the fee, taxes it once withfn_calculate_payment_taxes()and keeps$cart['kv_pfr'](quote + a snapshot of the tax fields before the fee tax).- Core
fn_update_payment_surcharge()has no hook and resets the surcharge after every calculation.calculate_payment_taxes_pre/postneutralise its tax pass when it re-applies a non-zero method surcharge; post controllers (checkout,separate_checkout,order_management) andpre_update_orderput the fee back (Engine::restore()). A payment change without a recalculation rolls the fee tax back to the snapshot and applies the new method. get_payment_taxes_post: rules with “no tax”.place_order: fee record in?:kv_pfr_orders(parent and Multi-Vendor sub-orders);get_order_infosetspayment_method.surcharge_title;change_order_statussets refund status “due”.
Tables
Section titled “Tables”| Table | Content |
|---|---|
?:kv_pfr_rules, ?:kv_pfr_rule_descriptions |
Fee rules and their labels per language |
?:kv_pfr_methods |
Kind override and cost of acceptance per payment method |
?:kv_pfr_jurisdictions |
Your own legal rules |
?:kv_pfr_orders |
Fee record per order (rule, label, kind, guard action / codes, amount not charged, refund status) |
REST API
Section titled “REST API”| Request | Result |
|---|---|
GET /api/kv_payment_fee_rules |
Rules (status, q) |
GET /api/kv_payment_fee_rules/:id |
One rule |
GET /api/kv_payment_fee_rules?quote=Y&payment_id=2&total=120&country=AU[&usergroup_id=&shipping_id=] |
Fee quote with the guard result |
POST /api/kv_payment_fee_rules |
Create (name, label, payment_ids, countries, countries_mode I/E, usergroup_ids, shipping_ids, min_total, max_total, fee_type F/P/FP/T, flat, percent, tiers, min_fee, max_fee, tax_mode M/N, status, position) |
PUT /api/kv_payment_fee_rules/:id / DELETE |
Update (fields sent only) / delete |
GET /api/kv_payment_fee_orders[/:order_id] |
Fee records |
PUT /api/kv_payment_fee_orders/:order_id |
{"refund_status": "R"} refunded, "D" due (root administrator) |
Privileges: view_payments / manage_payments for rules, view_orders / edit_order for records. Vendor API users reach their own rules and records.
Storefront
Section titled “Storefront”checkout:payments (post) prints the chips and the note; js/addons/kv_payment_fee_rules/func.js moves each chip into its method label. Checkout pages are never cached by the 4.21 full page cache; nothing is added to cacheable pages. index.php?dispatch=kv_pfr.quote returns the quotes of the visitor’s cart as JSON (Cache-Control: no-store).
PHP API
Section titled “PHP API”use Tygh\Addons\KvPaymentFeeRules\Engine;$quote = Engine::quote($cart, $auth, $payment_id); // fee, raw_fee, source, rule_id, label, kind, guard_action, guard_codes, blockedLicence
Section titled “Licence”Without an active licence the rules, the guard and the chips are off: payment methods charge only their own core surcharge. Rules, settings and fee records are kept.