PayPal - Crypter un bouton dynamiquement

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : PayPal - Crypter un bouton dynamiquement

Re: PayPal - Crypter un bouton dynamiquement

par exemplesite » 18 févr. 2010, 13:26

oui c'était pas facile :)

Re: PayPal - Crypter un bouton dynamiquement

par stealth35 » 18 févr. 2010, 10:55

content que t'ai réussi :D

Re: PayPal - Crypter un bouton dynamiquement

par exemplesite » 18 févr. 2010, 00:58

Bon je vient de passer 6 heures à préparer un code pour me simplifier la vie :

Ce code va servir à simplifier la vie de tous ceux qui veulent pas avoir de migraine affreuse...

( bien sûr le code est plus beau sans les retour à la ligne, et avec une tabulation égale à 5 espaces ) :D

Il y a 11 fichiers ( au minimum )

Le bouton crypté ( autant de fichier btn.php que de bouton ) :
<?php

//-->> DEMMARRAGE D'UNE SESSION
session_start();

####################################################################
##                 		    PROVISOIRE                           ##
####################################################################

if(!isset($_SESSION['espace_membre']))
{
	$_SESSION['espace_membre'] = "****";
}

####################################################################
##                 		 PRECONFIGURATION                        ##
####################################################################

$racine					= "test";

$situation_de_test 			= "OUI"; // OUI ou NON qui défini Paypal ou PayPal SandBox
$id_acheteur				= $_SESSION['espace_membre']; // Identifiant du client ou du membre
$montant 					= "29.99"; // Montant de l'objet ou de l'abonnement
$monaie 					= "EUR"; // Devise
$nom_produit				= "Premium"; // Nom du Produit
$avis					= "0"; // 0 ou 1 -> Demander l'avis des clients
$descrip_produit			= "Abonnement à **** pendant 1 Mois"; // Description du produit
$ref_produit				= "1M"; // Référence du produit
$langue 					= "FR"; // Langue -> FR, US ou autre
$page_paiement_accepte 		= "http://www.****.com/".$racine."/acc.php"; // Si le paiement s'est bien déroulé
$page_paiement_annule 		= "http://www.****.com/".$racine."/ann.php"; // Si le paiement à été annulé
$cac_a					= "b_1266149529_biz@****.com"; // Adresse e-mail du compte vendeur PayPal SandBox
$cac_b					= "service.client@****.com"; // Adresse e-mail du compte vendeur PayPal
$type_de_bouton			= "3"; // pour " Acheter maintenant " 	tapez 1 et réglez la " Partie 1 " ci-dessous et le fichier " notify1.php "
							  // pour " Don "			    	tapez 2 et réglez la " Partie 2 " ci-dessous et le fichier " notify2.php "
							  // pour " Abonnement "		 	tapez 3 et réglez la " Partie 3 " ci-dessous et le fichier " notify3.php "
							  // pour " Chèques cadeaux "		tapez 4 et réglez la " Partie 4 " ci-dessous et le fichier " notify4.php "
							  // pour " Panier "			tapez 5 et réglez la " Partie 5 " ci-dessous et le fichier " notify5.php "

####################################################################
##                 		    CERTIFICATS                          ##
####################################################################

putenv("HOME=~");
$MY_KEY_FILE 				= "/homez.323/****/www/".$racine."/9f71d63e4dac3a6f7c41b0058479a280-prvkey.pem";
$MY_CERT_FILE 				= "/homez.323/****/www/".$racine."/9f71d63e4dac3a6f7c41b0058479a280-pubcert.pem";
$PAYPAL_CERT_FILE 			= "/homez.323/****/www/".$racine."/paypal_cert_pem.pem";
$OPENSSL 					= "/usr/bin/openssl";
$cert_id					= "BYMFYZCEEREN6";
							  
####################################################################
##            		NE PAS MODIFIER CETTE PARTIE                  ##
####################################################################

if($situation_de_test == "OUI")
{
	$paypaltype 		= '<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">';
	$cac 			= $cac_a;
}
else
{
	$paypaltype 		= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">';
	$cac 			= $cac_b;
}

####################################################################
##                 		    	 Partie 1                           ##
####################################################################

$page_ipn 		= "http://www.****.com/".$racine."/notify1.php"; // Page IPN 1

$frais_de_port 	= "0.00"; // 0.00 -> Frais de livraison
$taxe 			= "0.00"; // 0.00 -> Pas de taxe
$u_quantity 		= "0"; // 1 -> Permet aux clients de choisir la quantité d'objet
$poids 			= "15"; // Poids de l'objet en Kg
$poids_units		= "kgs"; // Unité du poids kgs ou lbs
$address_override 	= "1"; // 1 -> Ne pas laisser le vendeur définir l'adresse
$address1			= ""; // 1ère Rue du client
$address2 		= ""; // 2ème Rue du client
$city 			= ""; // Ville du client
$email 			= ""; // Adresse e-mail du client
$first_name 		= ""; // Prénom du client
$last_name		= ""; // Nom du client
$night_phone_a 	= ""; // Indicatif régional pour les numéros de téléphone aux Etats-Unis ou indicatif national pour les numéros hors des Etats-Unis. Cette variable préremplit le numéro de téléphone du domicile du payeur.
$night_phone_b 	= ""; // Indicatif à trois chiffres pour les numéros de téléphone aux Etats-Unis ou intégralité du numéro de téléphone pour les numéros hors des Etats-Unis, sans l'indicatif du pays. Cette variable préremplit le numéro de téléphone du domicile du payeur.
$night_phone_c 	= ""; // Numéro à quatre chiffres pour les numéros de téléphone aux Etats-Unis. Cette variable préremplit le numéro de téléphone du domicile du payeur.
$state 			= ""; // Eats -> voir sur : http://www.usps.com/ncsc/lookups/abbreviations.html#states
$zip 			= ""; // Code Postal

	###############################################################
	##        Ne pas toucher cette partie de la Partie 1         ##
	###############################################################

	$bouton = "_xclick";
	
	$form_1 = array('cmd' => $bouton,
	'business' => $cac,
	'cert_id' => $cert_id,
	'item_name' => $nom_produit,
	'amount' => $montant,
	'weight' => $poids,
	'weight_unit' => $poids_units,
	'undefined_quantity' => $u_quantity,
	'shipping' => $frais_de_port,
	'no_shipping' => $activation_frais_de_port,
	'return' => $page_paiement_accepte,
	'notify_url' => $page_ipn,
	'cancel_return' => $page_paiement_annule,
	'no_note' => $avis,
	'item_number' => $ref_produit,
	'custom' => $id_acheteur.'-*-'.$descrip_produit.'-*-'.$date_us.'-*-'.$date_fr.'-*-'.$heure.'-*-'.$montant,
	'currency_code' => $monaie,
	'tax' => $taxe,
	'address_override' => $address_override,
	'address1' => $address1,
	'address2' => $address2,
	'city' => $city,
	'email' => $email,
	'first_name' => $first_name,
	'last_name' => $last_name,
	'charset' => $charset,
	'night_phone_a' => $night_phone_a,
	'night_phone_b' => $night_phone_b,
	'night_phone_c' => $night_phone_c,
	'state' => $state,
	'zip' => $zip,
	'lc' => $langue
	);

