PDA

View Full Version : Another question,


ParodyUK
08-21-2007, 09:57 AM
Ok, my friend has a directory website for business in his local area which is very popular.

And he wants to put a express process option on there. How would he go about this?
He wants a form which you fill in and then at the end you click one of 3 boxes

box 1 (6 - 8 week proecessing (not guranteed)

box 2 (1 - 2 week processing) £5.00

box 3 (48 hour processing) £10.00

i want the box 2 and 3 to take the information from the form to a paypal page.

How can i do this? I am using www.freephpdirectoryscript.com <-- that script.

dougp
08-21-2007, 06:03 PM
First you need to edit the form of course. Add in something similar to this, but replace the vars with ones you have grabbed from the shopping cart and throw them in. All buttons should work, it will take you to paypal and show the total titled "Demo"

Replace Demo with Company Name for example.

Live Demo: http://www.parkergt.com/examples/paypalbuttons.php

<?php

// Grab the total before shipping and store into $total, this case lets pretend it was 48.92
$total = "48.92";
// Calculate the extra 5 onto button 1
$totalvar1 = $total + 5;
// Calculate the extra 10 on button 2
$totalvar2 = $total + 10;
// This would have ben grabbed from the DB or hardcoded if you like.
$emailaddy = "setyouremailfromdb@here.com";
// Replace with your company
$CompanyName = "Demo";
// Replace with var getting the transaction id, receipt id, or other.
$itemnum = "002357446-IDK";

?>

Total Before Shipping: <? echo "$total"; ?>
<br /><br />
Button 2:
<br />
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<? echo "$emailaddy"; ?>">
<input type="hidden" name="item_name" value="<? echo "$CompanyName"; ?>">
<input type="hidden" name="item_number" value="<? echo "$itemnum"; ?>">
<input type="hidden" name="amount" value="<? echo "$totalvar1"; ?>">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but03.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form> Total here is: <? echo "$totalvar1"; ?>
<br />
Button 3:
<br />
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<? echo "$emailaddy"; ?>">
<input type="hidden" name="item_name" value="<? echo "$CompanyName"; ?>">
<input type="hidden" name="item_number" value="<? echo "$itemnum"; ?>">
<input type="hidden" name="amount" value="<? echo "$totalvar2"; ?>">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but03.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form> Total here is: <? echo "$totalvar2"; ?>

ParodyUK
08-21-2007, 06:06 PM
tinkering now. Taa

dougp
08-21-2007, 06:13 PM
np, might want to also set up IPN (Instant Payment Notification) on PayPal, with return link and catch it on your site when the customer returns as to automate payment verification for that transaction. You can check up on that via Paypal. Paypal also offers a "Sandbox" testing grounds where you can test "live" "fake" transactions to make sure everything is working.

ParodyUK
08-21-2007, 06:20 PM
ok, that is half solved but i want a form on there which i can enter data and when i click a payment option it take the data from that form to paypal and puts it in the optional instructions. hope you understand.

dougp
08-21-2007, 06:25 PM
Also take a look here:
http://www.parkergt.com/examples/paypalbuttons2.php

<?php

// Grab the total before shipping and store into $total, this case lets pretend it was 48.92
$total = "48.92";
// Calculate the extra 5 onto button 1
$totalvar1 = $total + 5;
// Calculate the extra 10 on button 2
$totalvar2 = $total + 10;
// This would have ben grabbed from the DB or hardcoded if you like.
$emailaddy = "setyouremailfromdb@here.com";
// Replace with your company
$CompanyName = "Demo";
// Replace with var getting the transaction id, receipt id, or other.
$itemnum = "002357446-IDK";

?>

Total Before Shipping: <? echo "$total"; ?>
<br />
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<? echo "$emailaddy"; ?>">
<input type="hidden" name="item_name" value="<? echo "$CompanyName"; ?>">
<input type="hidden" name="item_number" value="<? echo "$itemnum"; ?>">
<input type="hidden" name="amount" value="<? echo "$totalvar1"; ?>">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="radio" name="payoption" value="2"> (1 - 2 week processing) £5.00
<br />
<input type="radio" name="payoption" value="3"> (48 hour processing) £10.00
</form>

Since paypal is done via POST data, you can post to it however you like so long as all the required variables are there still. you can use Radio selection instead giving the 3 options and have it first check via PHP which option is selected and then redirect the post using the apprpriate total.

(Yup, I understand was posting this at same time as you so disregard the info above to some extent)

ParodyUK
08-21-2007, 06:36 PM
hi,

Thanks for your help, i am new to using paypal (dont use it at all, but it is my friends preferance) How would i get the data to post into paypal? i am going to use the first one you showed me.

dougp
08-21-2007, 06:47 PM
https://developer.paypal.com/ <-- sign up it is free, allows you to test and such.

Check this, click the paypal button (Login but just dont fill out the info and continue transaction) I set it for total $1.00 (1 dollar) and +1, or +2 depending on button.

It will allow "additional" instructions.
http://www.parkergt.com/examples/paypalbuttons3.php

<?php

// Grab the total before shipping and store into $total, this case lets pretend it was 48.92
$total = "1.00";
// Calculate the extra 5 onto button 1
$totalvar1 = $total + 1;
// Calculate the extra 10 on button 2
$totalvar2 = $total + 2;
// This would have ben grabbed from the DB or hardcoded if you like.
$emailaddy = "setyouremailfromdb@here.com";
// Replace with your company
$CompanyName = "Demo";
// Replace with var getting the transaction id, receipt id, or other.
$itemnum = "002357446-IDK";
// replace with your domain name
$domainname = "http://www.mysite.com";
// PAge customer taken to when order is complete, such as a thankyou page.
$thanksorder = "thanks.php";
// Page customer taken to if they decide not to go through with it. (can be index.php/html if you like)
$cancelorder = "cancelled.php";

?>
Total Before Shipping: <? echo "$total"; ?>
<br />
Button 2: Total here is: <? echo "$totalvar1"; ?><br />
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<? echo "$emailaddy"; ?>">
<input type="hidden" name="item_name" value="<? echo "$CompanyName"; ?>">
<input type="hidden" name="item_number" value="<? echo "$itemnum"; ?>">
<input type="hidden" name="amount" value="<? echo "$totalvar1"; ?>">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="return" value="<? echo "$domainname/$thanksorder"; ?>">
<input type="hidden" name="cancel_return" value="<? echo "$domainname/$cancelorder"; ?>">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but03.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
<br />
Button 3: Total here is: <? echo "$totalvar2"; ?><br />
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<? echo "$emailaddy"; ?>">
<input type="hidden" name="item_name" value="<? echo "$CompanyName"; ?>">
<input type="hidden" name="item_number" value="<? echo "$itemnum"; ?>">
<input type="hidden" name="amount" value="<? echo "$totalvar2"; ?>">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="return" value="<? echo "$domainname/$thanksorder"; ?>">
<input type="hidden" name="cancel_return" value="<? echo "$domainname/$cancelorder"; ?>">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but03.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

As far as getting it to post to Paypal, as long as the variables are set on your site and set in the above code accordingly, it will automatically be posted when the customer clicks the button. All the "hidden" inputs store the data that will be posted to Paypal.

And a screenshot showing incase you dont have a paypal account.
http://parkergt.com/examples/picpaypal.jpg

ParodyUK
08-21-2007, 07:11 PM
so i just make my form set the data to hidden like them ones, and name=note or something like that?

ParodyUK
08-21-2007, 07:25 PM
name = note didnt work hmm, what will it be :S:(

ParodyUK
08-21-2007, 07:31 PM
all i need to do now is everything entered into my form to be put as a var i think it is $name <-- like that and be able to put into the item id thing.

dougp
08-21-2007, 08:08 PM
how do i make a text box have var if you get what i mean so i can do like echo "$textbox" and it appears because if i can do that i may put that information into the item id and then its fixed :)

www.xdcn.net/q/test2.php is where it is saved.
I am misunderstanding you here, but will attempt to answer it lol.


<?php

$somecustom = "Some extra Info";

?>
<input type="text" name ="custom" value="<? echo "$somecustom"; ?>">

If you want the data hidden, change Type="text" to type="hidden"

But I think some additional features you would need Paypal Payments Pro ($20/month fee to use it)

all i need to do now is everything entered into my form to be put as a var i think it is $name <-- like that and be able to put into the item id thing.

Sorry for my slow replies, my net is having issues atm (storm here)

May want to sign up on Paypal Developer site, may be able to get exactly what you need easier here:

https://www.paypaldeveloper.com/pdn/forums

I can help you, just having a little trouble understanding the last part about putting everything into a single var??

Not sure why you need to do that, if sending to Paypal, Paypal is limited in how many characters you can enter.

If not, you can accumilate data into a single var like this

$myvar = $var1;
$myvar .= $var2;
$myvar .= $var3;

Notice the first is just = and the next 2 have .= (period then equal) this tells it to add the data into the already existing variable called myvar.

When you echo $myvar it will echo out "$var1$var2$var3" (replace the vars with whatever the data happens to be). You can seperate the data however you like such as adding in a "colon" : in between each var and using php explode function when you need to grab each one again, or you could even just add them to an array to fetch later.

ParodyUK
08-21-2007, 08:36 PM
ok done that but now i just need to know how to draw it up into paypal would it be in the item id (this is where i am placing it because they cant edit that) $itemnum = "fasttrack1-2week echo '$name $email $surl $sname $desc';";?

EDIT:::
aah :( i tried this
$itemnum = "echo '$name $email $surl $sname $desc'";

and paypal wont allow the $name $emai $surl $sname $desc bit :(

How do i do it now? :(

ParodyUK
08-21-2007, 08:48 PM
oh didnt see that message :P Ok going to try this now.

ParodyUK
08-21-2007, 08:54 PM
<?php

// this is start ammount
$total = "5";
// this is for second option 48hour
$totalvar1 = $total + 5;
// this cud be for a 3rd option if you want 24 hour processing or advert on front page?
$totalvar2 = $total + 0;
// This is your paypal account detail
$emailaddy = "hidden";
// company name
$CompanyName = "hidden";
// these are your referances and the $name $email and stuff is your information about submission (not working yet)
$itemnum = "1-2week '$form'";
$itemnum2 = "48hour '$form';";
// domain
$domainname = "http://hidden";
// thank you page (needs to be created)
$thanksorder = "thanks.php";
// cancel page (needs to be created)
$cancelorder = "cancelled.php";
// this just pulls all the vars together instead of about 50 lol
$form = $name;
$form .= $email;
$form .= $surl;
$form .= $sname;
$form .= $sdesc;


?>
<p>

<?php

$name = "Some extra Info";

?>Your Name:
<input type="text" name ="custom">

</p>
<p>
<?php

$email = "Some extra Info";

?>Your Email:
<input type="text" name ="custom">
</p>
<p>
<?php

$surl = "Some extra Info";

?>Site URL:
<input type="text" name ="custom">
</p>
<p>

<?php

$sname = "Some extra Info";

?>Site Name:
<input type="text" name ="custom">
</p>
<p>

<?php

$sdesc = "Some extra Info";

?>Site Description:
<input type="text" name ="custom">

&nbsp;</p>
<p>1 - 2 Week Processing: £<? echo "$total"; ?>.00<br />
<br />
</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<? echo "$emailaddy"; ?>">
<input type="hidden" name="item_name" value="<? echo "$CompanyName"; ?>">
<input type="hidden" name="item_number" value="<? echo "$itemnum"; ?>">
<input type="hidden" name="amount" value="<? echo "$total"; ?>">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="<? echo "$domainname . \"/\" . $thanksorder"; ?>">
<input type="hidden" name="cancel_return" value="<? echo "$domainname . \"/\" . $cancelorder"; ?>">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="lc" value="UK">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but03.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
<br />
48 Hour Express Processing: &pound;<? echo "$totalvar1"; ?>.00<br />
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<? echo "$emailaddy"; ?>">
<input type="hidden" name="item_name" value="<? echo "$CompanyName"; ?>">
<input type="hidden" name="item_number" value="<? echo "$itemnum2"; ?>">
<input type="hidden" name="amount" value="<? echo "$totalvar1"; ?>">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="<? echo "$domainname . \"/\" . $thanksorder"; ?>">
<input type="hidden" name="cancel_return" value="<? echo "$domainname . \"/\" . $cancelorder"; ?>">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="lc" value="UK">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but03.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

that is my exact code apart from somethings are hidden for secrurity.

dougp
08-21-2007, 09:19 PM
$itemnum = "echo '$name $email $surl $sname $desc'";

^^ you almost had that, try this instead.

$itemnum = $name . " " . $email . " " . $surl . " " . $sname . " " . $desc;

echo "$itemnum"; // Just to test it, remove this part after testing

If you don't want spaces in between each one then use

$itemnum = $name . $email . $surl . $sname . $desc;

Also you need to give each input field a unique "name", example:

<?php

$name = "Some extra Info";

?>Your Name:
<input type="text" name ="username">

</p>
<p>
<?php

$email = "Some extra Info";

?>Your Email:
<input type="text" name ="useremail">
</p>
<p>
<?php

$surl = "Some extra Info";

?>Site URL:
<input type="text" name ="surl">
</p>
<p>

<?php

$sname = "Some extra Info";

?>Site Name:
<input type="text" name ="sname">
</p>
<p>

<?php

$sdesc = "Some extra Info";

?>Site Description:
<input type="text" name ="sdesc">

it is used when geting get/post data using $_GET['FieldName'] or $POST['FieldName']

Such as

$username = $_GET['username'];

If ($username == "") {
echo "ERROR! You forgot to enter your name! Please go back and try again!";
exit();
}

Also check my code again for example 3 (the same one you used in the code you put above this post) check entries for these

<? echo "$domainname . \"/\" . $cancelorder"; ?>

Should be:

<? echo "$domainname/$cancelorder"; ?>

(all of them, the thankyou ones as well, I updated it (hoped to updated before you read it, but I am slow tonight) Was a mistake on my part as I was not using my noggin.

dougp
08-21-2007, 09:32 PM
oh, are you wanting majority of the form to be filled in automatically by grabbing the data from your database (such as username, etc..) ?? Is that what you were trying to acomplish with asking how to put them all into one var?

Cause if that is the case, then I indeed misunderstood you and the example I showed is not going to do you any justice for that (the one with puting them inline $var1 . $var2 . $var3 nor the .=)

Let me know and I will post your form up with vars in place to autofill from user account details.

ParodyUK
08-21-2007, 09:41 PM
nope, no account is required, its a fill your data in click pay data is sent to me i submit it type thing.

dougp
08-21-2007, 09:46 PM
nope, no account is required, its a fill your data in click pay data is sent to me i submit it type thing.
kk, just checking :)

<?php

// this is start ammount
$total = "5.00";
// this is for second option 48hour
$totalvar1 = $total + 5.00;
// this cud be for a 3rd option if you want 24 hour processing or advert on front page?
$totalvar2 = $total + 10.00;
// This is your paypal account detail
$emailaddy = "hidden";
// company name
$CompanyName = "hidden";
// these are your referances and the $name $email and stuff is your information about submission (not working yet)
$itemnum = "1-2week '$form'";
$itemnum2 = "48hour '$form';";
// domain
$domainname = "http://hidden";
// thank you page (needs to be created)
$thanksorder = "thanks.php";
// cancel page (needs to be created)
$cancelorder = "cancelled.php";
// this just pulls all the vars together instead of about 50 lol
$form = $name;
$form .= $email;
$form .= $surl;
$form .= $sname;
$form .= $sdesc;


?>
<p>

<?php

$name = "Some extra Info";

?>Your Name:
<input type="text" name ="username">

</p>
<p>
<?php

$email = "Some extra Info";

?>Your Email:
<input type="text" name ="useremail">
</p>
<p>
<?php

$surl = "Some extra Info";

?>Site URL:
<input type="text" name ="surl">
</p>
<p>

<?php

$sname = "Some extra Info";

?>Site Name:
<input type="text" name ="sname">
</p>
<p>

<?php

$sdesc = "Some extra Info";

?>Site Description:
<input type="text" name ="sdesc">

&nbsp;</p>
<p>1 - 2 Week Processing: & #163;<? echo "$total"; ?><br />
<br />
</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<? echo "$emailaddy"; ?>">
<input type="hidden" name="item_name" value="<? echo "$CompanyName"; ?>">
<input type="hidden" name="item_number" value="<? echo "$itemnum"; ?>">
<input type="hidden" name="amount" value="<? echo "$total"; ?>">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="<? echo "$domainname/$thanksorder"; ?>">
<input type="hidden" name="cancel_return" value="<? echo "$domainname/$cancelorder"; ?>">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="lc" value="UK">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but03.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
<br />
48 Hour Express Processing: & #163;<? echo "$totalvar2"; ?><br />
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<? echo "$emailaddy"; ?>">
<input type="hidden" name="item_name" value="<? echo "$CompanyName"; ?>">
<input type="hidden" name="item_number" value="<? echo "$itemnum2"; ?>">
<input type="hidden" name="amount" value="<? echo "$totalvar1"; ?>">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="<? echo "$domainname/$thanksorder"; ?>">
<input type="hidden" name="cancel_return" value="<? echo "$domainname/$cancelorder"; ?>">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="lc" value="UK">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but03.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

Also, cancel page, you can make one, or just put index.php or index.html for example which would just bring them back to your main page. Thank you is always a good idea though as it shows your appriciation for them shopping with you.

& #163; should be without space after &
But since I put in php tags it parsed it as £ :P same as using $pound

These forums parses html number code haha :) And still confused as to what your using the variable $form for :S

ParodyUK
08-21-2007, 09:50 PM
ye, i have just made a new page with all that and it gives same effect as the other :( and paypal still doesnt display the form data :(

dougp
08-21-2007, 09:54 PM
ye, i have just made a new page with all that and it gives same effect as the other :( and paypal still doesnt display the form data :(
because the data has not been set, you need to set the variables from whatever page leads to that page there and then it will be filled into the paypal button. Will code up a working 2 page order form later and show you what I mean. (or maybe even just 1 page :P since you can post to the same page)

As it is now, that is just the final checkout page. The info will need to be set properly for each variable and post data gathered to fill those spaces. Will work on that in a bit, lemme grab some food and drink.

ParodyUK
08-21-2007, 09:55 PM
what do you mean the data has not being set? it is being set in the form above the buttons isnt it..?

ParodyUK
08-21-2007, 09:57 PM
do you have aim or msn?

dougp
08-21-2007, 09:58 PM
do you have aim or msn?
yes, I have both. (I use Trillian), also SkyPE.

dougp
08-22-2007, 01:38 AM
Live Demo: Click Here (http://www.parkergt.com/examples/paypalorderform/index.php)

Files attached, you will need to fine tune the layout, etc.. and theme it to your liking. But it works nonetheless.

ParodyUK
08-22-2007, 06:48 AM
you are brillaint mate :D

Kudos to this man.

dougp
08-22-2007, 08:30 AM
np, I did not put anything fancy such as verifying the user has entered a valid email address, etc.. But you can search google for already made scripts that can do that and add it in easily.

ParodyUK
08-22-2007, 08:38 AM
will do that. Thanks.