<?php
defined( 'ABSPATH' ) || exit;

class WCP_Gateway_UPI implements WCP_Payment_Gateway_Interface {

	public function get_id(): string {
		return 'upi';
	}

	public function get_label(): string {
		return __( 'UPI (Google Pay · PhonePe · Paytm · BHIM)', 'woocom-pay' );
	}

	public function is_enabled(): bool {
		$settings = get_option( 'woocom_pay_settings', [] );
		$gw       = $settings['gateways']['upi'] ?? [];
		// Enabled by default; only off when explicitly disabled.
		return ! isset( $gw['enabled'] ) || ! empty( $gw['enabled'] );
	}

	public function is_configured(): bool {
		$gw = get_option( 'woocommerce_woocom_pay_settings', [] );
		return ! empty( $gw['upi_id'] );
	}

	/**
	 * UPI does not use an external API.
	 * Returns the WooCommerce order-received page URL — the payment-page.php template
	 * renders the QR/UPI-intent flow on that page.
	 */
	public function create_payment( WC_Order $order, float $amount, string $return_url ): string|WP_Error {
		return $return_url;
	}
}
