eazyhost
02-23-2009, 12:07 PM
Hi
Can anyone help me with this,
I am trying to get a script working properly so that people can automatically send payments from their paypal account to others (for use in a PTC script)
The script definately logs into my account, but does not actually send the money, below is the script
<?php
$pp_loginemail = "your_email";
$pp_loginpass = "your_pass";
$pp_msg = "Auto payment from Site name. Thank you";
$pp_personal = "";
$pp_subject = "Payment from Site name";
$price = "payment_amount";
$pemail = "receiver_email";
$cookiepath = '/tmp/';
function curlsetopt($url,$post='',$follow=1,$debugmode=0,$header=0){
global $curlstatus,$cookiepath;
$ch=curl_init();
curl_setopt($ch,CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_COOKIEJAR,$cookiepath);
curl_setopt($ch,CURLOPT_COOKIEFILE,$cookiepath);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch,CURLOPT_HEADER,$header);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,$follow);
if($post){curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch,CURLOPT_POSTFIELDS,$post);}
$returned=curl_exec($ch);
$curlstatus=curl_getinfo($ch);
curl_close($ch);
return $returned;
}
$ct=0;
while(file_exists($cookiepath.'gen2curlcookie'.$ct.'.gen2')===true){$ct++;}
$cookiepath.='gen2curlcookie'.$ct.'.gen2';
$getsession = curlsetopt('https://www.paypal.com/cgi-bin/webscr?cmd=_home','n/a',1,0);
$getsession=explode('
', $getsession);
foreach($getsession as $cont)
{
if(eregi('<div class="body"><form method="post" name="login_form" action="https://www.paypal.com/us/cgi-bin/webscr?cmd=_login-submit', $cont))
{
$token = str_replace("<div class=\"body\"><form method=\"post\" name=\"login_form\" action=\"https://www.paypal.com/cgi-bin/webscr?cmd=_login-submit&dispatch=", '', $cont);
$token = str_replace("\">",'',$token);
}
}
$login=curlsetopt('https://www.paypal.com/cgi-bin/webscr?cmd=_login-submit&dispatch='.$token,'login_email='.$pp_loginemail.'&login_password='.$pp_loginpass.'&submit.x=Log In&form_charset=UTF-8',1,0);
$sfunds = curlsetopt('https://www.paypal.com/cgi-bin/webscr?cmd=_send-money&nav=1', '', 1, 0);
$sfunds = explode('
', $sfunds);
foreach($sfunds as $cpont)
{
if(eregi("<form method=\"post\" id=\"ismForm\" name=\"ismForm\" action=\"", $cpont))
{
$to_url = str_replace("<form method=\"post\" id=\"ismForm\" name=\"ismForm\" action=\"", '', $cpont);
$to_url = str_replace("\">", '', $to_url);
}
}
$funds_complete = curlsetopt($to_url,'email='.$pemail.'&amount='.$price.'&amount_ccode=USD&payment_type=S&submit.x=Continue&cmd=_flow¤cy_out=USD&CONTEXT='.$context.'&myAllTextSubmitID=',1,0);
if(eregi('Your recipient does not yet have a PayPal account.', $ppVerified))
{
$paypalExist = 1;
}
if(!$paypalExist)
{
$s_funds_complete = str_replace('https://www.paypal.com/uk/cgi-bin/webscr?', 'index.php?', $funds_complete);
$funds_complete = explode('
', $funds_complete);
foreach($funds_complete as $cpont)
{
if(eregi("<div id=\"main\"><div class=\"layout1\"><form method=\"post\" id=\"reviewForm\" name=\"main\" action=\"", $cpont))
{
$ton_url = str_replace("<div id=\"main\"><div class=\"layout1\"><form method=\"post\" id=\"reviewForm\" name=\"main\" action=\"", '', $cpont);
$ton_url = str_replace("\">", '', $ton_url);
}
}
$funds_sent = curlsetopt($ton_url,'&cmd=_flow&pie_code_manual=&funding_type=B&funding_bufs=&no_adr_required=No Postage Required&address=none&shipping_address1=&shipping_address2=&shipping_city=&shipping_state=&shipping_zip=&subject='.$pp_subject.'&enterPersonalMessage=¬e='.$pp_msg.'&submit_x=Send Money&form_charset=UTF-8&',1,0);
if(eregi('The money has been sent.', $funds_sent))
{
$moneySent=1;
}
}
if($moneySent=="1"){
echo 'done';
}else{
echo 'failed';
}
?>
Any ideas?
Thanks for the help
Can anyone help me with this,
I am trying to get a script working properly so that people can automatically send payments from their paypal account to others (for use in a PTC script)
The script definately logs into my account, but does not actually send the money, below is the script
<?php
$pp_loginemail = "your_email";
$pp_loginpass = "your_pass";
$pp_msg = "Auto payment from Site name. Thank you";
$pp_personal = "";
$pp_subject = "Payment from Site name";
$price = "payment_amount";
$pemail = "receiver_email";
$cookiepath = '/tmp/';
function curlsetopt($url,$post='',$follow=1,$debugmode=0,$header=0){
global $curlstatus,$cookiepath;
$ch=curl_init();
curl_setopt($ch,CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_COOKIEJAR,$cookiepath);
curl_setopt($ch,CURLOPT_COOKIEFILE,$cookiepath);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch,CURLOPT_HEADER,$header);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,$follow);
if($post){curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch,CURLOPT_POSTFIELDS,$post);}
$returned=curl_exec($ch);
$curlstatus=curl_getinfo($ch);
curl_close($ch);
return $returned;
}
$ct=0;
while(file_exists($cookiepath.'gen2curlcookie'.$ct.'.gen2')===true){$ct++;}
$cookiepath.='gen2curlcookie'.$ct.'.gen2';
$getsession = curlsetopt('https://www.paypal.com/cgi-bin/webscr?cmd=_home','n/a',1,0);
$getsession=explode('
', $getsession);
foreach($getsession as $cont)
{
if(eregi('<div class="body"><form method="post" name="login_form" action="https://www.paypal.com/us/cgi-bin/webscr?cmd=_login-submit', $cont))
{
$token = str_replace("<div class=\"body\"><form method=\"post\" name=\"login_form\" action=\"https://www.paypal.com/cgi-bin/webscr?cmd=_login-submit&dispatch=", '', $cont);
$token = str_replace("\">",'',$token);
}
}
$login=curlsetopt('https://www.paypal.com/cgi-bin/webscr?cmd=_login-submit&dispatch='.$token,'login_email='.$pp_loginemail.'&login_password='.$pp_loginpass.'&submit.x=Log In&form_charset=UTF-8',1,0);
$sfunds = curlsetopt('https://www.paypal.com/cgi-bin/webscr?cmd=_send-money&nav=1', '', 1, 0);
$sfunds = explode('
', $sfunds);
foreach($sfunds as $cpont)
{
if(eregi("<form method=\"post\" id=\"ismForm\" name=\"ismForm\" action=\"", $cpont))
{
$to_url = str_replace("<form method=\"post\" id=\"ismForm\" name=\"ismForm\" action=\"", '', $cpont);
$to_url = str_replace("\">", '', $to_url);
}
}
$funds_complete = curlsetopt($to_url,'email='.$pemail.'&amount='.$price.'&amount_ccode=USD&payment_type=S&submit.x=Continue&cmd=_flow¤cy_out=USD&CONTEXT='.$context.'&myAllTextSubmitID=',1,0);
if(eregi('Your recipient does not yet have a PayPal account.', $ppVerified))
{
$paypalExist = 1;
}
if(!$paypalExist)
{
$s_funds_complete = str_replace('https://www.paypal.com/uk/cgi-bin/webscr?', 'index.php?', $funds_complete);
$funds_complete = explode('
', $funds_complete);
foreach($funds_complete as $cpont)
{
if(eregi("<div id=\"main\"><div class=\"layout1\"><form method=\"post\" id=\"reviewForm\" name=\"main\" action=\"", $cpont))
{
$ton_url = str_replace("<div id=\"main\"><div class=\"layout1\"><form method=\"post\" id=\"reviewForm\" name=\"main\" action=\"", '', $cpont);
$ton_url = str_replace("\">", '', $ton_url);
}
}
$funds_sent = curlsetopt($ton_url,'&cmd=_flow&pie_code_manual=&funding_type=B&funding_bufs=&no_adr_required=No Postage Required&address=none&shipping_address1=&shipping_address2=&shipping_city=&shipping_state=&shipping_zip=&subject='.$pp_subject.'&enterPersonalMessage=¬e='.$pp_msg.'&submit_x=Send Money&form_charset=UTF-8&',1,0);
if(eregi('The money has been sent.', $funds_sent))
{
$moneySent=1;
}
}
if($moneySent=="1"){
echo 'done';
}else{
echo 'failed';
}
?>
Any ideas?
Thanks for the help
