Developer notes
How an order is placed
Section titled “How an order is placed”The add-on is a CS-Cart payment processor (?:payment_processors, script app/addons/kv_sepa_direct_debit/payments/kv_sepa_direct_debit.php, storefront template addons/kv_sepa_direct_debit/views/orders/components/payments/kv_sepa_direct_debit.tpl). Creditor data lives in the payment method’s processor_params (creditor_name, creditor_id, creditor_iban, creditor_bic), so one payment method is one creditor.
get_payments_post(storefront): the method is offered only when the add-on is on and licensed, the store has a EUR currency and the creditor data is valid.pre_place_order:Orders::prePlace()validatespayment_info[holder|iban|bic|consent|mandate|keep](ISO 13616 length + MOD 97, accepted country list, BIC pattern, consent), sets$allow = falsewith a message on an error, and takes the account data out of$cart['payment_info']before core stores it (core encryptspayment_infointo?:order_data). Only a masked copy and the mandate reference stay.place_order:Orders::onPlace()stores the mandate (or reuses the saved one / the same account) and the debit of the top-level order. In Multi-Vendor the parent order carries the money; sub-orders (parent_order_id) get no debit.- The processor script sets the order status (setting “after placement”). Nothing is charged: the bank collects later.
get_order_infoadds$order['kv_sdd'](mandate without IBAN, debit, pre-notification text);template_snippet_render_postappends the SEPA block to theproducts_tablesnippet of theorder_invoiceandorder_summarydocuments (invoice, order e-mails).change_order_status_post(cancelled / declined) anddelete_orderclean up open debits;delete_usercuts the link of mandates to a deleted account;update_payment_prenormalises and checks the creditor fields.
Tables
Section titled “Tables”| Table | Content |
|---|---|
?:kv_sdd_mandates |
Mandate per creditor: reference (unique per creditor identifier), type OOFF / RCUR, status A / R, holder, iban_enc (encrypted), iban_hash (keyed HMAC), iban_masked, BIC, creditor snapshot, accepted text, signature time and type (W web, P recorded by the shop) |
?:kv_sdd_debits |
One collection per order: amount in EUR, state N / X / C / R / K, sequence type, end-to-end id (ORDER-<order>-D<debit>), due date, collection date, batch, return code, retry link |
?:kv_sdd_batches |
A bank file: message id, format, creation time, collection date, count, total, downloads |
?:kv_sdd_log |
Audit trail (created, exported, collected, returned, IBAN revealed, erased …) |
The bank file
Section titled “The bank file”Pain008::build($batch, '02'|'08') takes plain arrays (creditor, groups of debits with amounts in cents) and returns the XML; Pain008::problems() lists what would make a bank reject the file. Batches::create() claims the debits with one UPDATE ... WHERE status = 'N' per debit (two administrators never export the same debit), builds the file, and undoes the claim if the file is invalid. Batches::xml() rebuilds the file from the stored rows on every download, so no file with account numbers is written to disk.
Tests: tests/unit_pure.php builds files and validates them against tests/xsd/pain.008.001.02.xsd and pain.008.001.08.xsd (see tests/xsd/SOURCES.md for their origin), with negative cases to show that the check can fail.
Hooks of this add-on’s integrations
Section titled “Hooks of this add-on’s integrations”Registered when the other add-on is installed, harmless otherwise.
| Hook | From | What it does |
|---|---|---|
kv_subscriptions_payment_driver |
Subscriptions & Recurring Orders | Marks the SEPA methods as able to charge a saved credential |
kv_subscriptions_charge |
Subscriptions & Recurring Orders | Creates a debit for the renewal order from the customer’s recurrent mandate (pending, or failed without a mandate) |
kv_bank_reconcile_booked / kv_bank_reconcile_undone |
Bank Transfer Auto-Reconcile | Debit becomes collected / goes back to exported |
Debits::netTermsDue() and Orders::collectOrder() read \Tygh\Addons\KvNetTermsCreditLimit\Invoices when it exists.
Storefront
Section titled “Storefront”checkout.post.php assigns $kv_sdd_checkout (creditors, mandate text, saved mandates of the signed-in customer) to the payment step and removes account data from the session cart after every checkout request. Checkout, order and account pages are never cached by the 4.21 full page cache; nothing is added to cacheable pages. index.php?dispatch=kv_sdd.status returns {"state":"on|off","methods":N} as JSON (Cache-Control: no-store) for monitoring.
Security notes
Section titled “Security notes”- Every SQL statement uses placeholders. Backend and frontend modes check the company of every row (
runtime.company_id), and customers see only their own mandates (or the mandate of an order they may open). - The IBAN is encrypted with
fn_encrypt_text()(the store key), the lookup hash is an HMAC over the store key, the masked form is stored for display. - A mandate can be revoked by its customer or an administrator; a mandate of another customer, a revoked mandate and a mandate of another creditor are refused at checkout.
- Bulk erase is administrator-only; revealing a full IBAN is logged.
File map
Section titled “File map”app/addons/kv_sepa_direct_debit/ addon.xml, init.php, func.php payments/kv_sepa_direct_debit.php processor script controllers/backend/kv_sdd.php debits, mandates, batches, export, download, actions controllers/backend/kv_sepa_direct_debit_license.php "Check now" / license cron controllers/backend/orders.post.php collect-by-debit data for the order page controllers/frontend/kv_sdd.php my mandates, mandate view / PDF, revoke, status JSON controllers/frontend/checkout.post.php, orders.post.php account form data schemas/menu/menu.post.php, schemas/permissions/admin.post.php, vendor_multivendor.post.php Tygh/Addons/KvSepaDirectDebit/ Config.php Iban.php Text.php Calendar.php Pain008.php Pdf.php MandateDocument.php ReturnCodes.php Mandates.php Debits.php Batches.php Orders.php Lists.php Log.php License/Client.php License/Ed25519.php Upgrade/Synchronizer.phpdesign/backend/templates/addons/kv_sepa_direct_debit/ views/kv_sdd/{manage,mandates,mandate,update_mandate,batches}.tpl, views/kv_sdd/components/* views/payments/components/cc_processors/kv_sepa_direct_debit.tpl creditor fields views/orders/components/payments/kv_sepa_direct_debit.tpl (admin order editor hint) hooks/orders/payment_info.post.tpl, hooks/index/styles.post.tpl, hooks/addons/*, license/*design/backend/css/addons/kv_sepa_direct_debit/admin.less, license.lessvar/themes_repository/responsive/templates/addons/kv_sepa_direct_debit/ views/orders/components/payments/kv_sepa_direct_debit.tpl account form at checkout views/kv_sdd/{manage,view}.tpl hooks/orders/details.post.tpl, hooks/checkout/payment_instruction.post.tpl, hooks/profiles/my_account_menu.post.tpl, hooks/index/{styles,scripts}.post.tplvar/themes_repository/responsive/css/addons/kv_sepa_direct_debit/styles.lessjs/addons/kv_sepa_direct_debit/func.jsLicense
Section titled “License”The add-on ships the Kavio Labs license client (License/Client.php, kv_sepa_direct_debit_license controller, card / status bar / badge templates). License\Client::isActive() gates the checkout method and the subscription driver through Config::isOn(); collecting what was authorised does not depend on it. The client contacts https://cs-cart.kaviolabs.com from the admin panel or cron only.