Précédent   Forum des professionnels en informatique > PHP > PHP & SGBD
PHP & SGBD Forum d'entraide sur les SGBD avec PHP. Avant de poster : FAQ BDD, toutes les FAQ PHP, cours BDD et sources BDD
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 05/01/2012, 11h49   #1
Membre du Club
 
Inscription : janvier 2008
Messages : 706
Détails du profil
Informations forums :
Inscription : janvier 2008
Messages : 706
Points : 66
Points : 66
Par défaut POST VIDE IPN

bonjour,

voila je suis bloquer dans mon code pour paiment paypal:
j'ai l'erreur "Statut de paiement: Echec" donc il n'arrive pas a rentrer dans la boucle.

je ne suis plus quoi faire, c est tres important et je suis bloquer dessus depuis au moins 3 jours.
quand je fait if(isset($_POST)){...} il rentre bien dedans.

voila la page d'appel:

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 
<?php
 
$nbArticles=count($_SESSION['panier']['idProduit']);
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">';
  for ($i=0 ;$i < $nbArticles ; $i++)
   {
 
 
$index = $i +1;
 
 
<input type="text" name="item_name_'.$index.'" value="'.htmlspecialchars($_SESSION['panier']['libelleProduit'][$i]).'">
 
//<input type="text" name="poids_'.$index.'" value="'.htmlspecialchars($_SESSION['poids'][$i]).'">
 
<input type="text" name="amount_'. $index . '" value="'.htmlspecialchars($_SESSION['panier']['prixProduit'][$i]).'">
 
<input type="text" name="quantity_'. $index .'" value="'.htmlspecialchars($_SESSION['panier']['qteProduit'][$i]).'">
 
 
   }
 
<input type="text" name="amount" value="'.MontantGlobal().'" />
<input name="currency_code" type="text" value="EUR" />
<input name="shipping" type="text" value="0.00" />
<input name="tax" type="text" value="0.00" />
<input name="return" type="text" value="'.RACINE.'/modules/catalogue/validationPaiement.php" />
<input name="cancel_return" type="text" value="'.RACINE.'/modules/catalogue/paiementAnnule.php" />
<input name="notify_url" type="text" value="'.RACINE.'/modules/catalogue/validationPaiement.php" />
<input type="text" name="cmd" value="_cart">
<input type="text" name="upload" value="1">
<input name="business" type="text" value="my.bab_1324302424_biz@gmail.com" />
<input name="no_note" type="text" value="1" />
<input name="lc" type="text" value="FR" />
<input name="bn" type="text" value="PP-BuyNowBF" />
<input name="custom" type="text" value="'.$_SESSION['id'].'" />
 
 
 
 
<input alt="Effectuez vos paiements via PayPal : une solution rapide, gratuite et sécurisée" name="submit" src="https://www.paypal.com/fr_FR/FR/i/btn/btn_buynow_LG.gif" type="image" /><img src="https://www.paypal.com/fr_FR/i/scr/pixel.gif" border="0" alt="" width="1" height="1" />
</form>
';
 
//header("Location: ".$serveur_paypal.$liste_param_paypal['TOKEN']);
 
 
 
?>
voici la page validationPaiement.php:
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
 
<?php
 
 
*/
//lire le formulaire provenant du système PayPal et ajouter 'cmd'
$req = 'cmd=_notify-validate';
 
foreach ($_POST as $key => $value) {
 
	$value = urlencode(stripslashes($value));
	$req .= "&$key=$value";
}
// renvoyer au système PayPal pour validation
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.sandbox.paypal.com', 80, $errno, $errstr, 30);
/**commande**/
/** Le montant de la transaction**/
$payment_amount = $_POST['amount'];
/**nom command ici j 'ai mit le numero**/
$item_name = $_POST['item_name1'];
/**nombre d'article**/
$item_number = $_POST['item_number'];
/****/
$payment_status = $_POST['payment_status'];
/**Choix de la monnaie**/
$payment_currency = $_POST['mc_currency'];
/**Taxe TVA**/
$txn_id = $_POST['txn_id'];
/**Identifiant du membre**/
$id_user = $_POST['custom'];
/**Identifiant du membre**/
$receiver_email = $_POST['email'];
 
 
 
 
 
if (!$fp) {
 
	// ERREUR HTTP
} else {
 
	fputs ($fp, $header . $req);
	while (!feof($fp)) {
		$res = fgets ($fp, 1024);
		if (strcmp ($res, "VERIFIED") == 0) {
			// transaction valide
		}
		else if (strcmp ($res, "INVALID") == 0) {
			// Transaction invalide               
		}
	}
	fclose ($fp);
}
// transaction valide
 
 
// vérifier que payment_status a la valeur Completed
if ($payment_status == "Completed") {
 
	// vérifier que txn_id n'a pas été précédemment traité: Créez une fonction qui va interroger votre base de données
	if (VerifIXNID($txn_id) == 0) {
		// vérifier que receiver_email est votre adresse email PayPal principale
		if ( "my.bab_1324302424_biz@gmail.com" == $receiver_email) {
 
			// vérifier que payment_amount et payment_currency sont corrects
			// traiter le paiement
 
 
 
 
 
		}
		else {
			// Mauvaise adresse email paypal
			echo'Mauvaise adresse email paypal';
		}
	}
	else {
		// ID de transaction déjà utilisé
		echo'ID de transaction déjà utilisé';
	}
}
else {
	// Statut de paiement: Echec
	echo'Statut de paiement: Echec';
}
/*
include('../../config/base.php');*/
?>
merci.
kate59 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 09/01/2012, 16h33   #2
Membre du Club
 
