PAYPAL and pre-populated fields

Problems installing or using the NOP Design Free Shopping Cart. **ARCHIVE** Please post new topics to one of the groups below.

Moderator: scott

PAYPAL and pre-populated fields

Postby lmtoe » Sun Jan 26, 2003 5:39 pm

PayPal allows you to submit fields to pre-populate their signup for people who have never purchased through PayPal. This is from the instruction manual


"The following sample HTML code shows how the optional pre-population fields would be included in your payment buttons. The field entries would need to be dynamically generated by your website and included in the URL to which your customers are sent when they try to make a PayPal payment."

Code: Select all
 

<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="nora@paypal.com">
 <input type="hidden" name="item_name" value="baseball hat">
<input type="hidden" name="item_number" value="12345”>
<input type="hidden" name="amount" value="15.00">
input type="hidden" name="first_name" value="John"
input type="hidden" name="last_name" value="Doe"
input type="hidden" name="address1" value="9 Elm Street"
input type="hidden" name="address2" value="Apt 5"
input type="hidden" name="city" value="Berwyn"
input type="hidden" name="state" value="PA"
input type="hidden" name="zip" value="19312"
input type="hidden" name="night_phone_a" value="610"
input type="hidden" name="night_phone_b" value="555"
input type="hidden" name="night_phone_c" value="1234"
input type="hidden" name="day_phone_a" value="610"
input type="hidden" name="day_phone_b" value="555"
input type="hidden" name="day_phone_c" value="1222"
<input type="hidden" name="cn" value=”How Did You Hear About Us?”> <table><tr><td>
<input type=”hidden” name=”on0” value=”Color?”>Color?
<select name=”os0”> <option value=”Red”>Red
<option value=”Green”>Green
<option value=”Blue”>Blue</select></td></tr></table>
<input type="image" src="https://www.nora.paypal.com/images/x-click-but22.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<input type="hidden" name="add" value="1"> </form>



How would I go about changing the variables so that nopcart's fields variables get mapped to PayPals' variables. What I would need is something like...
b_first = first_name
b_last = last_name
b_addr = address1
.
.
.
etc., etc.

Would I need to change the nopcart.js script? Can I just simply rename the variables in nopcart.js to those of the PayPal? Or add a script in the web page to set the nopcart varibales equal to the PayPal variables?

I wil try to do this on my own, but since I'm not sure which method would work (if any), it would be great if someone could let me know, or show me how it could be done.

P.S. I did a "paypal" search of all the posts and did not find anything on this topic... please just let me know the url of the post if there is already one out there.

Thanks in advance!!!
lmtoe
 
Posts: 66
Joined: Sun Dec 15, 2002 3:41 pm

Postby BadHabit » Sun Jan 26, 2003 7:58 pm

Take a look at this tread. In the checkout.pl example is the code you are looking for.

http://www.nopdesign.com/forum/viewtopic.php?t=489

Look for this section there:

if ( $PAY eq "PP") {

print "Content-type: text/html\n\n";

open (HEAD, $header);
@LINES = <HEAD>;
close HEAD;
print @LINES;

print "<center><br><h2>Thank you</h2>";
print "<h4>... for using PAYPAL.<br>";
print "To complete your order, click the PAYPAL button.</h4>";

print "<form action='https://www.paypal.com/cgi-bin/webscr' target='new' method='post'>";
print "<input type='hidden' name='cmd' value='_ext-enter'>";
print"<input type='hidden' name='redirect_cmd' value='_xclick'>";
print "<input type='hidden' name='business' value=$youremail>";
print "<input type='hidden' name='item_name' value='A&J Variety Order - $OrdNum'>";
print "<input type='hidden' name='item_number' value='$b_phone'>";
print "<input type='hidden' name='amount' value=$TOTAL>";
print "<input type='hidden' name='cn' value='comment'>";
print "<input type='hidden' name='return' value='http://www.ajvariety.com'>";
print "<input type='hidden' name='first_name' value='$b_first'>";
print "<input type='hidden' name='last_name' value='$b_last'>";
print "<input type='hidden' name='address1' value='$b_addr'>";
print "<input type='hidden' name='address2' value='$b_addr2'>";
print "<input type='hidden' name='city' value='$b_city'>";
print "<input type='hidden' name='state' value='$b_state'>";
print "<input type='hidden' name='zip' value='$b_zip'>";
print "<input type='image' border='0' name='submit' src='http://images.paypal.com/images/x-click-but5.gif' alt='Buy with PayPal'></center>";
print "</form>";

open (FOOT, $footer);
@LINES = <FOOT>;
close FOOT;

print @LINES
BadHabit
WebMaster
 
Posts: 19
Joined: Thu Jan 16, 2003 12:25 pm
Location: Atlanta, Georgia

Postby lmtoe » Mon Jan 27, 2003 5:56 pm

This seems to be close to what I'm looking for, but I'm a bit confused on how the $PAY variable is assigned a value. This code states...

Code: Select all
if ( $PAY eq "PP")
...


Where does the $PAY get set equal to "PP"? Would I set $PAY="PP" in the html code if they choose the paypal payment? ... assuming they would have other payment options; or in the nopcart.js file? or where?

Rather than using a variable, couldn't I just set the form as an option for payment (assuming the code is the correct code to use). In other words, in the checkout.html page, have this code...

Code: Select all

<form action='https://www.paypal.com/cgi-bin/webscr' target='new' method='post'>";
    <SCRIPT>
        CheckoutCart();
    </SCRIPT>
<input type='hidden' name='cmd' value='_ext-enter'>";
<input type='hidden' name='redirect_cmd' value='_xclick'>";
<input type='hidden' name='business' value=$youremail>";
<input type='hidden' name='item_name' value='$OrdNum'>";
<input type='hidden' name='item_number' value='$b_phone'>";
<input type='hidden' name='amount' value=$TOTAL>";
<input type='hidden' name='cn' value='comment'>";
<input type='hidden' name='return' value='your website'>";
<input type='hidden' name='first_name' value='$b_first'>";
<input type='hidden' name='last_name' value='$b_last'>";
<input type='hidden' name='address1' value='$b_addr'>";
<input type='hidden' name='address2' value='$b_addr2'>";
<input type='hidden' name='city' value='$b_city'>";
<input type='hidden' name='state' value='$b_state'>";
<input type='hidden' name='zip' value='$b_zip'>";
<input type='image' border='0' name='submit' src='http://images.paypal.com/images/x-click-but5.gif' alt='Buy with PayPal'></center>";
</form>";




Would this work?

I will try and post my findings. In the meantime, any other help would be greatly appreciated!!!
lmtoe
 
Posts: 66
Joined: Sun Dec 15, 2002 3:41 pm

Postby lmtoe » Mon Jan 27, 2003 7:05 pm

ok, well I am 1/2 way there.

First, the code from the other post does not work... do not use it

Here is what I put in my checkout.html...

Code: Select all
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <SCRIPT>
        CheckoutCart();
    </SCRIPT>
<TABLE class="blacktext">
<TR><TD>Name:    </TD><TD><input type="text" size="18" name="b_first"> <input type="text" size="15" name="b_last"></TD></TR>
<TR><TD>Address: </TD><TD><input type="text" size="37" name="b_addr"> </TD></TR>
<TR><TD>Address: </TD><TD><input type="text" size="37" name="b_addr2"></TD></TR>
<TR><TD>City:    </TD><TD><input type="text" size="21" name="b_city"> </TD></TR>
<TR><TD>State:   </TD><TD><input type="text" size="1"  name="b_state"> </TD></TR>
<TR><TD>Zip:     </TD><TD><input type="text" size="5"  name="b_zip"></TD></TR>
<TR><TD>Phone:   </TD><TD><input type="text" size="37" name="b_phone"></TD></TR>
<TR><TD>Fax:     </TD><TD><input type="text" size="37" name="b_fax"></TD></TR>
<TR><TD>Email:   </TD><TD><input type="text" size="37" name="b_email"> </TD></TR>
</TABLE>
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="george@lmtoe.com">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="return" value="http://www.lmtoe.com">
<input type="hidden" name="first_name" value="$b_first">
<input type="hidden" name="last_name" value="$b_last">
<input type="hidden" name="address1" value="$b_addr">
<input type="hidden" name="address2" value="$b_addr2">
<input type="hidden" name="city" value="$b_city">
<input type="hidden" name="state" value="$b_state">
<input type="hidden" name="zip" value="$b_zip">
<input type="image" src="https://www.paypal.com/images/x-click-but22.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>


This gets me to the paypal checkout page with no problem and includes the total dollars and states what it is they are buying, so this part is good.

But if I click on the..."If you have never paid through PayPal, 'click here'" the info that is passed into the fields is "$b_first", "$b_last", etc.
I mean it literally prints out $b_first in the paypal form, as opposed to the actual name entered in the form.

I need to make it so that the name entered into the form (ie: Jim) gets passed through as opposed to b_first being passed through.

Any ideas on what I am doing wrong?
lmtoe
 
Posts: 66
Joined: Sun Dec 15, 2002 3:41 pm

Postby Steven Nyland » Mon Jan 27, 2003 9:50 pm

Imtoe,

I put together a small script that you need to add to the checkout.html page within the <head> </head> tags:
Code: Select all
<script language="JavaScript">
<!-- Begin PayPal pass variables
function PayPalPass() {
document.ppform.last_name.value = document.ppform.b_last.value
document.ppform.first_name.value = document.ppform.b_first.value
document.ppform.address1.value = document.ppform.b_addr.value
document.ppform.address2.value = document.ppform.b_addr2.value
document.ppform.city.value = document.ppform.b_city.value
document.ppform.state.value = document.ppform.b_state.value
document.ppform.zip.value = document.ppform.b_zip.value
}
// End PayPal pass variables-->
</script>


Change the <form> tag into:
Code: Select all
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" onSubmit="PayPalPass()">


The remainder of your form should be:
Code: Select all
   <SCRIPT>
        CheckoutCart();
    </SCRIPT>
<TABLE class="blacktext">
<TR><TD>Name:    </TD><TD><input type="text" size="18" name="b_first"> <input type="text" size="15" name="b_last"></TD></TR>
<TR><TD>Address: </TD><TD><input type="text" size="37" name="b_addr"> </TD></TR>
<TR><TD>Address: </TD><TD><input type="text" size="37" name="b_addr2"></TD></TR>
<TR><TD>City:    </TD><TD><input type="text" size="21" name="b_city"> </TD></TR>
<TR><TD>State:   </TD><TD><input type="text" size="1"  name="b_state"> </TD></TR>
<TR><TD>Zip:     </TD><TD><input type="text" size="5"  name="b_zip"></TD></TR>
<TR><TD>Phone:   </TD><TD><input type="text" size="37" name="b_phone"></TD></TR>
<TR><TD>Fax:     </TD><TD><input type="text" size="37" name="b_fax"></TD></TR>
<TR><TD>Email:   </TD><TD><input type="text" size="37" name="b_email"> </TD></TR>
</TABLE>
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="george@lmtoe.com">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="return" value="http://www.lmtoe.com">
<input type="hidden" name="first_name">
<input type="hidden" name="last_name">
<input type="hidden" name="address1">
<input type="hidden" name="address2">
<input type="hidden" name="city">
<input type="hidden" name="state">
<input type="hidden" name="zip">
<input type="image" src="https://www.paypal.com/images/x-click-but22.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>


Hope this helps,

Steven
[ If it ain't Dutch ... it ain't Much ]
Steven Nyland
Guru
 
Posts: 274
Joined: Thu Jan 02, 2003 1:20 pm
Location: Still here ...

Postby lmtoe » Mon Jan 27, 2003 10:19 pm

Steven,

Thanks for your help, but I don't think it's picking up any of these values. I get an error stating... "'document.ppform.last' is null or not an object"

I double checked the following:

added the script within <head> ... </head>

changed the first line of Form to be:


Code: Select all
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" onSubmit="PayPalPass()">
   
lmtoe
 
Posts: 66
Joined: Sun Dec 15, 2002 3:41 pm

Postby Steven Nyland » Mon Jan 27, 2003 10:22 pm

Well, I must be honest, I haven't tested the code myself...I'll run a test and let you know.

Steven
[ If it ain't Dutch ... it ain't Much ]
Steven Nyland
Guru
 
Posts: 274
Joined: Thu Jan 02, 2003 1:20 pm
Location: Still here ...

Postby Steven Nyland » Mon Jan 27, 2003 11:04 pm

Sorry, forgot to add the following to the form tag:

<form name="ppform" target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" onSubmit="PayPalPass()">

Hope this helps,

Steven
[ If it ain't Dutch ... it ain't Much ]
Steven Nyland
Guru
 
Posts: 274
Joined: Thu Jan 02, 2003 1:20 pm
Location: Still here ...

Postby lmtoe » Mon Jan 27, 2003 11:46 pm

Steven

Thanks!!!! That was it. Works like a charm.

Once I get it all formatted properly, I will post it in the MOD section for others to view.

Thanks again!
lmtoe
 
Posts: 66
Joined: Sun Dec 15, 2002 3:41 pm

Postby Steven Nyland » Tue Jan 28, 2003 2:13 am

Great stuff. I am glad I could help.

Steven
[ If it ain't Dutch ... it ain't Much ]
Steven Nyland
Guru
 
Posts: 274
Joined: Thu Jan 02, 2003 1:20 pm
Location: Still here ...

So....

Postby mikesf » Fri Feb 14, 2003 8:07 pm

I'm interested in using Paypal. So what's the whole code? Could some one help me with this?

Thanks, Mike
mike@mikesfigures.com
mikesf
 
Posts: 5
Joined: Fri Feb 14, 2003 7:55 pm

Postby lmtoe » Fri Feb 14, 2003 8:38 pm

Mike
Here's what you need to do. You can simply cut/paste the code below.

Also, by using this method, you will *not* receive an email from the cart. There is another post about this problem... http://www.nopdesign.com/forum/viewtopic.php?t=646

But this will work for paypal

First, change the payment processor option in the nopcart.js to look like this...

Code: Select all
//Payment Processor Options:
PaymentProcessor      = 'pp';


Then add an additional elsif statement near the bottom of the nopcar.js. It should go after the last elsif staement and before the else statement...

Code: Select all
      } else if ( PaymentProcessor == 'pp') {
         //Process this for PayPal
         strOutput += "<input type=hidden name=\"amount\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
         strOutput += "<input type=hidden name=\"item_name\" value=\""+ strPP + "\">";


Then the script that Steven wrote needs to go in your checkout.html within the <head></head> ...

Code: Select all
<script language="JavaScript">
<!-- Begin PayPal pass variables
function PayPalPass() {
document.ppform.last_name.value = document.ppform.b_last.value;
document.ppform.first_name.value = document.ppform.b_first.value;
document.ppform.address1.value = document.ppform.b_addr.value;
document.ppform.address2.value = document.ppform.b_addr2.value;
document.ppform.city.value = document.ppform.b_city.value;
document.ppform.state.value = document.ppform.b_state.value;
document.ppform.zip.value = document.ppform.b_zip.value;
}
// End PayPal pass variables-->
</script>


then here is the form for the checkout which goes in the body of the checkout.html...

Code: Select all
<form name ="ppform" target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" onSubmit="PayPalPass()">
    <SCRIPT>
        CheckoutCart();
    </SCRIPT>
<TABLE class="blacktext">
<TR><TD>Name:    </TD><TD><input type="text" size="18" name="b_first"> <input type="text" size="15" name="b_last"></TD></TR>
<TR><TD>Address: </TD><TD><input type="text" size="37" name="b_addr"> </TD></TR>
<TR><TD>Address: </TD><TD><input type="text" size="37" name="b_addr2"></TD></TR>
<TR><TD>City:    </TD><TD><input type="text" size="21" name="b_city"> </TD></TR>
<TR><TD>State:   </TD><TD><input type="text" size="1"  name="b_state"> </TD></TR>
<TR><TD>Zip:     </TD><TD><input type="text" size="5"  name="b_zip"></TD></TR>
<TR><TD>Phone:   </TD><TD><input type="text" size="37" name="b_phone"></TD></TR>
<TR><TD>Fax:     </TD><TD><input type="text" size="37" name="b_fax"></TD></TR>
<TR><TD>Email:   </TD><TD><input type="text" size="37" name="b_email"> </TD></TR>
</TABLE>
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="george@lmtoe.com">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="return" value="http://www.lmtoe.com">
<input type="hidden" name="first_name">
<input type="hidden" name="last_name">
<input type="hidden" name="address1">
<input type="hidden" name="address2">
<input type="hidden" name="city">
<input type="hidden" name="state">
<input type="hidden" name="zip">
<input type=submit Value="Submit Order"> <INPUT type=RESET value="  Clear Form  ">
</form>


Note: you will need to change to your email address for the business value, and to your url for the return page.

-lmtoe
lmtoe
 
Posts: 66
Joined: Sun Dec 15, 2002 3:41 pm

....

Postby mikesf » Fri Feb 14, 2003 8:52 pm

Thank you! He'll be very happy!... :lol:
mikesf
 
Posts: 5
Joined: Fri Feb 14, 2003 7:55 pm

...

Postby mikesf » Fri Feb 14, 2003 9:12 pm

lmtoe, I've had zero luck navigating through this code. Could you please set it up? The URL is "www.captzack.com" the e-mail is "jzakog@aol.com", the business name is Capt Zack's Patch Depot.

Thanks if you can, or anyone else can help me.
mikesf
 
Posts: 5
Joined: Fri Feb 14, 2003 7:55 pm

,,,

Postby mikesf » Fri Feb 14, 2003 9:28 pm

Does

<script language="JavaScript">
<!-- Begin PayPal pass variables
function PayPalPass() {
document.ppform.last_name.value = document.ppform.b_last.value;
document.ppform.first_name.value = document.ppform.b_first.value;
document.ppform.address1.value = document.ppform.b_addr.value;
document.ppform.address2.value = document.ppform.b_addr2.value;
document.ppform.city.value = document.ppform.b_city.value;
document.ppform.state.value = document.ppform.b_state.value;
document.ppform.zip.value = document.ppform.b_zip.value;
}
// End PayPal pass variables-->
</script>


Follow the rest of the header. Or must the rest of it be erased then added?

Where does

//Payment Processor Options:
PaymentProcessor = 'pp';


go? I can't find it.
Last edited by mikesf on Fri Feb 14, 2003 9:51 pm, edited 1 time in total.
mikesf
 
Posts: 5
Joined: Fri Feb 14, 2003 7:55 pm

Next

Return to Installation and Setup Problems

Who is online

Users browsing this forum: No registered users and 1 guest

cron