I am trying to update and complete the
members area modification, I know this product was released here under a false author and was never complete although it was never removed from here, and there are like 6 different threads for it which all have not been active in quite some time, and the author and co-authors (or anyone who has worked on it) has not been on in years.
I have managed to get the basics working, I have updated a lot of the code, added features, and everything seems to be functional.
What I am having problems with is getting the data to insert in the right places once the payment goes through.
The following code snippets are where the purchases take place:
members.php (Line 164) Says if the product is free, insert the data (Funstions as it should)
PHP Code:
if ($price == 0)
{
if ($product['pur_group'] == '0')
{
$product['pur_group'] = $vbulletin->userinfo['usergroupid'];
}
$vbma->setCustomerNumber($information, $product['pur_group']);
$vbma->sendOutNewSaleEmail();
$rand = rand($vbulletin->options['memarea_numstart'], $vbulletin->options['memarea_numend']);
$licnum = substr(md5($prodid . rand(0, 20000) . $rand . $rand), 0, rand(10, $vbulletin->
options['memarea_custnumleng']));
$licensedm = datamanager_init('License', $vbulletin, ERRTYPE_ARRAY);
$licensedm->setr('userid', $vbulletin->userinfo['userid']);
$licensedm->setr('productid', $id);
$licensedm->setr('licensenum', $licnum);
$licensedm->set('dateline', TIMENOW);
$licensedm->set('status', 2);
$licensedm->pre_save();
if (!empty($licensedm->errors))
{
var_dump($licensedm->errors);
}
else
{
$licensedm->save();
}
}
ELSE IF NOT FREE (right after the above) does not want to work.
PHP Code:
else
{
$ids = array($paypal, $id);
$itemnumber = $vbma->insertPurchaseInfo($ids, $information);
$itemname = $product['title'];
}
mem_payment.php (line 100) this is where the successful payment process starts, the payment goes through ok, but the data is never inserted into the license tables. Without this process I have to manually approve EVERY single transaction, I really need this to function.
PHP Code:
if ($result == 'VERIFIED')
{
$purchase = $vbulletin->db->query_first("SELECT * FROM " . TABLE_PREFIX .
"ma_purchases WHERE id = '" . $id . "'");
$order = unserialize($purchase['order']);
if ($order[0] !== $vbulletin->GPC['business'])
{
$status_code = '503 Service Unavailable';
// Paypal likes to get told its message has been received
if (SAPI_NAME == 'cgi' or SAPI_NAME == 'cgi-fcgi')
{
header('Status: ' . $status_code);
}
else
{
header('HTTP/1.1 ' . $status_code);
}
}
unset($order[0]);
if ($purchase and !in_array($order[1], array('renew', 'upgrade')))
{
$product = $vbulletin->db->query_read("SELECT pur_group FROM " . TABLE_PREFIX .
"ma_products WHERE id = '" . $order[1] . "'");
$userinfo = fetch_userinfo($purchase['userid']);
$vbma->setCustomerNumber(unserialize($purchase['info']), $product['pur_group'], false,
$userinfo);
$rand = rand($vbulletin->options['memarea_numstart'], $vbulletin->options['memarea_numend']);
$licnum = substr(md5($prodid . rand(0, 20000) . $rand . $rand), 0, rand(10, $vbulletin->
options['memarea_custnumleng']));
$licensedm = datamanager_init('License', $vbulletin, ERRTYPE_ARRAY);
$licensedm->setr('userid', $userinfo['userid']);
$licensedm->setr('productid', $order[1]);
$licensedm->setr('licensenum', $licnum);
$licensedm->set('dateline', TIMENOW);
$licensedm->set('status', 2);
$licensedm->pre_save();
if (!empty($licensedm->errors))
{
var_dump($licensedm->errors);
}
else
{
$licensedm->save();
}
} elseif ($purchase and $order[1] == 'renew')
{
$licenseinfo = $vbma->getLicense($order[2], false, false, '', false, false);
$licensedm = datamanager_init('License', $vbulletin, ERRTYPE_ARRAY);
$licensedm->set_existing($licenseinfo);
$licensedm->set('dateline', TIMENOW);
$licensedm->set('status', 2);
$licensedm->pre_save();
if (!empty($licensedm->errors))
{
var_dump($licensedm->errors);
}
else
{
$licensedm->save();
}
} elseif ($purchase and $order[1] == 'upgrade')
{
$licenseinfo = $vbma->getLicense($order[2], false, false, '', false, false);
$licensedm = datamanager_init('License', $vbulletin, ERRTYPE_ARRAY);
$licensedm->set_existing($licenseinfo);
$licensedm->set('upgrades', serialize($order[3]));
$licensedm->pre_save();
if (!empty($licensedm->errors))
{
var_dump($licensedm->errors);
}
else
{
$licensedm->save();
}
}
$vbma->sendOutNewSaleEmail();
$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX .
"ma_purchases WHERE id = '" . $id . "'");
$status_code = '200 OK';
// Paypal likes to get told its message has been received
if (SAPI_NAME == 'cgi' or SAPI_NAME == 'cgi-fcgi')
{
header('Status: ' . $status_code);
}
else
{
header('HTTP/1.1 ' . $status_code);
}
exit;
}
SOME of the things I have attempted to debug
I have tried removing the if condition verified, and even the condition
PHP Code:
if ($purchase and !in_array($order[1], array('renew', 'upgrade')))
So it reads the following not contained in any condition:
PHP Code:
$purchase = $vbulletin->db->query_first("SELECT * FROM " . TABLE_PREFIX .
"ma_purchases WHERE id = '" . $id . "'");
$order = unserialize($purchase['order']);
if ($order[0] !== $vbulletin->GPC['business'])
{
$status_code = '503 Service Unavailable';
// Paypal likes to get told its message has been received
if (SAPI_NAME == 'cgi' or SAPI_NAME == 'cgi-fcgi')
{
header('Status: ' . $status_code);
}
else
{
header('HTTP/1.1 ' . $status_code);
}
}
unset($order[0]);
$product = $vbulletin->db->query_read("SELECT pur_group FROM " . TABLE_PREFIX .
"ma_products WHERE id = '" . $order[1] . "'");
$userinfo = fetch_userinfo($purchase['userid']);
$vbma->setCustomerNumber(unserialize($purchase['info']), $product['pur_group'], false,
$userinfo);
$rand = rand($vbulletin->options['memarea_numstart'], $vbulletin->options['memarea_numend']);
$licnum = substr(md5($prodid . rand(0, 20000) . $rand . $rand), 0, rand(10, $vbulletin->
options['memarea_custnumleng']));
$licensedm = datamanager_init('License', $vbulletin, ERRTYPE_ARRAY);
$licensedm->setr('userid', $userinfo['userid']);
$licensedm->setr('productid', $order[1]);
$licensedm->setr('licensenum', $licnum);
$licensedm->set('dateline', TIMENOW);
$licensedm->set('status', 2);
$licensedm->pre_save();
if (!empty($licensedm->errors))
{
var_dump($licensedm->errors);
}
else
{
$licensedm->save();
}
if ($purchase and $order[1] == 'renew')
{
$licenseinfo = $vbma->getLicense($order[2], false, false, '', false, false);
$licensedm = datamanager_init('License', $vbulletin, ERRTYPE_ARRAY);
$licensedm->set_existing($licenseinfo);
$licensedm->set('dateline', TIMENOW);
$licensedm->set('status', 2);
$licensedm->pre_save();
if (!empty($licensedm->errors))
{
var_dump($licensedm->errors);
}
else
{
$licensedm->save();
}
} elseif ($purchase and $order[1] == 'upgrade')
{
$licenseinfo = $vbma->getLicense($order[2], false, false, '', false, false);
$licensedm = datamanager_init('License', $vbulletin, ERRTYPE_ARRAY);
$licensedm->set_existing($licenseinfo);
$licensedm->set('upgrades', serialize($order[3]));
$licensedm->pre_save();
if (!empty($licensedm->errors))
{
var_dump($licensedm->errors);
}
else
{
$licensedm->save();
}
}
That still didnt insert the data into the license table, so I begun to break it down, I created a test page, included what needed to be included and echoed every variable and array and they all returned the proper results. So maybe the script is breaking somewhere else?
I post the mem_payment.php on StackOverflow and a suggestion I got was to use
$script = 'ipnpb.paypal.com'; rather than
www.paypal
that still did nothing, the payment works. its just this data not being inserted and the rest of the script on the page. They also suggested to upgrade the payment method to the new paypal api, but I have no idea where to begin with that, and this works for the payment, so I'm not too concerned with that right away.
If anyone can help me get this functioning I will split the profit of my first 5 sales once this is complete. And I have ALOT of products to be sold.