The main readme file in this directory outlines the concept of WooCommerce Payments' core. Please familiarize yourself with it before proceeding with this document.
The initial (and so far current) contents of this directory, as described in README.md is the outcome of the initial phase of the WooCommerce Payments as a Platform project. However, in addition to further phases of the project, further contributions to the plugin should also strive to follow the same principles.
There are a few possible paths when it comes to services:
- Create a facade for an existing service: Create a new service class within
core/service
, which simply facades the existing service. Doing so will allow us to modify the facade in the future, keeping existing methods with the same parameters as existing ones. This is what was done with the customer service, and is the recommended way if a certain feature requires access to an existing service quickly. - Move an existing service to the core directory: This should be done with consideration how the service could change in the future, and whether it is core to the gateway. If it more suitable to an extension (ex. Multi-Currency), or a consumer (ex. WooPay), it likely needs to be somewhere else.
- When creating a new service, similarly to moving existing ones here, please consider whether the service belongs to core. If it does, do it with care, as services should be reliable and resilient.
🔗 Further information about services in core is available within the services directory.
The bulk of the communication between the client (plugin) and server is currently done through the WC_Payments_API_Client
class.
The foundation for request and response classes has already been laid down. However, not all requests have been converted to classes yet, and there is only a generic response class available for the moment.
Whenever creating new requests, please consider using request classes for them.
🔗 Read more about server requests 🔗 Guide for creating server requests classes
While working on WooCommerce Payments, please consider the concept of core vs non-core functionality. A lot of projects could be considered a part of WooCommerce Payments, WooPay being a good example. It's a part of WooCommerce Payments, but is not a part of core.
When using core APIs within isolated code, it will allow new developers to understand fewer products, and decrease the likelyhoold of side-effects.