Résolu J'ai une erreur avec mon IPN paypal.

Statut
N'est pas ouverte pour d'autres réponses.

Florian.

Premium
Inscription
8 Août 2012
Messages
4 251
Réactions
1 220
Points
14 353
RGCoins
25
Bonjour,

J'ai un probleme avec mon IPN paypal :@

Voici le code

PHP:
<?php
define("_VALID_PHP", true);
  				  file_put_contents("log.txt", print_r($GLOBALS, true)."\r\n", FILE_APPEND);
  if (isset($_POST['payment_status'])) {
      require_once("../../includes/db.php");
      require_once("../../includes/init.php");
      set_time_limit(0);      

      function verifyTxnId($txn_id, $odb)
      {          
          $sql = $odb->prepare("SELECT COUNT(id) FROM `payments` WHERE tid = :tid LIMIT 1");
	  $sql -> execute(array(":tid" => $txn_id));	
          if ($sql -> fetchColumn(0) > 0)
              return false;
          else
              return true;
      }
      
      $req = 'cmd=_notify-validate';
      
      foreach ($_POST as $key => $value) {
          $value = urlencode(stripslashes($value));
          $req .= '&' . $key . '=' . $value;
      }
      $demo = false;
      $url = 'www.paypal.com';
      
      $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($url, 80, $errno, $errstr, 30);
      
      $payment_status = $_POST['payment_status'];
      $receiver_email = $_POST['business'];
      list($membership_id, $user_id) = explode("_", $_POST['item_number']);
      $mc_gross = $_POST['mc_gross'];
      $txn_id = $_POST['txn_id'];
      
      $getxn_id = verifyTxnId($txn_id, $odb);
      $pricesql = $odb -> prepare("SELECT `price` FROM `plans` WHERE id = :id");
      $pricesql -> execute(array(":id" => (int)$membership_id));
      $price = $pricesql -> fetchColumn(0);
      
      $pp_emailsql = $odb -> query("SELECT `gateway` FROM `config` LIMIT 1");
      $pp_email = $pp_emailsql->fetchColumn(0);
      
      if (!$fp) {
          echo $errstr . ' (' . $errno . ')';
      } else {
          fputs($fp, $header . $req);
          
          while (!feof($fp)) {
	      $res = fgets($fp, 1024);
              if (strcmp($res, "VERIFIED") == 0) {
                  if (preg_match('/Completed/', $payment_status)) {
                      if ($receiver_email == $pp_email && $mc_gross == $price && $getxn_id == true) {


			  $data = array(
				':tid' => $txn_id, 
				':plan' => (int)$membership_id,
				':email' => $_POST['payer_email'],
				':user' => (int)$user_id,
				':paid' => (float)$mc_gross, 
			  );
			  $odb -> setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
			  $insertsql = $odb -> prepare("INSERT INTO `payments` VALUES(NULL, :paid, :plan, :user, :email, :tid, UNIX_TIMESTAMP())");
			  $insertsql -> execute($data);
 

		        }					 
                  }
				  
              }
          }
          fclose($fp);
      }
  }
  

?>

Comme vous voyer j'ai mis un pti log.txt et voici ce qu'il m’indique dedans

Array
(
[GLOBALS] => Array
*RECURSION*
[_POST] => Array
(
[transaction_subject] => ;0;0
[payment_date] => 03:13:29 Jun 03, 2015 PDT
[txn_type] => web_accept
[last_name] => Prenom du client
[residence_country] => FR
[item_name] => Lobby : BO2
[payment_gross] =>
[mc_currency] => EUR
[business] => Mon email
[payment_type] => instant
[protection_eligibility] => Ineligible
[verify_sign] => VerifySign
[payer_status] => unverified
[tax] => 0.00
[payer_email] => Email paypal du client
[txn_id] => Transaction ID
[quantity] => 1
[receiver_email] => Email qui a recu le payement = [business]
[first_name] => Mon prenom
[payer_id] => payer_id
[receiver_id] => receiver_id
[item_number] =>
[handling_amount] => 0.00
[payment_status] => Completed
[payment_fee] =>
[mc_fee] => 0.01
[shipping] => 0.00
[mc_gross] => 0.01
[custom] => ;0;0
[charset] => windows-1252
[notify_version] => 3.8
[ipn_track_id] => track id
)

[_GET] => Array
(
)

[_COOKIE] => Array
(
)

[_FILES] => Array
(
)

)
 
Sur le paypal.php qui redirige vers paypal

PHP:
<?php
if(isset($_GET['id']) && Is_Numeric($_GET['id']))
{
ob_start();
session_start();
require_once("includes/db.php");
require_once("includes/init.php");
function getPath()
{
	$temp = "http://".$_SERVER['HTTP_HOST'];
	if($_SERVER['PHP_SELF'][strlen($_SERVER['PHP_SELF'])-1] == "/")
	{
		$temp.=$_SERVER['PHP_SELF'];
	} else {
		$temp.=dirname($_SERVER['PHP_SELF']);
	}
	if($temp[strlen($temp)-1]=="/")
	{
		$temp = substr($temp, 0, strlen($temp)-1);
	}
	return dirname($temp);
}
$id = (int)$_GET['id'];
$paypalemail = $odb -> query("SELECT `email` FROM `gateway` LIMIT 1") -> fetchColumn(0);
$plansql = $odb -> prepare("SELECT * FROM `plans` WHERE `ID` = :id");
$plansql -> execute(array(":id" => $id));
$row = $plansql -> fetch();
if($row === NULL) { die("Bad ID"); }
$paypalurl = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amount=".urlencode($row['price'])."&business=".urlencode($paypalemail)."&item_name=".urlencode($row['name'])."&item_number=".urlencode($row['ID']."_".$_SESSION['ID'])."&return=http://www.monsite.fr/purchase.php"."&rm=2&notify_url=hhttp://www.monsite.fr/paypalipn.php"."&cancel_return=http://www.monsite.fr/purchase.php"."&no_note=1&currency_code=EUR";

header("Location: ".$paypalurl);
}
?>
 
J'ai édité http://reality-gaming.fr/attachments/edition-png.20322/ le titre de ta discussion pour que celle-ci soit plus compréhensible.

A l'avenir essaie de faire des titres plus longs et détaillés, plus le titre est long et détaillé, plus tu obtiendras de vues http://reality-gaming.fr/attachments/vues-png.20315/ ainsi que des réponses http://reality-gaming.fr/attachments/reponses-png.20332/. :tchuss:
 
Statut
N'est pas ouverte pour d'autres réponses.
Retour
Haut