Use new GatewayInterface methods on controller and processor
This commit is contained in:
@@ -2,11 +2,8 @@
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use ApiPlatform\Api\IriConverterInterface;
|
||||
use App\Library\Economy\Payment\GatewayLocator;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
@@ -22,8 +19,6 @@ class GatewayController extends AbstractController
|
||||
|
||||
public function __construct(
|
||||
private GatewayLocator $gatewayLocator,
|
||||
private EntityManagerInterface $entityManager,
|
||||
private IriConverterInterface $iriConverter
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -31,18 +26,13 @@ class GatewayController extends AbstractController
|
||||
public function handleRedirect(Request $request): Response
|
||||
{
|
||||
$gateway = $this->gatewayLocator->getGateway($request->query->get('gateway'));
|
||||
$checkout = $gateway->handleRedirect($request);
|
||||
|
||||
$this->entityManager->persist($checkout);
|
||||
$this->entityManager->flush();
|
||||
|
||||
// TO-DO: This should redirect the user to a GUI
|
||||
return new RedirectResponse($this->iriConverter->getIriFromResource($checkout));
|
||||
return $gateway->handleRedirect($request);
|
||||
}
|
||||
|
||||
#[Route('/gateway_webhooks', name: self::WEBHOOKS)]
|
||||
public function handleWebhook(Request $request): Response
|
||||
{
|
||||
return new Response(500);
|
||||
$gateway = $this->gatewayLocator->getGateway($request->query->get('gateway'));
|
||||
return $gateway->handleWebhook($request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class GatewayCheckoutProcessor implements ProcessorInterface
|
||||
$this->entityManager->persist($data);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$checkout = $gateway->create($data);
|
||||
$checkout = $gateway->sendData($data);
|
||||
|
||||
$this->entityManager->persist($checkout);
|
||||
$this->entityManager->flush();
|
||||
|
||||
Reference in New Issue
Block a user