Jump to content

Paypal help


motrellik

Recommended Posts

Hey guys

 

The following code is a paypal button with hidden fields:

 

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="website.com">
<input type="hidden" name="item_name" value="<?php print $link_name->getOutput(1) ?>">
<input type="hidden" name="item_number" value="2">
<input type="hidden" name="amount" value="<?php $cust_2 = $this->fields->getFieldById(13); if($cust_2->hasValue()) { echo $cust_2->getOutput (1); } ?>">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="<?php $cust_2 = $this->fields->getFieldById(36); if($cust_2->hasValue()) { echo $cust_2->getOutput (1); } ?>">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="return" value="http://www.vv1r3d.net/">
<input type="hidden" name="cancel_return" value="http://www.vv1r3d.net/">
<input type="hidden" name="name1" value="<?php $cust_2 = $this->fields->getFieldById(24); if($cust_2->hasValue()) { echo $cust_2->getOutput (1); } ?>">
<input type="hidden" name="notify_url" value="http://www.vv1r3d.net/paypal/paypal.php">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" name="submit" alt="Make payments with PayPal - it s fast, free and secure!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

 

 

The text is sent to this php file called paypal.php which then emails the buyer with an attachment

 

<?php 

// 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 ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];

if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
}
}
fclose ($fp);
}

$fileatt = "download link"; // Path to the file 
$fileatt_type = "application/file"; // File Type 
$fileatt_name = "file name"; // Filename that will be used for the file as the attachment 

$email_from = "[email protected]"; // Who the email is from 
$email_subject = "Purchase"; // The Subject of the email 
$email_message = "test"; // Message that the email has in it 

$email_to = "[email protected]"; // Who the email is too 

$headers = "From: ".$email_from; 

$file = fopen($fileatt,'rb'); 
$data = fread($file,filesize($fileatt)); 
fclose($file); 

$semi_rand = md5(time()); 
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 

$headers .= "\nMIME-Version: 1.0\n" . 
"Content-Type: multipart/mixed;\n" . 
" boundary=\"{$mime_boundary}\""; 

$email_message .= "This is a multi-part message in MIME format.\n\n" . 
"--{$mime_boundary}\n" . 
"Content-Type:text/html; charset=\"iso-8859-1\"\n" . 
"Content-Transfer-Encoding: 7bit\n\n" . 
$email_message . "\n\n"; 

$data = chunk_split(base64_encode($data)); 

$email_message .= "--{$mime_boundary}\n" . 
"Content-Type: {$fileatt_type};\n" . 
" name=\"{$fileatt_name}\"\n" . 
//"Content-Disposition: attachment;\n" . 
//" filename=\"{$fileatt_name}\"\n" . 
"Content-Transfer-Encoding: base64\n\n" . 
$data . "\n\n" . 
"--{$mime_boundary}--\n"; 

$ok = @mail($email_to, $email_subject, $email_message, $headers); 

if($ok) { 
echo ""; 
} else { 
die("Sorry but the email could not be sent."); 
} 


?>

 

In the $email_message of paypal.php I want the value of the name1 hidden field in the paypal button to be echoed or printed to display the text.

 

I have tried:

 

this: echo $name1 = $_POST['name1'];

 

and this: echo $_REQUEST["name1"]

and they don't seem to work.

 

This should be an easy solution so I apologise for my lack of knowledge in php :P

 

Kind Regards.

Link to comment
https://forums.phpfreaks.com/topic/180029-paypal-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.