Payment system?

Discussion in 'PHP' started by le007, Jan 6, 2010.

  1. #1
    Very simple question for you php'ers! :D

    What is the best way to do the following:
    Have someone pay a few dollars through paypal to view the content of my site? They can view it as many times as possible after they pay but up until then they must pay first?

    Vague? Maybe, but its very straightforward - I just want someone to have to click straight into paypal, pay 2 dollars and then redirected back to another part of the site where they get to view the content?

    Thank you :D
     
    le007, Jan 6, 2010 IP
  2. iAreCow

    iAreCow Peon

    Messages:
    85
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #2
    <?php
    $ref = $_SERVER['HTTP_REFERER']; // Get the referer URL
    if(preg_match("/paypal.com/",$ref)) { // IF referer URL contains "paypal.com" then echo the content
    echo "Here's your content :)"; }
    else { echo "You must pay first"; } // else show error message
    ?>
    PHP:
    No security (referer can be faked), but should do the trick
     
    iAreCow, Jan 6, 2010 IP
  3. le007

    le007 Well-Known Member

    Messages:
    481
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #3
    Thank you for the swift reply iAreCow.
    2 questions:

    Any way of making it secure?

    And, the visitor couldn't make a return visit without re-paying, am I wrong?

    Many thanks.
     
    le007, Jan 6, 2010 IP
  4. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Create a simple login system, and save the payment status to their profile in the database. Then ask people to log in to view content on your site, redirecting them if they haven't paid
     
    JAY6390, Jan 6, 2010 IP
  5. le007

    le007 Well-Known Member

    Messages:
    481
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #5
    Hi Jay,

    yeah thats definitely what I'm after - novice phper - any links to such a simple login etc that would survice?
    Thank you :)
     
    le007, Jan 6, 2010 IP
  6. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #6
    for the login tutorial, check out http://www.deathmonkeyz.com/tutorials (in the php section)
    For the paypal integration, check out their API and google around a bit. Modifying the code shouldn't prove too difficult
     
    JAY6390, Jan 6, 2010 IP
  7. iAreCow

    iAreCow Peon

    Messages:
    85
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #7
    Security:
    1. You could use PayPal IPN: customer pays, returns to your side with a unique transaction ID, the script checks if the ID is valid (a simple query to PayPal) and prints the content if it is.

    Returning visitor:
    1. Save the transaction ID in cookies (user will have access till he deletes the cookie or uses another browser)
    2. Work out some login system
    3. You could mail() them the content
     
    Last edited: Jan 6, 2010
    iAreCow, Jan 6, 2010 IP
  8. le007

    le007 Well-Known Member

    Messages:
    481
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #8
    Thanks alot for you replies, you both really helped.
     
    le007, Jan 6, 2010 IP