Solved

PayPal doesn't always work - Popup window issue?

Posted on 2007-12-03
6
256 Views
Last Modified: 2012-05-05
I have a website that uses PayPal to purchase items that were selected by using a form (simple shopping cart) on my website. When the user presses the Submit button on the form, a javascript call to openBrowserWindow("....") is called with the PayPal.com url and the appropriate parameters to initiate and complete the buying process on the PayPal site. (This is PayPal Standard.) The issue is that occationally users will complain that they were unable to complete the transaction, which I believe is due to the fact that the new browser window with the PayPal url did not appear. I have instructions on the site that the user should ensure that Pop Ups are not blocked for the site, etc., but many of them do not understand the concept.

So, what is the best way to handle this issue. I am not sure it is pop up related, but that is my first instinct. Has anyone else figured out how to make this process more reliable?

Thanks, Rich
0
Comment
Question by:Rich
  • 3
  • 3
6 Comments
 
LVL 50

Expert Comment

by:Steve Bink
ID: 20399186
Instead of using javascript to trigger the window, try using a plain ol' target="_blank" configuration:

<form action="http://paypal.link.com" method="POST" target="_blank">
0
 

Author Comment

by:Rich
ID: 20402502
Well, I actually call a Javascript function from the form onSubmit method, which takes numerous parameters from the form's fields.value and constructs the openBrowserWindow arguments needed to call PayPal. So I need to open the window from within a Javascript function.
0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 20406889
Still, you can make this a regular form post.  Keep the form's onSubmit event, and make sure you put the target="_blank" in the form element's declaration.  In the javascript, instead of using a DOM function to open a new window, kick it back to the regular form submission:

document.MyFormName.action = "<new javascript-built link here>";
document.MyFormName.submit();
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:Rich
ID: 20407947
Routinet,

I understand what you are saying, but I am a bit confused as to how to implement this. Right now, in the form (reg_form), I have an method="POST" action="" and onSubmit="callPayPal(bunch of values from this form)", and the window.open(paypalString) is in this function(callPayPal()).

I guess I can make the function return the paypalString, to which I will add the target="_blank", instead of calling window.open(paypalString), but where do I put the document.MyFormName.action="<paypalString>"; and the document.MyFormNAme.submit(); Do I pass the document reference to the callPayPal function and do these in there, or do I put it back in the original php file where the form is built? If the latter, where would it go?

I attached a bunch of my form code and the function below for reference.

Rich
<form id="reg_form" name="reg_form" method="post" action="" onSubmit="callPayPal_3(
this.name.value, this.firm.value, this.phone.value, this.email.value, this.date_venue.value, this.total_guests_listed.value, 
this.guest1.value, this.local1.value, this.zip1.value, this.cost1.value, 
this.guest2.value, this.local2.value, this.zip2.value, this.cost2.value, 
this.guest3.value, this.local3.value, this.zip3.value, this.cost3.value, 
this.guest4.value, this.local4.value, this.zip4.value, this.cost4.value, 
this.guest5.value, this.local5.value, this.zip5.value, this.cost5.value, 
this.guest6.value, this.local6.value, this.zip6.value, this.cost6.value, 
this.guest7.value, this.local7.value, this.zip7.value, this.cost7.value, 
this.guest8.value, this.local8.value, this.zip8.value, this.cost8.value, 
this.numBooks.value, 'HBAM');">
...
bunch of form stuff, including the 8 guest, local, zip and cost fields
then...
<input name="Submit" type="submit" onClick="validateForm();return document.validReturnValue" value="Submit" />
 
function callPayPal_3(name, firm, phone, email, date_venue, total_guests, guest1, local1, zip1, cost1, guest2, local2, zip2, cost2, guest3, local3, zip3, cost3, guest4, local4, zip4, cost4, guest5, local5, zip5, cost5, guest6, local6, zip6, cost6, guest7, local7, zip7, cost7, guest8, local8, zip8, cost8, numBooks, businessName) 
{
	alert ("A new browser window at PayPal should now open for you to complete your transaction. We request that you use PayPal to pay with your credit card. You DO NOT need a PayPal account for this transaction. If you do not have a PayPal account, simply click on CONTINUE on the PayPal screen. If you have difficulty with this process, please contact "+businessName+" directly.");
 
	item_name_1 = date_venue;
//	alert (item_name_1);
	amount_1 = "0.00";
//	alert (amount_1);
 
	on0_1 = "Contact Info";
	os0_1 = name+', '+firm+', '+phone+', '+email
 
	on1_1 = 'Number of Books ';	
	os1_1 = numBooks;
//	alert (os0);
 
	if (total_guests <=0 ) {
		alert ("Please enter some guests and try again.");
		return false;
	} 
 
	if (businessName == 'HBAM') {
		business = 'ldonato@hbama.com';
	} else {
		alert ("Business not identified");
		return false;
	}
//	alert (business);
totalBookCost = numBooks * 50;
 
	paypalStr = "https://www.paypal.com/cgi-bin/webscr?&cmd=_cart&upload=1&business="+business+"&item_name_1="+item_name_1+"&amount_1="+amount_1+"&quantity_1="+total_guests;
	var itemNum = 2;
	for (i=1; i<=8; i++) {
		var guestVar = 'guest' + i;
		var localVar = 'local' + i;
		var zipVar = 'zip' + i;
		var costVar = 'cost' + i;
		var PitemVar = 'item_name_' + itemNum;
		var PamountVar = 'amount_' + itemNum;
 
		if (eval(guestVar) != "") {
			paypalStr += "&item_name_"+itemNum+"="+eval(guestVar)+", "+eval(localVar)+", "+eval(zipVar)+"&amount_"+itemNum+"="+eval(costVar);
			itemNum++;
		}
	}
	if (numBooks > 0) {paypalStr += "&item_name_"+itemNum+"=Code Books"+"&amount_"+itemNum+"=50"+"&quantity_"+itemNum+"="+numBooks;}
	
	paypalStr += "&on0_1="+on0_1+"&os0_1="+os0_1+"&on1_1="+on1_1+"&os1_1="+os1_1+"&no_shipping=1&tax_cart=0&currency_code=USD&lc=US&return=http://www.hbama.com/Events/thanks_reg_code_review_wm.htm";
//	alert (paypalStr);
 
	window.open(paypalStr);
	return true;
}

Open in new window

0
 
LVL 50

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 20412610
In your code above, replace line 67 with this:

document.MyFormName.action=paypalStr;
document.MyFormName.submit();

You're taking the same URL you built for the window.open() function, and making it the POST target for the form before triggering the form's submit event.  When the form POSTs, it should be posting to that URL.  You should do some testing to make sure the additional POST parameters does not interfere with PayPal's system.
0
 

Author Closing Comment

by:Rich
ID: 31412438
Thanks, this works. I will not know if it is more reliable, but it opens PayPal in the same window, so it should alleviate the Pop Up issues.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn how to dynamically set the form action using jQuery.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question