####################################################################
##                 		    	 Partie 2                           ##
####################################################################

$page_ipn 		= "http://www.****.com/".$racine."/notify2.php"; // Page IPN 2

	###############################################################
	##        Ne pas toucher cette partie de la Partie 2         ##
	###############################################################

	$bouton = "_donations";
	
	$form_2 = array('cmd' => $bouton,
	'business' => $cac,
	'cert_id' => $cert_id,
	'item_name' => $nom_produit,
	'amount' => $montant,
	'return' => $page_paiement_accepte,
	'notify_url' => $page_ipn,
	'cancel_return' => $page_paiement_annule,
	'no_note' => $avis,
	'item_number' => $ref_produit,
	'custom' => $id_acheteur.'-*-'.$descrip_produit.'-*-'.$date_us.'-*-'.$date_fr.'-*-'.$heure.'-*-'.$montant,
	'currency_code' => $monaie,
	'tax' => $taxe,
	'lc' => $langue
	);

####################################################################
##                 		    	 Partie 3                           ##
####################################################################

$page_ipn 		= "http://www.****.com/".$racine."/notify3.php"; // Page IPN 3

$p3		= "1"; // Quantité de : Jours ou Semaines ou Mois ou d'Année de l'abonnement.
$t3 		= "M"; // D (jours), W (semaines), M (mois), Y (ans) de l'abonnement.
$src		= "1"; // 0 –> Les paiements d'abonnement ne sont pas récurrents
			  // 1 –> Les paiements d'abonnement sont récurrents
$srt		= "3"; // Nombre de récurrences, suppérieur à 1 et n'est valable que si $src = 1
$sra		= "1"; // 0 –> Pas de nouvelle tentative pour les paiements récurrents ayant échoué
			  // 1 –> Nouvelle tentative pour les paiements récurrents ayant échoué avant 

	###############################################################
	##        Ne pas toucher cette partie de la Partie 3         ##
	###############################################################

	$bouton = "_xclick-subscriptions";
	
	$form_3 = array('cmd' => $bouton,
	'business' => $cac,
	'cert_id' => $cert_id,
	'item_name' => $nom_produit,
	'a3' => $montant,
	'p3' => $p3,
	't3' => $t3,
	'src' => $src,
	'srt' => $srt,
	'sra' => $sra,
	'return' => $page_paiement_accepte,
	'notify_url' => $page_ipn,
	'cancel_return' => $page_paiement_annule,
	'no_note' => $avis,
	'custom' => $id_acheteur.'-*-'.$descrip_produit.'-*-'.$date_us.'-*-'.$date_fr.'-*-'.$heure.'-*-'.$montant,
	'currency_code' => $monaie,
	'lc' => $langue
	);
		
####################################################################
##                 		    	 Partie 4                           ##
####################################################################

$page_ipn 		= "http://www.****.com/".$racine."/notify4.php"; // Page IPN 4

	###############################################################
	##        Ne pas toucher cette partie de la Partie 4         ##
	###############################################################

	$bouton = "_oe-gift-certificate";
	
	$form_4 = array('cmd' => $bouton,
	'business' => $cac,
	'cert_id' => $cert_id,
	'return' => $page_paiement_accepte,
	'notify_url' => $page_ipn,
	'cancel_return' => $page_paiement_annule,
	'no_note' => $avis,
	'custom' => $id_acheteur.'-*-'.$descrip_produit.'-*-'.$date_us.'-*-'.$date_fr.'-*-'.$heure.'-*-'.$montant,
	'currency_code' => $monaie,
	'tax' => $taxe,
	'lc' => $langue
	);
		
####################################################################
##                 		    	 Partie 5                           ##
####################################################################

$page_ipn 		= "http://www.****.com/".$racine."/notify5.php"; // Page IPN 5

$quantity 		= "5"; // Nombre d'objet du même type
$frais_de_port 	= "0.00"; // 0.00 -> Frais de livraison
$taxe 			= "0.00"; // 0.00 -> Pas de taxe
$address_override 	= "0"; // 1 -> Ne pas laisser le vendeur définir l'adresse
$address1			= ""; // 1ère Rue du client
$address2 		= ""; // 2ème Rue du client
$city 			= ""; // Ville du client
$email 			= ""; // Adresse e-mail du client
$first_name 		= ""; // Prénom du client
$last_name		= ""; // Nom du client
$night_phone_a 	= ""; // Indicatif régional pour les numéros de téléphone aux Etats-Unis ou indicatif national pour les numéros hors des Etats-Unis. Cette variable préremplit le numéro de téléphone du domicile du payeur.
$night_phone_b 	= ""; // Indicatif à trois chiffres pour les numéros de téléphone aux Etats-Unis ou intégralité du numéro de téléphone pour les numéros hors des Etats-Unis, sans l'indicatif du pays. Cette variable préremplit le numéro de téléphone du domicile du payeur.
$night_phone_c 	= ""; // Numéro à quatre chiffres pour les numéros de téléphone aux Etats-Unis. Cette variable préremplit le numéro de téléphone du domicile du payeur.
$state 			= ""; // Eats -> voir sur : http://www.usps.com/ncsc/lookups/abbreviations.html#states
$zip 			= ""; // Code Postal

	###############################################################
	##        Ne pas toucher cette partie de la Partie 5         ##
	###############################################################

	$bouton = "_cart";
	
	$form_5 = array('cmd' => $bouton,
	'business' => $cac,
	'cert_id' => $cert_id,
	'item_name' => $nom_produit,
	'amount' => $montant,
	'weight' => $poids,
	'weight_unit' => $poids_units,
	'shipping' => $frais_de_port,
	'no_shipping' => $activation_frais_de_port,
	'return' => $page_paiement_accepte,
	'notify_url' => $page_ipn,
	'cancel_return' => $page_paiement_annule,
	'no_note' => $avis,
	'custom' => $id_acheteur.'-*-'.$descrip_produit.'-*-'.$date_us.'-*-'.$date_fr.'-*-'.$heure.'-*-'.$montant,
	'currency_code' => $monaie,
	'tax' => $taxe,
	'address_override' => $address_override,
	'address1' => $address1,
	'address2' => $address2,
	'city' => $city,
	'email' => $email,
	'first_name' => $first_name,
	'last_name' => $last_name,
	'charset' => $charset,
	'night_phone_a' => $night_phone_a,
	'night_phone_b' => $night_phone_b,
	'night_phone_c' => $night_phone_c,
	'state' => $state,
	'zip' => $zip,
	'lc' => $langue,
	'quantity' => $quantity
	);
	
