Skip to content

Developer notes

Technical reference for developers who customize Payfast Payments.

Item Value
Add-on id kv_payfast_payments
Function prefix fn_kv_payfast_payments_
Language variables kv_payfast_payments.*
CSS scope .kv-payfast-payments
PHP namespace Tygh\Addons\KvPayfastPayments
Preset payment (generated by kv new --kind integration)
Class Role
Client\BaseClient HTTP (cURL, TLS verification, timeouts), error mapping, masked logging
Client\Api Payfast: signed REST API (ping, refund query / create / balance), ITN server confirmation (/eng/query/validate), payment page URL
PaymentService Start (signed payment form), ITN booking, cancel, expiry, refunds with balance reconciliation, refund sync; one GET_LOCK per payment for all of them
ClientIp Sender address for the ITN source check (generated by kv client-ip)
Client Client per company, the connection test
Accounts, Secret Credentials (test and live) sealed with AES-256-GCM; one account per store owner or per vendor
Config, Access Settings, owner mode, who may see and manage what
Queue, Jobs, JobException Job queue: back-off 5 min / 15 min / 1 h / 3 h / 12 h, per-job isolation, overlap lock; handlers in Jobs::handle(), recurring work in Jobs::schedule()
Log Event log with masking, filters, CSV, retention
Webhook Form signature builder, ITN signature check, sender address ranges; the controller kv_payfast_payments.itn?c=<account> runs the checks and stores the reduced notification as a job
Table Purpose
?:kv_payfast_payments_accounts Credentials per company (secrets sealed), last connection check, token cache
?:kv_payfast_payments_log Log
?:kv_payfast_payments_jobs Queue
?:kv_payfast_payments_transactions, ?:kv_payfast_payments_refunds Payments and refunds

PHP: change_order_status_post (refund at a chosen order status), prepare_checkout_payment_methods (hides the method when the add-on or ZAR is not available), init_templater_post (upgrade synchronizer). Template hooks: orders:tabs_extra (payment tab). Every Payfast call and field is listed with its documentation page in notes/API-NOTES.md.

The base URL can be overridden for tests in config.local.php (development only):

$config['kv_payfast_payments_base_url'] = 'http://127.0.0.1:11870';

node tests/mock-server/server.js 11870 starts a local stand-in of the provider API; node tests/e2e/e2e.mjs runs the HTTP end-to-end test against it; php tests/unit.php runs the unit tests.

Admin templates live in design/backend/templates/addons/kv_payfast_payments/. Do not edit them in a store; they are replaced on update.