Few days back, we were working on a project for a customer where she wanted to start accepting online payments through PayPal for student’s registration. This is the link of the project – http://jeilivingston.com/class-registration/. The registration form was created using Contact Form 7 plugin – one of the famous wordpress plugin to create forms quickly in wordpress sites. We followed two steps approach to fulfill this requirement:

Create PayPal BuyNow button

  1. Visit Paypal Button Designer page and create a button as per your requirements
    PayPal Button Designer - Buy Now Button
  2. Once you create the BuyNow button, PayPal will you two types of code
    – HTML code to embed into your website
    – A link which you can send via Email to accept payments through EmailPayPal Non-hosted Button Email Link
    If you’re logged into PayPal, you can created a PayPal hosted Buy Now button:PayPal Hosted Button Email Link
  3. Copy the link from the ‘Email’ tab

Integrating PayPal payment link with your Contact Form 7

This step uses on_sent_ok JavaScript action hook provided by the Contact Form 7 plugin. By using this hook, you can specify a JavaScript code that you wish to run after the form is successfully submitted. Here are the steps:

  1. Login to the WordPress admin of your site, select the Contact Form 7 tab (‘Contact’) on the left and edit the form where you would like to integrate PayPal payment gateway
  2. Scroll down to the bottom of the form and you’ll notice a tab called ‘Additional Settings’
  3. Add the below code in the text area under ‘Additional Settings’ tab:on_sent_ok:”location.replace(‘PLACE YOUR PAYPAL EMAIL LINK HERE’);”Contact Form 7 Additional SettingsIn the above statement, we’re using the on_sent_ok JavaScript action hook to execute the location.replace javascript function to redirect to the PayPal url (i.e. the Email link)
  4. Save your form

Now whenever a user submits the contact form, on successful form submission he will be redirected to PayPal to make the payment!