templates/front/tunnel/step3a.html.twig line 118

Open in your IDE?
  1. {% extends 'front/tunnel/layout.html.twig' %}
  2. {% block head %}
  3.     <title>Étape 3</title>
  4. {% endblock %}
  5. {% block body %}
  6. <section class="w-full py-10 sm:py-20">
  7.     <ol class="flex flex-row w-full">
  8.         <!--first item-->
  9.         <li class="relative flex-1">
  10.             <div class="absolute top-2 left-1/2 w-full h-1.25 bg-bleuindigo"></div>
  11.             <div class="relative z-10 flex flex-col items-center">
  12.                 <div class="size-5 rounded-full bg-bleuindigo"></div>
  13.                 <p class="mt-4 text-sm font-bold text-bleuindigo text-center px-2">
  14.                     1. Je sélectionne la durée
  15.                 </p>
  16.             </div>
  17.         </li>
  18.         <!--Second item-->
  19.         <li class="relative flex-1">
  20.             <div class="absolute top-2 left-1/2 w-full h-1.25 bg-bleuindigo"></div>
  21.             <div class="relative z-10 flex flex-col items-center">
  22.                 <div class="size-5 rounded-full bg-bleuindigo border-4 border-bleuindigo"></div>
  23.                 <p class="mt-4 text-sm font-bold text-bleuindigo text-center px-2">
  24.                     2. J'accède à mon compte
  25.                 </p>
  26.             </div>
  27.         </li>
  28.         <!--Third item-->
  29.         <li class="relative flex-1">
  30.             <div class="relative z-10 flex flex-col items-center">
  31.                 <div class="size-5 rounded-full bg-bleuindigo"></div>
  32.                 <p class="mt-4 sm:mt-2 text-sm sm:text-lg font-bold text-bleuindigo text-center px-2">
  33.                     3. Je procède au paiement
  34.                 </p>
  35.             </div>
  36.         </li>
  37.     </ol>
  38. </section>
  39. {% if mode_free %}
  40. <section class="flex justify-center mb-8 sm:mb-16">
  41.     <div class="text-center bg-jaune text-bleuindigo font-bold py-2 px-4 rounded-full text-sm sm:text-lg">
  42.         Vous ne serez pas débité avant la fin de votre essai de 7 jours, résiliable à tout moment.
  43.     </div>
  44. </section>
  45. {% endif %}
  46. <!--Informations-->
  47. <section class="flex justify-center">
  48.     <div class="flex flex-col lg:flex-row justify-between">
  49.         <!--Colonne gauche-->
  50.         <div class="flex flex-col lg:w-6/12 xl:w-7/12 gap-10">
  51.             <!--Coordonnées bancaires-->
  52.             <div>
  53.                 <span class="text-bleuindigo font-bold text-2xl sm:text-3xl">Coordonnées bancaires</span>
  54.             </div>
  55.             <!--Widget CB-->
  56.             <div class="mt-10">
  57.                 <div id="payment-element">
  58.                 </div>
  59.             </div>
  60.             <div class="flex flex-col items-start text-sm sm:text-base gap-2">
  61.                 <div>
  62.                     <div>
  63.                         <input id="cgu" name="cgu" type="checkbox"
  64.                                class="size-5 border-lavande rounded-xl" />
  65.                         <label for="cgu" class="-mt-1">J’ai lu et j’accepte sans réserve les conditions générales d’abonnement et d’utilisation.</label>
  66.                     </div>
  67.                     <div class="hidden text-framboise text-center">Veuillez accepter les conditions générales d'abonnement et d'utilisation</div>
  68.                 </div>
  69.                 <div>
  70.                     <input id="offres" name="offres" type="checkbox"
  71.                            class="size-5 border-lavande rounded-xl" />
  72.                     <label for="offres" class="-mt-1">J’accepte de recevoir des conseils et des offres des Bons Profs et de ses partenaires.</label>
  73.                 </div>
  74.             </div>
  75.         </div>
  76.         <!--Colonne droite-->
  77.         <div class="flex flex-col lg:w-5/12 xl:w-4/12 my-16 lg:mt-0">
  78.             <!--Encadré lavande-->
  79.             <div class="flex flex-col bg-lavandeclair rounded-2xl text-sm sm:text-base gap-y-2 p-5 sm:p-10">
  80.                 <div class="text-bleuindigo font-bold text-xl">
  81.                     Vous avez choisi l’offre
  82.                 </div>
  83.                 <div class="text-pervenche font-bold text-2xl sm:text-3xl">
  84.                     {{ offer.title|upper }}
  85.                 </div>
  86.                 <div class="font-bold mt-2">
  87.                     {{ offer.typeOffer.textPaid|raw }}
  88.                 </div>
  89.                 <div class="flex justify-between items-center mt-4">
  90.             <span class="flex text-bleuindigo font-bold">
  91.               <span class="flex items-center bg-jaune rounded-xl px-2 mr-1"><span class="text-lg -my-1 pr-1">&#9733</span> 4,6</span>+ 300 avis Trustpilot
  92.             </span>
  93.                     <span class="text-pervenche text-xs hover:underline"><a href="https://fr.trustpilot.com/review/lesbonsprofs.com" target="_blank">Voir les avis</a></span>
  94.                 </div>
  95.                 {% if mode_free %}
  96.                     <div class="flex justify-between text-franboise font-bold mt-4">
  97.                         <span>Montant dû aujourd'hui</span>
  98.                         <span>0€</span>
  99.                     </div>
  100.                     <hr class="border-lavande border my-2" />
  101.                     <div class="flex justify-between text-bleuindigo">
  102.                         <span>Montant dû au {{ dateAchat|date_modify("+8 day")|format_datetime(locale='fr',pattern="dd MMMM YYYY") }}</span>
  103.                         <span class="font-bold" id="som-toto">{{ amount|number_format(2, ',', '.') }} €</span>
  104.                     </div>
  105.                 {% else %}
  106.                     <div class="flex justify-between text-franboise font-bold mt-4">
  107.                         <span>Montant dû aujourd'hui</span>
  108.                         <span id="som-toto">{{ amount|number_format(2, ',', '.') }} €</span>
  109.                     </div>
  110.                 {% endif %}
  111.                 {% if discount is not null %}
  112.                     <div class="text-bleuindigo mb-2"><span class="font-bold me-1">Promotion appliquée :</span> {{ discount.title }}</div>
  113.                 {% endif %}
  114.                 <button type="submit" class="bg-framboise hover:bg-bleuindigo hover:cursor-pointer text-white rounded-3xl font-bold py-3 mt-4 btn-validate">Payer</button>
  115.             </div>
  116.         </div>
  117.     </div>
  118. </section>
  119. {% endblock %}
  120. {% block javascripts %}
  121.     <script src="https://js.stripe.com/v3/"></script>
  122.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
  123.     <script type="text/javascript">
  124.         function displayErrorCard(event,target){
  125.             var displayError = document.getElementById(target);
  126.             if (event.error) {
  127.                 displayError.textContent = event.error.message;
  128.                 $('#'+target).show();
  129.             } else {
  130.                 displayError.textContent = '';
  131.             }
  132.         }
  133.         function noPaiement3DSecure(elem){
  134.             $.ajax({
  135.                 url:"{{ path('remove-3DS-stripe-paiement') }}",
  136.                 data:elem,
  137.                 method:'GET',
  138.                 success:function(msg){
  139.                 }
  140.             })
  141.         }
  142.         $(document).ready(function(){
  143.             var stripe,cardNumberElement
  144.             stripe = Stripe("{{ SPK }}",{
  145.                 locale: 'fr'
  146.             });
  147.             const options = {
  148.                 mode: 'setup',
  149.                 currency: 'eur',
  150.                 paymentMethodCreation: 'manual'
  151.             };
  152.             var elements = stripe.elements(options);
  153.             const paymentElement = elements.create("payment");
  154.             paymentElement.mount("#payment-element");
  155.             $('#cgu').change(function(){
  156.                 if($(this).prop('checked')){
  157.                     $(this).parent().next().addClass('hidden')
  158.                 }
  159.             })
  160.             $('.btn-validate').click(function(e){
  161.                 e.preventDefault();
  162.                 if(!$('#cgu').prop('checked')){
  163.                     $('#cgu').parent().next().removeClass('hidden');
  164.                 }else{
  165.                     // FB Add payment infos tracking
  166.                     $('.u-spinner').addClass('open');
  167.                     $(this).hide('slow');
  168.                     var optin = $('#optin').prop('checked') ? 1 : 0;
  169.                     elements.submit().then(function(submitResult) {
  170.                         if (submitResult.error) {
  171.                             $('.u-spinner').removeClass('open');
  172.                             $('.btn-validate').show();
  173.                             return;
  174.                         }
  175.                     stripe
  176.                         .createPaymentMethod({
  177.                             elements,
  178.                             params :{
  179.                                 billing_details: {
  180.                                     name: 'Jenny Rosen',
  181.                                 }},
  182.                         })
  183.                         .then(function(result) {
  184.                             // Handle result.error or result.paymentMethod
  185.                             if(result.paymentMethod){
  186.                                 $.ajax({
  187.                                     url:"{{ path('setup-subscription-paiement') }}",
  188.                                     type: 'POST',
  189.                                     data:'pmId='+result.paymentMethod.id,
  190.                                     success:function(elem){
  191.                                         if(elem.success){
  192.                                             var secret = elem.clientSecret;
  193.                                             {% if mode_free %}
  194.                                             stripe.confirmSetup({
  195.                                                 elements,
  196.                                                 clientSecret:secret,
  197.                                                 confirmParams: {
  198.                                                     // Return URL where the customer should be redirected after the SetupIntent is confirmed.
  199.                                                     return_url: '{{ app.request.getSchemeAndHttpHost() }}/confirm/subscription/paiement/stripe?free_mode=true&tt_id='+elem.tt+'&optin='+optin,
  200.                                                 },
  201.                                             })
  202.                                                 .then(function(result) {
  203.                                                     if (result.error) {
  204.                                                         // Inform the customer that there was an error.
  205.                                                         $('.u-spinner').removeClass('open');
  206.                                                         $('.btn-validate').show();
  207.                                                         console.log(result.error);
  208.                                                         alert(result.error)
  209.                                                     }else{
  210.                                                     }
  211.                                                 });
  212.                                             {% else %}
  213.                                             if (!secret && elem.payment_id) {
  214.                                                 window.location.href = '{{ app.request.getSchemeAndHttpHost() }}/confirm/subscription/paiement/stripe?payment_intent='+elem.payment_id+'&redirect_status=succeeded&free_mode=false&tt_id='+elem.tt;
  215.                                             } else {
  216.                                                 stripe.confirmPayment({
  217.                                                     elements,
  218.                                                     clientSecret:secret,
  219.                                                     confirmParams: {
  220.                                                         return_url: '{{ app.request.getSchemeAndHttpHost() }}/confirm/subscription/paiement/stripe?free_mode=false&tt_id='+elem.tt,
  221.                                                     },
  222.                                                 })
  223.                                                     .then(function(result) {
  224.                                                         if (result.error) {
  225.                                                             $('.u-spinner').removeClass('open');
  226.                                                             alert(result.error)
  227.                                                             noPaiement3DSecure(elem)
  228.                                                         }
  229.                                                     })
  230.                                                     .error(function(error) {
  231.                                                         $('.u-spinner').removeClass('open');
  232.                                                         alert(error)
  233.                                                     });
  234.                                             }
  235.                                             {% endif %}
  236.                                         }else{
  237.                                             $('.u-spinner').removeClass('open');
  238.                                             $('.btn-validate').show();
  239.                                             alert(elem.msg);
  240.                                             console.log(elem.msg)
  241.                                         }
  242.                                     }
  243.                                 })
  244.                             }
  245.                         }).catch(function(error) {
  246.                         $('.u-spinner').removeClass('open');
  247.                         alert(error);
  248.                         console.log(error);
  249.                     });
  250.                     }); // end elements.submit().then
  251.                 }
  252.             })
  253.         })
  254.     </script>
  255. {% endblock %}