####################################################################
##            		     OPTIMISER LE CODE                        ##
####################################################################
	
//->> Voir sur ce lien : https://cms.paypal.com/fr/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables

####################################################################
##            		  NE PAS MODIFIER CETTE PARTIE                ##
####################################################################

if($frais_de_port == "0.00")
{
	$activation_frais_de_port = "0";
}

$date_us 	= date("Y-m-d");
$date_fr 	= date("d-m-Y");
$heure 	= date("H:i:s");

function paypal_encrypt($hash)
{
	global $MY_KEY_FILE;
	global $MY_CERT_FILE;
	global $PAYPAL_CERT_FILE;
	global $OPENSSL;
	
	if (!file_exists($MY_KEY_FILE))
	{
		echo "ERROR: MY_KEY_FILE $MY_KEY_FILE not found\n";
	}
	if (!file_exists($MY_CERT_FILE))
	{
		echo "ERROR: MY_CERT_FILE $MY_CERT_FILE not found\n";
	}
	if (!file_exists($PAYPAL_CERT_FILE))
	{
		echo "ERROR: PAYPAL_CERT_FILE $PAYPAL_CERT_FILE not found\n";
	}
	if (!file_exists($OPENSSL))
	{
		echo "ERROR: OPENSSL $OPENSSL not found\n";
	}
	
	$hash['bn']= 'StellarWebSolutions.PHP_EWP';
	$openssl_cmd = "$OPENSSL smime -sign -signer $MY_CERT_FILE -inkey $MY_KEY_FILE " ."-outform der -nodetach -binary | $OPENSSL smime -encrypt " ."-des3 -binary -outform pem $PAYPAL_CERT_FILE";
	$descriptors = array(
	0 => array("pipe", "r"),
	1 => array("pipe", "w"),
	);
	
	$process = proc_open($openssl_cmd, $descriptors, $pipes);
	if (is_resource($process))
	{
		foreach ($hash as $key => $value)
		{
			if ($value != "")
			{
				fwrite($pipes[0], "$key=$value\n");
			}
		}
		
		fflush($pipes[0]);
		fclose($pipes[0]);
		$output = "";
		
		while (!feof($pipes[1]))
		{
			$output .= fgets($pipes[1]);
		}
		
		fclose($pipes[1]);
		$return_value = proc_close($process);
		return $output;
	}
	
	return "ERROR";
};

if($type_de_bouton == 1)
{
	$encrypted = paypal_encrypt($form_1);
}
elseif($type_de_bouton == 2)
{
	$encrypted = paypal_encrypt($form_2);
}
elseif($type_de_bouton == 3)
{
	$encrypted = paypal_encrypt($form_3);
}
elseif($type_de_bouton == 4)
{
	$encrypted = paypal_encrypt($form_4);
}
elseif($type_de_bouton == 5)
{
	$encrypted = paypal_encrypt($form_5);
}

echo''.$paypaltype.'
<input type="hidden" name="cmd" value="_s-xclick">
<input name="encrypted" type="hidden" value="'.$encrypted.'" />
<input class="button68" type="submit" value="S\'abonner" />
</form>
';

?>
Il y a 5 fichiers notify.php ( un pour chaque type de bouton : Acheter maintenant, Abonnement, Panier... ) soit : notify1.php, notify2.php, notify3.php, notify4.php et notify5.php
<?php

####################################################################
##            		   RECEPTION DES CHAMPS                       ##
####################################################################

$sonde = $sonde." 1";

$notify_situation_de_test 		= "OUI";

$notify_DB_Server 				= "****";
$notify_DB_Username 			= "****";
$notify_DB_Password 			= "****";
$notify_DB_DBName 				= "****";

$notify_recep_item_name 			= $_POST['item_name']; // Nom du produit
$notify_recep_a3 				= $_POST['a3']; // Montant de la transaction
$notify_recep_p3 				= $_POST['p3']; // Quantitié de la durée de l'abonnement
$notify_recep_t3				= $_POST['t3']; // Unité de la durée de l'abonnemen
$notify_recep_currency_code 		= $_POST['currency_code']; // Type de Monaie
$notify_recep_shipping			= $_POST['shipping']; // Frais de port
$notify_recep_tax				= $_POST['tax']; // Taxes
$notify_recep_cmd 				= $_POST['cmd']; // Type de transaction
$notify_recep_business 			= $_POST['business']; // Compte à créditer
$notify_recep_no_note 			= $_POST['no_note']; // Avis des clients
$notify_recep_lc				= $_POST['lc']; // Langue
$notify_recep_custom 			= $_POST['custom']; // ID Acheteur

####################################################################
##            		NE PAS MODIFIER CETTE PARTIE                  ##
####################################################################

$notify_tableau 				= explode("-*-",$notify_recep_custom);

$notify_recep_espace_membre 		= $notify_tableau[0];
$notify_recep_code_produit		= $notify_tableau[1];
$notify_recep_date_us			= date("Y-m-d");
$notify_recep_date_fr			= date("d-m-Y");
$notify_recep_heure				= date("H:i:s");
$notify_prix					= $notify_tableau[5];

if($notify_situation_de_test == "OUI")
{
	$notify_paypal = "www.sandbox.paypal.com";
	$sonde 		= $sonde." 2";
}
else
{
	$notify_paypal = "www.paypal.com";
	$sonde 		= $sonde." 3";
}

$notify_Connect 	= @mysql_connect($notify_DB_Server, $notify_DB_Username, $notify_DB_Password)or die("Couldn’t connect to MySQL:" . mysql_error() . "" . mysql_errno());
$notify_Db 		= @mysql_select_db($notify_DB_DBName, $notify_Connect)or die("Couldn’t select database:" . mysql_error(). "" . mysql_errno());

$notify_req = 'cmd=_notify-validate';

foreach ($_POST as $notify_key => $notify_value)
{
	$notify_value = urlencode(stripslashes($notify_value));
	$notify_req .= "&$notify_key=$notify_value";
	$sonde = $sonde." 4";
}

$notify_header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$notify_header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$notify_header .= "Content-Length: " . strlen($notify_req) . "\r\n\r\n";
$notify_fp = fsockopen ($notify_paypal, 80, $notify_errno, $notify_errstr, 30);
 
$notify_headerMail= "Content-Type:text/html;charset=iso-8859-1\n";
$notify_headerMail.= "Content-Transfer-Encoding: 8bit\n";
$notify_headerMail.="From: ****";

####################################################################
##                              CODE                              ##
####################################################################

$sonde = $sonde." 5";
 
