Skip to content

add a few events & make subscription-options more adjustable - #102

Open
rommelfreddy wants to merge 1 commit into
mollie:mainfrom
webidea24:task/events
Open

add a few events & make subscription-options more adjustable#102
rommelfreddy wants to merge 1 commit into
mollie:mainfrom
webidea24:task/events

Conversation

@rommelfreddy

@rommelfreddy rommelfreddy commented Apr 21, 2026

Copy link
Copy Markdown

Thank you for creating this pull request! To make the best use of your and our time we created this checklist to get the best possible pull requests:

  • The code is working on a plain Magento 2 installation.
  • The code follows the PSR-2 code style.
  • When an exception or error is logged the message is accompanied with some context, eg: Error when trying to get the payment status:
  • Contains tests for the changed/added code (great if so but not required).
  • I have added a scenario to test my changes.

This PR touches code in the following areas (Check what is applicable):

Frontend

  • Shopping cart
  • Checkout
  • Totals
  • Payment methods

Backend

  • Configuration
  • Order grid
  • Order view
  • Invoice view
  • Credit memo view
  • Shipment view
  • Email sending

Order Processing (Mollie communication)

  • Creating the order
  • Invoicing the order
  • Shipping the order
  • Refunding (credit memo) the order

Other
The subscriptions module currently offers only limited extension points for project-specific subscription flows and customizations.

This PR adds a few event dispatches and makes the SubscriptionOption DTO mutable by adding setters. This allows external modules to adjust subscription data before the subscription is created and to react to subscription creation and renewal events without overriding core logic.

Added extension points:

  • mollie_subscription_option_init
  • mollie_subscription_created
  • mollie_subscription_renewed

The mollie_subscription_created event payload was also expanded so observers can access the saved model, the Magento order, the Mollie subscription response, and the DTO that was used to create it.

Important
Currently the change does contain a BC in Mollie\Subscriptions\Observer\MollieProcessTransactionEnd\CreateSubscriptions::createSubscription. The event data for "mollie_subscription_created" with the key "subscription" has changed to the subscription provided from the API gateway instead of the SubscriptionToOption entity.

@Frank-Magmodules

Copy link
Copy Markdown
Collaborator

Thanks for this pull request, @rommelfreddy, much appreciated.
We’ll review it and include it in the next release. Thanks a lot!

@Frank-Magmodules
Frank-Magmodules self-requested a review April 21, 2026 12:32
@Frank-Magmodules Frank-Magmodules self-assigned this Apr 21, 2026
@Frank-Magmodules Frank-Magmodules added the enhancement New feature or request label Apr 21, 2026
@Frank-Magmodules

Copy link
Copy Markdown
Collaborator

Hi There @rommelfreddy ,

Thank you for opening this PR, this is much appreciated! We have a few comments though:

  • You are making DTO/SubscriptionOption.php mutable, but that can introduce race conditions. We prefer to keep it immutable.
  • You are changing the parameter of the mollie_subscription_created -> subscription variable, which can be unexpected for people relying on this event. Please find a different way for this.
  • When renewing you are trying to retrieve the subscription to product by the subscription id, but that will never succeed. You need getBySubscriptionId.

In general nice additions, but we can’t approve this PR as-is yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants