<?php declare(strict_types=1);
namespace App\Subscriber;
use App\Model\ChangeCard;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use VxsBundle\Event\VxsCreditsApprovedEvent;
class ChangeCardSubscriber implements EventSubscriberInterface
{
public function onCredits(VxsCreditsApprovedEvent $event): void
{
if ($event->isTransaction()) {
return;
}
$paymentVxsOrder = $event->getPaymentVxs();
if ($paymentVxsOrder->getCredits() !== 0) {
return;
}
if (ChangeCard::CREDIT_CHANGE_AMOUNT !== $paymentVxsOrder->getAmountFloat()) {
return;
}
$paymentVxsOrder->getUser()->setBaseTransactionId((string) $event->getTransactionId());
}
/**
* @return array<string, array<int|string, array<int|string, int|string>|int|string>|string>
*/
public static function getSubscribedEvents(): array
{
return [
VxsCreditsApprovedEvent::class => 'onCredits',
];
}
}