Step 6: PayPal configuration and Buy Now button creation steps


The Activation Kit integrates PayPal scripts that automate the addition of new users to the database and delivery of registration keys by email, immediately after a successful order with PayPal.

PayPal is an e-commerce business allowing payments and money transfers to be made through the Internet. PayPal serves as an electronic alternative to traditional paper methods such as checks and money orders.

A PayPal Business account is recommended if you want to use these scripts.

Note: on the HTML Executable website, there is a PayPal kit. You do not have to install this PayPal kit because it is already integrated in this activation kit.

How does it work for the end user?

How to configure the Paypal scripts

The PayPal associated script files are available in "heakdist\admin\paypal".

STEP 1: edit the "heakdist\admin\paypal\inc\settings.php" file and make the necessary modifications below.

The most important step is to configure the settings related to your ebook:

// Various Emails

$paypal_email = '[email protected]'; // Your Paypal email

$notify_email ='[email protected]'; // Email which will receive notifications

$download_email = 'My Business <[email protected]>'; // Email from which mails will be sent

$currency = 'USD';

// Customer Email Message

$email_subject = "{product_name} Registration";

$email_body = "Hello {first_name} {last_name}".

"\n\nThank you for having purchased {product_name}. Please start our program, 

select << I have a registration key and want to unlock the program >>. Enter your email address

 in the Registration Key field, and click Activate to unlock the program:".




"\nYour Signature";

// Notification Email Message

$notify_subject = "Product Sale Notification for {product_name}";

$notify_body = "\n\nThis mail is to notify you about the sale of {product_name} whose 

product id is {product_id}.".

"\nThe sale was made to {first_name} {last_name}, email: {payer_email} at ".date('Y-m-d');

/* Ebook Details

Number = a number associated to your ebook for internal purposes and security check.

The item ID (item_number) field of Paypal IPN must match this number.

Price = purchase price. Currency set up below.

Certificate ID = the "Unique Certificate Signature" of the registered certificate

 you want the user to activate.


product[number] = array('Ebook Title' ,'Price' , 'Certificate ID');


$products[0] = array('My Ebook','15.00', '8EKzn601IkXH7ip4z');

/* Email SMTP settings: configure the settings for email delivery.


$smtpserver = '';

$smtpport = 25;

$smtplogin = 'username';

$smtploginp = 'password';

$debug = false; // Enable if you want debug log

$debug_log = "debug.log";

$$sandbox = false; // Enable PayPal sandbox testing

All parameters are self-explanatory. For instance, we added the title of your ebook (My Ebook), its price ($15.00 for instance) and the Certificate ID mentioned in this page.

Email messages are sent with SMTP. You should provide valid SMTP information.

Save the modifications to the settings.php file on your server.

STEP 3: when it is done, open your web browser, navigate to the location of the check.php file (http://path/to/heakdist/admin/paypal/check.php).

All tests should be successful. Click Send email to verify that your SMTP server is correctly set up: a dummy email message will be sent to your notify email address.

You should keep this webpage open as it contains some settings useful for creating the Paypal Buy Now button.

IMPORTANT: we recommend you to restrict access to check.php (password protect it for instance) or simply remove it after use.

Now that the PayPal script is installed and configured, you can create a "Buy Now" button with PayPal.

Make Buy Now Buttons

Go to PayPal and log in. Choose Merchant Services and Buy Now Button.

Fill in the form as shown previously on the check.php page.

The Item ID must match the number that appears between the [] brackets in the $products[1] array variable (in settings.php). Same for the price.

Turn "Add advanced variables" on and add a variable notify_url that points to the location of the paypal.php file on your server (http://path/to/heakdist/admin/paypal/paypal.php)

Click "Create Button" and you have the button code to copy/paste in your purchase webpage.

You can now make tests with PayPal sandbox for instance.

Customize PayPal scripts

  • The "paypal/inc/settings.php" file contains additional parameters like templates for email messages ($email_subject, $email_body). These templates accept variables: variables are defined in the paypal.php script.
  • The PayPal script by default uses the email address of the customer as the activation key. In fact, an email address is considered as unique and thus we can use it as the identifier (userkey field) of the customer record in the database. You may use your own routine to generate the activation key: take a look in paypal.php at the function named addusertodatabase($name, $company, $certificate, $email, $comments).
  • Keep in mind that the activation key used for online activation has nothing in common with standard registration keys generated by HTML Executable. It is only a unique identifier for the customer's database record.

img Use the administration panel


This is the online documentation of the HTML Executable Activation Kit.

About this Activation Kit

HTML Executable is an ebook compiler that lets you build secure ebooks with your websites, HTML or PDF documents. The generated ebooks can work with online activation: you can create trial or restricted versions of your ebooks, and offer them for public downloads. After purchase, customers can activate their ebook thanks to an activation code on a given number of computers only. Moreover, you can control who may read your ebook, block access at any time and authorize refunds to your customers. Everything is automated thanks to this activation kit.

Learn more about HTML Executable - Free Trial