Skip to content

Developer notes

  • Tygh\Addons\KvTurkishBankPos\Drivers\{NestPay, Garanti, Posnet, VakifBank}: one class per gateway family (DriverInterface: begin, complete, inquiry, cancel, refund, test). The hash / MAC functions are public static and unit tested (tests/unit.php).
  • Router (bank choice and offers) and Installments (surcharge arithmetic, product table) are pure and unit tested.
  • PaymentService: card page context, attempt creation, return handling (per-order MySQL lock, atomic pending -> processing claim so a replayed bank post is handled once), read-back, order status, refunds and voids.
  • Banks (profiles, credentials sealed with AES-256-GCM per mode), Bins (BIN table, CSV), Vault (VakıfBank split-key card vault), Surcharge (instalment fee on the order).
  • Tables: kv_turkish_bank_pos_banks, _bins, _transactions (one row per card attempt), _refunds, _jobs, _log.

payments/kv_turkish_bank_pos.php opens kv_turkish_bank_pos.pay?order_id&key after the order is placed. The card form posts to kv_turkish_bank_pos.start, which validates the card, routes it, writes the attempt (oid = 20 characters KV<order 8><A><attempt 9>) and prints an auto-submit form to the bank. The bank posts back to payment_notification.return&t=<attempt>&key=<link key>; the raw body is parsed with the names as sent (PHP and CS-Cart rewrite request names and values, which would break the hashes). After settling, the customer is redirected to payment_notification.finish, which runs in the customer’s own session.

The VakıfBank MPI return carries no signature (integration guide v2.4): Status, ECI and CAVV come through the customer’s browser. The VPOS sale uses the MPI transaction id and the CAVV, which the issuer validates, and the amount always comes from the store’s own attempt record, so a forged ECI on a card the issuer would reject cannot book a payment. A VakıfBank transaction inquiry is a candidate for a later version. A POSNET reverse or return answered “approved=2” (already done at the bank) is shown as failed with the bank text: check the bank panel before refunding by hand.

Card data in the store database: only the masked number (first six and last four digits) and, for VakıfBank, the sealed card kept between 3D Secure and the sale (AES-256-GCM, key split with a one-time value that is not stored; wiped on return, on the next card-page start or return, and by the cron after 30 minutes at most).

Amounts are kept in minor units. An order in a currency the bank profile does not take is charged in TRY (store conversion rate).

tests/mock-server/server.js re-implements the documented requests, answers and hashes of the four gateways (and refuses wrong ones). Point a development store at it in config.local.php:

$config['kv_turkish_bank_pos_base_url'] = 'http://127.0.0.1:11847';

Every bank URL then goes to http://127.0.0.1:11847/<bank host>/<path>. Never set this on a live store. tests/e2e/e2e.mjs refuses to run unless the store points at the local mock.

Sources of every field and formula: see the add-on’s API sources notes shipped with the developer package (Payten 3D model guide v1.3, Garanti BBVA developer portal, POSNET 3D Secure guide v2.0.1.5, VakıfBank VPOS integration guide v2.4).

change_order_status_post (refund at a status), prepare_checkout_payment_methods (hide the method when the add-on cannot take payments), template hooks orders:tabs_extra (admin), products:product_detail_bottom, index:styles, index:scripts (storefront).

  • A new NestPay bank needs no code: choose Other bank and enter its gateway URLs.
  • Another gateway family: implement DriverInterface, register it in Drivers::CLASSES and add its issuers in BankPresets.