Paypal donation

8.4 Using PayPal Encrypt tool

As we have already seen at chapter 7 we can generate our 'BUY NOW' buttons really easily directly from PayPal.
This method is easy but kind of slow. If you have a small amount of products this is not big deal, but what happens if you have fifty or more digital products to add? In this section it is proposed an alternative method to generate the 'BUY NOW' buttons directly from your computer. You can generate huge quantity of 'BUY NOW' buttons in a few seconds. The only bad thing about this solution is that works only under Windows. The PPEncrypt tool (download PPEncrypt tool) made by the development team of PayPal is written in .NET. The PPEncryptGUI is a Graphical User Interface made by the author for the scope of this e-book. It will be shown to you how to use this tool in this section.
You may have already noticed some PayPal Button generators at the web but they produce clear code (unsecure) and not encrypted. Do you remember the 'Button Encryption option' at the PayPal Create button generator seen on chapter 7?

The real problem here is the encryption and not the generation of a 'BUY NOW' button. PPEncryptGUI generates encrypted 'BUY NOW' buttons like PayPal recommends. Please note that the core of this program (PPEncrypt) is developed by PayPal itself. Let's see the needed steps to make it work correctly.
  • Installing .NET framework.
  • As said before PPEncrypt is written over the .NET framework so this framework is needed in order to run this program. If you are unsure if you have the .NET framework, just go to your WINDOWS folder and see if you have any folder called 'Microsoft.Net'. If you have a structure like this :
    you already have the framework installed and the version is shown at the subfolder of the folder Framework. At windows vista .NET framework is already included. Anyway you can get the latest version of the .NET framework going to : . Make sure to download the Redistributable Package. If you are unsure or cannot find the redistributable package use Google with these keywords : 'download .net Redistributable Package'.
  • Installing OpenSLL.
  • Download and install OpenSSL Light from: or from
  • Configuring OpenSSL.
  • On windows go to Start -> Control Panel -> System. Hit the 'Advanced tab' and then the 'Environment Variables' button. A new form will appear with name 'Environment Variables', now, under the groupbox 'System variables' double click on 'Path'. Figure fig:78
    Windows Environment Variables
    fig:78 Windows Environment Variables

    This should open the 'Edit System Variable' form dialog. Go to the end of the line in the 'Variable value' text box and enter a semicolon ';C:\OpenSSL\bin' and click on 'OK' 'OK' 'OK' to save the changes. Figure fig:79
    Edit System Variables
    fig:79 Edit System Variables

  • Generate a private key.
  • Go to Start -> Run write 'cmd' to load the console. Write to the console :
    openssl genrsa -out my-prvkey.pem 1024
    Please do not close the console.
  • Generate public certificate.
  • Always at the console write :
    openssl req -new -key my-prvkey.pem -x509 -days 999 -out my-pubcert.pem
    Now you will be asked a few questions like country code, locality name etc... fill them with the correct information. Figure fig:80
    Testing Site Step 1
    fig:80 OpenSSL commandline and questions

    Find the generated files my-prvkey.pem my-pubcert.pem. The figure fig:81 will help you locate the containing folder of the my-prvkey.pem my-pubcert.pem files.
    Locating the generated files by OpenSLL
    fig:81 Locating the generated files by OpenSLL

  • Get the PayPal Public Certificate and your cert_id from PayPal.
  • Go to -> Profile -> Encrypted Payment Settings. Press the 'Add' button figure fig:82, in the next page hit the 'Browse' button to upload your public certificate (my-pubcert.pem) and press the 'Add' button figure fig:83.
    Adding a new public certificate at PayPal
    fig:82 Adding a new public certificate at PayPal

    Uploading the Public Certification
    fig:83 Uploading the Public Certification

    Now Download the PayPal Public Certificate paypal_cert_pem.txt fig:84
    Downloading the PayPal Public Certification.
    fig:84 Downloading the PayPal Public Certification.

    Do not forget to write down your cert_id for example AAAPAX3F6J9PD. Figure fig:85
    Finding  your Cert Id
    fig:85 Finding your Cert Id

After doing all this you should have :
  • The private key file : my-prvkey.pem.
  • The public certificate file : my-pubcert.pem.
  • The PayPal Public Certificate file : paypal_cert_pem.txt.
  • The cert_id string : like AAAPAX3F6J9PD.
Now we are ready to use PPEncryptGUI.
PPEncryptGUI does not need any installation, just include at the folder 'PPEncryptGUI' the three generated files my-prvkey.pem, my-pubcert.pem and paypal_cert_pem.txt. Please note that if you already have generated these files at one computer and you want to use the program in another computer you only have to install OpenSSL, the .NET framework and PPEncryptGUI will be ready to use. Run PPEncrypt GUI and fill it with your PayPal user name, cert_id, location, currency, return url and cancel url. Note that the location must have two letters like US for United States of America, UK for United Kingdom etc ... For return url and cancel url put the url to the 'PayPal/Code/pdthtml.php file. For example :
These values are the same for every product. Now you can start adding the products by filling the attributes : Name , Id and amount. Once you have written these values just press the 'Add product' button to add the product on your product list. Continue adding your products. When you are ready press the 'Save Job' to save all the values, of your PayPal account and your product list, into a ppe file. By pressing the 'Generate Buy Now buttons' you will generate one htm for each product with name equal at the product name. With Modify and Delete buttons you can modify and delete a selected product from the product list. Please remember always to save the job. If you closed the program when you re run it you will have a blank form. Just press the load job (ppe) to obtain the last saved status. One detail here : when you press the 'Generate Buy Now buttons' the program generates a 'run.bat' file and then generates the htm files. If you are an expert you can modify the run.bat file but it is not recommended. Anyway the gurus can modify the run.bat file and then execute it to get the 'BUY NOW' buttons. All the generated files are located at the root of the 'PPEncryptGUI' folder. Figure fig:86
PPEncrypt GUI
fig:86 PPEncrypt GUI

It is time now to test our results. Just double click at the generated htm files, these have to open with your default browser and you will see a nice 'BUY NOW' button. Figure fig:87.
Click on it to test it. The correct response of PayPal is shown on the figure fig:88. If you get errors make sure that your files my-prvkey.pem, my-pubcert.pem and paypal_cert_pem.txt are correct and the cert_id is correct too.
PPEncrypt GUI
fig:87 PPEncrypt GUI

Correct response from Paypal
fig:88 Correct response from Paypal

If everything looks ok, you can open the htm file with notepad++ copy everything and paste that code at the associated product file (example : productHX0001.php) in the attribute : $Product['ButtonLink'] like we did it before (listing "Real product file productHX0001.php"). Remember that the product file (php) must have the same attributes with those located at PPEncryptGUI tool. Figure fig:89
The same fact was true with the use of PayPal, just take a look again at the figure fig:41
Generating buttons. We must have the same attributes. In this example we have two errors.
fig:89 Generating buttons. We must have the same attributes. In this example we have two errors.

Unfortunately on some computers PPEncrypt, the core of PPEncryptGUI, has bugs and does not generate any htm files. Even in the official forum of PayPal for developers this question seems unanswered. The best thing to do is to install and convert PPEncryptGUI on another computer. I hope that this problem will be fixed as soon as possible.

Copyright © 1998-2017 - Made by TrustFm - All Rights Reserved Worldwide