<?php
/**
 * Gift Card Upsell Gateway Stub
 *
 * Gift cards cannot be used for upsell payments because they require
 * the customer to enter the gift card number for each transaction.
 * This stub class exists to properly register the gateway with FunnelKit
 * and indicate that upsells are not supported.
 *
 * @package FunnelKit_Square
 * @subpackage Payment
 */

namespace FKWCSQ\Includes\Modules\Payment\Upsell;

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

/**
 * Gift_Card class.
 *
 * Stub implementation that indicates gift cards don't support upsells.
 */
class Gift_Card extends \WFOCU_Gateway {

	/**
	 * Singleton instance.
	 *
	 * @var self
	 */
	protected static $instance = null;

	/**
	 * Payment gateway key.
	 *
	 * @var string
	 */
	public $key = 'fkwcsq_gift_card';

	/**
	 * Constructor.
	 */
	public function __construct() {
		parent::__construct();
		$this->refund_supported = false;
	}

	/**
	 * Get singleton instance.
	 *
	 * @return self Instance of this class.
	 */
	public static function get_instance() {
		if ( null === self::$instance ) {
			self::$instance = new self();
		}

		return self::$instance;
	}

	/**
	 * Check if the gateway has a token for upsell payments.
	 *
	 * Gift cards cannot be tokenized for future use, so this always returns false.
	 *
	 * @param \WC_Order $order The order object.
	 * @return bool Always returns false.
	 */
	public function has_token( $order ) {
		return false;
	}

	/**
	 * Check if the gateway is available for upsells.
	 *
	 * Gift cards are not available for upsells.
	 *
	 * @return bool Always returns false.
	 */
	public function is_available() {
		return false;
	}

	/**
	 * Process the upsell charge.
	 *
	 * This method should never be called since has_token() returns false.
	 *
	 * @param \WC_Order $order The order object.
	 * @return array Error response.
	 */
	public function process_charge( $order ) {
		return array(
			'result'  => 'error',
			'message' => __( 'Gift cards cannot be used for upsell payments.', 'funnelkit-payment-gateway-square-for-woocommerce' ),
		);
	}
}
