Member Avatar

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!

Recommended Answers

All 4 Replies

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

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.

Member Avatar

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

Member Avatar

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!

Your donation button should have a form associated with it.

<form action="" method="post">
	<input type="hidden" name="cmd" value="_xclick" />
	<input type="hidden" name="business" value="" />
	<input type="hidden" name="return" value="" />
	<input type="hidden" name="notify_url" value="" />
	<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=" logo.jpg" />
	<input type="hidden" name="no_shipping" value="1" />
	<input type="hidden" name="no_note" value="0" />
	<input type="image" src="" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" /></p>

	</form> looks like this:

use CGI::Carp qw(fatalsToBrowser);
@referers = ('', '');

# 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.				#
	foreach $referer (@referers) 
		if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) 
			$check_referer = 1;
	$check_referer = 1;

# If the HTTP_REFERER was invalid, send back an error.	#
if ($check_referer != 1) 
#auto-post configuration
	$YourEmail = '';
	$MailProgram = '/usr/sbin/sendmail -i -t';
	$Header = "Donations";
	$Signature1 = "Me";
	$Signature2 = "";
	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','';
	$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;
	# 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 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 "       \"\">\n";
				print "<html xmlns='' 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, 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=''>Paypal<\/a> and/or <a href='mailto:your\'>your\</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>";

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.