Requirement::UUID_V6], methods: ['POST'], )] public function preparePayment(Request $request, #[MapEntity(expr: 'repository.findOneActive(id)')] PlatformOffer $platformOffer, #[CurrentUser] User $user, PayumManager $payumManager): Response { /** @var ?string $token */ $token = $request->request->get('token'); if (!$this->isCsrfTokenValid('payment_prepare', $token)) { throw new UnprocessableEntityHttpException('Invalid CSRF token'); } $request->getSession()->set('payment_in_progress', true); // create and save the payment main reference $payment = $payumManager->getPayment($platformOffer, $user); // create the capture token and redirect to the capture action $captureToken = $payumManager->getCaptureToken($payment, DoneAction::ROUTE_NAME, [ 'id' => (string) $platformOffer->getId(), ]); return $this->redirect($captureToken->getTargetUrl()); } #[Route(path: [ 'en' => '/en/subcription', 'fr' => '/fr/abonnement', ], name: 'redirect_to_payment')] public function redirectToPayment(PlatformOfferRepository $platformOfferRepository, ConfigurationRepository $configurationRepository): Response { $offers = $platformOfferRepository->findBy(['active' => true]); $lowOffer = $platformOfferRepository->findLowOffer(); $platformName = $configurationRepository->getInstanceConfigurationOrCreate()->getPlatformName(); return $this->render('pages/redirect_to_payment.html.twig', compact('offers', 'lowOffer', 'platformName')); } }