Web Hosting Talk







View Full Version : Alertpay IPN help


pwalters09
01-20-2010, 02:17 PM
Hi guys

I am in need of some help with the Alertpay IPN system, basically when IPN reports back to my server it should update an order that gets inserted into the database before the user is redirected, there is nothing wrong on my end, but nothing gets updated by the IPN script, when I try to access the IPN page myself via the browser it reports an error with line 128 on the IPN code

Error:

Parse error: syntax error, unexpected '=', expecting ',' or ';' in /var/www/html/ipn.php on line 128

Line 128:

global $ap_SecurityCode = $_POST['ap_securitycode'];

Full code:

<?php

require 'backend/config.php';
require 'backend/global.php';

// Security code variable
$ap_SecurityCode;

// Customer info variables
$ap_CustFirstName;
$ap_CustLastName;
$ap_CustAddress;
$ap_CustCity;
$ap_CustCountry;
$ap_CustZip;
$ap_CustEmailAddress;

// Common transaction variables
$ap_ReferenceNumber;
$ap_Status;
$ap_PurchaseType;
$ap_Merchant;
$ap_ItemName;
$ap_ItemCode;
$ap_Description;
$ap_Quantity;
$ap_Amount;
$ap_AdditionalCharges;
$ap_ShippingCharges;
$ap_TaxAmount;
$ap_DiscountAmount;
$ap_TotalAmount;
$ap_Currency;
$ap_Test;

// Custom fields
$ap_Apc_1;
$ap_Apc_2;
$ap_Apc_3;
$ap_Apc_4;
$ap_Apc_5;
$ap_Apc_6;

// Subscription variables
$ap_SubscriptionReferenceNumber;
$ap_TimeUnit;
$ap_PeriodLength;
$ap_PeriodCount;
$ap_NextRunDate;
$ap_TrialTimeUnit;
$ap_TrialPeriodLength;
$ap_TrialAmount;


// Initialize variable
setSecurityCodeVariable();

if ($ap_SecurityCode != "P1ebpmmk30B6I2dU")
{
$sql = mysql_query("UPDATE orders SET status = 'fraud' WHERE pemail = '$ap_CustEmailAddress'") or die(mysql_error());
}
else
{
if ($ap_Test == "1")
{
$sql = mysql_query("UPDATE orders SET status = 'testmode' WHERE pemail = '$ap_CustEmailAddress'") or die(mysql_error());
}
else
{
// Initialize variables
setCustomerInfoVariables();
setCommonTransactionVariables();

// Initialize the custom field variables.
setCustomFields();

// If the transaction is subscription-based (recurring payment), initialize the
// Subscription variables too.
if ($ap_PurchaseType == "Subscription")
{
setSubscriptionVariables();
}

if (strlen($ap_ReferenceNumber) == 0 && $ap_TrialAmount != "0")
{
// Invalid reference number. The reference number is invalid because the ap_ReferenceNumber doesn't
// contain a value and the ap_TrialAmount is not equal to 0.
}
else
{
if ($ap_Status == "Success")
{
$sql = mysql_query("UPDATE orders SET status = 'completed' WHERE pemail = '$ap_CustEmailAddress'") or die(mysql_error());
// Process non-subscription order.
if ($ap_PurchaseType != "Subscription")
{
// NOTE: The subscription variables are not applicable here. Don't use them.
}
// Process the subscription order. Use ap_SubscriptionReferenceNumber to uniquely identify
// this particular subscription transaction.
else
{
// Check whether the trial is free or not
if ($ap_TrialAmount == "0")
{
// Process the free trial here.
// NOTE: The ap_ReferenceNumber is always empty for trial periods and therefore you
// should not use it.
}
else
{
// The is not a free trial and ap_TrialAmount contains some amount and the
// ap_ReferenceNumber contains a valid transaction reference number.
}
}
}
else
{
$sql = mysql_query("UPDATE orders SET status = 'cancelled' WHERE pemail = '$ap_CustEmailAddress'") or die(mysql_error());
}
}
}
}

// Security code variable
function setSecurityCodeVariable()
{
global $ap_SecurityCode = $_POST['ap_securitycode'];
}

// Customer info variables
function setCustomerInfoVariables()
{
global $ap_CustFirstName =$_POST['ap_custfirstname'];
global $ap_CustLastName = $_POST['ap_custlastname'];
global $ap_CustAddress = $_POST['ap_custaddress'];
global $ap_CustCity = $_POST['ap_custcity'];
global $ap_CustCountry = $_POST['ap_custcountry'];
global $ap_CustZip = $_POST['ap_custzip'];
global $ap_CustEmailAddress = $_POST['ap_custemailaddress'];
global $ap_PurchaseType = $_POST['ap_purchasetype'];
global $ap_Merchant = $_POST['ap_merchant'];
}

// Common transaction variables
function setCommonTransactionVariables()
{
global $ap_ItemName = $_POST['ap_itemname'];
global $ap_Description = $_POST['ap_description'];
global $ap_Quantity = $_POST['ap_quantity'];
global $ap_Amount = $_POST['ap_amount'];
global $ap_AdditionalCharges=$_POST['ap_additionalcharges'];
global $ap_ShippingCharges=$_POST['ap_shippingcharges'];
global $ap_TaxAmount=$_POST['ap_taxamount'];
global $ap_DiscountAmount=$_POST['ap_discountamount'];
global $ap_TotalAmount = $_POST['ap_totalamount'];
global $ap_Currency = $_POST['ap_currency'];
global $ap_ReferenceNumber = $_POST['ap_referencenumber'];
global $ap_Status = $_POST['ap_status'];
global $ap_ItemCode = $_POST['ap_itemcode'];
global $ap_Test = $_POST['ap_test'];
}

// Subscription variables
function setSubscriptionVariables()
{
global $ap_SubscriptionReferenceNumber = $_POST['ap_subscriptionreferencenumber'];
global $ap_TimeUnit = $_POST['ap_timeunit'];
global $ap_PeriodLength=$_POST['ap_periodlength'];
global $ap_PeriodCount=$_POST['ap_periodcount'];
global $ap_NextRunDate=$_POST['ap_nextrundate'];
global $ap_TrialTimeUnit=$_POST['ap_trialtimeunit'];
global $ap_TrialPeriodLength=$_POST['ap_trialperiodlength'];
global $ap_TrialAmount=$_POST['ap_trialamount'];
}

// Custom fields
function setCustomFields()
{
global $ap_Apc_1 = $_POST['apc_1'];
global $ap_Apc_2 = $_POST['apc_2'];
global $ap_Apc_3 = $_POST['apc_3'];
global $ap_Apc_4 = $_POST['apc_4'];
global $ap_Apc_5 = $_POST['apc_5'];
global $ap_Apc_6 = $_POST['apc_6'];
}

?>

Can anyone help me with this?

Thanks

Neseema M M
01-21-2010, 12:53 AM
Try by changing


global $ap_SecurityCode = $_POST['ap_securitycode'];


as


global $ap_SecurityCode;
$ap_SecurityCode = $_POST['ap_securitycode'];


Hope it helps.

pwalters09
01-21-2010, 01:59 AM
hi,

Thanks but I managed to get it working properly by using a different code, seems alertpays default code is a little buggy :D

Thanks anyway

Coffeecash
02-06-2010, 09:51 PM
hi,

Thanks but I managed to get it working properly by using a different code, seems alertpays default code is a little buggy :D

Thanks anyway

Do you have a link to the code you used? I too am looking for a working IPN script for AlertPay.

Thanks

nextnaro
02-12-2010, 10:18 PM
need too:D