0byt3m1n1
Path:
/
home
/
k
/
a
/
s
/
kassiope
/
www
/
achat
/
[
Home
]
File: fin_commande.php
<? $menu = 3; $sousmenu = 1; include("../configuration.inc.php"); necessite_identification(); /* ini_set('display_errors',1); error_reporting(E_ALL); */ if (isset($_GET['commandeid'])) { //$commandeid = (int)$_GET['commandeid']; $commandeid = $_GET['commandeid']; $modele_a_montrer = "affichage_fin_succes(1)"; } else { /* Test pour empêcher d'arriver ici par hasard ou en tapant l'url */ $caddie_est_vide = $_SESSION['caddie']->compte_elements() == 0; $commande = charge_commande(); if ($caddie_est_vide || ! $commande) { header("Location: $wwwroot"); die; } /* Création de la commande dans la base, autorise alors le paiement * et informe le client que la commande est ok */ $commandeid = cree_commande($commande); $modele_a_montrer = "affichage_fin_succes()"; } //gestion du paiement stripe // PAIEMENT / STRIPE /*if(!empty($_POST) && $_POST['payer'] == 'valider') { $token = $_POST['stripeToken']; $result = mysql_query_override("SELECT * FROM gaia_commandes WHERE id ='".$commandeid."'"); $com = mysql_fetch_object_override($result); $customer = \Stripe\Customer::create(array( 'email' => $com->email, 'source' => $token )); $charge = \Stripe\Charge::create(array( 'customer' => $customer->id, 'amount' => number_format($com->montant,'2','.','')*100, 'currency' => 'EUR' )); if($charge->status=='succeeded') { include(__DIR__.'/../cb/return_payment.php'); $modele_a_montrer = "affichage_fin_succes(1)"; } }*/ /**************************************/ /* Le caddie est réinitialisé pour ne pas laisser le client passer une deuxième commande en soumettant une deuxième fois le formulaire $_SESSION['caddie']->init(); vide_commandeinfo(); unset ($_SESSION['wantsurl']); */ include("$repertoire_modele/haut.php"); ?> <?=header_page(STEP3); ?> <? eval($modele_a_montrer.";"); ?> <?=footer_page(); ?> <? include("$repertoire_modele/bas.php"); /****************************************************************************** * FONCTIONS *****************************************************************************/ function affichage_fin_succes($payeok=0) { global $stripe_api_key; if(empty($payeok)) global $commandeid; else $commandeid = $_GET['commandeid']; global $wwwroot; global $dirroot; global $paypal; global $site; global $support; global $param_paypal; global $param_stripe; global $param_mercanet; $sql = "SELECT * FROM gaia_commandes WHERE intent_id = '".$commandeid."' OR id ='".$commandeid."'"; $result = mysql_query_override($sql); $com = mysql_fetch_object_override($result); $commandeid = $com->id; $message = "La commande $commandeid vient d'être enregistrée sur le site $site"; $message .= "\n\r"; $message .= "Email client : ".$com->email; $message .= "\n\r"; $message .= "Référence commande : ".$com->id; $message .= "\n\r"; $message .= "Montant de la commande : ".fprix($com->montant)." EUR"; $message .= "\n\r"; $message .= "Date de la commande : ".return_date_fr($com->o_timestamp); $message .= "\n\r"; $message .= "Paiement : ".$com->paiement; $message .= "\n\r"; $message .= "Merci de consulter l'interface d'administration de votre site."; if($payeok==1) { echo '<div class="col-md-12 bloc-final text-center">'. PAYMENT_OK .'!</div>'; } else { mail_confirm($support,"[$site] Enregistrement de la commande $commandeid",nl2br($message),"FROM:$support"); echo '<div class="col-md-12 bloc-final text-center">'.MSG_THANKS.'</div>'; echo '<div class="col-md-12 bloc-final text-center">'; switch ($com->paiement) { case html_entity_decode(CHECK) : email_commande($commandeid); ?> <p> - <?echo PRINT_PROFORMA?></p> <p> - <?echo SEND_CHECK ?> : <?php print_societe(); echo "</p>"; break; case html_entity_decode(TRANSFER) : email_commande($commandeid); echo nl2br(SEND_TRANSFER); print_rib(); break; case html_entity_decode(CB) : echo ' <div align="center"> '.MERCICB.'<br /><br /> </div>'; $price = explode('.', ($com->montant * 100)); $price = intval($price[0]); if($param_mercanet==1) { include($dirroot.'/cb/mercanet/paiement_simple.php'); } elseif($param_stripe==1) { \Stripe\Stripe::setApiKey($stripe_api_key); $intent = \Stripe\PaymentIntent::create([ 'amount' => $price, 'currency' => 'eur', 'receipt_email' => $com->email, ]); mysql_query_override("UPDATE gaia_commandes SET intent_id = '" . $intent->id . "' WHERE id ='" . $commandeid . "'"); //##################################################### echo ' <div class="credit-card-group"> <span id="payment-errors"></span> <input id="cardholder-name" class="cardholder-name" type="hidden" value="' . $com->prenom_bill . ' ' . $com->nom_bill . '"> <input id="cardholder-phone_number" class="cardholder-phone_number" type="hidden" value="' . $com->telephone_bill . '"> <div id="card-element"></div> <button id="card-button" class="proceedbtn" data-secret="' . $intent->client_secret . '"> Valider votre paiement </button> </div> '; } break; case html_entity_decode(PAYPAL) : ?> <div align="center"> Pour régler par carte bancaire, cliquez ici :<br /> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <INPUT TYPE="hidden" NAME="cmd" VALUE="_ext-enter"> <INPUT TYPE="hidden" NAME="redirect_cmd" VALUE="_xclick"> <input type="hidden" name="business" value="<?=$paypal?>"> <input type="hidden" name="item_name" value="<?=$site?> COMMANDE <?=$commandeid?>"> <input type="hidden" name="item_number" value="<?=$commandeid?>"> <input type="hidden" name="amount" value="<?echo number_format($com->montant,2);?>"> <input type="hidden" name="page_style" value="Primary"> <input type="hidden" name="no_shipping" value="1"> <input type="hidden" name="return" value="<?=$wwwroot?>/modules/paypal/ok.php?id=<?=$commandeid?>"> <input type="hidden" name="cancel_return" value="<?=$wwwroot?>/modules/paypal/nok.php?id=<?=$commandeid?>"> <input type="hidden" name="notify_url" value="<?=$wwwroot?>/modules/paypal/ipn.php"> <input type="hidden" name="no_note" value="1"> <input type="hidden" name="currency_code" value="EUR"> <input type="hidden" name="lc" value="FR"> <input TYPE="hidden" NAME="email" VALUE="<?=$com->email?>"> <button type="submit" class="proceedbtn">Payer ma commande</button> </form> <br> </div> <? break; } echo '</div>'; ?> <div class="col-md-6 offset-md-3" style="margin-top:20px"> <div class="table-responsive"> <table class="cart-table"> <tbody> <tr> <th><?echo ORDER_RESUME ?> :</th> <td><?=$com->email?></td> </tr> <tr> <th><?echo REFERENCE ?> :</th> <td><?=$commandeid?></td> </tr> <tr> <th><?echo ORDER_AMOUNT ?> :</th> <td><?=fprix($com->montant)?> €</td> </tr> <tr> <th><?echo ORDER_DATE ?> :</th> <td><?=return_date_fr($com->o_timestamp)?></td> </tr> <tr> <th><?echo PAYEMENT ?> :</th> <td><?=$com->paiement?></td> </tr> <tr> <th><?echo PROFORMA ?> :</th> <td><a href="javascript:OpenWin2('<?=$wwwroot?>/factures/facture_html.php?mode=proforma&id=<?=$commandeid?>×tamp=<?=urlencode($com->o_timestamp)?>',550,450,'bdc');"> <?echo PRINT_PROFORMA?></a>.</td> </tr> </tbody> </table> </div> </div> <!-- Shopping Cart Table --> <? } ?> <?php } ?>