Solved

PayPal doesn't always work - Popup window issue?

Posted on 2007-12-03
6
254 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

New Relic: Our company recently started researching several products to figure out what were the best ways for us to increase our web page speed and to quickly identify performance problems that we may be having. One of the products we evaluated wa…
This article will show, step by step, how to integrate R code into a R Sweave document
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now