Home > Tips & Tricks > WooCommerce Payment Gateway Class Skeleton

WooCommerce Payment Gateway Class Skeleton

If you want to build a custom woocommerce payment gateway then you need to extend the woocommerce core class. WooCommerce has many core classes such as payment gateway, email notification, etc and we can extend them into our code snippet to enhance the functionality.

To make the custom woocommerce payment gateway plugin, you need to extend the WC_Payment_Gateway class. It will give you the structure of the class and its functions.

This class has functions like: you can add the payment form field, you can add the validation on those fields. You can process the payment and you can add any webhook if you want to add.

So following are the skeleton of WooCommerce Payment Gateway class ( WC_Payment_Gateway ) that you can extend and build your own custom payment plugin from scratch.

WooCommerce Payment Gateway Class Skeleton

In the above code, you can see the first function to register the custom payment class (as registered WC_Custom_Gateway). And the second function is about to load the payment gateway plugin’s settings, form fields, process payment, webhook, etc.

Being Tricky 😉

Photo of author

About Aman Mehra

Hey there! I'm Aman Mehra, a full-stack developer with over six years of hands-on experience in the industry. I've dedicated myself to mastering the ins and outs of PHP, WordPress, ReactJS, NodeJS, and AWS, so you can trust me to handle your web development needs with expertise and finesse. In 2021, I decided to share my knowledge and insights with the world by starting this blog. It's been an incredible journey so far, and I've had the opportunity to learn and grow alongside my readers. Whether you're a seasoned developer or just dipping your toes into the world of web development, I'm here to provide valuable content and solutions to help you succeed. So, stick around, explore the blog, and feel free to reach out if you have any questions or suggestions. Together, let's navigate the exciting world of web development!

Leave a Comment