Custom WooCommerce Payment Gateway on Block Theme

How to Integrate a Custom WooCommerce Payment Gateway in a Block Theme?

WooCommerce continues to evolve, and with the rise of Full Site Editing (FSE) and Block Themes, developers need to ensure their custom payment gateways are fully compatible with both Classic and Block-based checkout experiences.

In this guide, we’ll walk through the key steps to create and integrate a custom WooCommerce payment gateway that works seamlessly in a Block theme environment, including support for WooCommerce’s Cart and Checkout blocks.


🛠️ Prerequisites

  • A WordPress installation with a Block-compatible theme (e.g., Twenty Twenty-Four).
  • WooCommerce installed and activated.
  • Basic familiarity with PHP and JavaScript.

1. Create the Custom Gateway Class

First, register your gateway by extending WC_Payment_Gateway. Place your gateway code inside a plugin or theme’s functions.php for testing.

Then register the gateway:


2. Make It Block Checkout Compatible

To work with WooCommerce Blocks (used in Block themes), your gateway needs to support the woocommerce_blocks_payment_method_type interface.

Step 1: Register Gateway Integration

Create a class that extends AbstractPaymentMethodType.

Then register the integration with WooCommerce Blocks:


3. Add JavaScript for Checkout Block UI

You can add interactivity or branding using a simple JS entry point like frontend.js.

Bundle it with a tool like Webpack or use ESBuild if you prefer.


4. Test in a Block Theme

Activate a Block theme and ensure you’re using the WooCommerce Cart & Checkout blocks.

  • Go to Pages > Checkout.
  • Insert the Checkout block if it isn’t already.
  • Try placing an order with your custom gateway.

It should appear like any other payment method.


✅ Bonus Tips

  • Use wp_localize_script() to pass PHP values to JS.
  • Support payment_complete() and payment_failed() status transitions.
  • Consider adding webhook support if your gateway uses async confirmation.

Final Thoughts

Supporting WooCommerce’s Block checkout requires just a bit more setup than traditional gateways, but it’s the future-proof way to integrate payments on modern WordPress sites. Once your custom gateway supports the AbstractPaymentMethodType and registers its scripts correctly, you’re fully Block-compatible.

I recently worked with SMEPay for WooCommerce. You can review the code.

Keep your payment integration clean, test across themes, and your gateway will be a reliable option in any WooCommerce-powered store using Block themes.

Crazy about CRO?

Dessert Calories Don’t Count

Our Sales Funnel Strategy does.

We don’t spam! Read more in our privacy policy

Leave a Reply

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