Enhancing Paypal for Political Contributions

by Jonas Palmero on August 11, 2011

in Blog, Digital

As you may know, PayPal does not offer a form that collects “Employer and Occupation” information from the donor, which is required for every Federal race, and most other political election contributions.  Go figure.

When we asked PayPal about this, they agreed this is an issue with their political campaign customers, but could not say what they were going to do about it or when.  This seems very strange.

In order to help a client who wanted to use PayPal for their online contributions back-end, we set out to enhance PayPal for political contributions.

The tricky parts were how to push data into Paypal and how to make sure the donor fills in all the information required by law.

Pushing data to Paypal
After you create a new donation button with Paypal.com, you are given a basic html code which simply links a button to your Paypal page.

Thankfully, you can push more data by adding some extra HTML code.

How does this work?
By adding some HTML between the <form> and </form> tags:

 <form id="contribution_form action="" method=""> ... <input type="hidden" value="Employer" name="on0"> <input type="hidden" value="Occupation" name="on1"> <input type="text" name="os0" /> <input type="text" name="os1" /> <input type="submit" value="Submit"> </form> 

Great, now we can push data to Paypal, but how do we make sure the donor fills in all of the required information? There are many solutions to achieve this, but we decided to use the reliable and cross-browser compatible JQuery library.

Securing the form
If your website is not already using JQuery, you need to call it somewhere in your header. You will also need to call the Jquery Validate plugin:

 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script type="text/javascript" src="http://mywebsite.com/jquery.validate.js"></script> 

Is that it? Not exactly.
You still have to indicate to the plugin which form to secure and which fields need to be secured:

 <script type="text/javascript"> $(document).ready(function(){ $("#contribution_form").validate(); }); </script> ... <form id="contribution_form action="" method=""> <input name="os0" type="text" class="required" /> <input name="os1" type="text" class="required" /> ... </form> 

Required Fields

You’re done! The “required” class indicates to the plugin which fields need to be filled. Your campaign website is now equipped to accept donations using Paypal. For more on setting up Paypal donations, visit their site.

Previous post:

Next post: