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
- Visit Paypal Button Designer page and create a button as per your requirements
- 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 Email
If you’re logged into PayPal, you can created a PayPal hosted Buy Now button: - 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:
- 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
- Scroll down to the bottom of the form and you’ll notice a tab called ‘Additional Settings’
- Add the below code in the text area under ‘Additional Settings’ tab:on_sent_ok:”location.replace(‘PLACE YOUR PAYPAL EMAIL LINK HERE’);”In 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)
- 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!
Leave A Comment