From bd403a9ac892933cd21155c8c442e7ffd4cfcf2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jib=C3=A9=20Barth?= Date: Tue, 28 Apr 2026 10:16:10 +0200 Subject: [PATCH] PPSYL-184 - Always add a notification url when create payment --- src/Command/Handler/CapturePaymentRequestHandler.php | 4 ---- src/Creator/PayPlugPaymentDataCreator.php | 5 +++++ src/Provider/Payment/ApplePayPaymentProvider.php | 4 ---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Command/Handler/CapturePaymentRequestHandler.php b/src/Command/Handler/CapturePaymentRequestHandler.php index 71bcf9dd..c6c91792 100644 --- a/src/Command/Handler/CapturePaymentRequestHandler.php +++ b/src/Command/Handler/CapturePaymentRequestHandler.php @@ -27,7 +27,6 @@ public function __construct( private PayPlugPaymentDataCreator $paymentDataCreator, #[Autowire(service: 'sylius_shop.provider.order_pay.after_pay_url')] private UrlProviderInterface $afterPayUrlProvider, - private UrlGeneratorInterface $urlGenerator, ) {} public function __invoke(CapturePaymentRequest $capturePaymentRequest): void @@ -67,9 +66,6 @@ public function __invoke(CapturePaymentRequest $capturePaymentRequest): void 'cancel_url' => $returnUrl . '?&' . http_build_query(['status' => PayPlugApiClientInterface::STATUS_CANCELED]), ]; - $notificationUrl = $this->urlGenerator->generate('sylius_payment_method_notify', ['code' => $payment->getMethod()?->getCode()], UrlGeneratorInterface::ABSOLUTE_URL); - $data['notification_url'] = $notificationUrl; - $paymentRequest->setPayload($data); try { diff --git a/src/Creator/PayPlugPaymentDataCreator.php b/src/Creator/PayPlugPaymentDataCreator.php index e9e32322..8ba4a9a7 100644 --- a/src/Creator/PayPlugPaymentDataCreator.php +++ b/src/Creator/PayPlugPaymentDataCreator.php @@ -27,6 +27,7 @@ use Sylius\Component\Core\Model\Shipment; use Sylius\Component\Resource\Repository\RepositoryInterface; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; class PayPlugPaymentDataCreator { @@ -41,6 +42,7 @@ public function __construct( private RepositoryInterface $payplugCardRepository, private RequestStack $requestStack, private PayplugFeatureChecker $payplugFeatureChecker, + private UrlGeneratorInterface $urlGenerator, ) { } @@ -83,6 +85,9 @@ public function create( $paymentMethod = $payment->getMethod(); $gatewayFactoryName = $paymentMethod?->getGatewayConfig()?->getFactoryName(); + $notificationUrl = $this->urlGenerator->generate('sylius_payment_method_notify', ['code' => $payment->getMethod()?->getCode()], UrlGeneratorInterface::ABSOLUTE_URL); + $details['notification_url'] = $notificationUrl; + if ( PayPlugGatewayFactory::FACTORY_NAME === $gatewayFactoryName && $paymentMethod instanceof PaymentMethodInterface diff --git a/src/Provider/Payment/ApplePayPaymentProvider.php b/src/Provider/Payment/ApplePayPaymentProvider.php index 74f9b93c..1f195d9e 100644 --- a/src/Provider/Payment/ApplePayPaymentProvider.php +++ b/src/Provider/Payment/ApplePayPaymentProvider.php @@ -5,7 +5,6 @@ namespace PayPlug\SyliusPayPlugPlugin\Provider\Payment; use DateTimeImmutable; -use Doctrine\ORM\EntityManagerInterface; use LogicException; use Payplug\Resource\IVerifiableAPIResource; use Payplug\Resource\Payment; @@ -32,7 +31,6 @@ use Sylius\Component\Payment\PaymentTransitions; use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\RouterInterface; use Webmozart\Assert\Assert; class ApplePayPaymentProvider @@ -45,7 +43,6 @@ public function __construct( #[Autowire('@payplug_sylius_payplug_plugin.api_client.apple_pay')] private PayPlugApiClientInterface $applePayClient, private OrderTokenAssignerInterface $orderTokenAssigner, - private RouterInterface $router, private LoggerInterface $logger, ) { } @@ -81,7 +78,6 @@ public function provide(Request $request, OrderInterface $order): PaymentInterfa ); $paymentData = $paymentDataObject->getArrayCopy(); - $paymentData['notification_url'] = $this->router->generate('sylius_payment_method_notify', ['code' => $payment->getMethod()?->getCode()], RouterInterface::ABSOLUTE_URL); $this->logger->notice('[Payplug] ApplePay payment data', ['data' => $paymentData]); $paymentResource = $this->applePayClient->createPayment($paymentData);