Creating a Custom Payment Gateway — a practical guide to create WooCommerce payment gateway with clear examples you can reuse in real projects.
WooCommerce Plugin Development Series (44/101). Prefer one article? Read the complete WooCommerce plugin development tutorial.
Short description
Return thank-you redirect on success and handle failures with notices + order notes.
Gateway skeleton
class WC_Gateway_Acme extends WC_Payment_Gateway {
public function __construct() {
$this->id = 'acme';
$this->method_title = 'Acme Pay';
$this->has_fields = false;
$this->init_form_fields();
$this->init_settings();
}
public function process_payment($order_id) {
$order = wc_get_order($order_id);
$order->payment_complete();
return ['result' => 'success', 'redirect' => $this->get_return_url($order)];
}
}