Search by

brianhenryie / bh-wp-order-email-reconcile

BrianHenryIE

Mark orders as paid by reconciling payment-confirmation emails. WooCommerce supported; designed to be extensible to other order sources (e.g. GiveWP).

Package info

github.com/BrianHenryIE/bh-wp-order-email-reconcile

Type:wordpress-library

pkg:composer/brianhenryie/bh-wp-order-email-reconcile

Statistics

Installs: 145

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 6

dev-master 2026-09-10 17:43 UTC

This package is auto-updated.

Last update: 2026-09-10 17:43:55 UTC


README

PHPCS WPCS

BH WP Order Email Reconcile

Mark orders as paid by reconciling payment-confirmation emails against unpaid orders.

Emails are fetched and stored by BH WP Mailboxes. When new emails arrive, this library parses them and matches them to unpaid orders by order id (from the payment note), customer payment id (e.g. Venmo/$CashTag), email address, then name.

The core is integration-agnostic: it deals only with Unpaid_Order objects supplied by an Unpaid_Orders_Provider_Interface. WooCommerce is supported today; GiveWP is scaffolded as a second integration. See ARCHITECTURE.md and PLAN.md.

Usage

$settings = new My_Reconcile_Settings(); // implements Email_Reconcile_Settings_Interface
$logger   = Logger::instance( $settings );
BH_WP_Order_Email_Reconcile::make( $settings, $logger );

Call make() when your plugin file loads. It only registers hooks: the integrations (WooCommerce, GiveWP) are checked for availability at query time, so it does not matter whether those plugins have loaded yet. Do not defer instantiation past plugins_loaded — the cron jobs are (un)scheduled from plugins_loaded callbacks, which would then never run.

Email accounts (address, display name, filters) and their credentials are owned by BH WP Mailboxes, which stores credentials encrypted through the WordPress Secrets API; this library never handles them.

To let store owners manage the mailbox, append the library's settings fields to a WooCommerce payment gateway's form fields:

$this->form_fields = ( new Credentials_Settings_Fields() )->append_imap_reconcile_fields( $this->form_fields );

This adds an "Add account" button to the gateway's settings screen, which opens BH WP Mailboxes' add/edit IMAP account modal (credentials are saved by that library and the connection is tested), plus a "Manage accounts" link to the emails list screen. That screen's accounts table is where accounts are enabled/disabled, edited, checked now, or deleted, and where recent login failures are flagged.

Development

See CONTRIBUTING.md.