HTTP / Paypal IPN's Question(s)
#1

Hey,

I have a few questions regarding paypal's 'IPN' and SA-MP's "HTTP". I've made a vip system that in which gives you the VIP level along with it's perks. But I need a site that can generate redeem codes, and that can validate with it. The system via SA-MP works, but I'm not sure on how to script an PayPal IPN php script to validate the codes.

Sums it up: I need a PHP script that generates random VIP codes, that can be redeemed in-game.
Reply
#2

Something like this?
Код:
<?php
	mysql_connect("localhost", "root", "") or die(mysql_error());
	mysql_select_db("db");
	$query=mysql_query("SELECT * FROM codes WHERE code > 0");
	$numrows=mysql_num_rows($query);
	while($row=mysql_fetch_assoc($query))
	{
		$redeemcode = rand(2744,100000);
		if($row['code'] == $redeemcode) die echo '<meta http-equiv="refresh" content="5">'; // refresh the page, code already exists.
		$query = mysql_query("INSERT INTO codes(code) VALUES('$redeemcode')");
		if($query)
		{
			echo("Your code has been generated($redeemcode)");
		}
	}
?>
pawn Код:
CMD:vredeem(playerid, params[])
{
      if(!isnull(params))
      {
          new query[250];
          mysql_format(  mysql_format(MySQLCon, query, sizeof(query),"SELECT * FROM `code` WHERE `code` = '%d' LIMIT 1", params);
        mysql_tquery(MySQLCon, query, "RedeemVIP", "id", playerid, params);
            return true;
      }
}

public RedeemVIP(playerid, code)
{
     new numrows = cache_get_row_count(), query[250];
     if(numrows == 0) return SendClientMessage(playerid, -1, "That code is invalid, or has already been redeemed!");
     if(numrows >= 1)
     {
          mysql_format(MySQLCon, query, sizeof(query), "DELETE FROM codes WHERE code = '%d'", code);
          mysql_tquery(MySQLCon, query, "", "");
     }
     player_VIP[playerid] = true;
     SendClientMessage(playerid, -1, "The code has been redeemed.");
     return 1;
}
Requires MySQL, though.
Reply
#3

That's good, but there's so many vulnerabilities. If you can, try a sample donation page. I need codes that will be generated, but deleted after use. Also they need to be generated on purchase. As someone may provide a lucky guess.

Edit: There also needs to be a generated code section of each VIP level. There's only so much people can do for free. Thanks for your help, your decision to help further. But, now. How would I make PayPal redirect them to the generated code, but only if they donated. Like ex: http://blahb.com/VIP-redemption.php but if a person that didn't donate tries to go to that link, I want it to deny them. Also I already have the samp system done, just need the php scripts.
Reply
#4

I imagine there's an API or some-sort for paypal. I will check it out and respond with what I can find.
EDIT: This seems relevant https://developer.paypal.com/webapps.../docs/classic/.
Regarding the code I posted using the SA-MP example it does delete after redemption, and it can be a very complex password if generated through PHP since it starts from around 2000 and can go all the way to 100000 characters. That should be complex enough.

Furthermore, using MySQL you can make a "VIPLevel" column accordingly. So, then each code would go with a level.
Reply
#5

Could you explain how to make a VIP redemption code collumn, also how to make the codes actually generate.
Reply
#6

Quote:
Код:
$redeemcode = rand(2744,100000);
This generates a random integer between 2744 and 1000000. This generates it for you, easily. And regarding creating columns, this can be done using things such as phpMyAdmin depending on what set up you have(for example XAMPP).
Reply
#7

I know to make columns, but I don't know how to add the codes.
Reply
#8

You could use MySQL's UUID() or UUID_SHORT() function. They're guaranteed to be unique, but they're predictable. You can also wrap it in a SHA1 to obfuscate this fact and it should still be pretty much unique.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)