PHP Cool Paypal Script - Digital Downloads Made Easy

Last updated on
((( spellific )))
Practice spelling while playing a fun word game!
Click here to play
Speech Recognition Anywhere
  • Type emails with your voice
  • Write documents with your voice
  • Control the Internet with your voice
  • Chrome Extension
Reconocimiento de voz en cualquier lugar
  • Escribe correos electrónicos con tu voz
  • Escribe documentos con tu voz
  • Controla la Internet con tu voz
  • Extensión de Chrome
Spracherkennung Allerorts
  • Geben Sie E-Mails mit Ihrer Stimme ein
  • Schreiben Sie Dokumente mit Ihrer Stimme
  • Steuern Sie das Internet mit Ihrer Stimme
  • Chrome-Erweiterung
Reconnaissance de la parole
  • Tapez des e-mails avec votre voix
  • Écrivez des documents avec votre voix
  • Contrôlez l'Inernet avec votre voix
  • Extension Chrome
Riconoscimento vocale ovunque
  • Digita e-mail con la tua voce
  • Scrivi documenti con la tua voce
  • Controlla Internet con la tua voce
  • Estensione Chrome
どこでも
音声認識
  • あなたの声で文書を書く
  • あなたの声でメールを入力してください
  • 音声でインターネットをコントロール
  • Chrome拡張機能
语音识别
无处不在
  • 用你的声音写文件
  • 用您的声音输入电子邮件
  • 用你的声音控制互联网
  • Chrome 扩展程序
語音識別
無處不在
  • 用你的聲音寫文件
  • 用您的聲音輸入電子郵件
  • 用你的聲音控制互聯網
  • Chrome 擴展程序
Subscribe to Internet Tips and Tools Feed

Are you looking for a way to easily allow digital downloads of files after a paypal payment is received? This PHP script uses the latest Paypal Express Checkout method.

Features

This script does the following with one php file, without any other scripts needed:

		1. Request token from paypal
		2. Create a payment by sending payment json object to paypal
		3. Redirect user to Paypal with returned 'approval_url'.
			Paypal will redirect back to this file after payment.
		4. Execute payment with paypal
		5. Create encrypted download link that expires
		6. When user clicks link, send download file to customer
		

Requirements

Paypal requires TLS v. 1.2 which requires OpenSSL 1.0.1c. For more information see: https://github.com/paypal/TLS-update#php

Instructions

  1. Create a "Buy Now" link to coolpaypal.php on your html page similar to: coolpaypal.php?file=yourfile.zip

    You can use this code which includes a Paypal Buy Now button:

  2. Create a secret folder on your server and put all your downloads in that folder.
  3. Edit coolpaypal.php and edit the $secret_folder variable and set the default price for downloads. You can also set different prices for different filenames.
  4. Go to: https://developer.paypal.com/dashboard/
  5. Click Log into Dashboard.
  6. Select Apps & Credentials.
  7. To create a new project, select "Create App".
  8. PayPal generates a set of OAuth client_id and secret credentials for your app for both the sandbox and live environments. Go to Apps & Credentials and make sure the "Sandbox" switch is on.
  9. Copy your Sandbox Client Id and then copy your Secret into coolpaypal.php in the $client_id and $secret variables.
  10. To test it you need to use sandbox accounts. Click on Testing Tools > Sandbox Accounts. The account to test purchases with will look something like "name-buyer@email.com". If you don't know the password then click on the account and click on "Change password".
  11. After testing click on your app under App Name at https://developer.paypal.com/dashboard/applications/live and make sure the "Live" switch is on.
  12. Copy your Live Client Id and then your copy your Secret into coolpaypal.php in the $client_id and $secret variables. Also in coolpaypal.php change $mode to "live".

Download

Buy Now    You may download and use the script after a Paypal payment of $25.00. This "Buy Now" button uses the script you are about to download.

Or download the script to setup and test for a donation: dlc_b

Download

Downloaded 0 times.
Please make a donation to reveal the download link.

History

10/21/2019 - Version 1.2 - This month Paypal started rejecting the payment request with http code 415 (Unsupported Media Type) because something changed on Paypal's servers in detecting Content-Tpye of "application/json" header. Found out it was because the header was previously with a space between Content-Type and the colon. Changed it to 'Content-Type: application/json' throughout the code and now it works again.

12/18/2018 - Version 1.1 - Added support for a download countdown to auto start download and changed the download method from using readfile() to using fopen() with file chunks for better support at downloading larger files on servers with limits.

8/25/2017 - Version 1.0 - Paypal Digital Download Script Created

Last updated on August 21, 2023
Created on August 25, 2017

((( spellific )))
Practice spelling while playing a fun word game!
Click here to play
Speech Recognition Anywhere
  • Type emails with your voice
  • Write documents with your voice
  • Control the Internet with your voice
  • Chrome Extension
Reconocimiento de voz en cualquier lugar
  • Escribe correos electrónicos con tu voz
  • Escribe documentos con tu voz
  • Controla la Internet con tu voz
  • Extensión de Chrome
