Search code examples
phpdatabasepaypalpayment-processing

Make content visible after PayPal payment?


I am making a website where you can have 2 types of articles: free and paid. Each user has it's own profile. When user purchases certain article it is visible to him when he is logged in. For starters I was thinking of using PayPal to process my payments.

THE QUESTION IS: How to make this process automatic? I know how to do it manually but not a practical solution. How can i achieve this?


Solution

  • First take a look at Paypal API

    You can create a table to store payments in your database, a user can user a payment button on the page to pay for the content. Use paypal PHP-PayPal-IPN to check if a payment status. If payment is complete you redirect to a php page to update the payment status on the payment table and redirect to your information page.

    Your payment table could include:

    |id|payment_code|user_id|amount|information_id|payment_date|payment_status
    

    On your information page always check if payment is been made by user to display the paid content.

       //fetch payment status from payment_table where content_id = $content_id and user_id = $user_id
       // if status is paid then display content