API ReferencePlatform Adapters

Platform adapters

The PlatformAdapter class and its request objects.

Namespace PayLexer\Integration. Each method calls the function in the last column and throws Exception where the function would return a WP_Error.

For a complete working adapter, with registration, a checkout and on_event(), see the Platform adapters guide.

PlatformAdapter

PlatformAdapter (abstract). Set the properties $id, $name (both required), $by, $icon, $plugin, $plugin_url, $addon_icon, $description and $supports.

Set the logo URLs in a constructor, since plugins_url() can't appear in a property default.

Methods

MethodReturnsSame as
id()string
is_enabled()boolpaylexer_is_platform_enabled()
gateways( array $filters = [] )arraypaylexer_get_gateways()
currencies()arraypaylexer_get_currencies()
create_checkout( CheckoutRequest $request )arraypaylexer_create_checkout()
create_subscription( SubscriptionRequest $request )arraypaylexer_create_subscription()
update_subscription( string $subscription_id, string $action )arraypaylexer_cancel_subscription(), _pause_, _resume_ ($action: cancel, pause, resume)
refund( string $order_reference, ?float $amount = null, string $reason = '' )arraypaylexer_refund()
get_payment_status( string $order_reference )arraypaylexer_get_payment_status()
get_subscription_status( string $subscription_id )arraypaylexer_get_subscription_status()
get_orders( array $args = [] )arraypaylexer_get_orders()
render_order_details( string $order_reference, bool $with_heading = true, array $known = [] )prints HTMLpaylexer_render_order_details()
on_event( WebhookEvent $event )voidOverride it. paylexer_platform_{id}_webhook

Request objects

Build them with named arguments. Their fields are the keys the matching function takes, and empty strings fall back to the same defaults.

ClassRequiredOptional
Customeremailfirst_name, last_name, phone, address
LineItemname, unit_amountquantity (1), id
CheckoutRequestgateway, amount, currency, customer, return_urlcancel_url, reference, description, items, metadata, test_mode, merchant_name, theme_color, order_url
SubscriptionRequestgateway, amount, currency, interval, customer, return_urlinterval_count, cancel_url, reference, product_name, plan_name, trial_days, billing_cycles, sign_up_fee, items, metadata, test_mode, order_url, product_id (shown as the SKU)

Webhooks and errors

Webhook objects: see WebhookEvent.

Exception: get_error_code() returns one of the error codes; getMessage() the message.