Homme
Développeur informatique
Inscription : décembre 2009
Messages : 40
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Développeur informatique

Informations forums :
Inscription : décembre 2009
Messages : 40
Points : 66
Points : 66
Bonjour,

Ce post ne réglerait-il pas votre problème ?

Apparemment il faut remplacer
Code :
$fp = fsockopen ('www.sandbox.paypal.com', 80, $errno, $errstr, 30);
par
Code :
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
Pourcentage est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/01/2012, 12h26   #3
Membre du Club
 
Inscription : janvier 2008
Messages : 706
Détails du profil
Informations forums :
Inscription : janvier 2008
Messages : 706
Points : 66
Points : 66
bonjour,

voila ce que cela m'affiche:
array(0) { } 1
non cela n'a rien changer du tout voici le formulaire modifier:
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
var_dump($_POST); 
if(isset($_POST))
{
echo'1';
}
//lire le formulaire provenant du système PayPal et ajouter 'cmd'
$req = 'cmd=_notify-validate';
 
foreach ($_POST as $key => $value) {
 
	$value = urlencode(stripslashes($value));
	$req .= "&$key=$value";
}
// renvoyer au système PayPal pour validation
$header  = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
/**commande**/
/** Le montant de la transaction**/
$payment_amount = $_POST['amount'];
/**nom command ici j 'ai mit le numero**/
$item_name = $_POST['item_name1'];
/**nombre d'article**/
$item_number = $_POST['item_number'];
/****/
$payment_status = $_POST['payment_status'];
/**Choix de la monnaie**/
$payment_currency = $_POST['mc_currency'];
/**Taxe TVA**/
$txn_id = $_POST['txn_id'];
/**Identifiant du membre**/
$id_user = $_POST['custom'];
/**Identifiant du membre**/
$receiver_email = $_POST['email'];
 
 
 
if (!$fp) {
 
	// ERREUR HTTP
} else {
 
	fputs ($fp, $header . $req);
	while (!feof($fp)) {
		$res = fgets ($fp, 1024);
		if (strcmp ($res, "VERIFIED") == 0) {
			// transaction valide
		}
		else if (strcmp ($res, "INVALID") == 0) {
			// Transaction invalide               
		}
	}
	fclose ($fp);
}
// transaction valide
 
 
// vérifier que payment_status a la valeur Completed
if ($payment_status == "Completed") {
echo'1';
	// vérifier que txn_id n'a pas été précédemment traité: Créez une fonction qui va interroger votre base de données
	if (VerifIXNID($txn_id) == 0) {
		// vérifier que receiver_email est votre adresse email PayPal principale
		if ( "my.bab_1324302424_biz@gmail.com" == $receiver_email) {
 
			// vérifier que payment_amount et payment_currency sont corrects
			// traiter le paiement
 
			$managerRegrouper->addMultiple($item_name,$id_commande,$item_number,$payment_amount);
 
			$managerCommande->add($commande);
			$commande = new Commande(
			array (
			'date_cmd' => NOW(),
			'total_poid_cmd' => "",
			'montant_cmd' => $payment_amount,
			'mode_reglement' => "PAYPAL",
			'mode_livraison' => "COLISSIMO",
			'livraison_prenom' => $_POST['first_name'],
			'livraison_nom' => ($_POST['last_name']),
			'livraison_adresse1' => ($_POST['address1']),
			'livraison_cp' => ($_POST['zip']),
			'livraison_ville' => ($_POST['city']),
			'livraison_pays' => "FRANCE",
			'paiement_status' => $payment_status,
			'id_client' => ($_POST['custom'])
			)
			);
 
 
 
 
		}
		else {
			// Mauvaise adresse email paypal
			$body.='Mauvaise adresse email paypal';
		}
	}
	else {
		// ID de transaction déjà utilisé
		$body.='ID de transaction déjà utilisé';
	}
}
else {
	// Statut de paiement: Echec
	$body.='Statut de paiement: Echec';
}
 
 
?>
merci.
kate59 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/01/2012, 13h24   #4
Membre du Club
 
Homme
Développeur informatique
Inscription : décembre 2009
Messages : 40
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Développeur informatique

Informations forums :
Inscription : décembre 2009
Messages : 40
Points : 66
Points : 66
Dommage que ça ne fonctionne pas... Le lien que je vous ai donné est pourtant un sujet marqué "Résolu" et utilise visiblement la même méthode que vous. En y regardant de plus près peut-être remarquerez-vous le problème.

