# fluent-cart/1.6.0/app/Hooks/Handlers/AddonGatewaysHandler.php

FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler, version 1.6.0. 86 lines.

- Page: https://pluginprobe.com/plugins/fluent-cart/1.6.0/code/app/Hooks/Handlers/AddonGatewaysHandler.php
- Raw: https://pluginprobe.com/plugins/fluent-cart/1.6.0/raw/app/Hooks/Handlers/AddonGatewaysHandler.php
- Modified: 2026-07-01T09:25:24+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-cart/1.6.0/code/app/Hooks/Handlers/AddonGatewaysHandler.php#L10-L20`.

```php
<?php

namespace FluentCart\App\Hooks\Handlers;

use FluentCart\App\Modules\PaymentMethods\Core\GatewayManager;
use FluentCart\App\Modules\PaymentMethods\PromoGateways\Addons\PaystackAddon;
use FluentCart\App\Modules\PaymentMethods\PromoGateways\Addons\RazorpayAddon;
use FluentCart\App\Modules\PaymentMethods\PromoGateways\Addons\MercadoPagoAddon;
use FluentCart\App\Modules\PaymentMethods\PromoGateways\Addons\FlutterwaveAddon;
use FluentCart\App\Modules\PaymentMethods\PromoGateways\Addons\SquareAddon;
use FluentCart\App\Modules\PaymentMethods\PromoGateways\Addons\SslcommerzAddon;

class AddonGatewaysHandler
{
    /**
     * Default addon gateways to register
     * @var array
     */
    protected $defaultGateways = [
        'paystack'    => PaystackAddon::class,
        'razorpay'    => RazorpayAddon::class,
        'mercado_pago' => MercadoPagoAddon::class,
        'flutterwave' => FlutterwaveAddon::class,
        'square'      => SquareAddon::class,
        'sslcommerz'  => SslcommerzAddon::class,
    ];
    
    public function register()
    {
        add_action('fluent_cart/register_payment_methods', [$this, 'registerPromoGateways'], 20);
    }
    
    /**
     * Register addon gateways
     * Can be filtered to add or remove gateways
     */
    public function registerPromoGateways()
    {
        // Allow filtering of addon gateways
        $gateways = apply_filters('fluent_cart/addon_gateways', $this->defaultGateways);
        
        foreach ($gateways as $slug => $addonClass) {
            // Skip if class doesn't exist
            if (!class_exists($addonClass)) {
                continue;
            }
            
            $isGatewayRegistered = GatewayManager::has($slug);
            if (!$isGatewayRegistered) {
                $gateway = GatewayManager::getInstance();
                try {
                    $gateway->register($slug, new $addonClass());
                } catch (\Exception $e) {
                    // Log error but continue with other gateways
                    error_log(sprintf(
                        'Failed to register addon gateway %s: %s',
                        $slug,
                        $e->getMessage()
                    ));
                }
            }
        }
    }
    
    /**
     * Add a new addon gateway to the default list
     * 
     * @param string $slug
     * @param string $className
     */
    public function addGateway($slug, $className)
    {
        $this->defaultGateways[$slug] = $className;
    }
    
    /**
     * Remove an addon gateway from the default list
     * 
     * @param string $slug
     */
    public function removeGateway($slug)
    {
        unset($this->defaultGateways[$slug]);
    }
}

```
