Developer notes
Technical reference for developers who customize ifthenpay Payments.
Add-on identity
Section titled “Add-on identity”| Item | Value |
|---|---|
| Add-on id | kv_ifthenpay_payments |
| Function prefix | fn_kv_ifthenpay_payments_ |
| Language variables | kv_ifthenpay_payments.* |
| CSS scope | .kv-ifthenpay-payments |
| PHP namespace | Tygh\Addons\KvIfthenpayPayments |
| Preset | payment (generated by kv new --kind integration) |
Structure
Section titled “Structure”| Class | Role |
|---|---|
Client\BaseClient |
HTTP (cURL, TLS verification, timeouts), JSON, error mapping, masked logging |
Client\Api |
The ifthenpay endpoints (Multibanco init / sandbox / list, MB WAY request / status, Payshop reference / sandbox, card init / sandbox, refund, payment list, callback activation); see notes/API-NOTES.md in the source package |
Methods |
The four methods: processor name, script, templates, ifthenpay method name, order id limit, refundable |
Rules |
Pure rules: amounts (“10.99”), MB WAY number (“351#912345678”), signature (HMAC-SHA256 of orderId + amount + requestId), expiry options, dates, callback URL templates |
PaymentService |
Start per method, callback, MB WAY notification, read-back, settle (under a per-payment lock), reference expiry, card return, refunds |
Transactions, Transition |
Payment attempts (Multi-Vendor parent resolution, child shares), read-back schedule; status mapping, never backwards |
Accounts, Secret |
Keys sealed with AES-256-GCM; one account per store owner or per vendor; the anti-phishing key |
Config, Access |
Settings, owner mode, who may see, manage and move money |
Queue, Jobs, JobException |
Job queue (sync, expire, refund); back-off 5 min / 15 min / 1 h / 3 h / 12 h |
Log |
Event log with masking (keys, e-mail addresses, names, phone numbers), filters, CSV, retention |
Retention |
Retention-safe uninstall (records kept unless the purge setting is on) |
Payment processors
Section titled “Payment processors”| Processor | Script | Checkout template |
|---|---|---|
| ifthenpay: Multibanco | payments/kv_ifthenpay_mb.php |
views/orders/components/payments/cc_outside.tpl |
| ifthenpay: MB WAY | payments/kv_ifthenpay_mbway.php |
addons/kv_ifthenpay_payments/views/orders/components/payments/mbway.tpl (field payment_info[kv_mbway_phone]) |
| ifthenpay: Payshop | payments/kv_ifthenpay_payshop.php |
views/orders/components/payments/cc_outside.tpl |
| ifthenpay: Credit card | payments/kv_ifthenpay_ccard.php |
views/orders/components/payments/cc_outside.tpl |
The four scripts share payments/kv_ifthenpay_payments.php. Each processor has its own script because core answers payment_notification.* only while a payment method of that script’s processor is active.
Endpoints of the add-on
Section titled “Endpoints of the add-on”| Dispatch | Caller | Proof |
|---|---|---|
kv_ifthenpay_payments.callback&c=<account>&m=<method>&k=... (GET) |
ifthenpay callback | anti-phishing key (constant-time compare), order id, request id / entity / reference, amount |
kv_ifthenpay_payments.mbway_notify&c=<account> (POST JSON) |
ifthenpay MB WAY notification | X-Ifthenpay-Signature (HMAC-SHA256 with the MB WAY key); the status is then read back |
kv_ifthenpay_payments.mbway / .mbway_status |
the customer’s browser | order id + secret key of the attempt |
payment_notification.return&payment=kv_ifthenpay_mbway |
MB WAY page | order id + key |
| `payment_notification.success | error | cancel&payment=kv_ifthenpay_ccard` |
kv_ifthenpay_payments.cron&key=... |
cron | secret key |
Answers of the callback: 200 booked (or already booked), 400 malformed, 403 wrong key / other account, 404 unknown payment, 409 identifiers do not match, 503 busy (ifthenpay retries).
Hooks used
Section titled “Hooks used”| Hook | Use |
|---|---|
change_order_status_post |
refund at the chosen order status |
prepare_checkout_payment_methods |
hides a method without key, licence, euro amount or within the Multibanco amount range |
mailer_send_pre |
adds the reference block to the customer’s order e-mails while the reference waits for the payment |
init_templater_post |
Upgrade Synchronizer (only while an upgrade is pending) |
template checkout:payment_instruction (post) |
reference card on the order complete page |
template orders:info (post) |
reference card on the customer’s order page |
template orders:tabs_extra (post, admin) |
the ifthenpay payment tab |
template index:styles (post) |
storefront styles |
Smarty helper for your own templates: {$order_id|fn_kv_ifthenpay_payments_reference} returns method, label, entity, reference, amount, expires, paid, expired (empty when the order has no reference).
Database tables
Section titled “Database tables”| Table | Purpose |
|---|---|
?:kv_ifthenpay_payments_accounts |
Keys per company (sealed), anti-phishing key (sealed), last connection check, callback activations |
?:kv_ifthenpay_payments_log |
Log |
?:kv_ifthenpay_payments_jobs |
Queue |
?:kv_ifthenpay_payments_transactions |
Payment attempts: method, order id sent, request id, entity, reference, masked phone, amount (cents, EUR), status, expiry, read-back schedule |
?:kv_ifthenpay_payments_refunds |
Refunds (creating, succeeded, failed, unconfirmed) |
Test against a mock of the API
Section titled “Test against a mock of the API”The base URL can be overridden for tests in config.local.php (development only):
$config['kv_ifthenpay_payments_base_url'] = 'http://127.0.0.1:11833';node tests/mock-server/server.js 11833 starts a local stand-in built from the official ifthenpay OpenAPI files; node tests/e2e/e2e.mjs runs the HTTP end-to-end test against it; php tests/unit.php runs the unit tests. The add-on was built and tested against the documentation and this mock, not against a live ifthenpay account.
Template overrides
Section titled “Template overrides”Admin templates live in design/backend/templates/addons/kv_ifthenpay_payments/. Do not edit them in a store; they are replaced on update.