<?php 
    session_start();
    include('db.php');

    $montant="";
    $_SESSION['formation_id']="";
    $_SESSION['user_id']="";
    $_SESSION['mont']="";

    if (isset($_GET['formation_id'])) {
        $_SESSION['formation_id']=$_GET['formation_id'];
        $mnt_ticket=$db->prepare('SELECT * FROM formation WHERE id=?');
        $mnt_ticket->execute(array($_SESSION['formation_id']));
        while ($mnt_tickets=$mnt_ticket->fetch()) {
            $montant=$mnt_tickets['prix'];
        }
    }
    
    $_SESSION['mont']=$montant;
    
    $_SESSION['mPay']="feexpay";

    if (!empty($_GET['user_id'])) {
        $_SESSION['user_id']=$_GET['user_id'];
        $sel=$db->prepare('SELECT * FROM user WHERE id=?');
        $sel->execute(array($_SESSION['user_id']));
        while($sels=$sel->fetch()){
            $_SESSION['code_parrain']=$sels['code_parrain'];
        }
        
    }
?>
<!DOCTYPE html>
<html lang="fr">
<head>
    <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.min.js"></script>
<script src="https://api.feexpay.me/feexpay-javascript-sdk/index.js"></script>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vision million</title>
</head>
<body>

    <div class="container">
        <div class="row">
            <div class="col-sm-4"></div>
            <div class="col-sm-4"><br><br><br>
                <div class="card">
                    <div class="card-body">
                        <div class="card-title">
                            
                            <center>
                                <h3>Sentinelle de paiement</h3> <br><br><br>
                                
                               <div id="render">
                                <script>
                                        FeexPayButton.init("render",{
                                            id: "6666b1c1b0f6d152dbc09109",
                                              amount: <?php echo $montant; ?>,
                                              token: "fp_b5oZt4RMe2TJq0dr0qHv07AccRFBUaDmJhKu9oM2UbNhCkZH6bIm6qhHgQcajVX7",
                                              callback_url: "https://api.astramave.com/vision-million/succes.php",
                                              error_callback_url: "https://api.astramave.com/vision-million/echec.php",
                                              mode: 'LIVE',
                                              custom_button: false,
                                              description: "Test",
                                              
                                  })
                                    function suivant(){

                                    window.location.href="succes.php";
                                            
                                    }
                                    </script>
                                </div>
                            </center>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-4"></div>
        </div>
    </div>

</body>
</html>