Probleme avec Tutoriel PHP - Paiement Paypal

Par Anthony Delgehier, il y a 8 ans


Bonjour,

Voila je rencontre un petit problème avec mon code.

ipn.php: https://pastebin.com/MfXk55eH
index.php: https://pastebin.com/6hLFH9EH

Le paiement s'execute biens mais le fichier ipn.php ne s'execute pas.

2 réponses

Lramelot, il y a 8 ans

Déjà, partons sur du code plus propre en retirant les parties inutiles et en nettoyant l'indentation et le reste.

<?php session_start(); require_once('../config/baseDonnees.php'); // read the post from PayPal system and add 'cmd' $email_account = "taureau30190-facilitator@gmail.com"; $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"; $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', 80, $errno, $errstr, 30); // assign posted variables to local variables $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; // id commande $payment_status = $_POST['payment_status']; // Completed, $payment_amount = $_POST['mc_gross']; //0.01 $payment_currency = $_POST['mc_currency']; //CAD $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; parse_str($_POST['custom'], $custom); if ($fp) { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { if ($payment_status == "Completed") { if($email_account == $receiver_email) { $pseudo = "1"; $item_name = "1"; $req = $bdd->prepare('INSERT INTO commande(id_user, montant) VALUES(:pseudo, :offre)'); $req->bindParam(':pseudo', $pseudo, PDO::PARAM_STR); $req->bindParam(':offre', $item_name); $req->execute(); } } } } fclose ($fp); } ?>

En partant de ce nouveau code :

  • Peux-tu expliquer clairement ce qui ne fonctionne pas ?
  • As-tu des logs d'accès à ta page ?
  • Des erreurs ou autre que tu aurais loggué ?
  • As-tu bien configuré la notification sur cette page ?

Globalement, tu ne donnes pas assez d'information que pour qu'on puisse te répondre.

Anthony Delgehier, il y a 8 ans

Bonjour, j'ai fais des petit log et le fichier ne se creer pas donc j'en deduis que paypal ne redirige pas vers ma page http://craftacms.fr/credit/ipn.php

Pourtant je pense avoir bin configurer paypal voir les image si dessous: