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 😉

Leave a Reply

Your email address will not be published. Required fields are marked *