mod_payment

Manage payment requests, local payment records, status notifications and PSP adapters.

Enable this module and at least one payment provider module. Configure the site under System → Payment configuration, which requires use.mod_admin_config. Payment administration and exports use use.mod_payment.

Integration

Include zotonic_mod_payment/include/payment.hrl and send a #payment_request{} with z_notifier:first/2. Set preferred_psp_module to select a provider explicitly. A successful request returns #payment_request_redirect{} with the checkout URL. Observe #payment_status{} to react to status changes. Provider adapters implement #payment_psp_request{} and status synchronization notifications.

Verified provider updates enter through receive_payment/3. Shared logic validates amounts and currencies, deduplicates PSP identities, records updates and emits notifications after the receive transaction commits. Repeated updates must not reopen finalized payments.

Site configuration

  • description, currency and amount: defaults for new payment requests. Amounts use major currency units; the optional configured amount is a whole number.
  • email_paid: recipients of paid-payment notifications.
  • delete_after_days: retention based on modification time; unset disables deletion, and configured retention must be at least two days.
  • accept_unknown_payments: allow verified incoming payments not initiated here. Defaults to false.
  • disable_unknown_payment_polling: disable discovery while retaining webhook imports. Defaults to false.

With unknown payments enabled, supported providers are polled every four hours. Discovery starts with a recent window, not a complete historical backfill. Payments created before the retention cutoff are not imported by polling. Mollie, Stripe and PayPal implement discovery; PayPal additionally requires its reporting option. Buckaroo and Sovergn do not discover unknown payments by polling.

Configuration

Configuration keys declared by this module. The defaults below are from the source code.

Module Key Type Default Description
mod_payment description binary <<>> Default description for new payment requests.
mod_payment currency binary <<"EUR">> Three-letter currency code for new payment requests.
mod_payment amount integer <<>> Optional default payment amount in major currency units (whole numbers).
mod_payment email_paid binary <<>> Email addresses receiving a notification when a payment is paid.
mod_payment delete_after_days integer <<>> Delete payments not modified for this many days. Leave empty to retain payments; minimum 2 days.
mod_payment accept_unknown_payments boolean false Import payments received through verified PSP webhooks or polling that were not initiated here.
mod_payment disable_unknown_payment_polling boolean false Disable four-hour discovery polling; verified webhooks can still import unknown payments.

Observes

Notifications

observe_export_resource_data/2

mod_export - fetch a row for the export, can return a list of rows, a binary, and optionally a continuation state. Where Values is [ term() ], i.e. a list of…

Notification

payment_request

Notification

tick_24h

Notification

tick_4h

Models

Models

m_payment

Read payment data and maintain local payment records.

Models

m_payment_config

Expose editable configuration for active payment modules.

Models

m_payment_log

Append audit events to a payment's log from trusted server code.

Dispatch rules

Dispatch rules

mod_payment dispatch rules (dispatch)

This file defines the URL dispatch rules for mod_payment . Rules are matched from top to bottom; the first matching rule handles the request.

Filters