<?php
/**
 * Beaver Builder module: Square Payment Link.
 *
 * @package SHC4WC
 */

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

if ( ! class_exists( 'FLBuilderModule' ) ) {
	return;
}

/**
 * Square Payment Link module for Beaver Builder.
 */
class SHC4WC_BB_Payment_Link extends FLBuilderModule {

	public function __construct() {
		parent::__construct(
			array(
				'name'            => __( 'Square Payment Link', 'payments-connect-square' ),
				'description'     => __( 'Button that sends visitors to Square Hosted Checkout to pay a fixed amount.', 'payments-connect-square' ),
				'group'           => __( 'Payments Square Connect', 'payments-connect-square' ),
				'category'        => __( 'Square', 'payments-connect-square' ),
				'dir'             => SHC4WC_PLUGIN_DIR . 'includes/beaver-builder/modules/payment-link/',
				'url'             => SHC4WC_PLUGIN_URL . 'includes/beaver-builder/modules/payment-link/',
				'icon'            => 'button.svg',
				'editor_export'   => true,
				'partial_refresh' => true,
			)
		);
	}
}

FLBuilder::register_module(
	'SHC4WC_BB_Payment_Link',
	array(
		'general' => array(
			'title'    => __( 'General', 'payments-connect-square' ),
			'sections' => array(
				'general' => array(
					'title'  => '',
					'fields' => array(
						'amount'      => array(
							'type'        => 'text',
							'label'       => __( 'Amount', 'payments-connect-square' ),
							'default'     => '25.00',
							'placeholder' => '25.00',
							'help'        => __( 'Example: 25.00', 'payments-connect-square' ),
						),
						'label'       => array(
							'type'    => 'text',
							'label'   => __( 'Button label', 'payments-connect-square' ),
							'default' => __( 'Pay Now', 'payments-connect-square' ),
						),
						'description' => array(
							'type'  => 'text',
							'label' => __( 'Description (optional)', 'payments-connect-square' ),
							'help'  => __( 'Shown on the Square Hosted Checkout page.', 'payments-connect-square' ),
						),
						'currency'    => array(
							'type'        => 'text',
							'label'       => __( 'Currency (optional)', 'payments-connect-square' ),
							'placeholder' => 'USD',
							'help'        => __( 'Leave empty to use WooCommerce store currency or USD.', 'payments-connect-square' ),
						),
					),
				),
			),
		),
	)
);
