Commit e0cdca17 by Yvon Kerdoncuff

cosmetic

parent 856eb656
...@@ -32,13 +32,14 @@ class PaymentController extends AbstractController ...@@ -32,13 +32,14 @@ class PaymentController extends AbstractController
protected $guardHandler; protected $guardHandler;
protected $paymentUtils; protected $paymentUtils;
public function __construct(EntityManagerInterface $em, public function __construct(
TranslatorInterface $translator, EntityManagerInterface $em,
LoginAuthenticator $authenticator, TranslatorInterface $translator,
GuardAuthenticatorHandler $guardHandler, LoginAuthenticator $authenticator,
Payum $payum, GuardAuthenticatorHandler $guardHandler,
PaymentUtils $paymentUtils) Payum $payum,
{ PaymentUtils $paymentUtils
) {
$this->em = $em; $this->em = $em;
$this->translator = $translator; $this->translator = $translator;
$this->payum = $payum; $this->payum = $payum;
...@@ -55,7 +56,8 @@ class PaymentController extends AbstractController ...@@ -55,7 +56,8 @@ class PaymentController extends AbstractController
// Enregistre les données du Flux en json, pour l'enregistrer une fois le paiement validé // Enregistre les données du Flux en json, pour l'enregistrer une fois le paiement validé
$serializer = $this->container->get('serializer'); $serializer = $this->container->get('serializer');
$toSerialize = Payment::TYPE_ADHESION == $type ? $form->get('cotisation')->getData() : $form->getData(); $toSerialize = Payment::TYPE_ADHESION == $type ? $form->get('cotisation')->getData() : $form->getData();
$data = $serializer->normalize($toSerialize, $data = $serializer->normalize(
$toSerialize,
null, null,
[AbstractNormalizer::ATTRIBUTES => [ [AbstractNormalizer::ATTRIBUTES => [
'reference', 'reference',
...@@ -75,7 +77,8 @@ class PaymentController extends AbstractController ...@@ -75,7 +77,8 @@ class PaymentController extends AbstractController
'expediteur' => ['id'], 'expediteur' => ['id'],
'destinataire' => ['id'], 'destinataire' => ['id'],
'operateur' => ['id'], ], 'operateur' => ['id'], ],
]); ]
);
$jsondata = $serializer->serialize($data, 'json'); $jsondata = $serializer->serialize($data, 'json');
...@@ -84,9 +87,9 @@ class PaymentController extends AbstractController ...@@ -84,9 +87,9 @@ class PaymentController extends AbstractController
$gatewayName = 'payzen'; $gatewayName = 'payzen';
} else { } else {
$this->addFlash( $this->addFlash(
'error', 'error',
$this->translator->trans('Une erreur est survenue due à la configuration du paiement dans l\'application. Il est pour l\'instant impossible de payer par CB, merci de contacter votre monnaie locale.') $this->translator->trans('Une erreur est survenue due à la configuration du paiement dans l\'application. Il est pour l\'instant impossible de payer par CB, merci de contacter votre monnaie locale.')
); );
return $this->redirectToRoute('index'); return $this->redirectToRoute('index');
} }
...@@ -129,9 +132,9 @@ class PaymentController extends AbstractController ...@@ -129,9 +132,9 @@ class PaymentController extends AbstractController
$storage->update($payment); $storage->update($payment);
$captureToken = $this->payum->getTokenFactory()->createCaptureToken( $captureToken = $this->payum->getTokenFactory()->createCaptureToken(
$gatewayName, $gatewayName,
$payment, $payment,
'payment_done' // the route to redirect after capture 'payment_done' // the route to redirect after capture
); );
// Symfony creates URLs with http and not https -> replace // Symfony creates URLs with http and not https -> replace
...@@ -297,41 +300,43 @@ class PaymentController extends AbstractController ...@@ -297,41 +300,43 @@ class PaymentController extends AbstractController
if (Payment::TYPE_ACHAT_MONNAIE_ADHERENT == $type || Payment::TYPE_ACHAT_MONNAIE_PRESTA == $type) { if (Payment::TYPE_ACHAT_MONNAIE_ADHERENT == $type || Payment::TYPE_ACHAT_MONNAIE_PRESTA == $type) {
$this->addFlash( $this->addFlash(
'success', 'success',
$this->translator->trans('Achat de monnaie locale bien effectué !') $this->translator->trans('Achat de monnaie locale bien effectué !')
); );
} elseif (Payment::TYPE_COTISATION_ADHERENT == $type || Payment::TYPE_COTISATION_PRESTA == $type) { } elseif (Payment::TYPE_COTISATION_ADHERENT == $type || Payment::TYPE_COTISATION_PRESTA == $type) {
$this->addFlash( $this->addFlash(
'success', 'success',
$this->translator->trans('Cotisation bien reçue. Merci !') $this->translator->trans('Cotisation bien reçue. Merci !')
); );
} elseif (Payment::TYPE_ADHESION == $type) { } elseif (Payment::TYPE_ADHESION == $type) {
$this->addFlash( $this->addFlash(
'success', 'success',
$this->translator->trans('Votre adhésion a bien été prise en compte, bienvenue !') $this->translator->trans('Votre adhésion a bien été prise en compte, bienvenue !')
); );
// Connect new user // Connect new user
return $this->guardHandler return $this->guardHandler
->authenticateUserAndHandleSuccess( ->authenticateUserAndHandleSuccess(
$this->em->getRepository(User::class)->findOneBy(['id' => $payment->getClientId()]), $this->em->getRepository(User::class)->findOneBy(['id' => $payment->getClientId()]),
$request, $request,
$this->authenticator, $this->authenticator,
'main' 'main'
); );
} elseif (Payment::TYPE_PAIEMENT_COTISATION_TAV == $type || Payment::TYPE_PAIEMENT_RECURRENT_COTISATION_TAV) { } elseif (Payment::TYPE_PAIEMENT_COTISATION_TAV == $type || Payment::TYPE_PAIEMENT_RECURRENT_COTISATION_TAV) {
$this->addFlash( $this->addFlash(
'success', 'success',
$this->translator->trans('Cotisation payée !') $this->translator->trans('Cotisation payée !')
); );
} }
} elseif (GetHumanStatus::STATUS_CANCELED == $payment->getStatus() || } elseif (
GetHumanStatus::STATUS_CANCELED == $payment->getStatus() ||
GetHumanStatus::STATUS_EXPIRED == $payment->getStatus() || GetHumanStatus::STATUS_EXPIRED == $payment->getStatus() ||
GetHumanStatus::STATUS_FAILED == $payment->getStatus()) { GetHumanStatus::STATUS_FAILED == $payment->getStatus()
) {
$this->addFlash( $this->addFlash(
'error', 'error',
$this->translator->trans('La transaction a été annulée.') $this->translator->trans('La transaction a été annulée.')
); );
} }
return $this->redirectToRoute('index'); return $this->redirectToRoute('index');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment