Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > TBDev > Mods & Themes
Reply
  #1  
Old 27th April 2013, 00:13
sharpie sharpie is offline
Senior Member
 
Join Date: Apr 2012
United Kingdom
Posts: 17
Default paypal ipn
how do i deal with subscription payments via the paypal.php so that members get correct credits currently the paypal.php only deals with donations and not subscriptions

Code:
<?php
require "include/bittorrent.php";
require_once("ircbot.php");	
dbconn();


$donb=0;
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value)
{
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
// assign posted variables to local variables
$id = mysql_insert_id();
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
$clid = $_POST['custom'];
$payment_type = $_POST['payment_type'];
$ip =  $_SERVER['REMOTE_ADDR'];
$trans_id = $_POST['txn_id'];
$os2 = $_POST['option_selection2'];
$payment_gross = $_POST['mc_gross'];
$payment_fee = $_POST['payment_fee'];
$os1 = $_POST['option_selection1'];
if (!$txn_id) die; 
if (!$clid) die;
if ($receiver_email != "****@*****") die; #Your Paypal Emial here

// block pending echecks. paypal posts payments again when echecks clear, blocks double credits.
if ($payment_type == "echeck" && $payment_status == "Pending") die;

if (!$fp){
}
else
{
fputs ($fp, $header . $req);
while (!feof($fp))
{
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0)
{
// process payment

///Sort Upload and Donor time amounts
if ($payment_amount == 2)
{$days = 1*1;}
if ($payment_amount == 5)
{$days = 1*2;}
elseif ($payment_amount == 10)
{$days = 1*4;}
elseif ($payment_amount == 20)
{$days = 1*8;}
elseif ($payment_amount == 25)
{$days = 1*16;}
elseif ($payment_amount == 40)
{$days = 1*32;}
elseif ($payment_amount == 30)
{$days = 1*52;}
elseif ($payment_amount == 45)
{$days = 1*704;}
else {$days = 1*1;}

//set donor upload upgrade
if ($payment_amount == 2)
{$donb = 5368709120; }
if ($payment_amount == 5)
{$donb = 10737418240; }
elseif ($payment_amount == 10)
{$donb = 21474836480; }
elseif ($payment_amount == 20)
{$donb = 42949672960; }
elseif ($payment_amount == 25)
{$donb = 128849018880; }
elseif ($payment_amount == 40)
{$donb = 171798691840; }
elseif ($payment_amount == 30)
{$donb = 257698037760; }
elseif ($payment_amount == 45)
{$donb = 322122547200; }
else {
$donb = 1073741824*$payment_amount;}

//Set User Invites
if ($payment_amount == 2)
{$invites = 1; }
if ($payment_amount == 5)
{$invites = 2; }
elseif ($payment_amount == 10)
{$invites = 4; }
elseif ($payment_amount == 20)
{$invites = 6; }
elseif ($payment_amount == 25)
{$invites = 8; }
elseif ($payment_amount == 40)
{$invites = 10; }
elseif ($payment_amount == 30)
{$invites = 12; }
elseif ($payment_amount == 45)
{$invites = 14; }
else {
$invites = 0;}

//Set User Seedbonus
if ($payment_amount == 2)
{$seedbonus = 1000; }
if ($payment_amount == 5)
{$seedbonus = 15625; }
elseif ($payment_amount == 10)
{$seedbonus = 31250; }
elseif ($payment_amount == 20)
{$seedbonus = 62500; }
elseif ($payment_amount == 25)
{$seedbonus = 125000; }
elseif ($payment_amount == 40)
{$seedbonus = 250000; }
elseif ($payment_amount == 30)
{$seedbonus =500000; }
elseif ($payment_amount == 45)
{$seedbonus = 1000000; }
else {
$seedbonus = 0;}

//get user information from DB
$query = "SELECT * FROM users WHERE id='".$clid."'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$username = $row['username'];
$old=date($row['donoruntil']);
$class = $row['class'];
$dona = $row['uploaded'];

//Set class to VIP if lower then VIP
if ($class <= 32)
{$class = 32;}
$r = @mysql_query("SELECT * FROM users WHERE id=$clid") or sqlerr();
$user = mysql_fetch_array($r) or bark("No user with ID.");
//Reset download upload post and reset to zero H&R's
$query = "UPDATE users SET donor='yes', downloadpos='yes', class=$class, timeswarned = 0,warned ='no',invites=invites+$invites,seedbonus=seedbonus+$seedbonus WHERE id='".$clid."'";
$result = mysql_query("$query");


//Get Donor time if already some left from before
If ($old<>"0000-00-00 00:00:00")
{
$old1=strtotime($old)- gmtime();
$donateuntil = get_date_time((gmtime() + $days * 604800) +$old1);
}
else
{$donateuntil = get_date_time(gmtime() + $days * 604800);}
//add Upload bonus for amount given at 1Gb per ?1
$bonus = $donb + $dona;
$donordif =strtotime($donateuntil)- gmtime();
//add to mod comment for staff to check if payment made via here
$modcomment = gmdate("d-m-Y [H:i]") . " Donation Made Auto Promoted to Vip.\n". $modcomment;
//$modcomment = gmdate("d-m-Y H:i") . " Donation Made Auto Promoted to Vip";
$modcom = sqlesc($modcomment);
//update users total and bonus totals
$query = "UPDATE users SET uploaded='".$bonus."', modcomment = CONCAT($modcom,modcomment), donoruntil='$donateuntil', donated=$payment_amount,total_donated=total_donated+$payment_amount WHERE id='".$clid."'";
$result = mysql_query($query);

//Send Message to Site Owners
$sysop = mysql_query("SELECT id FROM users WHERE id=9") or sqlerr(__FILE__, __LINE__); 
while ($sysopid = mysql_fetch_assoc($sysop)){
//$sysopmsg = "User: ".$username." | Amount : $$payment_amount | Email: $payer_email";
//new_msg(0, $sysopid['id'], $sysopmsg);
}
}}

$day = date("d");
$month = date("m");
$year = date("Y");
$time = time();
//Update users User Level.				
$query = "INSERT into donations 
(ip,txn_id,name,donation,fees,dnuid,time,username)
VALUES
('$ip','$trans_id','$os2','$payment_gross','$payment_fee','$os1','$time','$username')";
$result = mysql_query($query);
//bot signup end
/** shoutbox announce new signup **/
$message = "Thanks  ".$username." for supporting GT & adding £$payment_amount to the site fund ";
autoshouts($message);
/** end **/
/** irc announce new donation **/
$msgs = array();
$msgs[] = "\0036$username Added \0038£$payment_amount To The Site Fund";
IRCSendMsg($msgs);
/** end **/

header("Location: http://****/");

fclose ($fp);
}
stdfoot();
?>
Thanks in advance

Last edited by sharpie; 27th April 2013 at 02:00.
Reply With Quote
  #2  
Old 27th April 2013, 12:42
joeroberts's Avatar
joeroberts joeroberts is offline
BT.Manager Owner
 
Join Date: Jan 2008
United States
Posts: 2,113
Default
you have to A premium account on paypal and activate it on paypal first
__________________
Do not ask me to help you work on your site that is not phpMyBitTorrent
Do not ask me to make a mod for any other source
Do not Ask me to setup your site.
I will no longer help you setup your site, there is a setup script if you have trouble with it post in the forum here or in BT.Manager™ forum
My Current Demo is here http://demo.btmanager.org/
Reply With Quote
  #3  
Old 27th April 2013, 13:13
sharpie sharpie is offline
Senior Member
 
Join Date: Apr 2012
United Kingdom
Posts: 17
Default
is that the same as a Premier account? if so i have this m8
Reply With Quote
  #4  
Old 27th April 2013, 13:37
joeroberts's Avatar
joeroberts joeroberts is offline
BT.Manager Owner
 
Join Date: Jan 2008
United States
Posts: 2,113
Default
In paypal go to My Account=> Profile =>My selling tools
and edit Instant payment notifications
every time a user sends you money for any reason it well notify that page be it for donation or subscription.
__________________
Do not ask me to help you work on your site that is not phpMyBitTorrent
Do not ask me to make a mod for any other source
Do not Ask me to setup your site.
I will no longer help you setup your site, there is a setup script if you have trouble with it post in the forum here or in BT.Manager™ forum
My Current Demo is here http://demo.btmanager.org/
Reply With Quote
  #5  
Old 27th April 2013, 13:56
sharpie sharpie is offline
Senior Member
 
Join Date: Apr 2012
United Kingdom
Posts: 17
Default
Awesome m8 will give it a bash thank you for the help
Reply With Quote
Reply

Tags
ipn , paypal

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 18:51. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.