<?php
/**
 * PeachPay Square payment integration admin settings.
 *
 * @package PeachPay
 */

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

/**
 * .
 */
final class PeachPay_Admin_Square_Integration {
	use PeachPay_Admin_Extension;

	/**
	 * .
	 */
	private function init() {
		peachpay_square_sync_apple_pay_domain_status();

		add_action(
			'peachpay_admin_add_payment_setting_section',
			function () {
				$class = 'pp-header pp-sub-nav-square no-border-bottom';

				add_settings_field(
					'peachpay_square_setting',
					null,
					array( 'PeachPay_Admin_Square_Integration', 'do_admin_page' ),
					'peachpay',
					'peachpay_payment_settings_section',
					array( 'class' => $class )
				);
			}
		);
	}

	/**
	 * Square admin page HTML. This is embedded on the page ?page=peachpay&section=payments
	 */
	public static function do_admin_page() {
		?>
		<div id="square" class="peachpay-setting-section">
			<div>
				<?php
				require PeachPay::get_plugin_path() . '/core/payments/square/admin/views/html-square-connect.php';
				?>
			</div>
			<?php if ( peachpay_square_connected() ) : ?>
				<div>
					<?php
					$gateway_list = PeachPay_Square_Integration::get_payment_gateways();
					require PeachPay::get_plugin_path() . '/core/admin/views/html-gateways.php';
					?>
				</div>
			<?php endif; ?>
		</div>
		<?php
	}
}
PeachPay_Admin_Square_Integration::instance();
