DarkHorizon Posted October 19, 2006 Share Posted October 19, 2006 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 https://forums.phpfreaks.com/topic/24442-php-help-with-payment/ Share on other sites More sharing options...
trq Posted October 19, 2006 Share Posted October 19, 2006 Place the files in a non accessible directory, with there filenames and paths stored in a database. You then use the [url=http://php.net/header]header[/url] function to force a download once authorized. Link to comment https://forums.phpfreaks.com/topic/24442-php-help-with-payment/#findComment-111261 Share on other sites More sharing options...
Design Posted October 19, 2006 Share Posted October 19, 2006 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 https://forums.phpfreaks.com/topic/24442-php-help-with-payment/#findComment-111265 Share on other sites More sharing options...
printf Posted October 19, 2006 Share Posted October 19, 2006 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 https://forums.phpfreaks.com/topic/24442-php-help-with-payment/#findComment-111271 Share on other sites More sharing options...
DarkHorizon Posted October 19, 2006 Author Share Posted October 19, 2006 thanks,now i can make a start on building it up.. Link to comment https://forums.phpfreaks.com/topic/24442-php-help-with-payment/#findComment-111282 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.