Search for a plugin or theme

How to Integrate Contact Form 7 With PayPal

How to Integrate Contact Form 7 With PayPal

Contact Form 7 is one of the most popular WordPress plugins with thousands of users around the world.

This article will teach you how to integrate Contact Form 7 with PayPal to accept payments.

With CF7, you can only set one price for each form. If you have products with variable prices, use a different plugin such as Easy Digital Downloads or WooCommerce.

Integrate Contact Form 7 With PayPal

It’s a good idea to integrate both when a customer needs to make a payment after submitting a form.

We can accomplish that in two different ways, the first one is by using an add-on plugin, and the second way is without a plugin.

Let’s start with the first way, by using a plugin.

Contact Form 7 – PayPal Integration Plugin

In this way, we will use an add-on plugin that will help us integrate between Contact Form 7 and PayPal.

Step 1: Install the plugin

From your WordPress dashboard, navigate to Plugins -> Add New. Search for Contact Form 7 – PayPal & Stripe Add-on, install and activate it.

Install Contact Form 7 PayPal Plugin

Step 2: Set up the plugin

After activating the plugin, navigate to PayPal & Stripe Settings under the contact tab.

CF7 PayPal & Stripe Settings

On this screen, you’ll have a few tabs where we can set up the plugin.

  • Language & Currency tab – Set and change the charged currency.
  • PayPal tab – Enter your PayPal email address or your Merchant account ID. You can find your Merchant account ID in your PayPal account under Profile -> My business info. Alternatively, you can use your PayPal email address to keep it simple.
  • Other tab – Set a PayPal Cancel and Return URL. For example, you can create a new page and call it ‘Incomplete Payment’, and paste its URL in the Cancel URL field. When a customer clicks on ‘Cancel and return to merchant account’ in PayPal, he will be redirected to that page.

If the customer isn’t redirected to PayPal after submission, change the Redirect Method to Method 1 and try resubmitting the form again.

When done, click on the ‘Save Settings’ button.

Step 3: Enable PayPal for the form

On this step, navigate to the form that you would like to integrate with PayPal (Contact tab -> Contact Forms -> Edit form).

Inside the form options, navigate to the PayPal & Stripe tab.

Check the Enable PayPal on this form box, enter the item description and amount, and click Save.

Enable PayPal to a specific form

Step 4: Test the form

When the form is ready, fill and submit it. Then, you will be redirected to PayPal to complete the sale.

If you are not being redirected, change the Redirect Method under the PayPal & Stripe settings tab, and resubmit the form.

Integrate Without a Plugin

Using this method, we will integrate CF7 with PayPal without a plugin.

Step 1: Create a PayPal button.

The first step is to create a PayPal link with a price amount. To do that, we will need to create a button.

Log in to your PayPal account and go to Tools -> All Tools.

On the left sidebar, click on Integrate PayPal and then on Buttons.

Create PayPal Button

Here you’ll have a few buttons to chose from. Because we will use the button link only without displaying the button on our website, chose a simple button like Buy Now.

Create a buy now button

Fill in the Item name field and the price (chose the right currency for you).

You also having the option to add a shipping cost (if it’s a physical product) and tax rate.

In steps 2 and 3, set advanced options such as track inventory, profit & loss and etc. Both steps (2 and 3) are optional and we won’t get into it in this tutorial.

When you all done, click Create Button.

Create the PyaPal buy now button

On the next screen, you’ll have the button URL under the Email tab. We will use it in a second.

Copy the PayPal URL button link

Step 2: Use an integration function

After creating the button and got the button link, we will need to use a function to integrate CF7 with PayPal.

To do that, paste the code below at the bottom of the functions.php file of your child theme or a site-specific plugin.

If you don’t use a child theme yet, read our article on how to create a child theme.

From your WordPress dashboard, navigate to Appearance -> Theme Editor and click on the functions.php file from the right sidebar.

Now, scroll to the bottom and paste this code.

add_action( 'wp_footer', 'pfwp_connect_cf7_with_paypal' );
 
function pfwp_connect_cf7_with_paypal() {
?>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
    if ( 'FORM ID HERE' == event.detail.contactFormId ) {
        location = 'LINK HERE';
    }
}, false );
</script>
<?php
}

Change the Form ID HERE with the actual ID of the form (you can find it in the form shortcode).

[contact-form-7 id="64" title="Cake Decoration Form"]

Change the Link Here with the actual link of the PayPal button (the one we’ve created a second ago). When done, Save the changes.

Paste the function in the functions php file

Step 3: Test the form

Now, navigate to the page with that contact form.

Fill the form and submit it. If you set it up correctly you will be redirected to PayPal and you’ll see the button price and description.

Conclusion

In this article, you learned how to integrate the Contact Form 7 plugin with PayPal to accept payments.

You may also be interested in how to integrate ReCaptcha with Contact Form 7.

If you have any questions, please watch the video and leave us a comment down below.

Also, make sure to subscribe to our YouTube channel and like our page on Facebook.

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on email

PluginsForWP

PluginsForWP is a website specializing in redistributing WordPress plugins and themes with a variety of knowledge about WordPress, internet marketing, and blogging.

Leave a Reply