if (!$notify_fp)
{
	// Envoyer un e-mail si il y a une erreur HTTP
	$sonde = $sonde." Erreur HTTP - $notify_recep_item_name le $notify_recep_date_fr à $notify_recep_heure - valeur $notify_prix EUR";
	$sonde = $sonde." 6";
} 
else
{
	$sonde = $sonde." 7";
	
	fputs ($notify_fp, $notify_header . $notify_req);
	
	while (!feof($notify_fp))
	{
		$sonde = $sonde." 8";
		
		$notify_res = fgets ($notify_fp, 1024);
		
		if (strcmp ($notify_res, "VERIFIED") == 0)
		{
			$sonde = $sonde." 9";
			
			$sonde = $sonde." Statut VERIFIED - $notify_recep_item_name le $notify_recep_date_fr à $notify_recep_heure - valeur $notify_prix EUR";
			
			$notify_succes = "ok";
		}
		else if (strcmp ($notify_res, "INVALIDE") == 0)
		{
			$sonde = $sonde." 10";
			
			// consigner pour étude manuelle
			$sonde = $sonde." Statut INVALIDE - $notify_recep_item_name le $notify_recep_date_fr à $notify_recep_heure - valeur $notify_prix EUR";
		}
	}
	
	fclose ($notify_fp);
}

$sonde = $sonde." 11";

if($notify_succes == "ok")
{
	$sonde = $sonde." 12";
	
	// Vérifier si le client à déjà un forfait en cours
	$notify_req = mysql_query("SELECT identifiant FROM forfait WHERE identifiant = '".$notify_recep_espace_membre."'") or ($notify_erreur = mysql_error());
	while($notify_data = mysql_fetch_assoc($notify_req));
	{
		$sonde = $sonde." 13";
		
		$notify_identifiant = $notify_data['identifiant'];
	}

	if($notify_erreur == 1)
	{
		$sonde = $sonde." 14";
		
		// Envoyer un e-mail si la requete n'as pas été envoyé
		$sonde = $sonde." Erreur requête échoué - $notify_recep_item_name le $notify_recep_date_fr à $notify_recep_heure - valeur $notify_prix EUR";
	}
	else
	{
		$sonde = $sonde." 15";
		
		$notify_duree = $notify_recep_code_produit;
		
		// Ajoute dans la table créer le récapitulatif du paiement paypal
		$notify_strQuery = "INSERT INTO paypal (var,identifiant,date_us,date_fr,heure,code_produit,nom_produit,montant,duree,type_monnaie,frais_de_port,taxes,type_transaction,compte_crediter_paypal,avis_clients,langue) values ('".$notify_recep_espace_membre.$notify_recep_date_us.$notify_recep_date_fr.$notify_recep_heure.$notify_recep_code_produit.$notify_recep_item_name.$notify_prix.$notify_duree."EUR0.000.00_xclick-subscriptions".$notify_recep_business."0FR','".$notify_recep_espace_membre."', '".$notify_recep_date_us."', '".$notify_recep_date_fr."', '".$notify_recep_heure."', '".$notify_recep_code_produit."', '".$notify_recep_item_name."', '".$notify_prix."', '".$notify_duree."', 'EUR', '0.00', '0.00', '_xclick-subscriptions', '".$notify_recep_business."', '0', 'FR')";
		$notify_result = mysql_query($notify_strQuery) or ($notify_erreur = mysql_error());
		
		if(isset($notify_erreur))
		{
			$sonde = $sonde." 16";
			
			// Envoyer un e-mail si la requete n'as pas été envoyé
			$sonde = $sonde." Erreur requête échoué - $notify_recep_item_name le $notify_recep_date_fr à $notify_recep_heure - valeur $notify_prix EUR";
		}
		else
		{
			$sonde = $sonde." 17";
			
			$notify_tm = str_replace("1","",$notify_duree);
			$notify_tm = str_replace("3","",$notify_tm);
			$notify_tm = str_replace(" ","",$notify_tm);

			$notify_tn = str_replace("M","",$notify_duree);
			$notify_tn = str_replace("A","",$notify_tn);

			if($notify_tm == "M")
			{
				$sonde = $sonde." 18";
				
				// Année
				$notify_duree_php_bis = "month";
			}
			else
			{
				$sonde = $sonde." 19";
				
				// Année
				$notify_duree_php_bis = "year";
			}
			
			$notify_duree_php = "+".$notify_tn." ".$notify_duree_php_bis;
			
			// Ensuite on crée le forfait 
			$notify_date_expiration_fr = date('d-m-Y',strtotime("$notify_duree_php", strtotime(date("d-m-Y"))));
			$notify_date_expiration_us = date('Y-m-d',strtotime("$notify_duree_php", strtotime(date("Y-m-d"))));
			
			if($notify_recep_code_produit == "1M")
			{
				$notify_duree = "1 Mois"; $sonde = $sonde." 20";
			}
			elseif($notify_recep_code_produit == "3M")
			{
				$notify_duree = "3 Mois"; $sonde = $sonde." 21";
			}
			elseif($notify_recep_code_produit == "1A")
			{
				$notify_duree = "1 AN"; $sonde = $sonde." 22";
			}
			
			// Requête
			mysql_query("INSERT INTO forfait (identifiant,forfait,heure_debut,duree,date_debut_us,date_debut_fr,etat,date_fin_us,date_fin_fr) VALUES ('".$notify_recep_espace_membre."','".$notify_recep_code_produit."','".$notify_recep_heure."','".$notify_duree."','".$notify_recep_date_us."','".$notify_recep_date_fr."','en_cours','".$notify_date_expiration_us."','".$notify_date_expiration_fr."')") or ($notify_erreur = mysql_error());
								
			if(isset($notify_erreur))
			{
				$sonde = $sonde." 23";
				
				// Envoyer un e-mail
				$sonde = $sonde." Erreur la requête FORFAIT échoué - $notify_recep_item_name le $notify_recep_date_fr à $notify_recep_heure - valeur $notify_prix EUR - $notify_erreur";
			}
			else
			{
				$sonde = $sonde." 24";
				
				// Envoyer un e-mail si tout se spasse bien
				$sonde = $sonde." VERIFIED - SUCCES requête effectué - $notify_recep_item_name le $notify_recep_date_fr à $notify_recep_heure - valeur $notify_prix EUR";
			}
		}
	}
}

$sonde = $sonde." 25";

$sondes = str_replace("VERIFIED","<42545>VERIFIED</42545>",$sonde);

$md = '<42545>';
$d = strpos( $sondes, $md ) + strlen( $md );

$mf = '</42545>';
$f = strpos( $sondes, $mf );

$verified = substr( $sondes, $d, $f - $d ); 

if($verified == "VERIFIED")
{
	$etat = "Transaction Effectuée";
}
else
{
	$etat = "Transaction Erronée";
}

//-->> ENVOI DU RAPPORT

