# How to Create a Custom Payment Gateway for Paymattic?

> This article talks about how you can create a custom payment gateway add-on for Paymattic in six simple steps. No extra coding needed. Just hook and deploy.

- URL: https://paymattic.com/create-a-custom-payment-gateway-for-paymattic/
- Markdown: https://paymattic.com/create-a-custom-payment-gateway-for-paymattic/index.md
- Modified: 2026-02-26

---

![how to create a custom payment gateway for paymattic](https://paymattic.com/wp-content/uploads/2025/11/How-to-create-a-custom-payment-gateway-for-Paymattic-scaled.webp)

- [Features](/category/features/)

8 Min Read

# How To Create A Custom Payment Gateway For Paymattic? (A Simple Guide For Developers)

[![Mahfuzur Rahman Nafi](/_mirror/3724388f-15e4249bd34136b8e392ad068a485073d2a54aef33a8091d8778cbb72224.png) Mahfuzur Rahman Nafi Marketing Strategist](https://paymattic.com/author/mahfuz-nafi/)

Reviewed

By

Editorial Team

 Hide

Updated February 26, 2026

Summarize with: 

[![Claude AI Icon](/_mirror/d0be93af-Frame-1321317365-2.png)](https://claude.ai/new?q=Summarize%20the%20blog%20clearly%20and%20concisely%3A%20https%3A%2F%2Fpaymattic.com%2Fcreate-a-custom-payment-gateway-for-paymattic%2F) [![Grok AI Icon](/_mirror/933e5f8f-Frame-1538234108.png)](https://grok.com/?q=Summarize%20the%20blog%20clearly%20and%20concisely%3A%20https%3A%2F%2Fpaymattic.com%2Fcreate-a-custom-payment-gateway-for-paymattic%2F) [![Google AI Mode](/_mirror/6b468f7b-Frame-1321317980-3.png)](https://gemini.google.com/app?q=Summarize%20the%20blog%20clearly%20and%20concisely%3A%20https%3A%2F%2Fpaymattic.com%2Fcreate-a-custom-payment-gateway-for-paymattic%2F) [![ChatGPT Icon](/_mirror/70a9d48c-Frame-1538234107.png)](https://chatgpt.com/?q=Summarize%20the%20blog%20clearly%20and%20concisely%3A%20https%3A%2F%2Fpaymattic.com%2Fcreate-a-custom-payment-gateway-for-paymattic%2F)

Table of Content

**Download Paymattic – it’s Free!**

Download Now

![Download Paymattic - it's Free!](/_mirror/e1ed4556-Download-Paymattic-its-Free-banne3r.webp)

**Subscribe To Get**

WordPress Guides, Tips, and Tutorials

We will never spam you. We will only send you product updates and tips.

Paymattic already integrates with 14 payment gateways, including major platforms like Stripe, PayPal, and Authorize.net. Also, there’s an offline payment method.

But 14 is not enough if your business or nonprofit needs a payment gateway that is not available in Paymattic.

We understand the situation. You want the feature. But the payment gateway is not supporting you. This is exactly why I’m writing this article.

**If you are a developer or have a team to do some coding, you can create your own custom payment gateway for Paymattic.**

Paymattic is incredibly flexible and shows all the necessary hooks to create a custom payment gateway add-on. And it takes no more than 1 hour.

> In this article, I’ll show you how you can create your custom payment gateway add-on for Paymattic. At the end of the article, I’ve attached a real-time demo of how we made the Mollie payment gateway add-on for Paymattic.

So, let’s get started.

## **What will you build?**

After going through this article and implementing the steps, you’ll be able to build your own **payment gateway add-on** for Paymattic. You can use it for your purpose or sell it if you want.

So, let’s see what you’ll build. You’ll build a complete payment gateway add-on that –

- Shows up in Paymattic’s payment method selector
- Handles one-time payments seamlessly
- Manages subscription (if needed)
- Processes refunds and confirmations (if needed)

## **Why is it so easy?**

Paymattic was designed with developers in mind. Its architecture prioritizes flexibility, speed, and zero friction during integration.

That’s why building a new gateway isn’t a painful process. Rather, it’s modular, predictable, and elegant.

**Paymattic offers:**

- **Standard WordPress hooks system:** Extend without breaking the core
- **Clean API interfaces:** Communicate with any payment provider effortlessly
- **Automatic form rendering:** Your gateway elements appear instantly in forms
- **Built-in transaction management:** Track, refund, and verify payments from one place
- **Zero core modifications:** Everything runs as an add-on. There’s no code hacking or version conflicts

## **The SIX-step process to build a payment gateway for Paymattic**

In only six steps, you’ll be able to create your custom payment gateway for Paymattic. And it’ll show up in the Paymattic’s Payment Gateway menu with necessary settings as well as the Paymattic form builder.

Let’s look at the steps.

### **Step 1: Set up your plugin structure**

Before diving into the code, let’s get your foundation right.

Every solid plugin starts with a clean, organized structure. So should your custom payment gateway for Paymattic.

Here’s the recommended folder layout:

📁 Recommended Folder Layout:

Copy to clipboard

```
your-gateway-<span class="hljs-keyword">for</span>-paymattic/
├── your-gateway-<span class="hljs-keyword">for</span>-paymattic.<span class="hljs-title function_ invoke__">php</span> (main plugin file)
├── API/
│   ├── YourGatewayProcessor.<span class="hljs-title function_ invoke__">php</span> (payment logic)
│   └── API.<span class="hljs-title function_ invoke__">php</span> (gateway API calls)
└── Settings/
    ├── YourGatewayElement.<span class="hljs-title function_ invoke__">php</span> (form element)
    └── YourGatewaySettings.<span class="hljs-title function_ invoke__">php</span> (admin settings)
```

This simple structure keeps your code modular and easy to scale.

- The **main plugin** file initializes everything.
- The **API folder** handles *your gateway logic* and *external API requests*.
- The **Settings folder** contains everything related to *user configuration* and *form elements* in Paymattic.

This simple layout ensures that your custom gateway remains developer-friendly, maintainable, and compatible with future Paymattic updates.

### **Step 2: Register your payment gateway**

Now that your structure is ready, it’s time to make your gateway come alive.

The first step is registering it with WordPress and Paymattic.

Open your main plugin file and add this header to boot up your gateway:

📑 Register your gateway:

Copy to clipboard

1

2

```
Plugin Name: YourGateway For Paymattic
Description: Custom payment gateway <span class="hljs-keyword">for</span> Paymattic
```

This tells WordPress what your plugin is and helps Paymattic recognize it as a compatible payment gateway.

Once registered, Paymattic automatically integrates with your plugin’s logic, and no extra configuration or complicated setup is required. That’s the beauty of Paymattic’s developer-friendly architecture.

You just set up the foundation, and Paymattic does the rest. In a few lines of code, you’ve built a Paymattic add-on that can integrate seamlessly into any WordPress payment workflow.

Think of this step as flipping the power switch. From here, your gateway is officially part of the Paymattic ecosystem.

### **Step 3: Set up the processor *init( )* method**

Now comes the real magic. We’ll connect your custom gateway to Paymattic’s payment engine. This is where your gateway logic comes to life.

In your processor file, create a **`init( )`** method and initialize everything inside it.

This is the heart of your integration, where your settings, form elements, and API all start working together.

🐘

Processor init( ) method:

Copy to clipboard

1

2

3

4

5

6

7

8

9

10

11

```
<span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">init</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-comment">// Initialize your components</span>
    <span class="hljs-keyword">new</span> <span class="hljs-title class_">YourGatewayElement</span>();
    (<span class="hljs-keyword">new</span> <span class="hljs-title class_">YourGatewaySettings</span>())-><span class="hljs-title function_ invoke__">init</span>();
    (<span class="hljs-keyword">new</span> <span class="hljs-title function_ invoke__">YourGatewayAPI</span>());

    <span class="hljs-comment">// Hook into Paymattic's payment system</span>
    <span class="hljs-title function_ invoke__">add_filter</span>(<span class="hljs-string">'wppayform/choose_payment_method_for_submission'</span>, <span class="hljs-keyword">array</span>(<span class="hljs-variable">$this</span>, <span class="hljs-string">'choosePaymentMethod'</span>), <span class="hljs-number">10</span>, <span class="hljs-number">4</span>);
    <span class="hljs-title function_ invoke__">add_action</span>(<span class="hljs-string">'wppayform/form_submission_make_payment_yourgateway'</span>, <span class="hljs-keyword">array</span>(<span class="hljs-variable">$this</span>, <span class="hljs-string">'makeFormPayment'</span>), <span class="hljs-number">10</span>, <span class="hljs-number">7</span>);
    <span class="hljs-title function_ invoke__">add_action</span>(<span class="hljs-string">'wppayform_load_checkout_js_yourgateway'</span>, <span class="hljs-keyword">array</span>(<span class="hljs-variable">$this</span>, <span class="hljs-string">'addCheckoutJs'</span>), <span class="hljs-number">10</span>, <span class="hljs-number">3</span>);
}
```

**What’s happening here:**

- Your gateway’s components are being loaded and initialized.
- You’re using Paymattic’s hooks to tie your payment logic into the system.
- The `choosePaymentMethod`, `makeFormPayment`, and `addCheckoutJs` actions handle how your gateway behaves during checkout.

Once this is in place, your gateway becomes an active part of Paymattic’s payment flow. You’re no longer building in isolation. Your custom payment gateway now talks directly with Paymattic’s form submissions and payment events.

This is where your custom logic, API requests, and transaction flow all come together.

### **Step 4: Create the payment element**

Now it’s time to make your gateway visible to users. This step ensures your new payment method actually shows up in Paymattic’s form builder.

To do this, extend Paymattic **`BaseComponent`** and define your gateway details:

- Set your gateway name so Paymattic can identify it.
- Add your logo or brand icon to display in the payment options.
- Define the payment method label that users will see on the form.
- Finally, push it to the list of available payment methods.

Once done, your gateway appears in Paymattic’s form builder interface. And it’s ready for users to enable it just like PayPal, Stripe, or any other supported gateway in Paymattic.

From here, you can test your full flow, refine your API integration, and customize the front-end experience to match your brand.

Your custom payment gateway is officially live in Paymattic. And it’s working seamlessly from backend logic to frontend display.

### **Step 5: Build your API and Settings classes**

This step focuses on two key classes that make your gateway functional, secure, and configurable.

#### **Settings Class:**

This class manages everything related to admin configuration, including API credentials, live/test mode toggles, and any custom options you want your users to adjust from the dashboard. It’s the bridge between your plugin’s backend and the Paymattic admin interface.

#### **API Class:**

This is where the actual communication with your payment provider happens. The API class sends requests, receives responses, and ensures every transaction is processed correctly. You’ll define methods for creating payments, verifying responses, and handling webhooks.

Together, these two classes form the backbone of your gateway’s payment logic. They handle all the critical operations securely and without cluttering your core files.

From here, you’re just a few configurations away from a working, production-ready custom payment gateway add-on.

### **Step 6: Configure your gateway fields**

Your next task is to define the fields your gateway will use inside the admin panel. These fields tell Paymattic what credentials, keys, and settings your gateway requires to operate.

In your settings class, define a **`globalFields()`** method to list out all necessary inputs.

**Paymattic supports a wide range of field types, including text boxes, dropdowns, and checkboxes:**

- **`payment_mode`** – Switch between Test and Live environments
- **`test_pub_key`** & **`live_pub_key`** – Public API keys
- **`test_secret_key`** and **`live_secret_key`** – Secret API keys
- **`text`** – For custom labels, merchant IDs, or button text
- **`checkbox`** – To enable or disable specific features
- **`html_attr`** – For documentation links or webhook URLs

An example setup should look like this:

🧩 And example setup:

Copy to clipboard

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

```
<span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">globalFields</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">array</span>(
        <span class="hljs-string">'payment_mode'</span> => <span class="hljs-keyword">array</span>(
            <span class="hljs-string">'type'</span> => <span class="hljs-string">'payment_mode'</span>,
            <span class="hljs-string">'options'</span> => <span class="hljs-keyword">array</span>(<span class="hljs-string">'test'</span> => <span class="hljs-string">'Test'</span>, <span class="hljs-string">'live'</span> => <span class="hljs-string">'Live'</span>)
        ),
        <span class="hljs-string">'live_api_key'</span> => <span class="hljs-keyword">array</span>(
            <span class="hljs-string">'type'</span> => <span class="hljs-string">'live_pub_key'</span>,
            <span class="hljs-string">'required'</span> => <span class="hljs-literal">true</span>,
            <span class="hljs-string">'label'</span> => <span class="hljs-string">'Live API Key'</span>
        ),
        <span class="hljs-string">'button_text'</span> => <span class="hljs-keyword">array</span>(
            <span class="hljs-string">'type'</span> => <span class="hljs-string">'text'</span>, 
            <span class="hljs-string">'value'</span> => <span class="hljs-string">'Pay with YourGateway'</span>
        )
    );
}
```

And that’s it. Your custom payment gateway add-on is ready.

Paymattic automatically generates a clean, user-friendly admin interface based on your field definitions. No extra coding is required. From here, users can configure their credentials, test payments, and switch environments.

Your gateway is now fully integrated, customizable, and ready to process real transactions.

**💁🏻‍♂️ Pro Tip: Start with [Paymattic’s Mollie add-on](https://github.com/WPManageNinja/mollie-for-paymattic) example on GitHub. It’s a complete, working implementation you can customize in minutes.**

## **The final result**

Once your gateway is fully integrated, you’ll see the beauty of Paymattic’s flexible architecture in action.

Your custom payment gateway add-on now works hand-in-hand with major processors like Stripe, PayPal, and Razorpay within the same clean Paymattic interface.

**Here’s what you’ve achieved:**

- Your payment gateway appears alongside Paymattic’s built-in options, styled automatically with no extra front-end work.
- Processes payments using your own API logic while maintaining full compatibility with Paymattic’s payment flow.
- Confirms transactions instantly, giving users a smooth checkout experience and accurate transaction feedback.
- Manages everything inside Paymattic’s dashboard, from payment history to transaction logs and customer details.

Subscribe Newsletter

Subscribe to our newsletter for updates, exclusive offers, and news you won’t miss!

![Email Newsletter image](/_mirror/95ca8311-blog-cta-banner-2.webp)

## **Test and deploy**

You don’t have to start from scratch. To save time, grab Paymattic’s live Mollie add-on as your base structure and build from there.

[Our Mollie add-on](https://github.com/WPManageNinja/mollie-for-paymattic) took just 30 minutes to build, and it handles –

- One-time payments
- Recurring subscriptions
- Payment confirmations
- Refund processing

**Here’s your quick launch checklist:**

- Download the Mollie add-on from Paymattic’s GitHub repository.
- Replace every instance of “mollie” with your gateway’s name.
- Update the API calls to connect your chosen payment provider.
- Run a quick test and then deploy

## **Conclusion**

Integrating a payment gateway used to mean days of documentation, endless debugging, and deep core edits. With Paymattic, we made it super simple and super easy.

Paymattic handles the complex parts for you: rendering forms, processing transactions, and managing payment data. All you need to do is plug in your API and focus on your needs.

Join the thousands already enjoying Paymattic Pro!

[Try Paymattic Pro](/pricing/) Start For Free

- [Facebook](https://www.facebook.com/paymattic)
- [Instagram](https://www.instagram.com/Paymattic)
- [LinkedIn](https://www.linkedin.com/company/paymattic/)
- [X](https://x.com/Paymattic)
- [WordPress](https://wordpress.org/plugins/wp-payment-form/)
- [YouTube](https://youtube.com/playlist?list=PLXpD0vT4thWH80g5e9wYnoBMgEqUXbr53&si=WtVIZVVrXyyDm94H)

![Mahfuzur Rahman Nafi](/_mirror/3724388f-15e4249bd34136b8e392ad068a485073d2a54aef33a8091d8778cbb72224.png)

## Mahfuzur Rahman Nafi

Mahfuzur Rahman Nafi is a Marketing Strategist at WPManageNinja. With 4 years of experience in Product Marketing, he has developed marketing strategies, launched products, written content, and published websites for WordPress products. In his free time, he loves to read geeky stuffs.

## Popular Articles

- [![add gift aid to wordpress donation form](/_mirror/500efcc4-Add-gift-aid-to-WordPress-Donation-form-1024x536.webp)](/add-gift-aid-to-wordpress-donation-form/)
- [![4.6.25](/_mirror/45bd3132-4.6.25-1024x536.webp)](/paymattic-4-6-25/)
- [![accept stripe recurring payments in wordpress 1](/_mirror/f98b9fe3-ccept-Stripe-Recurring-Payments-in-WordPress-1-1024x536.webp)](/stripe-recurring-payments/)
- [![Stripe payment gateway a complete guide](/_mirror/d880022d-Stripe-Payment-Gateway-A-Complete-Guide-1024x536.webp)](/stripe-payment-gateway/)
- [![reduce credit card processing fees for donations](/_mirror/73dc39c6-duce-Credit-Card-Processing-Fees-for-Donations-1024x536.webp)](/how-to-reduce-credit-card-processing-fees/)
- [![add gift aid to wordpress donation form](/_mirror/500efcc4-Add-gift-aid-to-WordPress-Donation-form-1024x536.webp)](/add-gift-aid-to-wordpress-donation-form/)
- [![4.6.25](/_mirror/45bd3132-4.6.25-1024x536.webp)](/paymattic-4-6-25/)
- [![accept stripe recurring payments in wordpress 1](/_mirror/f98b9fe3-ccept-Stripe-Recurring-Payments-in-WordPress-1-1024x536.webp)](/stripe-recurring-payments/)
- [![Stripe payment gateway a complete guide](/_mirror/d880022d-Stripe-Payment-Gateway-A-Complete-Guide-1024x536.webp)](/stripe-payment-gateway/)
- [![reduce credit card processing fees for donations](/_mirror/73dc39c6-duce-Credit-Card-Processing-Fees-for-Donations-1024x536.webp)](/how-to-reduce-credit-card-processing-fees/)
- [![add gift aid to wordpress donation form](/_mirror/500efcc4-Add-gift-aid-to-WordPress-Donation-form-1024x536.webp)](/add-gift-aid-to-wordpress-donation-form/)
- [![4.6.25](/_mirror/45bd3132-4.6.25-1024x536.webp)](/paymattic-4-6-25/)
- [![accept stripe recurring payments in wordpress 1](/_mirror/f98b9fe3-ccept-Stripe-Recurring-Payments-in-WordPress-1-1024x536.webp)](/stripe-recurring-payments/)
- [![Stripe payment gateway a complete guide](/_mirror/d880022d-Stripe-Payment-Gateway-A-Complete-Guide-1024x536.webp)](/stripe-payment-gateway/)
- [![reduce credit card processing fees for donations](/_mirror/73dc39c6-duce-Credit-Card-Processing-Fees-for-Donations-1024x536.webp)](/how-to-reduce-credit-card-processing-fees/)
- [![add gift aid to wordpress donation form](/_mirror/500efcc4-Add-gift-aid-to-WordPress-Donation-form-1024x536.webp)](/add-gift-aid-to-wordpress-donation-form/)
- [![4.6.25](/_mirror/45bd3132-4.6.25-1024x536.webp)](/paymattic-4-6-25/)

### Leave a Reply [Cancel reply](/create-a-custom-payment-gateway-for-paymattic/#respond)
