Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 267
  • Last Modified:

PayPal doesn't always work - Popup window issue?

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
Rich
Asked:
Rich
  • 3
  • 3
1 Solution
 
Steve BinkCommented:
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
 
RichAuthor Commented:
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
 
Steve BinkCommented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
RichAuthor Commented:
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
 
Steve BinkCommented:
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
 
RichAuthor Commented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now