Sinon il existe quelques tutos sur la toile qui expliquent comment intégrer Paypal, par exemple : http://www.entreprise-epi.fr/2008/04...-presentation/
Pourcentage est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/01/2012, 13h26   #5
Membre du Club
 
Inscription : janvier 2008
Messages : 706
Détails du profil
Informations forums :
Inscription : janvier 2008
Messages : 706
Points : 66
Points : 66
merci pour votre aide cela fait une semaine que je tourne en rond sur ce sujet, merci pour le lien je l'ai déjà lu mais rien ne m'indique pourquoi j'ai cette erreur.
j'ai laisser plusieurs message sur ces forums sans résultats pour le moment.
je suis désespérée
kate59 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/01/2012, 17h19   #6
Membre du Club
 
Inscription : janvier 2008
Messages : 706
Détails du profil
Informations forums :
Inscription : janvier 2008
Messages : 706
Points : 66
Points : 66
Bonjour je me suis aider de cette page:
<lien>https://www.paypaltech.com/SG2/scriptparse.php</lien>

pour faire ma page ipn avec email


Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<form action="https://www.sandbox.paypal.com/fr/cgi-bin/webscr" method="POST">
 
<img alt="" border="0" src="https://www.paypal.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="my.bab_1324302424_biz@gmail.com">
<input type="hidden" name="item_name_1" value="mon objet">
<input type="hidden" name="item_number_1" value="6">
<input type="hidden" name="custom" value="22">
<input type="hidden" name="amount_1" value="15.00">
<input type="hidden" name="no_shipping" value="0">
<input name="return" type="text" value="http://www.webcreation66.com/mybabylove/test3.php" />
<input name="cancel_return" type="text" value="http://www.webcreation66.com/mybabylove/test3.php" />
<input name="notify_url" type="text" value="http://www.webcreation66.com/mybabylove/test3.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="image" src=" <lien url="https://www.paypal.com/fr_FR/i/bnr/horizontal_solution_PP.gif">https://www.paypal.com/fr_FR/i/bnr/horizontal_solution_PP.gif</lien>
border="0" name="submit" alt="Paiement sécurisé par carte bancaire"/>
</form>
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
 
<?php
// Revision Notes
// 11/04/11 - changed post back url from <lien>https://www.paypal.com/cgi-bin/webscr</lien> to <lien>https://ipnpb.paypal.com/cgi-bin/webscr</lien>
// For more info see below:
// <lien url="https://www.x.com/content/bulletin-ip-address-expansion-paypal-services">https://www.x.com/content/bulletin-ip-address-expansion-paypal-services</lien>
// "ACTION REQUIRED: if you are using IPN (Instant Payment Notification) for Order Management and your IPN listener script is behind a firewall that uses ACL (Access Control List) rules which restrict outbound traffic to a limited number of IP addresses, then you may need to do one of the following: 
// To continue posting back to <lien>https://www.paypal.com</lien>  to perform IPN validation you will need to update your firewall ACL to allow outbound access to *any* IP address for the servers that host your IPN script
// OR Alternatively, you will need to modify  your IPN script to post back IPNs to the newly created URL <lien>https://ipnpb.paypal.com</lien> using HTTPS (port 443) and update firewall ACL rules to allow outbound access to the ipnpb.paypal.com IP ranges (see end of message)."
 
 
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
 
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
 
// post back to PayPal system to validate
 
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
 
	// If testing on Sandbox use: 
	 $header .= "Host: www.sandbox.paypal.com:443\r\n";
//$header .= "Host: ipnpb.paypal.com:443\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
 
	// If testing on Sandbox use:
	$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
//$fp = fsockopen ('ssl://ipnpb.paypal.com', 443, $errno, $errstr, 30);
 
// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = "my.babylove66140@gmail.com";
$payer_email = $_POST['payer_email'];
 
//set email variables
$From_email = "From: my.babylove66140@gmail.com";
$Subject_line = "SUBJ";
 
$email_msg = "TEXT";
$email_msg .= "\n\nThe details of your order are as follows:";
$email_msg .= "\n\n" . "Transaction ID: " .  $txn_id ;
$email_msg .= "\n" . "Payment Date: " . $payment_date;
 
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
 
$mail_From = $From_email;
$mail_To = $payer_email;
$mail_Subject = $Subject_line;
$mail_Body = $email_msg;
 
mail($mail_To, $mail_Subject, $mail_Body, $mail_From);
 
 
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
 
$mail_From = $From_email;
$mail_To = $receiver_email;
$mail_Subject = "INVALID IPN POST";
$mail_Body = "INVALID IPN POST. The raw POST string is below.\n\n" . $req;
 
mail($mail_To, $mail_Subject, $mail_Body, $mail_From);
 
}
}
fclose ($fp);
}
?>
le recoit un email mais aucun post j'ai ce message dans l'email:
INVALID IPN POST cmd=_notify-validate.

Merci.
kate59 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 21h01.


 
 
 
 
Partenaires

Hébergement Web