Jump to content

PHP help with payment


DarkHorizon

Recommended Posts

Hi folks, its the age old question...

i have some mp3 files that are available for sale. I want customers to pay for them using paypal then download them once payment has been taken.

I am familiar with PayPal integration into a 3rd party (my) PHP shopping cart.

How do i restrict access to a file on a server such as an MP3 until the user has paid?

Just some rough ideas, a plan would be great. You dont have to offer any code, i know you are busy enough witout me butting in.
Link to comment
Share on other sites

you could use a variable with a boolean(true/false) value, so that if it's not paid for, say $paid = false,  you restrict the page by checking the value of $paid when the page loads, if false then redirect, otherwhise let them continue.
Link to comment
Share on other sites

place the files in a no web access directory, then serve them via PHP...


[code]// no web access directory and file paid for!

$file = '/path/paid.mp3';

if ( has been paid logic )
{
if ( not dowloaded already logic OR allowed download time limit logic < time () )
{
header ( 'Cache-control: max-age=31536000' );
header ( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
header ( 'Content-Length: ' . filesize ( $file ) );
header ( 'Content-Disposition: filename="' . basename ( $file ) . '"' );
header ( 'Content-Type: application/download; name="' . basename ( $file ) . '"' );
readfile ( $file );
}
else
{
echo 'sorry you already downloaded this music file';
}
}
else
{
echo 'sorry you have not paid to use this service!';
}[/code]


me!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.