0

Hello guys, i hope i am at the right place!
I've just added a pay pal button to my website but i don't know how to configure it to send an email to the donor confirming receipt of the donation and giving the EIN number.

Any help and suggestions will be highly appreciated!

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by Dandello
0

The feature is called IPN (Instant Payment Notification). (You may have to login to PayPal to get to this page)

https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_admin_IPNIntro

As far as I am aware, in order to send an automated email to your buyer from you, you need PayPal's software working on your site. Your button sends the form info to PayPal which then sends info back to the IPN script which then does whatever it's programmed to do - enter data into a database, email the customer, etc. The IPN script will also send you an email detailing the transaction.

But PayPal itself does send confirmation emails to the buyers reminding them that a transaction has taken place. You should be able to add that info as part of the "item_name" input line in your button form.

Edited by Dandello: n/a

0

Thanks Dondello,
Let me read that and try... will get back to you ;)

0

Dear Dondello, i haven't got any solutions yet but i really appreciate your help!
The link you gave me has a lot, but i didn't get what i needed from there :(

I still don't know how people will get a confirmation email for donations they make from my site!! But thank you!

0

Your donation button should have a form associated with it.

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
	<input type="hidden" name="cmd" value="_xclick" />
	<input type="hidden" name="business" value="your@email.com" />
	<input type="hidden" name="return" value="http://www.mysite.com/cgi-bin/ipn.pl" />
	<input type="hidden" name="notify_url" value="http://www.mysite.com/cgi-bin/ipn.pl" />
	<input type="hidden" name="undefined_quantity" value="0" />
	<input type="hidden" name="amount" value="35" />
	<input type='hidden' name='item_name' value='Donation' />

	<p><input type="hidden" name="image_url" value="http://www.mysite.com/images/your logo.jpg" />
	<input type="hidden" name="no_shipping" value="1" />
	<input type="hidden" name="no_note" value="0" />
	<input type="image" src="http://images.paypal.com/images/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" /></p>

	</form>

ipn.pl looks like this:

#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
@referers = ('www.paypal.com', 'paypal.com');
@valid_ENV = ('REMOTE_HOST','REMOTE_ADDR','REMOTE_USER','HTTP_USER_AGENT');

# Localize the check_referer flag which determines if user is valid.	#

local($check_referer) = 0;

# If a referring URL was specified, for each valid referer, make sure	#
# that a valid referring URL was passed to the form.				#
if ($ENV{'HTTP_REFERER'}) 
	{
	foreach $referer (@referers) 
		{
		if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) 
			{
			$check_referer = 1;
			last;
			}
		}
	}
else 	
	{
	$check_referer = 1;
	}

# If the HTTP_REFERER was invalid, send back an error.	#
if ($check_referer != 1) 
	{ 
	&error('bad_referer') 
	}
