This commit is contained in:
parent
267a81a837
commit
caa25c9e95
@ -28,8 +28,6 @@ final class TicketController extends AbstractController
|
|||||||
#[Route(path: '/ticket/submit', name: 'app_submit', methods: Request::METHOD_POST)]
|
#[Route(path: '/ticket/submit', name: 'app_submit', methods: Request::METHOD_POST)]
|
||||||
public function submit(Request $request): Response
|
public function submit(Request $request): Response
|
||||||
{
|
{
|
||||||
Stripe::setApiKey($_ENV['STRIPE_SECRET_KEY']);
|
|
||||||
|
|
||||||
$ticketData = $this->serializer->deserialize($request->getContent(), TicketFormData::class, 'json');
|
$ticketData = $this->serializer->deserialize($request->getContent(), TicketFormData::class, 'json');
|
||||||
|
|
||||||
return $this->json(['id' => $this->service->handleTicketData($ticketData)->id]);
|
return $this->json(['id' => $this->service->handleTicketData($ticketData)->id]);
|
||||||
|
@ -11,6 +11,8 @@ use App\Enum\TicketData as TicketEnum;
|
|||||||
use App\Repository\PaymentRepository;
|
use App\Repository\PaymentRepository;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Stripe\Checkout\Session;
|
use Stripe\Checkout\Session;
|
||||||
|
use Stripe\Stripe;
|
||||||
|
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
|
|
||||||
class TicketService
|
class TicketService
|
||||||
@ -19,7 +21,10 @@ class TicketService
|
|||||||
private readonly UrlGeneratorInterface $generator,
|
private readonly UrlGeneratorInterface $generator,
|
||||||
private readonly EntityManagerInterface $em,
|
private readonly EntityManagerInterface $em,
|
||||||
private readonly PaymentRepository $paymentRepository,
|
private readonly PaymentRepository $paymentRepository,
|
||||||
|
#[Autowire(env: 'STRIPE_SECRET_KEY')]
|
||||||
|
string $stripeKey
|
||||||
) {
|
) {
|
||||||
|
Stripe::setApiKey($stripeKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handleTicketData(TicketFormData $data): Session
|
public function handleTicketData(TicketFormData $data): Session
|
||||||
|
Loading…
x
Reference in New Issue
Block a user