Extending Payment Gateways

Extending Payment Gateways

VTUPress gateways (like Paystack, Monnify, etc.) are structured identically. They all extend the abstract class `Vtupress_Gateway`.

Base Class: `Vtupress_Gateway`

**File:** `includes/gateway_class.php`

To create a new payment gateway (e.g., “Flutterwave” or “Stripe”):

1. Create a class extending `Vtupress_Gateway`.

2. Hook into `vtupress_gateway_registry`.

Example: Adding a Custom Gateway

“`php

class Stripe_Gateway extends Vtupress_Gateway {

    public function __construct() {

        $this->id = ‘stripe’;

        $this->name = ‘Stripe Payment’;

        $this->has_webhook = true;

    }

    public function initialize_payment($amount, $user_id) {

        // Logic to redirect user to Stripe checkout

    }

    public function process_webhook($payload) {

        // Handle Stripe IPN / Webhooks here

    }

}

// Register the gateway

add_filter(‘vtupress_gateway_registry’, function($registry) {

    $registry[‘stripe’] = ‘Stripe_Gateway’;

    return $registry;

});

“`

Was this page helpful?