PHP Cool Paypal Script - Digital Downloads Made Easy

Last updated on
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.


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


Paypal requires TLS v. 1.2 which requires OpenSSL 1.0.1c. For more information see:


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

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

  2. Go to:
  3. Click Log into Dashboard.
  4. In the REST API apps section, click Create App.
  5. PayPal generates a set of OAuth client_id and secret credentials for your app for both the sandbox and live environments. To test it you need to use sandbox accounts. On the left side of the Paypal Dashboard under Sandbox click Accounts. The test account to test a purchase with will look something like ""
  6. After testing click on your app under App Name at and click on live and copy your live client_id and secret and change $mode to "live".


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

Or download the script at no cost to setup and test: dlc_b


Downloaded 0 times.
Please make a donation to help with server costs and other expenses.


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 December 18, 2018
Created on August 25, 2017

Back to
Subscribe to Internet Tips and Tools Feed        

User Comments

There are 0 comments.

Displaying first 50 comments.