Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-18-2010, 05:16 PM   PM User | #1
treeleaf20
Regular Coder

 
Join Date: Oct 2009
Posts: 438
Thanks: 9
Thanked 7 Times in 7 Posts
treeleaf20 is an unknown quantity at this point
Get sending page name

All,
I'm working with Paypal and after someone makes a payment on Paypal I'm redirecting them back to a receipt page that I'm hosting. I don't want this page to display anything unless the redirecting page is Paypal, is there anyway to control this with PHP?

Thanks in advance.
treeleaf20 is offline   Reply With Quote
Old 12-18-2010, 05:31 PM   PM User | #2
durangod
Senior Coder

 
Join Date: Nov 2010
Posts: 1,177
Thanks: 214
Thanked 31 Times in 30 Posts
durangod is on a distinguished road
dont recreate the horse, paypal handles this for you in your paypal script for the product sale, if you dont advertise your receipt page and nonone knows about it then the only way anyone can see it is from the paypal process using the return url in your code..


there are two return url for paypal, one is set inside your account as the default, and the other is set in specific in your code...

if you want every customer to go to the same place every time after every sale then put the url in your account, it will override anything else..

if you have dif places to send them depending on the product type then use the return url in the payment code process..

if you just want to keep anyone from typing the receipt page url in their browser window and bringing it up manually you can always control that with htaccess or you can put a switch in the page header that if the var are not set then send them to the main page....
durangod is offline   Reply With Quote
Old 12-18-2010, 05:37 PM   PM User | #3
treeleaf20
Regular Coder

 
Join Date: Oct 2009
Posts: 438
Thanks: 9
Thanked 7 Times in 7 Posts
treeleaf20 is an unknown quantity at this point
Thanks for the post, yeah I've already set it in my Paypal preferences. I guess I just don't have to let anyone know it's out there. Could you give me more specifics about the htaccess though? If I put it in there can I control htaccess to basically not show it if someone types in the adress but if someone got to it from a redirect then that's ok?
treeleaf20 is offline   Reply With Quote
Old 12-18-2010, 06:21 PM   PM User | #4
durangod
Senior Coder

 
Join Date: Nov 2010
Posts: 1,177
Thanks: 214
Thanked 31 Times in 30 Posts
durangod is on a distinguished road
if they do bring it up then its not gonna show anything just a blank page with no data right..

i know you can do some pretty fancy stuff with mod rewrite and im not an htaccess or mod rewrite pro by far so for that prob someone better can help you..

but what i would do, is one of two things or both..

first if they need to be logged in to purchase then the user session should be set for them already. and just going to paypal and back wont break that link.. so you could just say something like if !$SESSION or use isset with it to check to see if session is set, if not then use header location to send them to the main page of the site..

or if they are not required to be a member or be logged in you could just use the same methology on another var...
whatever you use for your payment var that you display on the receipt page you could just say if !isset that var name then send them to the home page using header location,

basically, if that val is not set it means they didnt come from paypal because there is no value, if it is set then you know they are finishing up a sale and you can let them in..

hope that helps you, if you really want to do the htaccess and some fancy stuff then i would suggest reposting a reply and maybe one of the pro's here can help do that...

peace
durangod is offline   Reply With Quote
Old 12-18-2010, 07:31 PM   PM User | #5
pigpen
Regular Coder

 
Join Date: Dec 2007
Posts: 137
Thanks: 1
Thanked 21 Times in 21 Posts
pigpen is on a distinguished road
There are many ways to check using the various PayPal APIs, but alternatively as durangod suggested you can do a session check or simply check for a variable, like in your querystring.

Just to illustrate, here's an example of using the querystring.

So in your PayPal preference, have the return url set to your receipt page but append a variable to the url, like: ?referer_url=paypal

So your URL would look like:

Code:
http://www.mysite.com/receipt.php?referer_url=paypal
Then in your receipt.php page, check if the referer_url is equal to 'paypal' and if not, then don't show the page.

Code:
<?php
if($_GET['referer_url'] != 'paypal') {
    die('go away!');
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Thank You</title>
    </head>
    <body>
        <h1>Thank You for your PayPal transaction!</h1>
    </body>
</html>
If the referer_url doesn't equal to paypal, the die command will stop the page from showing (and just display a message, "go away"). This will happen if someone goes to your page with just http://www.mysite.com/receipt.php instead of http://www.mysite.com/receipt.php?referer_url=paypal

Anyway, just one way of doing it.

EDIT: fixed a typo in the php code
pigpen is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:52 PM.


Advertisement
Log in to turn off these ads.