Ok.. I am trying to make VIP+ to be automatically given after you buy it.. (normal VIP works)
here's the paypal.php:paypal.class.php:Code:////////////////////////////// // Script written for RevCMS // Coded by lDiverse // Edits by LaceUp // Free Released by LaceUp // ////////////////////////// <?php function filter($var) { return stripslashes(htmlspecialchars($var)); } require_once('paypal.class.php'); $p = new paypal_class; $p->paypal_url = 'https://www.paypal.com/cgi-bin/webscr'; $this_script = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; if (empty($_GET['action'])) $_GET['action'] = 'process'; switch ($_GET['action']) { case 'process': if(!isset($_POST['username']) || !isset($_POST['amount'])) { echo 'username and amount needed for purchase'; die; } $name = filter($_POST['username']); switch($_POST['amount']) { case '1': $cost = '1'; //Cost of VIP $wut = 'VIP'; //Name of Package break; default: $cost = '1'; //Cost of VIP again break; case '2': $cost = '1'; //Cost of VIP $wut = 'VIP+'; //Name of Package break; default: $cost = '1'; //Cost of VIP again break; } $p->add_field('business', '****************); // <---------------- CHANGE ME CHANGE ME CHANGE ME CHANGE ME <---------------- $p->add_field('return', 'http://'.$_SERVER['HTTP_HOST']); $p->add_field('custom', $name); $p->add_field('cancel_return', 'http://'.$_SERVER['HTTP_HOST']); $p->add_field('notify_url', $this_script.'?action=ipn'); $p->add_field('item_number', filter($_POST['amount'])); $p->add_field('item_name', $wut); $p->add_field('amount', $cost); $p->submit_paypal_post(); break; //EDIT YOUR DATABSE SETTINGS BELOW (Same as your Phoenix Database Info) case 'ipn': if ($p->validate_ipn()) { $host = "localhost"; $username = "root"; //IIS and XAMPP is root $password = "***********"; // <---------------- CHANGE ME CHANGE ME CHANGE ME CHANGE ME <---------------- $dbname = "************"; // <---------------- CHANGE ME CHANGE ME CHANGE ME CHANGE ME <---------------- $connect = mysql_connect($host, $username, $password) or die(mysql_error()); mysql_select_db($dbname, $connect) or die("Could not connect to database, error: ".mysql_error()); switch($p->ipn_data['item_number']) { case '1': $coins = '2000'; //Amount of coins they recieve $pixels = '1000'; //Amount of pixels they recieve $rank = '2'; //Your Hotel's VIP rank (2 is default for Pheonix) break; case '2': $coins = '2000'; //Amount of coins they recieve $pixels = '1000'; //Amount of pixels they recieve $rank = '3'; //Your Hotel's VIP rank (2 is default for Pheonix) break; } mysql_query("UPDATE users SET vip = '1', rank = '2', credits = credits + 2000, activity_points = activity_points + 1000 WHERE username = '".$p->ipn_data['custom']."' LIMIT 1"); } mysql_query("UPDATE users SET vip = '1', rank = '3', credits = credits + 2500, activity_points = activity_points + 1500 WHERE username = '".$p->ipn_data['custom']."' LIMIT 1"); break; } ?>This is my problem: when a user buys VIP they get VIP+ what's wrong?Code:////////////////////////////// // Script written for RevCMS // Coded by lDiverse // Edits by LaceUp // Free Released by LaceUp // ////////////////////////// <?php class paypal_class { var $last_error; var $ipn_log; var $ipn_log_file; var $ipn_response; var $ipn_data = array(); var $fields = array(); function paypal_class() { $this->paypal_url = 'https://www.paypal.com/cgi-bin/webscr'; $this->last_error = ''; $this->ipn_log_file = './ipn_results.log'; $this->ipn_log = true; $this->ipn_response = ''; $this->add_field('rm','2'); $this->add_field('cmd','_xclick'); } function add_field($field, $value) { $this->fields["$field"] = $value; } function submit_paypal_post() { echo "<html>\n"; echo "<head><title>Processing Payment...</title>"; echo "<body onLoad=\"document.forms['paypal_form'].submit();\">\n"; echo "<center><h2>Please wait, your order is being processed and you"; echo " will be redirected to the paypal website.</h2></center>\n"; echo "<form method=\"post\" name=\"paypal_form\" "; echo "action=\"".$this->paypal_url."\">\n"; foreach ($this->fields as $name => $value) { echo "<input type=\"hidden\" name=\"$name\" value=\"$value\"/>\n"; } echo "<center><br/><br/>If you are not automatically redirected to "; echo "paypal within 5 seconds...<br/><br/>\n"; echo "<input type=\"submit\" value=\"Click Here\"></center>\n"; echo "</body></html>\n"; } function validate_ipn() { $url_parsed=parse_url($this->paypal_url); $post_string = ''; foreach ($_POST as $field=>$value) { $this->ipn_data["$field"] = $value; $post_string .= $field.'='.urlencode(stripslashes($value)).'&'; } $post_string.="cmd=_notify-validate"; $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); if(!$fp) { $this->last_error = "fsockopen error no. $errnum: $errstr"; $this->log_ipn_results(false); return false; } else { fputs($fp, "POST $url_parsed[path] HTTP/1.1\r\n"); fputs($fp, "Host: $url_parsed[host]\r\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp, "Content-length: ".strlen($post_string)."\r\n"); fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $post_string . "\r\n\r\n"); while(!feof($fp)) { $this->ipn_response .= fgets($fp, 1024); } fclose($fp); } if (eregi("VERIFIED",$this->ipn_response)) { $this->log_ipn_results(true); return true; } else { $this->last_error = 'IPN Validation Failed.'; $this->log_ipn_results(false); return false; } } function log_ipn_results($success) { if (!$this->ipn_log) return; // is logging turned off? $text = '['.date('m/d/Y g:i A').'] - '; if ($success) $text .= "SUCCESS!\n"; else $text .= 'FAIL: '.$this->last_error."\n"; $text .= "IPN POST Vars from Paypal:\n"; foreach ($this->ipn_data as $key=>$value) { $text .= "$key=$value, "; } $text .= "\nIPN Response from Paypal Server:\n ".$this->ipn_response; $fp=fopen($this->ipn_log_file,'a'); fwrite($fp, $text . "\n\n"); fclose($fp); } function dump_fields() { echo "<h3>paypal_class->dump_fields() Output:</h3>"; echo "<table width=\"95%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\"> <tr> <td bgcolor=\"black\"><b><font color=\"white\">Field Name</font></b></td> <td bgcolor=\"black\"><b><font color=\"white\">Value</font></b></td> </tr>"; ksort($this->fields); foreach ($this->fields as $key => $value) { echo "<tr><td>$key</td><td>".urldecode($value)." </td></tr>"; } echo "</table><br>"; } }


Reply With Quote