else
	{
#auto-post configuration
	$YourEmail = 'your@email.com';
	$MailProgram = '/usr/sbin/sendmail -i -t';
	$Header = "Donations";
	$Signature1 = "Me";
	$Signature2 = "www.mysite.com";
	
	use Time::Local;
	$tm = timelocal((localtime)[0,1,2,3,4,5]);
	($secs, $mins, $hrs, $dys, $mnths, $yrs, $wdays, $ydays, $isdsts) = localtime($tm);
	$yras = $yrs + 1900;
	$time3 = $tm + 30*24*60*60;
	($seconds, $minutes, $hours, $dy, $month, $year, $wday, $yday, $isdst) = localtime($time3);
	$yra = $year + 1900;
	@monthsa = ("January","February","March","April","May","June","July","August","September","October","November","December");
	
	# read post from PayPal system and add 'cmd'
	read (STDIN, $query, $ENV{'CONTENT_LENGTH'});
	$query .= '&cmd=_notify-validate';
	
	# post back to PayPal system to validate
	use LWP::UserAgent;
	$ua = new LWP::UserAgent;
	$req = new HTTP::Request 'POST','https://www.paypal.com/cgi-bin/webscr';
	$req->content_type('application/x-www-form-urlencoded');
	$req->content($query);
	$res = $ua->request($req);
	
	# split posted variables into pairs
	@pairs = split(/&/, $query);
	$count = 0;
	foreach $pair (@pairs) 
		{
		($name, $value) = split(/=/, $pair);
		$value =~ tr/+/ /;
		$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
		$variable{$name} = $value;
		$count++;
		}
	
	# assign posted variables to local variables
	$first_name = $variable{'first_name'};
	$last_name = $variable{'last_name'};
	$item_name = $variable{'item_name'};
	$item_number = $variable{'item_number'};
	$payment_status = $variable{'payment_status'};
	$os0 = $variable{'option_selection1'};
	$payment_amount = $variable{'mc_gross'};
	$payment_currency = $variable{'mc_currency'};
	$txn_id = $variable{'txn_id'};
	$receiver_email = $variable{'receiver_email'};
	$payer_email = $variable{'payer_email'};
	
	if ($res->is_error) 
		{
		print "content-type: text/plain\n\n";
		print "is error";
		}
	elsif ($res->content eq 'VERIFIED') 
		{
	#	check the $payment_status=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
		if($receiver_email eq $YourEmail && $payment_status eq "Completed")
			{
		        
				open (MAIL,"|$MailProgram");
				print MAIL "To: $payer_email\n";
				print MAIL "From: $YourEmail\n";
				print MAIL "Subject: Donation\n";
				print MAIL "$Header\n";
				print MAIL "$monthsa[$mnths] $dys, $yras\n\n";
				print MAIL "Donation\n\n";
				print MAIL "==============================\n\n";
				print MAIL "Message: Thank you for your donation to www.mysite.com EIN Number xxx-xxx-xxxx\n\n";
				
				print MAIL "==============================\n\n";
				print MAIL "Thank You,\n\n\n";
				print MAIL "$Signature1\n";
				print MAIL "$Signature2\n\n";
				close (MAIL);
				
				
				print "Content-type: text/html\n\n";
				print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n";
				print "       \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
				print "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n";
				print "<head>";
				print "<title>Thank you</title>\n";
				print "<meta http-equiv='content-type' content='text/html; charset=iso-8859-1' />\n";
				print "<link rel='stylesheet' type='text/css' href='../master.css' />\n";
				print "</head>";
				print "<body>";
				print "<p>Thank you for your donation.</p>";
				print "<p>$first_name $last_name has donated X amount to www.mysite.com, EIN xxx-xxx-xxxx.</p>";
				print "<p>Please print this page. We will also be sending you a confirmation email.";
				print "<p>Return to <a href='../index.html'>Index</a> </p>";
				print "</body></html>\n";
				}
			}
		}
	elsif ($res->content eq 'INVALID') 
		{
		print "content-type: text/html\n\n";
		print "Transaction pending. Please contact <a href='https://www.paypal.com'>Paypal<\/a> and/or <a href='mailto:your\@email.com'>your\@email.com</a> if you do not receive email confirmation of your donation within a few hours.";
		}
	else {
		print "content-type: text/html\n\n";
		print "There has been an Error";
		}
	}
sub error
	{ 
	# Localize variables and assign subroutine input.	#
	local($error,@error_fields) = @_;

	if ($error eq 'bad_referer')
		{
		if ($ENV{'HTTP_REFERER'} =~ m|^https?://([\w\.]+)|i)
			{
			$host = $1;
			my $referer = ($ENV{'HTTP_REFERER'});

			print "<html>";
			print "<head>";
			print "<title>Bad Referrer - Access Denied</title>";
			print "</head>";
			print "<body bgcolor=#FFFFFF text=#000000>";
			print "<center>";
			print "<table border=0 width=600 bgcolor=#9C9C9C>";
			print "<tr><th><font size=+2>Bad Referrer - Access Denied</font></th></tr>";
			print "</table>";
			print "<table border=0 width=600 bgcolor=#CFCFCF>";
			print "<tr><td>The form attempting to use this script resides at <tt>$referer</tt>, which is not allowed to access this cgi script.<p>";
			print "</font></center>";
			print "</td></tr>";
			print "</table>";
			print "</center>";
			print "</body>";
			print "</html>";
			}
		}
	}
exit;

Needless to say, you need access to the cgi-bin and you will need to go through and edit things so they point to your email address and site (both in the perl script and the form) and the path to sendmail.

I edited this quickly from one of the sites I manage so the script above may not work perfectly the first time out. (PM me if it doesn't or you need additional help editing the script.)

The key is for the form to point to the script, telling PayPal to trigger the script once the transaction is finalized.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.