close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

PayPal IPN not working

Thread began 11/23/2011 6:52 am by ccdantas101117 | Last modified 11/23/2011 2:17 pm by Dani Chankhour | 1080 views | 1 replies |

ccdantas101117

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);
}
?>

Sign in to reply to this post

Dani Chankhour

It is really difficult to debug IPN, but the most important thing is to make sure an IPN is being sent correctly.

In your PayPal account, under the Profile, there is a link to an IPN History page which lists all the Notifications to your site. Check that page and ensure there is an IPN that was made once the purchase was made and that that it was made to the correct url.

The second thing i recommend is that you simplify the page. Once you confirm there is an IPN, i recommend that you only send a Static email address to ensure IPN is working. And then you can go back and try to insert the order to the database.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...