Spracherkennung Allerorts
  • Geben Sie E-Mails mit Ihrer Stimme ein
  • Schreiben Sie Dokumente mit Ihrer Stimme
  • Steuern Sie das Internet mit Ihrer Stimme
  • Chrome-Erweiterung
Reconnaissance de la parole
  • Tapez des e-mails avec votre voix
  • Écrivez des documents avec votre voix
  • Contrôlez l'Inernet avec votre voix
  • Extension Chrome
Riconoscimento vocale ovunque
  • Digita e-mail con la tua voce
  • Scrivi documenti con la tua voce
  • Controlla Internet con la tua voce
  • Estensione Chrome
どこでも
音声認識
  • あなたの声で文書を書く
  • あなたの声でメールを入力してください
  • 音声でインターネットをコントロール
  • Chrome拡張機能
语音识别
无处不在
  • 用你的声音写文件
  • 用您的声音输入电子邮件
  • 用你的声音控制互联网
  • Chrome 扩展程序
語音識別
無處不在
  • 用你的聲音寫文件
  • 用您的聲音輸入電子郵件
  • 用你的聲音控制互聯網
  • Chrome 擴展程序
Back to www.seabreezecomputers.com
Subscribe to Internet Tips and Tools Feed        

User Comments

There are 13 comments.

Displaying first 50 comments.

1. Posted By: OneGuy - - April 16, 2019, 12:52 pm
How does this work for subscriptions and recurring invoices?

2. Posted By: Jeff - - April 16, 2019, 7:26 pm
Hi OneGuy,

It does not work for subscriptions. This script is for purchasing and then downloading an individual file such as a music file, a photo, a document, etc.

Jeff
www.seabreezecomputers.com/

3. Posted By: Joe - - April 22, 2019, 8:41 am
Hi - it seems to be a great script - one question before buying it: Can I modify the list with the download files individually (I must indicate some features like format-size-author-production and so on) AND - can I offer free downloads within the list too? Is the size of the download-files limited?
thanks so much for answering
greetings
Joe

4. Posted By: Jeff - - April 22, 2019, 10:32 am
Hi Joe,

You can edit the PHP file and specify the filenames and prices. It is setup to edit with simple if statements like this:

// Setup your file names and prices here:
if ($file=="download.zip")
$price="5.00";
else if ($file=="other.zip")
$price="10.00";

As for indicating format-size-author-production and so on you would specify that in your html file. Also any free files would go through html and not through the paypal script. The size of the download files is not limited by the script but you may have some settings on your php server that limit the file size.

Jeff
www.seabreezecomputers.com/

5. Posted By: Jeff - - April 23, 2019, 10:26 am
Hi Joe,

1. License: You may use the script on any page on your own website. Additional website domains should purchase their own copy of the script.
2. SQL is not used.
3. The script does not bill or email the user. It sends the user to paypal where they complete a payment with paypal and then they are sent back to the website where the download of the file begins.
4. The link will last until the amount of hours you specify in the script. You can set it to last for 1 to 24 hours. The link does not need to be secure. The only way to make it secure is if you require that your website be run over https.

Jeff
www.seabreezecomputers.com/

6. Posted By: Chad - - October 17, 2019, 8:42 pm
I am getting a error I think its 416? or something like that but i haven't change anything so i don't know why this is happening. Do you know what this error means? thanks

7. Posted By: Jeff - - October 18, 2019, 8:55 am
Hi Chad,

The error is on Paypal's end. They changed something. I have a support ticket submitted with them. Hopefully they will get back to me soon. If you would like to submit a support ticket to Paypal then maybe they will get more techs on the problem. I submitted it here: https://www.paypal-support.com/s/contactsupport  

Jeff
www.seabreezecomputers.com/

8. Posted By: vinbon - - November 30, 2019, 4:57 am
hey it looks like a very dead link

9. Posted By: Jeff - - November 30, 2019, 12:22 pm
Hi vinbon,

Thank you for notifying me. Sorry about that. There was a mysql error on the server. It is fixed now

Jeff
www.seabreezecomputers.com/

10. Posted By: vinbon - - November 30, 2019, 3:34 pm
Hi Jeff,
the new link works fine, thanks a lot, bye

11. Posted By: RS - - August 6, 2021, 7:48 am
Would it be possible to specify the quantity of the item too? I know there can be no control over how many times it's downloaded, so there's an element of trust, but I would like the buyer to be able to select - say - 30 to allow them to copy the book to 30 devices. If the book is $5, that would then mean the total charge would be $150, of course.

12. Posted By: Imhotep - - July 20, 2022, 2:45 am
This script looks promising, but I get a Error: http_code=429 all the time.
So I need to find another script! :D

13. Posted By: Jeff - - July 27, 2022, 7:13 pm
Hi Imhotep,
The Paypal website says that http_code 429 is too many requests. They say they block if there are more than 50 requests in 1 minute. Are you receiving 50 payments a minute? There is more information here: https://www.paypal.com/us/smarthelp/article/why-did-i-get-http-error-code-429-ts2115

Jeff
http://www.seabreezecomputers.com/