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.

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. Go to: https://developer.paypal.com/developer/applications/
  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 "name-buyer@email.com"
  6. After testing click on your app under App Name at https://developer.paypal.com/developer/applications/ and click on live and copy your live client_id and secret and 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

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 April 1, 2019
Created on August 25, 2017

Back to www.seabreezecomputers.com
Subscribe to Internet Tips and Tools Feed        

User Comments

There are 5 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/