weareplanet/plugin-core

Core functionality for the WeArePlanet plugins.

Maintainers

Package info

github.com/weareplanet/plugin-core

pkg:composer/weareplanet/plugin-core

Statistics

Installs: 0

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

0.2.0 2026-04-02 10:10 UTC

This package is not auto-updated.

Last update: 2026-04-03 11:35:54 UTC


README

The canonical, framework-agnostic business logic engine for WeArePlanet payment integrations.

This library abstracts the complexity of the WeArePlanet SDK and provides a standardized, robust implementation of payment flows. It is designed to be used as a core dependency by platform-specific plugins (Magento, WooCommerce, Shopware, etc.), decoupling business logic from platform infrastructure.

Core Philosophy

The goal of this project is to centralize all payment business logic into a single, reusable library, decoupling it from the specific constraints of platforms like Magento or WooCommerce.

Instead of duplicating complex logic across different shop systems, plugin-core implements the payment workflows once, using pure PHP. This shifts the role of the shop-specific plugin:

  • Plugin Core: Implements the business logic, manages state machines, and handles all API interactions via the SDK.
  • Shop Plugin: Acts as an adapter. It interchanges data between the shop and the Core, handles database persistence, manages configuration, and integrates into the shop's frontend/backend events.

Key Architectural Benefits

  • Pure PHP: Framework-agnostic code that runs anywhere PHP runs.
  • Minimal Dependencies: Depends only on the official weareplanet/php-sdk, making it lightweight and easy to port to any environment.
  • Type Safety: Written with strict typing to catch errors early.
  • Testability: Designed for 100% unit test coverage with isolated components.
  • PSR Standards: Fully compliant with PSR-3 (Logging) and other standard interfaces.
  • Contract-Driven: Clear Interfaces and Abstract Base Classes guide developers to implement the necessary platform-specific adapters correctly.

Key Features

The library is divided into major functional components, each designed for robustness and ease of integration.

1. Checkout Engine

The core of the payment flow. Handles transaction creation and management with a sophisticated "upsert" strategy, ensuring seamless navigation without duplicate charges.

2. Webhook Processor

The engine for handling asynchronous events from the WeArePlanet Portal. It's built for scale and high concurrency.

3. Webhook Management

Tools for programmatically managing webhooks in the WeArePlanet Portal, including URL creation and Listener setup.

4. Transaction Completion (Capture & Void)

Manage the final stages of the transaction lifecycle. Finalize payments (Capture) or cancel them (Void) with dedicated service handlers.

5. Recurring Payments

Enables Merchant Initiated Transactions (MIT) for seamless subscription renewals and unscheduled subsequent charges using saved tokens.

6. Refund Management

Support for full and partial refunds. Includes precise line-item logic and validation to prevent over-refunding.

7. Document Management

Retrieve official PDF documents (Invoices, Packing Slips, Credit Notes) directly from the WeArePlanet Portal for the merchants.

8. Payment Method Service

A centralized service to fetch available payment method configurations from the WeArePlanet Portal, ensuring the shop systems have an up-to-date view of available payment methods.

Documentation

For a detailed look at how to implement each module, refer to the guides in the docs/ directory:

Examples

For a runnable example for each of the modules, refer to the examples subdirectories in each of the module directories.

Installation

composer require weareplanet/plugin-core

Unit Tests

You can run the test suite to verify the library's behavior.

composer test

License

Apache License. See [LICENSE.txt].