
Originally Posted by
Hejula
Surprised no one has pointed this out yet, it does not function! This is merely a base, it does not communicate with the 2CO API, so a bit of work is required before you can use this.
It does function, or it should. Just set the correct URL in your 2checkout account & when purchases etc are made it will send the $_POST data to the INS.

Originally Posted by
Kryptos
It's alright but I think the SQL query, for the platinumVIP for example, should be something like.. (Sorry for any mistake, pretty tired)
PHP Code:
mysql_query("UPDATE `users` SET `rank` = '4' WHERE `username` = '" . $username . "' AND `rank` < '4'");
Yes, I suppose. But I don't think any of my staff are going to buy VIP 

Originally Posted by
Aaron
2Checkout is such a great company.
Nice script btw.
Just had to point out that if you're going to do CC processing, then definitely use them.

They are. It took me this long to realise. They accept everything, it's great.
Here's the finished version:
PHP Code:
<?php
require_once "global.php";
// ########################
// Zap Hotel 2Checkout IPN
// ########################
$ipn['vendor_id'] = '';
$ipn['secret_word'] = '';
$allowedItems = Array("SuperVip", "PlatinumVip", "Throne");
if(isset($_POST["item_list_amount_1"]) && isset($_POST["order_number"]))
{
$ipn['total_price'] = filter($_POST["item_list_amount_1"]);
$ipn['order_num'] = filter($_POST["order_number"]);
}
$md5 = md5($ipn['secret_word'] . $ipn['vendor_id'] . $ipn['order_num'] . $ipn['total_price']);
$secretKey = strtoupper($md5);
if(isset($_POST["md5_key"]) && $secretKey == $_POST["md5_key"])
{
if(isset($_POST["message_type"]))
{
$message = filter($_POST["message_type"]);
if($message == "INVOICE_STATUS_CHANGED")
{
if(isset($_POST["invoice_status"])) { $status = filter($_POST["invoice_status"]); } else { exit; }
if(isset($_POST["ship_name"])) { $username = filter($_POST["ship_name"]); } else { exit; }
if(isset($_POST["item_name_1"])) { $item = filter($_POST["item_name_1"]); } else { exit; }
// Check the prices against the product before we go any further.
if($item == "SuperVip" && $ipn['total_price'] == "10.00")
{
$final_product = "SVIP";
}
else if($item == "PlatinumVip" && $ipn['total_price'] == "20.00")
{
$final_product = "PVIP";
}
else if($item == "Throne" && $ipn['total_price'] == "3.00")
{
$final_product = "T";
}
else
{
exit;
}
if($status == "deposited")
{
switch($final_product)
{
case "SVIP": // Give them Super VIP
mysql_query("UPDATE users SET activity_points = activity_points + '2000000' WHERE `username` = '" . $username . "'");
mysql_query("UPDATE users SET credits = credits + '2000000' WHERE `username` = '" . $username . "'");
mysql_query("UPDATE users SET rank = '3' WHERE username = '" . $username . "'");
mysql_query("UPDATE users SET points = points + '2' WHERE username = '" . $username . "'");
mysql_query("INSERT INTO vip_payments (username, type) VALUES ('". $username ."', 'S')");
break;
case "PVIP": // Give them Plat VIP
mysql_query("UPDATE users SET activity_points = activity_points + '5000000' WHERE `username` = '" . $username . "'");
mysql_query("UPDATE users SET credits = credits + '5000000' WHERE `username` = '" . $username . "'");
mysql_query("UPDATE users SET rank = '4' WHERE username = '" . $username . "'");
mysql_query("UPDATE users SET points = points + '6' WHERE username = '" . $username . "'");
mysql_query("INSERT INTO vip_payments (username, type) VALUES ('". $username ."', 'P')");
break;
case "T": // Give them a throne
//mysql_query("INSERT INTO `shop_purchases` (`username`, `product`) VALUES ('" . $username . "', 'Throne')");
mysql_query("INSERT INTO vip_payments (username, type) VALUES ('". $username ."', 'Throne')");
break;
}
} // TODO: More status updates.
}
} // TODO: More messages.
else
{
exit;
}
}
else
{
exit;
}
?>
Updated main post.
Oh, BTW:
This was a bastard to code. The documentation differs from how it's actually implemented so there's a lot of guess work to be done. If you want to write your own from scratch, I recommend looking at this first.
~ Jonteh