mail("****@hotmail.fr",$etat,$sonde);

?>
Et le reste :

acc.php, ann.php, ****-prvkey.pem ( pour moi : 9f71d63e4dac3a6f7c41b0058479a280-prvkey.pem ), ****-pubcert.pem et paypal_cert_pem.pem

Il y a l'intégralité de ces fichiers ici, sur une partie de mon site : [url]http://www.%20Vente%20en%20ligne.com/source/paypal.rar[/url] 8-)

et pour ceux qui n'ont pas WinRar... [url]http://www.%20Vente%20en%20ligne.com/source/paypal.exe[/url] :D

Si il y a des erreurs, je vais les corriger, si vous en voyez merci de me les indiquer...

Re: PayPal - Crypter un bouton dynamiquement

par exemplesite » 17 févr. 2010, 21:38

J'ai une piste...

quand je met :
<input type="hidden" name="cmd" value="_s-xclick">
au lien de :
<input type="hidden" name="cmd" value="_xclick-subscriptions">
bah ça à l'air de marcher, donc je vais me renseigner sur : https://cms.paypal.com/us/cgi-bin/?cmd= ... lvariables

après vérification :
_s-xclick : Le bouton que la personne clique était protégé contre la falsification en utilisant le cryptage ou le bouton a été enregistré dans le compte PayPal du commerçant. PayPal détermine quel type de bouton a été cliqué par le décodage du code crypté ou en recherchant sur le bouton enregistrées dans le compte du commerçant.
Bon ça marche : [url]http://www.%20Vente%20en%20ligne.com/test/btn.php[/url]

Je fait quelques tests...

Re: PayPal - Crypter un bouton dynamiquement

par exemplesite » 17 févr. 2010, 21:27

Je vais essayer ces deux lien :

http://www.lafermeduweb.net/billet/tuto ... 1-275.html
( bon après avoir jetté un oeil celui-ci ne parle pas de cryptage du bouton PayPal via PHP, donc FBI : [ Fausse Bonne Idée ] :lol: )

et

