paylexer / wordpress-starter
Starter WordPress plugin that takes payments through the PayLexer plugin's developer API. Generate it, rename it, make it yours.
Package info
github.com/PayLexer/wordpress-starter
Type:project
pkg:composer/paylexer/wordpress-starter
Requires
- php: >=8.1
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A small working plugin that takes payments through the PayLexer plugin's developer API, built on a platform adapter (PayLexer\Integration\PlatformAdapter). Generate a copy, rename it, then change it to fit your site.
It doesn't talk to PayLexer itself and holds no keys. The merchant connects their account once in the PayLexer plugin, and your plugin uses that connection:
src/Adapter.phpis your platform: its id, name and features, andon_event(), where verified webhooks arrive. It's registered onpaylexer_initwithpaylexer_register_adapter()and can take payments while your plugin is active.- Settings → PayLexer Starter shows the connection, your plugin's settings (test mode, default gateway), the merchant's gateways, and your orders and subscriptions with refund and cancel buttons. Every panel is one
Adaptercall you can copy. src/Payments.phptakes one-time payments and subscriptions through PayLexer's hosted checkout (CheckoutRequest,SubscriptionRequest). Failures throwPayLexer\Integration\Exception. Whether checkout opens in a modal or as a redirect is PayLexer's decision per gateway.- PayLexer checks each webhook's signature, then calls
Adapter::on_event(). Settle your orders there, never from the browser.
You can only see and refund orders and subscriptions your own plugin created.
Create your plugin
cd wp-content/plugins
composer create-project paylexer/wordpress-starter acme-pay
You're asked for the plugin name, slug, prefix and namespace, with defaults from the folder name (Acme Pay, acme-pay, acme_pay, AcmePay). You're also asked for the platform you integrate (e.g. acme-bookings / "Acme Bookings"), which is what PayLexer records on orders and lists under Integrations. Add --no-interaction to accept the defaults.
Try it
- Install and connect the PayLexer plugin, and enable at least one gateway.
- Activate your plugin.
- Put
[acme_pay_pay amount="10.00" currency="USD" description="T-shirt"]on a page and pay with a sandbox card. Addinterval="month"for a subscription, and optionallyinterval_count,trial_days,sign_up_feeandbilling_cycles. Gateways that can't run a trial or charge a sign-up fee are left out of the list. - Refund from Settings → PayLexer Starter, or from code with
AcmePay\Adapter::instance()->refund( $order_reference ), where$order_referenceis the onecreate_checkout()returned.
PayLexer delivers webhooks to the site's own domain, so a local site needs a tunnel.
Make it yours
src/Payments.php stores its orders in a WordPress option so the template runs on its own; replace that with your own orders. Everything to change is marked TODO. Webhooks arrive in Adapter::on_event(): payment events settle one-time orders, and subscription.* events (activated, trial, renewed, payment failed, paused, resumed, cancelled) move subscriptions through Payments::settle_subscription(), where you grant or remove access. Every adapter method is documented at docs.paylexer.com/wordpress/adapters; the same calls also exist as plain paylexer_* functions.
Before going live, untick Test mode under Settings → PayLexer Starter.