add missing info on redirect to payment page (#729)

This commit is contained in:
Sarahshr 2024-07-31 18:05:06 +02:00 committed by Hugo Nicolas
parent 7fd21b6dda
commit ac791cfae6
No known key found for this signature in database
GPG key ID: 09CB3D93EB8B0E61
4 changed files with 33 additions and 4 deletions

View file

@ -7,6 +7,7 @@ namespace App\Controller\Payment\PlatformMembership;
use App\Entity\PlatformOffer;
use App\Entity\User;
use App\Payment\PayumManager;
use App\Repository\ConfigurationRepository;
use App\Repository\PlatformOfferRepository;
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -57,10 +58,12 @@ final class PrepareAction extends AbstractController
'en' => '/en/subcription',
'fr' => '/fr/abonnement',
], name: 'redirect_to_payment')]
public function redirectToPayment(PlatformOfferRepository $platformOfferRepository): Response
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'));
return $this->render('pages/redirect_to_payment.html.twig', compact('offers', 'lowOffer', 'platformName'));
}
}

View file

@ -6,6 +6,7 @@ namespace App\Repository;
use App\Entity\PlatformOffer;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\Persistence\ManagerRegistry;
/**
@ -37,4 +38,19 @@ class PlatformOfferRepository extends ServiceEntityRepository
{
return $this->findOneBy(['id' => $id, 'active' => true]);
}
/**
* @throws NonUniqueResultException
*/
public function findLowOffer(): ?PlatformOffer
{
/** @var ?PlatformOffer */
return $this
->createQueryBuilder('o')
->andWhere('o.active = true')
->orderBy('o.price', 'ASC')
->getQuery()
->setMaxResults(1)
->getOneOrNullResult();
}
}

View file

@ -5,11 +5,21 @@
{% block body %}
<div class="">
{% include 'components/layout/_title_3.html.twig' with {
name: (i18n_prefix ~ '.title')|trans
name: (i18n_prefix ~ '.title')|trans({'%name%': platformName})
} %}
{% include 'components/layout/_text.html.twig' with {
text: (i18n_prefix ~ '.text')|trans
} %}
<div class="col-md-6 col-lg-4 col-xl-4 mx-lg-auto">
<p class="text-gray fw-bolder fs-6 text-lg-center">
{{ (i18n_prefix ~ '.membership')|trans }}
<span class="text-gray fs-6 fw-normal">
{{ (i18n_prefix ~ '.membership.start')|trans }}
{{ lowOffer.actualPrice|format_currency(lowOffer.currency) }}
</span>
</p>
</div>
<div class="d-grid col col-lg-4 mx-auto">
<button
type="button"

View file

@ -48,7 +48,7 @@
<trans-unit id="QsIj9kp" resname="templates.pages.redirect_to_payment.title">
<source>templates.pages.redirect_payment.title</source>
<target>Bienvenue</target>
<target>Bienvenue sur %name%</target>
</trans-unit>
<trans-unit id="wSc8oud" resname="templates.pages.redirect_to_payment.text">