http://www.wikistuce.info/doku.php/arti ... e_marchand
( bon bah j'ai la même erreur ) :
Nous ne sommes pas en mesure de traiter cette transaction en raison d'un problème concernant l'adresse email PayPal fournie par le vendeur. Veuillez contacter le vendeur afin de résoudre ce problème. Si ce paiement concerne une annonce eBay, vous pouvez contacter le vendeur par l'intermédiaire du lien Poser une question au vendeur dans la page de l'annonce. Lorsque vous disposez de l'adresse email correcte, vous pouvez effectuer le paiement à l'adresse www.paypal.com.
Et je vous dit ce qu'il en est, je voudrais savoir si des personnes ont déjà essayer de crypter un bouton PayPal, et si il pouvait m'envoyer une copie de leur code, merci.

Re: PayPal - Crypter un bouton dynamiquement

par exemplesite » 17 févr. 2010, 16:21

Bon je suis tombé sur un forum http://www.developpez.net/forums/d55123 ... on-paypal/ et apparemment ça fonctionne sur OVH mutualisé
Pour info, ça fonctionne sur OVH mutualisé.
Quand je fait :
$form = array('cmd' => $bouton, // bouton paypal abonnement
'business' => $cac, // adresse de votre compte paypal
'cert_id' => 'BYMFYZCEEREN6', // clef
'item_name' => $nom_produit, // nom du forfait
'a3' => $montant, // tarif
'p3' => $cycle, // 1 ou 3
't3' => $unite_cycle, // M ou A
'shipping' => $frais_de_port, //Frais de port
'no_shipping' => '0',
'return' => $page_paiement_accepte,
'notify_url' => $page_ipn,
'cancel_return' => $page_paiement_annule,
'no_note' => $avis,
'custom' => $id_acheteur.'-*-'.$code_produit.'-*-'.$date_us.'-*-'.$date_fr.'-*-'.$heure.'-*-'.$montant,
'currency_code' => $monaie,
'tax' => $frais_de_port,
'lc' => $langue
);

echo $form['cmd']; echo'</br>';
echo $form['business']; echo'</br>';
echo $form['cert_id']; echo'</br>';
echo $form['item_name']; echo'</br>';
echo $form['a3']; echo'</br>';
echo $form['p3']; echo'</br>';
echo $form['t3']; echo'</br>';
echo $form['shipping']; echo'</br>';
echo $form['no_shipping']; echo'</br>';
echo $form['return']; echo'</br>';
echo $form['notify_url']; echo'</br>';
echo $form['cancel_return']; echo'</br>';
echo $form['no_note']; echo'</br>';
echo $form['custom']; echo'</br>';
echo $form['currency_code']; echo'</br>';
echo $form['tax']; echo'</br>';
echo $form['lc']; echo'</br>';
j'ai bien :
_xclick-subscriptions
b_1266149529_biz@ Vente en ligne.com
BYMFYZCEEREN6
Vente en ligne pendant 1 Mois
29.99
1
M
0.00
0
http://www. Vente en ligne.com/test/finpaiement.php
http://www. Vente en ligne.com/test/notify.php?situation_de_test=OUI
http://www. Vente en ligne.com/test/annuler.php
0
0091-*-1M-*-2010-02-17-*-17-02-2010-*-20:01:46-*-29.99
EUR
0.00
FR
Quand j'essaie de modifier ces adresses, j'ai une erreur ( sa veut dire que sont sont les bonnes ) :
$MY_KEY_FILE 		= "/homez.323/ Vente en ligne/www/test/9f71d63e4dac3a6f7c41b0058479a280-prvkey.pem";
$MY_CERT_FILE 		= "/homez.323/ Vente en ligne/www/test/9f71d63e4dac3a6f7c41b0058479a280-pubcert.pem";
$PAYPAL_CERT_FILE 	= "/homez.323/ Vente en ligne/www/test/paypal_cert_pem.pem";
$OPENSSL 			= "/usr/bin/openssl";
J'ai même suivi le tutoriel présenté ici : http://www.stellarwebsolutions.com/en/a ... on_php.php

Je vais encore chercher...

Re: PayPal - Crypter un bouton dynamiquement

par exemplesite » 16 févr. 2010, 18:50

- Je n'est pas trouvé de document sur le site de PayPal sur les sujet " Crypter un bouton dynamiquement avec PHP "...

- Je me pose aussi des question sur OPENSSL, j'ai un abonnement PERSO chez OVH je ne sais pas si il y a un protocole indispensable fournis par l'hébergeur pour crypter ses bouton dynamiquement avec OVH...

- Après bien des recherches, je suis tombé sur le fichier paypal_php_wps_toolkit.rar je ne sais pas si il peut m'aider je ne sais pas ce qu'il fait exactement, j'aurai besoin que vous m'éclairiez sur le sujet.

Ce lien me parait intéressant, mais pas de code PHP :
https://cms.paypal.com/fr/cgi-bin/?&cmd ... 8A3I0P017Q

Help :priere:

Re: PayPal - Crypter un bouton dynamiquement

par stealth35 » 16 févr. 2010, 16:31

Ha bon ? Mais comment je suis censé faire maintenant ?

Sa veut dire que tout les sites qui utilisait ce système en 2008 ne sont plus fonctionnel ou ont été remis à jour ? C'est pas très pratique de la part de PayPal...

Que puis-je faire ? Merci
c'est une supposition, t'as été voir du coté de la doc officiel de paypal ?
https://cms.paypal.com/fr/cgi-bin/?&cmd ... loper/home

Re: PayPal - Crypter un bouton dynamiquement

par exemplesite » 16 févr. 2010, 16:27

Ha bon ? Mais comment je suis censé faire maintenant ?

Sa veut dire que tout les sites qui utilisait ce système en 2008 ne sont plus fonctionnel ou ont été remis à jour ? C'est pas très pratique de la part de PayPal...

Que puis-je faire ? Merci

Re: PayPal - Crypter un bouton dynamiquement

par stealth35 » 16 févr. 2010, 16:19

le tuto est un peux vieux ca a peu être changer depuis...

Re: PayPal - Crypter un bouton dynamiquement

par exemplesite » 16 févr. 2010, 16:16

Ce problème me rend chèvre, j'ai beau tout recommencer, je retombe sur le même soucis :cry:


- 1 - Je vais sur http://www.stellarwebsolutions.com/cert ... uilder.php pour prendre mes deux certificat 9f71d63e4dac3a6f7c41b0058479a280-pubcert.pem et 9f71d63e4dac3a6f7c41b0058479a280-prvkey.pem

- 2 - Je me connecte sur PAYPAL SANDBOX, en tant que b_1266149529_biz@ Vente en ligne.com qui a pour statut : Business et Verified

- 3 - Je télécharge le certificat paypal_cert_pem.txt que je renomme en paypal_cert_pem.pem

- 4 - Je fait "Ajouter" pour uploader mon certificat 9f71d63e4dac3a6f7c41b0058479a280-pubcert.pem

- 5 - Je crée mon fichier btn.php comme ici : http://www.entreprise-epi.fr/2008/03/cr ... ns-paypal/ :
<?php

//-->> DEMMARRAGE D'UNE SESSION
session_start();

####################################################################
##                 		     PROVISOIRE                          ## V
####################################################################

if(!isset($_SESSION['espace_membre']))
{
	$_SESSION['espace_membre'] = "0091";
}

####################################################################
##                 		     A MODIFIER                          ## V
####################################################################

$situation_de_test 		= "OUI"; // OUI ou NON
$montant 				= "29.99"; // Pas de virgule juste un point !!
$cycle				= "1"; // quantité
$unite_cycle			= "M"; // D (jours), W (semaines), M (mois), Y (ans)
$nom_produit			= " Vente en ligne pendant 1 Mois";
$code_produit			= "1M";
$taxe 				= "0.00"; // 0 -> Pas de taxe ( par exemple la TVA )

####################################################################
##                 		 PARAMETRES GENERALES                    ## -
####################################################################

$monaie 				= "EUR";
$frais_de_port 		= "0.00"; // 0 -> Pas de frais de port
$avis				= "0"; // 0 ou 1 -> Demander l'avis des clients
$id_acheteur			= $_SESSION['espace_membre']; // Identifiant du client
$bouton 				= "_xclick-subscriptions"; // Type de bouton ( dans ce cas c'est un abonnement)
$langue 				= "FR";

$page_paiement_accepte 	= "http://www. Vente en ligne.com/test/finpaiement.php"; // Si le paiement est accepté
$page_paiement_annule 	= "http://www. Vente en ligne.com/test/annuler.php"; // Si le paiement n'est pas accepté

####################################################################
##                 		     TEST / REEL                         ## -
####################################################################

if($situation_de_test == "OUI")
{
	$paypaltype 		= '<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">';
	$cac 			= "b_1266149529_biz@ Vente en ligne.com";
	$page_ipn 		= "http://www. Vente en ligne.com/test/notify.php?situation_de_test=OUI";
}
else
{
	$paypaltype 		= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">';
	$cac 			= "service.client@ Vente en ligne.com";
	$page_ipn 		= "http://www. Vente en ligne.com/test/notify.php?situation_de_test=NON";
}



####################################################################
##                 A PARTIR D'ICI, NE PAS MODIFIER                ## X
####################################################################

//-->> DATE

$date_us 	= date("Y-m-d");
$date_fr 	= date("d-m-Y");
$heure 	= date("H:i:s");

//-->> FORMULAIRE

echo $paypaltype;

//-->> ABONNEMENT

echo'<input name="a3" type="hidden" value="'.$montant.'" />';
echo'<input name="p3" type="hidden" value="'.$cycle.'" />';
echo'<input name="t3" type="hidden" value="'.$unite_cycle.'" />';

//-->> MONTANT - MONAIE - FRAIS DE PORT - TAXE

echo'<input name="currency_code" type="hidden" value="'.$monaie.'" />';
echo'<input name="shipping" type="hidden" value="'.$frais_de_port.'" />';
echo'<input name="tax" type="hidden" value="'.$taxe.'" />';

//-->> PAGES DE RETOUR

echo'<input name="return" type="hidden" value="'.$page_paiement_accepte.'" />';
echo'<input name="cancel_return" type="hidden" value="'.$page_paiement_annule.'" />';
echo'<input name="notify_url" type="hidden" value="'.$page_ipn.'" />';

//-->> TYPE DE BOUTON

echo'<input name="cmd" type="hidden" value="'.$bouton.'" />';

//-->> ADRESSE E-MAIL DU COMPTE A CREDITER

echo'<input name="business" type="hidden" value="'.$cac.'" />';

//-->>  NOM DU PROFUIT

echo'<input name="item_name" type="hidden" value="'.$nom_produit.'" />';

//-->> AVIS DES CLIENTS

echo'<input name="no_note" type="hidden" value="'.$avis.'" />';

//-->> LANGUE

echo'<input name="lc" type="hidden" value="'.$langue.'" />';

//-->> IDNETIFIANT DU MEMBRE

echo'<input name="custom" type="hidden" value="'.$id_acheteur.'-*-'.$code_produit.'-*-'.$date_us.'-*-'.$date_fr.'-*-'.$heure.'-*-'.$montant.'" />';

//-->> LE BOUTON

echo'<input alt="Effectuez vos paiements  Vente en ligne via PayPal : une solution rapide, gratuite et sécurisée" name="submit" src="http://www. Vente en ligne.com/boite3/29.png" type="image" />';

//-->> FIN DU FORMULAIRE

echo'</form>';

//-->> CRYPTAGE DU CODE SOURCE

putenv("HOME=~");
$MY_KEY_FILE 		= "/homez.323/ Vente en ligne/www/test/9f71d63e4dac3a6f7c41b0058479a280-prvkey.pem";
$MY_CERT_FILE 		= "/homez.323/ Vente en ligne/www/test/9f71d63e4dac3a6f7c41b0058479a280-pubcert.pem";
$PAYPAL_CERT_FILE 	= "/homez.323/ Vente en ligne/www/test/paypal_cert_pem.pem";
$OPENSSL 			= "/usr/bin/openssl";

function paypal_encrypt($hash)
{
	global $MY_KEY_FILE;
	global $MY_CERT_FILE;
	global $PAYPAL_CERT_FILE;
	global $OPENSSL;
	
	if (!file_exists($MY_KEY_FILE))
	{
		echo "ERROR: MY_KEY_FILE $MY_KEY_FILE not found\n";
	}
	if (!file_exists($MY_CERT_FILE))
	{
		echo "ERROR: MY_CERT_FILE $MY_CERT_FILE not found\n";
	}
	if (!file_exists($PAYPAL_CERT_FILE))
	{
		echo "ERROR: PAYPAL_CERT_FILE $PAYPAL_CERT_FILE not found\n";
	}
	if (!file_exists($OPENSSL))
	{
		echo "ERROR: OPENSSL $OPENSSL not found\n";
	}
	
	$hash['bn']= 'StellarWebSolutions.PHP_EWP';
	$openssl_cmd = "$OPENSSL smime -sign -signer $MY_CERT_FILE -inkey $MY_KEY_FILE " ."-outform der -nodetach -binary | $OPENSSL smime -encrypt " ."-des3 -binary -outform pem $PAYPAL_CERT_FILE";
	$descriptors = array(
	0 => array("pipe", "r"),
	1 => array("pipe", "w"),
	);
	
	$process = proc_open($openssl_cmd, $descriptors, $pipes);
	if (is_resource($process))
	{
		foreach ($hash as $key => $value)
		{
			if ($value != "")
			{
				fwrite($pipes[0], "$key=$value\n");
			}
		}
		
		fflush($pipes[0]);
		fclose($pipes[0]);
		$output = "";
		
		while (!feof($pipes[1]))
		{
			$output .= fgets($pipes[1]);
		}
		
		fclose($pipes[1]);
		$return_value = proc_close($process);
		return $output;
	}
	
	return "ERROR";
};

function paypal_button($item_name,$prix,$membre,$heure,$date_us,$date_fr,$cac,$code_produit,$cycle,$unite_cycle)
{
	$form = array('cmd' => '_xclick-subscriptions', // bouton paypal abonnement
	'business' => $cac, // adresse de votre compte paypal
	'cert_id' => 'BYMFYZCEEREN6', // clef
	'item_name' => $item_name, // nom du forfait
	'a3' => $prix, // tarif
	'p3' => $cycle, // 1 ou 3
	't3' => $unite_cycle, // M ou A
	'shipping' => '0.00', //Frais de port
	'no_shipping' => '0',
	'return' => 'http://www. Vente en ligne.com/test/finpaiement.php',
	'notify_url' => 'http://www. Vente en ligne.com/test/notify.php',
	'cancel_return' => 'http://www. Vente en ligne.com/test/annuler.php',
	'no_note' => '0',
	'custom' => $membre."-*-".$code_produit."-*-".$date_us."-*-".$date_fr."-*-".$heure."-*-".$prix,
	'currency_code' => 'EUR',
	'tax' => '0.00',
	'lc' => 'FR'
	);
	$encrypted = paypal_encrypt($form);
	return $encrypted;
}

echo'
'.$paypaltype.'
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<input name="encrypted" type="hidden" value="'; echo paypal_button($nom_produit,$montant,$id_acheteur,$heure,$date_us,$date_fr,$cac,$code_produit,$cycle,$unite_cycle); echo'" />
<input class="button68" type="submit" value="Buy" />
</form>
';

?>
Et voilà que quand je vais sur [url]http://www.%20Vente%20en%20ligne.com/test/btn.php[/url] ( ma page de test ), tout est bien crypté :
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<input name="encrypted" type="hidden" value="-----BEGIN PKCS7-----
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
g2swxGD47bQFRk3A/M//euM=
-----END PKCS7-----
" />
<input class="button68" type="submit" value="S'abonner" />
</form>
Mais quand je clique sur "S'abonner" PayPal SandBox ( situation de test ) me détruit complètement le morale avec ce message :
Nous ne sommes pas en mesure de traiter cette transaction en raison d'un problème concernant l'adresse email PayPal fournie par le vendeur. Veuillez contacter le vendeur afin de résoudre ce problème. Si ce paiement concerne une annonce eBay, vous pouvez contacter le vendeur par l'intermédiaire du lien Poser une question au vendeur dans la page de l'annonce. Lorsque vous disposez de l'adresse email correcte, vous pouvez effectuer le paiement à l'adresse http://www.paypal.com.
Le problème est le même avec PayPal ( une situation réelle )

Mais où est le soucis ?

PayPal - Crypter un bouton dynamiquement

par exemplesite » 15 févr. 2010, 22:04

Bonjour, je travail sur un projet " Vente en ligne ", je suis nouveau sur ce forum, je sais pas vraiment si c'est le bon endroit pour exposer mon problème, mais le voici :

Je veut réalisé des bouton PayPal crypté, j'ai suivi les explications suivante :

# Tutorial Paypal : Présentation
# Tutorial Paypal : Création des comptes de Tests
# Tutorial Paypal : Création du Bouton HTML ‘Acheter Maintenant’
# Tutorial Paypal : La récupération des données par IPN
# Tutorial Paypal : Cryptage dynamique en php des boutons Paypal

Sur ce lien : http://www.entreprise-epi.fr/2008/03/cr ... ns-paypal/

( C'est très bien expliqué, d'ailleurs bravo à l'auteur de l'article ), j'ai voulu optimiser le code de base j'obtiens donc 2 fichiers :

notify.php et btn.php ( ou ithem.php )

Le contenu du fichier notify.php fonctionne parfaitement, j'ai réalisé une série de test et tout fonctionne :)

Par contre le fichier btn.php à quelques soucis : [url]http://www.%20Vente%20en%20ligne.com/test/btn.php[/url]

Quand je clique sur le bouton crypté j'ai le message suivant sur le site de PayPal :
Nous ne sommes pas en mesure de traiter cette transaction en raison d'un problème concernant l'adresse email PayPal fournie par le vendeur. Veuillez contacter le vendeur afin de résoudre ce problème. Si ce paiement concerne une annonce eBay, vous pouvez contacter le vendeur par l'intermédiaire du lien Poser une question au vendeur dans la page de l'annonce. Lorsque vous disposez de l'adresse email correcte, vous pouvez effectuer le paiement à l'adresse http://www.paypal.com.
Voici le code source du fichier btn.php :
<?php

//-->> DEMMARRAGE D'UNE SESSION
session_start();

####################################################################
##                 		     PROVISOIRE                          ## V
####################################################################

if(!isset($_SESSION['espace_membre']))
{
	$_SESSION['espace_membre'] = "0091";
}

####################################################################
##                 		     A MODIFIER                          ## V
####################################################################

$situation_de_test 		= "OUI"; // OUI ou NON
$montant 				= "29.99"; // Pas de virgule juste un point !!
$cycle				= "1"; // quantité
$unite_cycle			= "M"; // D (jours), W (semaines), M (mois), Y (ans)
$nom_produit			= " Vente en ligne pendant 1 Mois";
$code_produit			= "1M";
$taxe 				= "0.00"; // 0 -> Pas de taxe ( par exemple la TVA )

####################################################################
##                 		 PARAMETRES GENERALES                    ## -
####################################################################

$monaie 				= "EUR";
$frais_de_port 		= "0.00"; // 0 -> Pas de frais de port
$avis				= "0"; // 0 ou 1 -> Demander l'avis des clients
$id_acheteur			= $_SESSION['espace_membre']; // Identifiant du client
$bouton 				= "_xclick-subscriptions"; // Type de bouton ( dans ce cas c'est un abonnement)
$langue 				= "FR";

$page_paiement_accepte 	= "http://www. Vente en ligne.com/test/finpaiement.php"; // Si le paiement est accepté
$page_paiement_annule 	= "http://www. Vente en ligne.com/test/annuler.php"; // Si le paiement n'est pas accepté

####################################################################
##                 		     TEST / REEL                         ## -
####################################################################

if($situation_de_test == "OUI")
{
	$paypaltype 		= '<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">';
	$cac 			= "b_1266149529_biz@ Vente en ligne.com";
	$page_ipn 		= "http://www. Vente en ligne.com/test/notify.php?situation_de_test=OUI";
}
else
{
	$paypaltype 		= '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">';
	$cac 			= "service.client@ Vente en ligne.com";
	$page_ipn 		= "http://www. Vente en ligne.com/test/notify.php?situation_de_test=NON";
}

//-->> DATE

$date_us 	= date("Y-m-d");
$date_fr 	= date("d-m-Y");
$heure 	= date("H:i:s");

####################################################################
##                 A PARTIR D'ICI, NE PAS MODIFIER                ## X
####################################################################

putenv("HOME=~");
$MY_KEY_FILE 		= "/homez.323/ Vente en ligne/www/test/9f71d63e4dac3a6f7c41b0058479a280-prvkey.pem";
$MY_CERT_FILE 		= "/homez.323/ Vente en ligne/www/test/9f71d63e4dac3a6f7c41b0058479a280-pubcert.pem";
$PAYPAL_CERT_FILE 	= "/homez.323/ Vente en ligne/www/test/paypal_cert_pem.pem";
$OPENSSL 			= "/usr/bin/openssl";

function paypal_encrypt($hash)
{
	global $MY_KEY_FILE;
	global $MY_CERT_FILE;
	global $PAYPAL_CERT_FILE;
	global $OPENSSL;
	
	if (!file_exists($MY_KEY_FILE))
	{
		echo "ERROR: MY_KEY_FILE $MY_KEY_FILE not found\n";
	}
	if (!file_exists($MY_CERT_FILE))
	{
		echo "ERROR: MY_CERT_FILE $MY_CERT_FILE not found\n";
	}
	if (!file_exists($PAYPAL_CERT_FILE))
	{
		echo "ERROR: PAYPAL_CERT_FILE $PAYPAL_CERT_FILE not found\n";
	}
	if (!file_exists($OPENSSL))
	{
		echo "ERROR: OPENSSL $OPENSSL not found\n";
	}
	
	$hash['bn']= 'StellarWebSolutions.PHP_EWP';
	$openssl_cmd = "$OPENSSL smime -sign -signer $MY_CERT_FILE -inkey $MY_KEY_FILE " ."-outform der -nodetach -binary | $OPENSSL smime -encrypt " ."-des3 -binary -outform pem $PAYPAL_CERT_FILE";
	$descriptors = array(
	0 => array("pipe", "r"),
	1 => array("pipe", "w"),
	);
	
	$process = proc_open($openssl_cmd, $descriptors, $pipes);
	if (is_resource($process))
	{
		foreach ($hash as $key => $value)
		{
			if ($value != "")
			{
				fwrite($pipes[0], "$key=$value\n");
			}
		}
		
		fflush($pipes[0]);
		fclose($pipes[0]);
		$output = "";
		
		while (!feof($pipes[1]))
		{
			$output .= fgets($pipes[1]);
		}
		
		fclose($pipes[1]);
		$return_value = proc_close($process);
		return $output;
	}
	
	return "ERROR";
};

function paypal_button($nom_produit,$montant,$id_acheteur,$heure,$date_us,$date_fr,$cac,$code_produit,$cycle,$unite_cycle,$id_acheteur)
{
	$form = array('cmd' => '_xclick-subscriptions', // bouton paypal abonnement
	'business' => ''.$cac.'', // adresse de votre compte paypal
	'cert_id' => 'BYMFYZCEEREN6', // clef
	'item_name' => ''.$nom_produit.'', // nom du forfait
	'a3' => ''.$montant.'', // tarif
	'p3' => ''.$cycle.'', // 1 ou 3
	't3' => ''.$unite_cycle.'', // M ou A
	'shipping' => '0.00', //Frais de port
	'no_shipping' => '0',
	'return' => 'http://www. Vente en ligne.com/test/finpaiement.php',
	'notify_url' => 'http://www. Vente en ligne.com/test/notify.php',
	'cancel_return' => 'http://www. Vente en ligne.com/test/annuler.php',
	'no_note' => '0',
	'custom' => ''.$id_acheteur.'-*-'.$code_produit.'-*-'.$date_us.'-*-'.$date_fr.'-*-'.$heure.'-*-'.$montant.'',
	'currency_code' => 'EUR',
	'tax' => '0.00',
	'lc' => 'FR'
	);
	$encrypted = paypal_encrypt($form);
	return $encrypted;
}


echo''.$paypaltype.'
<input type="hidden" name="cmd" value="'.$bouton.'">
<input name="encrypted" type="hidden" value="'; echo paypal_button($nom_produit,$montant,$id_acheteur,$heure,$date_us,$date_fr,$cac,$code_produit,$cycle,$unite_cycle,$id_acheteur); echo'" />
<input class="button68" type="submit" value="S\'abonner" />
</form>
';

?>
Un sincère Merci à vous tous