Solved

PayPal doesn't always work - Popup window issue?

Posted on 2007-12-03
6
261 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 51

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 51

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
WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

 

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 51

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

630 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