mod_paysub

Manage paid memberships, customers, products, prices, subscriptions, invoices and payments. The bundled payment-service integration uses Stripe. Local records support membership checks and administration without a provider request on every page view.

Setup

Enable mod_paysub; its declared dependencies are mod_authentication and mod_l10n. Schema installation creates the payment tables and, when the ACL user-group category exists, the ug_inactive_member group. Configure these per-site mod_paysub settings:

KeyDefaultPurpose
stripe_api_keyEmptyAPI key for Stripe requests.
stripe_webhook_secretEmptyKey for authenticating Stripe callbacks.
is_unpaid_accessfalseAlso grant subscription access for incomplete_expired and unpaid states.
is_no_customer_syncfalseSuppress copying provider customer billing changes back to resource fields.

Configure the provider webhook at the site's /paysub/stripe/webhook URL (dispatch paysub_stripe_webhook). See controller_paysub_stripe_webhook for supported events. A nonempty API key marks the Stripe integration as configured; this does not test connectivity or credentials.

The Payments entries under the admin Modules menu provide a dashboard and invoice, subscription, product and payment lists. Management uses administrator status or use permission for mod_paysub; individual operations can also require resource edit permission. Fetch products and prices through the admin or mod_paysub:sync_products(Context), then associate products with user groups. The direct sync function returns ok when Stripe is unconfigured, or the synchronization result when configured.

Membership and synchronization

When a user context is initialized, subscription products add their associated user groups. Subscriptions of organizations for which the user is a hasmaincontact contact also contribute groups, as do those organizations' hasusergroup edges. If none are found, ug_inactive_member is added. Access states are incomplete, trialing, active and past_due, plus incomplete_expired and unpaid when is_unpaid_access is enabled.

Provider callbacks synchronize local payment records. Resource pivot updates schedule billing changes toward the provider; customer notifications copy changed billing fields back unless is_no_customer_sync is enabled. Resource merging and subscription moves update linked customer records.

Use m_paysub for template data, checkout status and Erlang integration. m_paysub_search supplies administrative searches and resource query terms. The module also supplies checkout completion/cancellation pages, survey payment-status columns and a subscription spreadsheet export.

Configuration

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

Module Key Type Default Description
mod_paysub stripe_api_key string <<>> The API key for Stripe. This is required to use Stripe as a payment service provider.
mod_paysub stripe_webhook_secret string <<>> The webhook secret for Stripe. This is required to verify the authenticity of webhook events from Stripe.
mod_paysub is_unpaid_access boolean false If set to true, users with incomplete_expired and unpaid subscriptions will have access to the site. If set to false, users with unpaid subscriptions will not have access to the site. This can be useful if you want to allow users to access the site while they are in the process of renewing their subscription or if you want to give users a grace period after their subscription has expired.
mod_paysub is_no_customer_sync boolean false If set to true, the customer data will not be synced from the PSP to the resource. This means that changes to the customer data at the PSP will not be reflected in the resource. This can be useful if you want to manage the customer data manually or if you have a large number of customers and want to avoid syncing all data.

Observes

Notifications

observe_acl_user_groups_modify/3

Modify the list of user groups of a user. Called internally by the ACL modules when fetching the list of user groups a user is member of.

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

paysub_customer

Notifications

observe_rsc_merge/2

Map to signal merging two resources. Move any information from the loser to the winner. The loser will be deleted.

Notifications

observe_survey_result_column_values/3

Modify row with answers for export. The header columns are given and the values that are known are set in the folded value. The user_id is the user who filled…

Notifications

observe_survey_result_columns/3

Add header columns for export. The values are the names of the answers and the text displayed above the column. The text format is for a complete export, the…

Models

Models

m_paysub

Access local payment and subscription records, membership state and provider customer portals. Database records generally use binary map keys. Template paths…

Models

m_paysub_search

Provide geographic filter choices and subscription searches for Paysub.

Controllers

Controllers

controller_paysub_stripe_webhook

Receive Stripe payment and subscription events with POST at /paysub/stripe/webhook (dispatch paysub_stripe_webhook ). Generate the absolute endpoint URL in a…

Dispatch rules

Dispatch rules

mod_paysub dispatch rules (dispatch)

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