PayPal IPN not working
Hello everybody, if anyone can give me a clue what am I missing here because it is not working.
I have created an IPN response page, activate IPN and point to the proper URL and when I run a transaction it doesn't work. The IPN page has an order update info update and send email to customer. Please help here.
IPN RESPONSE PAGE CODE BELOW:
<?php require_once('Connections/phdconn.php'); ?>
<?php
//WA eCart Include
require_once("WA_eCart/phdCart_PHP.php");
?>
<?php
$phdCart->GetContent();
?>
<?php
//WA eCart Include
require_once("WA_eCart/WA_eCart_Database_PHP.php");
?>
<?php require_once("WA_Universal_Email/mail_PHP.php"); ?>
<?php require_once("WA_Universal_Email/MailFormatting_PHP.php"); ?>
<?php
// WA eCart Get Form PaypalIPN.xml
if (WA_isValidPayPal()) {
$phdCart->ClearCart();
$displayIndex = 0;
$runOnce = "run";
while (isset($_POST["item_number".($displayIndex+1)])) {
$ATC_AddIfIn = 0;
$ATC_RedirectIfIn = "";
$ATC_ID = "".$_POST["item_number".($displayIndex+1)] ."";
$ATC_Name = "".$_POST["item_name".($displayIndex+1)] ."";
$ATC_Description = "";
$ATC_Weight = "0";
$ATC_Quantity = "".$_POST["quantity".($displayIndex+1)] ."";
$ATC_Price = "".$_POST["mc_gross_".($displayIndex+1)]/$_POST["quantity".($displayIndex+1)] ."";
$ATC_size = "";
$ATC_SizePriceInc = "0";
$ATC_color = "";
$ATC_ColorPriceInc = "0";
$ATC_Thumbnail = "";
$ATC_shipusa = "0";
$ATC_shipintl = "0";
$ATC_specialIn = "0";
$ATC_Specials = "0";
$ATC_specQty = "0";
if (is_numeric($ATC_Quantity) && $ATC_Quantity != 0) {
$phdCart->AddToCart($ATC_AddIfIn, $ATC_RedirectIfIn, $ATC_ID, $ATC_Name, $ATC_Description, $ATC_Weight, $ATC_Quantity, $ATC_Price, $ATC_size, $ATC_SizePriceInc, $ATC_color, $ATC_ColorPriceInc, $ATC_Thumbnail, $ATC_shipusa, $ATC_shipintl, $ATC_specialIn, $ATC_Specials, $ATC_specQty);
}
$runOnce = null;
$displayIndex++;
}
}
?>
<?php
// WA eCart Store Cart Summary in Db
if (WA_isValidPayPal()) // Trigger
{
$WA_connection = $phdconn;
$WA_table = "orders";
$WA_redirectURL = "";
$WA_indexField = "OrderID";
$WA_fieldNamesStr = "OrderID|OrderReferenceID|OrderPaypalID|OrderPaypalStatus|OrderStatus";
$WA_fieldValuesStr = WA_eCDB_ConvertNumber("".((isset($_POST["invoice"]))?$_POST["invoice"]:"") ."") . "|" . "PHD".data("Y") ."".((isset($_POST["invoice"]))?$_POST["invoice"]:"") ."" . "|" . "".((isset($_POST["txn_id"]))?$_POST["txn_id"]:"") ."" . "|" . "".((isset($_POST["payment_status"]))?$_POST["payment_status"]:"") ."" . "|" . WA_eCDB_ConvertNumber("1");
$WA_columnTypesStr = "none,none,NULL|',none,''|',none,''|',none,''|none,none,NULL";
$WA_sessionName = "OrderID";
$WA_Sql = "";
$NeedInsert = false;
$indexFieldIndex = -1;
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_phdconn;
$updateFieldValue = "";
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
if ($WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos('?', $WA_redirectURL) === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
for ($i = 0; $i < sizeof($WA_fieldNames); $i++)
{
if ($WA_indexField == $WA_fieldNames[$i])
{
$indexFieldIndex = $i;
break;
}
}
$deleteFieldValue = "";
$updateColType = "none,none,NULL";
if ($indexFieldIndex >= 0) $updateFieldValue = $WA_fieldValues[$indexFieldIndex];
if ($updateFieldValue == "" && isset($_SESSION[$WA_sessionName])) $updateFieldValue = $_SESSION[$WA_sessionName];
if ($indexFieldIndex >= 0) $updateColType = $WA_columns[$indexFieldIndex];
if ($updateFieldValue != "") {
$updateParamsObj = WA_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, $indexFieldIndex);
$valueForWhere = WA_generateInsertParams(array($WA_indexField), array($updateColType), array($updateFieldValue), -1);
$WA_Sql = "update " . $WA_table . " SET " . $updateParamsObj->WA_setValues . " where " . $WA_indexField . " = " . $valueForWhere->WA_dbValues;
$WA_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = $updateFieldValue;
$result = mysql_query("SELECT * FROM " . $WA_table . " where " . $WA_indexField . " = " . $valueForWhere->WA_dbValues, $WA_connection);
$num_rows = mysql_num_rows($result);
$NeedInsert = (mysql_num_rows($result) === 0);
}
if ($updateFieldValue === "" || $NeedInsert) {
$updateFieldValue = "";
$insertParamsObj = WA_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "insert into " . $WA_table . " (" . $insertParamsObj->WA_tableValues . ") values (" . $insertParamsObj->WA_dbValues . ")";
$WA_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
}
if ($WA_redirectURL != "") {
header("Location: ".$WA_redirectURL); exit;
}
}
?>
<?php
if ((WA_isValidPayPal())) {
//WA Universal Email object="mail"
//Send Loop Once Per Entry
$RecipientEmail = "".((isset($_POST["payer_email"]))?$_POST["payer_email"]:"") ."";include("WA_Universal_Email/WAUE_ipnresponse_1.php");
$RecipientEmail = "sales@princesshairdesigns.com";include("WA_Universal_Email/WAUE_ipnresponse_1.php");
$RecipientEmail = "ccdantas@ccdantaswebdesign.com";include("WA_Universal_Email/WAUE_ipnresponse_1.php");
//Send Mail All Entries
if (""!="") {
header("Location: ");
}
}
?>
<?php
// WA eCart Redirect
if ($phdCart->redirStr != "") {
header("Location: ".$phdCart->redirStr);
}
?>