Bonjour je recontre des problèmes avec la notification instantanée de paiement de PayPal. En effet j'ai l'impression que PayPal ne visite jamais ma page ipn.php.
Voici mon formulaire
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> <input class="form-control" name="amount" type="hidden" value="10" /> <input name="currency_code" type="hidden" value="EUR" /> <input name="shipping" type="hidden" value="0.00" /> <input name="tax" type="hidden" value="0.00" /> <input name="return" type="hidden" value="http://monsite.com/paypal/success.php" /> <input name="cancel_return" type="hidden" value="http://monsite.com/paypal/cancel.php" /> <input name="notify_url" type="hidden" value="http://monsite.com/paypal/ipn.php" /> <input name="cmd" type="hidden" value="_xclick" /> <input name="business" type="hidden" value="mrsaooty-seller@gmail.com" /> <input name="item_name" type="hidden" value="10EUR Easy Ranked" /> <input name="no_note" type="hidden" value="1" /> <input name="lc" type="hidden" value="FR" /> <input name="bn" type="hidden" value="PP-BuyNowBF" /> <input name="custom" type="hidden" value="<?php echo $_SESSION['id']; ?>" /> <input type="submit" class="hl-btn hl-btn-default hl-btn-block" value="Confirmer"> </form>
Et ipn.php
J'ai suivi un tuto trouvé sur un autre site.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?php include '../functions.php'; //permet de traiter le retour ipn de paypal $email_account = "mon email"; $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } $header = "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Host: www.sandbox.paypal.com\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); $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 = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; $custom = $_POST['custom']; if(!$fp){ } else { fputs($fp, $header . $req); if(!feof($fp)){ $res = fgets ($fp, 1024); if(strcmp ($res, "VERIFIED") == 0){ // vérifier que payment_status a la valeur Completed if($payment_status == "Completed"){ if($email_account == $receiver_email){ /** * C'EST LA QUE TOUT SE PASSE * PS : tjrs penser à vérifier la somme !! */ mail('mon email', 'success', 'success'); /** * FIN CODE */ } } else { mail('mon email', 'echec', 'echec'); } exit(); } else if (strcmp ($res, "INVALID") == 0) { mail('mon email', 'invalide', 'invalide'); } } fclose ($fp); } ?>
Partager