<?php
/**
 * Base class for guest payment providers (Stripe, Swish).
 *
 * @package Maca_Menu_List
 */

if (!defined('ABSPATH')) {
    exit;
}

/**
 * Abstract payment provider.
 */
abstract class Maca_Menulist_Payment_Provider {

    /**
     * Unique provider id (stripe, swish).
     *
     * @return string
     */
    abstract public function get_id();

    /**
     * Human-readable name.
     *
     * @return string
     */
    abstract public function get_label();

    /**
     * Short description for admin.
     *
     * @return string
     */
    abstract public function get_description();

    /**
     * Option keys used for this provider (without maca_menulist_payment_ prefix).
     *
     * @return array<int, string>
     */
    abstract public function get_setting_keys();

    /**
     * Whether required credentials are stored.
     *
     * @return bool
     */
    public function is_configured() {
        foreach ($this->get_required_setting_keys() as $key) {
            if (maca_menulist_payments_get_setting($this->get_id(), $key) === '') {
                return false;
            }
        }

        return true;
    }

    /**
     * Keys that must be non-empty for is_configured().
     *
     * @return array<int, string>
     */
    abstract public function get_required_setting_keys();

    /**
     * Validate submitted settings; return WP_Error or true.
     *
     * @param array<string, string> $values Raw POST values keyed by setting key.
     * @return true|WP_Error
     */
    public function validate_settings($values) {
        return true;
    }

    /**
     * Admin field definitions.
     *
     * @return array<int, array<string, mixed>>
     */
    abstract public function get_admin_fields();
}
