<?
	// Récupération des données passées en paramètres
	$mon_action = $_POST["mon_action"];
	$num_produit = ( $_GET["n"] != "" ) ? $_GET["n"] : $_POST["num_produit"];
	
	$produit = new produit();
	$commande = new commande();
	$commande_produit = new commande_produit();
	
	/*echo "<pre>";
	print_r( $_POST );
	echo "</pre>";*/
	
	// Création ou modification de la commande en attente
	//echo "--- num_client : " . $_SESSION["site"]["num_client"] . "<br>";
	if ( ( $_SESSION["site"]["num_client"] != "" ) && ( !$commande->load( $_SESSION["site_num_commande"] ) ) ) {
		$post["num_etat"] = 2;
		$post["num_etat_paiement"] = 1;
		$post["num_client"] = $_SESSION["site"]["num_client"];
		$num_commande = $commande->gererDonnees( $post );
		//echo "--> num_commande : " . $num_commande . "<br>";
		$_SESSION["site_num_commande"] = $num_commande;
	}
	
	/*echo "<pre>";
	//print_r( $_SESSION["site_panier"][ $num_produit ] );
	//print_r( $_SESSION["site_panier"] );
	echo "</pre>";*/
	//echo "<br>---------------<br>";
	$num_produit = 0;
	
	function getListe( $transaction_id=0, $liste_exclusion='', $tri='commande_paiement.date_creation', $ordre='ASC') {
		$commande = new commande();
		
		if ( $tri == "" ) $tri = "commande.date_creation";
		if ( $ordre == "" ) $ordre = "ASC";
		
		$requete = "SELECT * FROM commande_paiement";
		$requete .= " INNER JOIN client ON client.transaction_id = commande.transaction_id";
		$requete .= " WHERE num_paiement > 0";
		
		if ( intval( $transaction_id ) > 0 ) $requete .= " AND commande.transaction_id = '" . $transaction_id . "'";
		if ( $liste_exclusion != "" ) $requete .= " AND commande.num_paiement NOT IN (" . $liste_exclusion . ")";
		if ( $supprime != "" ) $requete .= " AND supprime = " . $supprime;
		$requete .= " ORDER BY " . $tri . " " . $ordre;
		//echo $requete . "<br><br>";
		$liste = mysql_query($requete);
		
		// Retourne un tableau
		$tableau_commande = array();
		
		if (mysql_num_rows($liste) != 0) {
			$i = 0;
			while($data = mysql_fetch_assoc($liste)) {
				
				// Tentative de chargement
				if ( $commande->load( $data["num_paiement"] ) ) {
					//echo "-->" . $this->transaction_id . "<br>";
					$tableau_commande[$i] = new commande();
					
					$tableau_commande[$i]->num_paiement = $commande->num_paiement;
					$tableau_commande[$i]->num_commande = $commande->num_commande;
					$tableau_commande[$i]->transaction_id = $commande->transaction_id;
					$tableau_commande[$i]->payer_email = $commande->payer_email;
					$tableau_commande[$i]->montant = $commande->montant;
					$tableau_commande[$i]->statut = $commande->statut;
					$tableau_commande[$i]->date_creation = $commande->date_creation;
					
					$i++;
				}
			}
		}
		
		return $tableau_commande;
	}
						if ( $debug ) fputs( $fp_test, "- " . date("H:i:s") . "- Transaction ID : OK \n" );
						
						// Vérifier que receiver_email est votre adresse email PayPal principale
						if ( $receiver_email == COMPTE_PAYPAL ) {
							if ( $debug ) fputs( $fp_test, "- " . date("H:i:s") . "- Compte PayPal : OK \n" );
							
							// traiter le paiement
							$tab_retour = explode( ";", $custom );
							$num_commande = $tab_retour[ 0 ];
							$montant_paye = $tab_retour[ 1 ];
							
							// Vérifier que payment_amount et payment_currency sont corrects
							if ( $payment_amount == $montant_paye ) {
							
								// Modification de la commande
								$commande->load( $num_commande );
								$commande->num_etat_paiement = 2;
								$commande->prix = $payment_amount;
								$commande->transaction_id = $txn_id;
								$num_commande = $commande->modifier();
								if ( $debug ) fputs( $fp_test, "- " . date("H:i:s") . "1 - num_commande : " . $num_commande . "\n" );
								
								// Ajout du paiement
								$tab["num_commande"] = $num_commande;
								$tab["transaction_id"] = $txn_id;
								$tab["payer_email"] = $payer_email;
								$tab["montant"] = $payment_amount;
								$tab["statut"] = $payment_status;
								$requete = $paiement->gererDonnees( $tab );
								if ( $debug ) fputs( $fp_test, "- " . date("H:i:s") . "2 - requete : " . $requete . "\n" );
							}
Example #4
0
	$etat = new etat();	
	$commande = new commande();	
	
	// Gestion des messages de retour
	$affichage_div_valide = ( $_GET["v"] == 1 ) ? "block" : "none";
	$affichage_div_annule = ( $_GET["a"] == 1 ) ? "block" : "none";
	
	// En cas de paiement validé --> On vide le panier
	if ( $_GET["v"] == 1 ) {
		unset( $_SESSION["site_num_commande"] );
		unset( $_SESSION["site_panier"] );
	}
	
	// En cas de commande annulée --> On le spécifie dans l'enregistrement de la commande
	if ( $_GET["a"] == 1 ) {
		if ( $commande->load( $_SESSION["site_num_commande"] ) ) {
			$commande->num_etat_paiement = 0;
			$commande->modifier();
			
			unset( $_SESSION["site_num_commande"] );
		}
	}
	
	// Liste des commandes en cours
	//echo "--- " . $_SESSION["site"]["num_client"] . "<br>";
	//$liste_commande_en_cours = $commande->getListe( $_SESSION["site"]["num_client"], 2, "commande.num_etat_paiement = '2'" );
	$liste_commande_en_cours = $commande->getListe( $_SESSION["site"]["num_client"], 2, '' );
	
	if ( !empty( $liste_commande_en_cours ) ) {
		$liste_exclusion = "0";
		foreach($liste_commande_en_cours as $_commande) {