Skip to content

Developer notes

Path Purpose
app/addons/kv_mollie_payments/payments/kv_mollie_payments.php Processor script: start, return, cancel, webhook
Tygh/Addons/KvMolliePayments/PaymentService.php Payment flow, order status, refund, capture
Tygh/Addons/KvMolliePayments/Transition.php State rules and the identity and amount checks
Tygh/Addons/KvMolliePayments/OrderMapper.php, Lines.php, Money.php Order to Mollie payment, exact amounts
Tygh/Addons/KvMolliePayments/Api/Client.php Payments API v2 client
URL Purpose
index.php?dispatch=payment_notification.webhook&payment=kv_mollie_payments Mollie webhook. Sent with each payment, nothing to configure.
...payment_notification.return&...&order_id=N&key=K Customer return. key is a per-payment random value.
...payment_notification.cancel&... Customer cancel. It proves nothing by itself: the state is read from Mollie.

Webhook answers: 200 for anything needing no retry, including unknown and malformed IDs. 503 when the payment could not be read or another request is working on it, so Mollie retries.

Local status in ?:kv_mollie_payments_transactions.status: creating, open, pending, authorized, paid, canceled, expired, failed, superseded, mismatch, error.

  • paid never changes back.
  • A failed, canceled or expired result of an older attempt doesn’t touch the order.
  • A payment becomes superseded when the customer starts a new one for the order. If it is paid later anyway, it still counts, or it is flagged as a duplicate when another payment is already paid.
  • Repository::claim() lets one request work on a payment at a time. A crashed request frees it after 60 seconds.

Mollie’s classic webhooks are not signed. The body is only id=tr_xxx, so the add-on trusts nothing in the call. It looks the ID up locally, reads the payment from the API with the store’s key, and requires the payment ID, mode, metadata.order_id, amount, currency and current order total to match before an order counts as paid. Only tr_ IDs known to the store cause an API call.

Next-gen signed webhooks are in beta at Mollie and aren’t used.

Define KV_MOLLIE_API_BASE in local_conf.php to point the client at a local server. It is honored only for http://localhost and http://127.0.0.1.

  • ?:kv_mollie_payments_transactions: one row per payment attempt, with amounts in minor units. details (1.1.0) keeps the Multibanco or bank transfer instructions, the expiry and the payment time as JSON.
  • ?:kv_mollie_payments_refunds: one row per refund, keyed by the Mollie refund ID.

The method list per payment method is stored in ?:storage_data as kv_mollie_methods_<payment_id>. Since 1.1.0 each entry also has the limits per currency (currencies), read with one extra API call per non-EUR store currency (up to 12), because Mollie lists only EUR methods without an amount. Catalog.php holds the documented currency, countries and refund period of the local methods. It is written only from the admin, so checkout pages cause no writes and no API calls.

prepare_checkout_payment_methods, change_order_status_post, save_log. Template hooks checkout:order_confirmation and orders:totals_payment (payment instructions). Schema documents/order.post.php adds the instructions to the payment variable p of order documents (p.payment and p.kv_mollie_instructions).

The order lines always add up to the amount: taxes outside prices, gift certificates, reward points and conversion rounding go into one balancing line. Lines carry no VAT fields, since the add-on sends only the required ones.

Next: FAQ. Back to the overview.