Fires once the plugin has finished bootstrapping and all of its components are loaded. This is the recommended moment for add-ons to register their own gateways, settings, or callbacks against Cafetito, because the container and registries are ready at this point.
Parameters
Name
Type
Description
$plugin
`Cafetito\Plugin`
The main plugin instance, giving access to its registries and services.
Source: includes/Plugin.php:122
PHP
add_action( 'cafetito_loaded', function ( $plugin ) {
// The plugin is fully initialized here.
error_log( 'Cafetito is ready.' );
}, 10, 1 );
cafetito_activatedAction
Fires when the plugin is activated, after the installer has created or upgraded the database tables and registered capabilities. Use it to seed default options or run one-time activation tasks for your extension.
Fires when the plugin is deactivated, after Cafetito has performed its own cleanup of scheduled events. Use it to clear your add-on's scheduled tasks or transient state.
Source: includes/Installer.php:50
PHP
add_action( 'cafetito_deactivated', function () {
wp_clear_scheduled_hook( 'my_addon_cron' );
} );
cafetito_uninstalledAction
Fires from the uninstall routine after Cafetito has removed its own data. Use it to delete any options, tables, or files your extension created so the uninstall is complete.
Source: uninstall.php:50
PHP
add_action( 'cafetito_uninstalled', function () {
delete_option( 'my_addon_settings' );
} );
cafetito_admin_loadedAction
Fires when the Cafetito admin layer has finished initializing (menus, list tables, and admin services). Use it to hook additional admin-only behavior that depends on Cafetito's admin objects being available.
Parameters
Name
Type
Description
$admin
`Cafetito\Admin\Admin`
The admin controller instance.
Source: includes/Admin/Admin.php:40
PHP
add_action( 'cafetito_admin_loaded', function ( $admin ) {
// Register extra admin behavior here.
}, 10, 1 );
Settings & capabilities 8
cafetito_capabilitiesFilter
Filters the list of WordPress roles that receive the Cafetito management capability when the plugin is installed. By default only administrator is granted. Add role slugs to extend access.
Parameters
Name
Type
Description
$roles
`string[]`
*Value to return.* Array of role slugs that should receive the capability.
Filters the default settings values for a given settings group. It fires once per group (for example general and email), with the group name as the second argument. Use it to provide defaults for your own settings or override the plugin's.
Parameters
Name
Type
Description
$defaults
`array`
*Value to return.* Map of setting key to default value for the group.
$group
`string`
The settings group being defaulted (for example general or email).
Source: includes/Admin/Settings.php:97 (primary). Fired in 2 locations (Settings.php:97 and Settings.php:123).
Fires after a settings tab has been saved. Use it to react to configuration changes, for example to flush caches or recompute derived options.
Parameters
Name
Type
Description
$tab
`string`
The slug of the settings tab that was saved.
Source: includes/Admin/Settings.php:230
PHP
add_action( 'cafetito_settings_saved', function ( $tab ) {
if ( 'general' === $tab ) {
// React to saved general settings.
}
} );
cafetito_settings_render_tabAction
Fires while rendering the settings page so a custom tab can output its own fields. The current tab slug is passed so you can render only when your tab is active.
Parameters
Name
Type
Description
$current
`string`
The slug of the tab currently being rendered.
$settings
`Cafetito\Admin\Settings`
The settings service instance, for reading current values.
Source: includes/Admin/SettingsPage.php:106
PHP
add_action( 'cafetito_settings_render_tab', function ( $current, $settings ) {
if ( 'my_addon' === $current ) {
echo '<p>My add-on settings go here.</p>';
}
}, 10, 2 );
cafetito_settings_gateway_itemsAction
Fires within the gateways section of the settings page so add-on gateways can render their configuration controls alongside the built-in ones.
Parameters
Name
Type
Description
$settings
`Cafetito\Admin\Settings`
The settings service instance.
Source: includes/Admin/SettingsPage.php:203
PHP
add_action( 'cafetito_settings_gateway_items', function ( $settings ) {
// Output configuration UI for a custom gateway.
}, 10, 1 );
cafetito_settings_groupsAction
Fires while rendering a settings tab to allow adding extra setting groups (sections) to that tab. The tab slug is passed so output can be conditional.
Parameters
Name
Type
Description
$tab
`string`
The slug of the tab being rendered.
$settings
`Cafetito\Admin\Settings`
The settings service instance.
Source: includes/Admin/SettingsPage.php:708
PHP
add_action( 'cafetito_settings_groups', function ( $tab, $settings ) {
if ( 'general' === $tab ) {
// Render an extra settings group.
}
}, 10, 2 );
Gateways & payment methods 6
cafetito_gatewaysFilter
Filters the array of registered payment gateways. This is the primary extension point to add a custom gateway to Cafetito: append your gateway instance to the array.
Parameters
Name
Type
Description
$gateways
`array`
*Value to return.* Array of gateway instances keyed by gateway id.
Source: includes/Gateways/GatewayRegistry.php:132
PHP
add_filter( 'cafetito_gateways', function ( $gateways ) {
$gateways['my_gateway'] = new My_Gateway();
return $gateways;
} );
cafetito_gateway_registeredAction
Fires each time a gateway is registered in the registry. Use it to react when a particular gateway becomes available, for example to attach gateway-specific hooks.
Filters the id of the gateway used by default when none is explicitly selected. By default it is the first available gateway. Return a different gateway id to change the default.
Filters the parameters sent to Redsys when starting or processing a payment. Use it to add or adjust merchant parameters before the request is signed and sent. The third argument is the payment context, which is null for some flows (such as refunds).
Parameters
Name
Type
Description
$params
`array`
*Value to return.* The Redsys request parameters.
$transaction
`Cafetito\Payments\Transaction`
The transaction being processed.
$context
`Cafetito\Payments\PaymentContext|null`
The payment context, or null when not applicable.
Source: includes/Gateways/Redsys/RedsysGateway.php:222 (primary). Fired in 2 locations (RedsysGateway.php:222 and RedsysGateway.php:298).
Filters the map of Redsys error codes to human-readable messages used when surfacing refund and operation errors. Add or override codes to customize the wording shown to administrators.
Parameters
Name
Type
Description
$messages
`array`
*Value to return.* Map of Redsys error code (for example SIS0057) to its message string.
Source: includes/Admin/RefundController.php:330
PHP
add_filter( 'cafetito_redsys_error_messages', function ( $messages ) {
$messages['SIS0058'] = __( 'Response data is not valid.', 'my-addon' );
return $messages;
} );
Payment & transaction lifecycle 10
cafetito_transaction_createdAction
Fires immediately after a new transaction is created and persisted, before the visitor is redirected to the gateway. Use it to record or enrich the transaction with your own metadata.
add_action( 'cafetito_transaction_created', function ( $transaction ) {
// Persist extra data linked to this transaction.
}, 10, 1 );
cafetito_transaction_status_changedAction
Fires whenever a transaction transitions from one status to another. This is the central place to react to any state change, receiving both the old and the new status so you can branch on the specific transition.
Fires just before the visitor is redirected to the gateway to complete payment. Use it for last-minute logging or to set session data tied to the payment context.
Filters whether a given transaction is allowed to be refunded. Cafetito computes an initial value from the gateway's refund support and the transaction state; return false to block, or true to allow, based on your own rules.
Parameters
Name
Type
Description
$can_refund
`bool`
*Value to return.* Whether the refund is permitted.
add_action( 'cafetito_refund_failed', function ( $transaction, $amount, $result ) {
// Handle the failed refund.
}, 10, 3 );
Notifications (IPN) & returns 12
cafetito_notification_receivedAction
Fires when a gateway notification (IPN) is received and its result has been parsed. Use it to react to server-to-server payment notifications, for example to trigger custom fulfillment.
Parameters
Name
Type
Description
$result
`mixed`
The parsed notification result object produced by the gateway.
add_action( 'cafetito_notification_received', function ( $result, $gateway_id ) {
// Handle the incoming notification.
}, 10, 2 );
cafetito_notification_invalid_signatureAction
Fires when an incoming gateway notification fails signature verification. Use it for security monitoring and alerting on potentially fraudulent or malformed callbacks.
Parameters
Name
Type
Description
$gateway_id
`string`
The id of the gateway the notification claimed to come from.
$context
`array`
Context about the invalid request (such as request data for diagnosis).
Filters the notification (IPN) URL that Cafetito sends to the gateway as the callback endpoint for a given gateway. Use it to override the URL, for example behind a proxy or custom routing.
Fires on the return screen when the visitor comes back from a successful payment. Use it to display a thank-you, fire analytics, or run front-end side effects on the success page.
Parameters
Name
Type
Description
$transaction
`Cafetito\Payments\Transaction`
The transaction associated with the return.
Source: includes/Frontend/ReturnScreen.php:80
PHP
add_action( 'cafetito_payment_return_success', function ( $transaction ) {
// Fire a conversion event, etc.
}, 10, 1 );
cafetito_payment_return_cancelAction
Fires on the return screen when the visitor returns after cancelling the payment. Use it to record the cancellation or show a custom message.
Parameters
Name
Type
Description
$transaction
`Cafetito\Payments\Transaction`
The transaction associated with the return.
Source: includes/Frontend/ReturnScreen.php:87
PHP
add_action( 'cafetito_payment_return_cancel', function ( $transaction ) {
// Handle the cancellation return.
}, 10, 1 );
cafetito_result_htmlFilter
Filters the full HTML of the return result card before it is output to the page. Use it to wrap, replace, or augment the rendered result.
Parameters
Name
Type
Description
$card
`string`
*Value to return.* The HTML of the result card.
$transaction
`Cafetito\Payments\Transaction|null`
The transaction, or null if not resolvable.
$variant
`string`
The result variant: success, cancelled, or rejected.
Filters the body message shown on a successful return. The second argument indicates whether the result is definitive (confirmed) or still provisional.
Filters the parsed attributes of the Cafetito shortcode before they are used to build the button configuration. Use it to inject defaults or override attributes globally.
Filters the resolved button configuration object built from the shortcode or block attributes. This is the central object describing a payment button or form. Use it to programmatically adjust amounts, fields, labels, or gateway selection.
Fires after a front-end form has been submitted and successfully validated, just before checkout starts. Use it to react to a valid submission, for example to capture the sanitized visitor input.
Parameters
Name
Type
Description
$config
`Cafetito\Frontend\ButtonConfig`
The button configuration of the submitted form.
$input
`array`
The sanitized visitor input.
Source: includes/Frontend/CheckoutHandler.php:101
PHP
add_action( 'cafetito_form_submitted', function ( $config, $input ) {
// React to a valid submission.
}, 10, 2 );
cafetito_validation_failedAction
Fires when server-side validation of a form submission fails, before the visitor is redirected back with errors. Use it to log or monitor failed submissions.
Filters the validation errors of a form submission. It lets an add-on add or remove errors (for example, to enforce a custom required field). The errors map uses field keys to message strings.
Parameters
Name
Type
Description
$errors
`array`
*Value to return.* Map of field key to error message.
Filters the data array used to create a transaction from a validated submission. Use it to attach additional fields, metadata, or computed values to the transaction at creation time.
Filters the URL the gateway should redirect to after a successful payment. Use it to send the visitor to a custom thank-you page instead of the default return screen.
Filters the client IP address resolved for the current request, used for logging and fraud checks. Use it when behind a proxy or load balancer to provide the correct originating IP.
Parameters
Name
Type
Description
$ip
`string|null`
*Value to return.* The resolved client IP, or null if none was determined.
Filters the currency code used by the plugin. Defaults to EUR. Return a different ISO currency code to change the currency used for amounts and formatting.
Parameters
Name
Type
Description
$currency
`string`
*Value to return.* The currency code (default EUR).
Source: includes/Frontend/ButtonConfig.php:492 (primary). Fired in 2 locations (ButtonConfig.php:492 and Admin/TransactionsListPage.php:166).
Filters the default concept (description) text used for a payment when none is supplied, for a given button type. Use it to provide a custom default concept.
Filters the formatted, human-readable string of a monetary amount. Use it to fully customize how amounts are displayed (separators, symbol placement, decimals).
Fires after the front-end assets (scripts and styles) have been registered with WordPress. Use it to register additional assets or declare dependencies on Cafetito's handles.
Filters the placeholder map used to interpolate the email subject and body for a transaction. Use it to add custom placeholders that your templates can reference.
Parameters
Name
Type
Description
$placeholders
`array`
*Value to return.* Map of placeholder token to replacement value.
Filters the final HTML of a notification email after the body has been assembled. Use it to wrap the content in a custom template or add a header/footer.
Filters the email preset (style/template preset) applied to a notification email for a given type and transaction. Use it to switch presets per email type.
Filters the map of transaction statuses to their admin badge definitions (label and styling). Use it to add badges for custom statuses or restyle existing ones.
Parameters
Name
Type
Description
$map
`array`
*Value to return.* Map of status key to badge definition.
Fires while rendering the filter controls above the transactions list. Use it to output additional filter inputs. The current active filters are passed.
add_action( 'cafetito_admin_filters', function ( $filters ) {
// Render an extra filter control.
}, 10, 1 );
cafetito_admin_list_query_argsFilter
Filters the query arguments used to fetch transactions for the admin list, given the active filters. Use it to apply custom filtering logic to the admin list query.
Filters a translatable text string by key, allowing centralized overriding of the plugin's user-facing copy. Match on the key to override a specific string.
Filters the REST API namespace used by the plugin (default cafetito/v1) for its endpoints, including the notification (IPN) route. Use it to version or relocate the plugin's REST routes. Note that changing this affects the notification URL sent to gateways, so adjust gateway configuration accordingly.
Parameters
Name
Type
Description
$namespace
`string`
*Value to return.* The REST namespace (default cafetito/v1).
Source: includes/Frontend/CheckoutHandler.php:578 (primary). Fired in 2 locations (CheckoutHandler.php:578 and Rest/NotificationController.php:115).