Skip to content

Add support for Payum 2.0 - #591

Open
pierredup wants to merge 4 commits into
masterfrom
claude/payum-v2-support
Open

Add support for Payum 2.0#591
pierredup wants to merge 4 commits into
masterfrom
claude/payum-v2-support

Conversation

@pierredup

Copy link
Copy Markdown
Member

Summary

Makes the bundle work against both payum/core 1.x and 2.0. Which one is installed is detected at compile time and the services which differ are loaded accordingly, so nothing has to change in an application to keep running on 1.x.

The interesting difference in 2.0 is that Payum builds every gateway with a dependency injection container. The bundle hands it the application's services as the global container, which is what lets a service of the application be injected into the constructor of an action.

How the version is detected

PayumVersion::supportsDependencyInjection() asks interface_exists(ContainerConfiguration::class) rather than reading Composer's metadata. payum/payum replaces payum/core, and neither declares a version outside of a release, so a development install reports a version that says nothing about which APIs are present. The DI interfaces added in 2.0 do.

Changes

  • Service config split — the services which differ between generations move to Resources/config/payum_v1.php and payum_v2.php; PayumExtension loads one or the other.

  • PayumCoreGatewayFactory — implements Payum\Core\DI\ContainerConfiguration and takes the place of ContainerAwareCoreGatewayFactory / CoreGatewayFactoryBuilder on 2.0. Replacing payum.core_gateway_factory_builder with your own still works; it now has to build a factory implementing ContainerConfiguration.

  • New payum.global_service tag — shares an application service with Payum. The optional id attribute names it, which is how a service is shared under the interface an action type-hints:

    services:
        App\Payment\ExchangeRates:
            tags:
                - { name: payum.global_service, id: App\Payment\ExchangeRatesInterface }
  • Existing tags keep workingpayum.action, payum.api and payum.extension keep the same attributes. A tagged service now reaches a gateway as an entry of its container rather than as an "@id" string resolved at runtime, so the alias attribute no longer names anything and is ignored.

  • Gateway factories that predate ContainerConfiguration — still every factory payum/core ships — are built the way they were in 1.x, and payum/core triggers a deprecation for them.

  • composer.jsonpayum/core widened to ^1.7.2 || ^2.0.

  • UPGRADE.md — documents all of the above under a "Payum 2.0" heading.

Tests

New coverage in PayumCoreGatewayFactoryTest, PayumVersionTest, Tests/DI/SymfonyContainerAdapterTest, BuildGlobalContainerPassTest, and a functional PayumV2Test booting the kernel with config_payum_v2.yml.

The CI matrix gains payum: 2.x legs which swap the sub-package dev requirements for payum/payum:2.x-dev — the gateways became part of the monorepo in 2.0, so they cannot be installed alongside it.

Note on the second commit

14b4233 skips the autowiring test when the installed payum/core cannot be told a container lists its entries. That was needed while ListableContainerInterface was still unmerged; it landed in Payum/Payum#1046, so on 2.x-dev the guard no longer trips and the test asserts for real. The skip stays for anyone running the suite against a payum/core without it.

Running the suite locally against payum/core 1.x skips the 2.0-specific tests as designed — the payum: 2.x CI legs are what exercise the new paths.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ARB2EkkjTiRA2WvJjgwteU


Generated by Claude Code

pierredup and others added 2 commits August 11, 2026 11:38
Payum 2.0 builds every gateway with a dependency injection container of its
own, on top of a global one holding what all gateways share, and a gateway
factory declares its services through Payum\Core\DI\ContainerConfiguration
rather than through a configuration array.

The bundle now supports both generations. Which one is installed is asked
through PayumVersion, and the services which differ are loaded from
Resources/config/payum_v1.php or payum_v2.php. An application running on
payum/core 1.x is not affected in any way.

With payum/core 2.0:

* The services of the application are handed to Payum as its global
  container, through a service locator so that Payum only ever sees what the
  bundle decided to share. Besides a handful of services of the framework,
  any service tagged payum.global_service is shared, which makes it
  resolvable from a gateway and injectable into the constructor of an action.
* PayumCoreGatewayFactory takes the place of ContainerAwareCoreGatewayFactory.
  It registers the actions of the bundle and the services tagged payum.action,
  payum.api and payum.extension, which now reach a gateway as entries of its
  container rather than as "@id" strings resolved at runtime.
* The gateway factories payum/core ships do not implement ContainerConfiguration
  yet, so their gateways are still built the way they were, tagged services
  included.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ARB2EkkjTiRA2WvJjgwteU
The test proves a service of the application reaches the constructor of an
action, which needs a payum/core able to be told a container lists its
entries. Without it the bundle still works, so skip rather than fail.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ARB2EkkjTiRA2WvJjgwteU
Copilot AI lite review requested due to automatic review settings August 11, 2026 14:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

claude added 2 commits August 11, 2026 14:50
get_class(...) is first class callable syntax, which arrived in 8.1, while the
bundle still supports 8.0. PHPUnit parses every test file before it runs
anything, so the syntax error took the whole 8.0 job down rather than the two
files using it. A plain callable string does the same work.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ARB2EkkjTiRA2WvJjgwteU
The jobs were installing 2.x-dev at b7ecdba, the commit the branch sat on
hours earlier, while Packagist had long since moved it to 39df36c. A dev
branch is a moving reference behind a constraint that never changes, and the
composer cache is keyed on composer.json alone - composer.lock is gitignored -
so restore-keys hands every run a cache that still resolves the branch to
whatever it was when that cache was written.

The visible cost was StatusCommandTest failing on a TypeError in
ensureArrayObject() that payum/core had already fixed, which reads as a bug in
this branch rather than a stale dependency.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ARB2EkkjTiRA2WvJjgwteU
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants