Platform
Register the plugin you integrate, and check PayLexer's state.
Register platform
paylexer_register_platform( string $id, array $args )
Registers the platform you integrate. Call it only inside the paylexer_init action. Called anywhere else, it returns paylexer_register_too_late.
Parameters
| Name | Required | Description |
|---|---|---|
$id | yes | e.g. acme-bookings. ^[a-z0-9_-]{1,40}$. Built-in IDs (woocommerce, edd, wptravelengine, fluentcart, wordpress, custom, unknown, none) are reserved. A second registration of the same ID is refused and the merchant sees a notice naming both plugins. |
name | yes | The platform's name. |
icon | The platform's square logo URL, shown under PayLexer → General → Supported Integrations. | |
by | Your plugin's name, shown under Available Add-ons while your plugin is active. | |
plugin | The integrated plugin's file (e.g. acme-bookings/acme-bookings.php), so Supported Integrations shows "Activated" or an Activate button. | |
plugin_url | Where to get the integrated plugin. A WordPress.org page gives an Install button; any other URL gives a Get link. | |
addon_icon | Your plugin's own square logo URL. Defaults to icon. | |
description | Optional. | |
supports | Any of payments, refunds, subscriptions. payments is always included. |
Responses
| Result | Description |
|---|---|
true | Registered. |
WP_Error | paylexer_register_too_late, paylexer_invalid_platform_id, paylexer_duplicate_platform or paylexer_platform_name_required. See Errors. |
Example
add_action( 'paylexer_init', function () {
paylexer_register_platform( 'acme-bookings', array(
'name' => 'Acme Bookings',
'by' => 'PayLexer for Acme Bookings',
'plugin' => 'acme-bookings/acme-bookings.php',
'supports' => array( 'payments', 'refunds' ),
) );
} );
Returns
true
WP_Error( 'paylexer_duplicate_platform', '…' )
Register adapter
paylexer_register_adapter( PlatformAdapter $adapter )
Call only inside paylexer_init, after loading your adapter class there.
Registers the adapter's platform with its properties and sends every verified webhook for that platform to its on_event(). See Platform adapters.
Responses
| Result | Description |
|---|---|
true | Registered. |
WP_Error | Same codes as above. |
Example
add_action( 'paylexer_init', function () {
require_once __DIR__ . '/src/Adapter.php';
paylexer_register_adapter( new Acme\Adapter() );
} );
Returns
true
Check state
paylexer_api_version()
paylexer_is_platform_enabled( string $id )
paylexer_is_connected()
paylexer_settings_url()
| Function | Returns |
|---|---|
paylexer_api_version() | string, e.g. "1.0". |
paylexer_is_platform_enabled( $id ) | bool. |
paylexer_is_connected() | bool. |
paylexer_settings_url() | string, PayLexer's settings page, where the merchant connects. |
Example
if ( ! paylexer_is_connected() ) {
echo esc_url( paylexer_settings_url() );
}
Returns
"https://example.com/wp-admin/admin.php?page=paylexer"
Was this page helpful?