[REL] 2checkout INS - Auto VIP Payments [Uber/zCMS]
THIS WILL ONLY WORK IF YOU HAVE A 2CHECKOUT ACCOUNT.
This may or may not work. I've tested it to an extent but not fully. This is the first time I wrote an IPN from scratch and it looks good. I'm rewriting it into a class for my personal use, but here is the base for any budding programmers to learn from.
http://cloud.soshort.me/2co.rar
Enjoy guys, PHP code below if you don't want to download it.
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;
}
?>
Re: [REL] 2checkout INS - Auto VIP Payments [Uber/zCMS]
Cheer's for this mate. Using this straight away, hate having to confirm every purchase.
Re: [REL] 2checkout INS - Auto VIP Payments [Uber/zCMS]
I saw you coding this over TeamViewer earlier today, seems legit man, well done overall.
Re: [REL] 2checkout INS - Auto VIP Payments [Uber/zCMS]
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'");
Re: [REL] 2checkout INS - Auto VIP Payments [Uber/zCMS]
This is great, love to see you releasing more stuff Jonteh! 10/10
Sadly, I don't use 2Checkout..
Re: [REL] 2checkout INS - Auto VIP Payments [Uber/zCMS]
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.
Re: [REL] 2checkout INS - Auto VIP Payments [Uber/zCMS]
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. :blushing:
Re: [REL] 2checkout INS - Auto VIP Payments [Uber/zCMS]
Re: [REL] 2checkout INS - Auto VIP Payments [Uber/zCMS]
Quote:
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.
Quote:
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 :tongue:
Quote:
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. :blushing:
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
Re: [REL] 2checkout INS - Auto VIP Payments [Uber/zCMS]
A really nice release Jonty! Cheers.
Re: [REL] 2checkout INS - Auto VIP Payments [Uber/zCMS]
I use the MOSMS, and how can I connect the service to that code?
(SMS service)
Help please!
Re: [REL] 2checkout INS - Auto VIP Payments [Uber/zCMS]
Quote:
Originally Posted by
GHB
I use the MOSMS, and how can I connect the service to that code?
(SMS service)
Help please!
This is for 2checkout only. Please read the CAPITALIZED BOLD TEXT (xD) at the top :thumbup1:
Re: [REL] 2checkout INS - Auto VIP Payments [Uber/zCMS]
Great job Jonteh, you always impress me :):
Re: [REL] 2checkout INS - Auto VIP Payments [Uber/zCMS]
does this work with revcms?
Re: [REL] 2checkout INS - Auto VIP Payments [Uber/zCMS]
Quote:
Originally Posted by
Okok
does this work with revcms?
You can make it work.
Just remove:
PHP Code:
require_once "global.php";
and replace it with your mysql settings, eg:
PHP Code:
$con = mysql_connect('127.0.0.1', 'root', 'password');
mysql_select_db('database', $con);
:) hope it helps