🏨 Hotel Booking Enhancements: - Implemented Eagle Booking Advanced Pricing add-on - Added Booking.com-style rate management system - Created professional calendar interface for pricing - Integrated deals and discounts functionality 💰 Advanced Pricing Features: - Dynamic pricing models (per room, per person, per adult) - Base rates, adult rates, and child rates management - Length of stay discounts and early bird deals - Mobile rates and secret deals implementation - Seasonal promotions and flash sales 📅 Availability Management: - Real-time availability tracking - Stop sell and restriction controls - Closed to arrival/departure functionality - Minimum/maximum stay requirements - Automatic sold-out management 💳 Payment Integration: - Maintained Redsys payment gateway integration - Seamless integration with existing Eagle Booking - No modifications to core Eagle Booking plugin 🛠️ Technical Implementation: - Custom database tables for advanced pricing - WordPress hooks and filters integration - AJAX-powered admin interface - Data migration from existing Eagle Booking - Professional calendar view for revenue management 📊 Admin Interface: - Booking.com-style management dashboard - Visual rate and availability calendar - Bulk operations for date ranges - Statistics and analytics dashboard - Modal dialogs for quick editing 🔧 Code Quality: - WordPress coding standards compliance - Secure database operations with prepared statements - Proper input validation and sanitization - Error handling and logging - Responsive admin interface 🤖 Generated with Claude Code (https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
273 lines
10 KiB
PHP
273 lines
10 KiB
PHP
<?php
|
|
defined('ABSPATH') || exit;
|
|
|
|
class EB_Redsys_Settings {
|
|
private $option_group = 'eb_redsys_settings';
|
|
private $page_slug = 'eb-redsys-settings';
|
|
|
|
public function __construct() {
|
|
add_action('admin_menu', array($this, 'add_settings_page'));
|
|
add_action('admin_init', array($this, 'register_settings'));
|
|
add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
|
|
add_filter('eb_payment_methods', array($this, 'add_payment_method'));
|
|
}
|
|
|
|
/**
|
|
* Add settings page to menu
|
|
*/
|
|
public function add_settings_page() {
|
|
if (!function_exists('eb_get_option')) {
|
|
add_menu_page(
|
|
__('Redsys Gateway', 'eb-redsys-gateway'),
|
|
__('Redsys Gateway', 'eb-redsys-gateway'),
|
|
'manage_options',
|
|
$this->page_slug,
|
|
array($this, 'render_settings_page'),
|
|
'dashicons-money-alt',
|
|
85
|
|
);
|
|
} else {
|
|
add_submenu_page(
|
|
'eb_bookings',
|
|
__('Redsys Gateway', 'eb-redsys-gateway'),
|
|
__('Redsys Gateway', 'eb-redsys-gateway'),
|
|
'manage_options',
|
|
$this->page_slug,
|
|
array($this, 'render_settings_page')
|
|
);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Register plugin settings
|
|
*/
|
|
public function register_settings() {
|
|
register_setting($this->option_group, 'eb_redsys_enabled', array('default' => 'yes'));
|
|
register_setting($this->option_group, 'eb_redsys_test_mode', array('default' => 'yes'));
|
|
register_setting($this->option_group, 'eb_redsys_merchant_code');
|
|
register_setting($this->option_group, 'eb_redsys_terminal');
|
|
register_setting($this->option_group, 'eb_redsys_encryption_key');
|
|
register_setting($this->option_group, 'eb_redsys_title', array(
|
|
'default' => __('Credit Card (Redsys)', 'eb-redsys-gateway')
|
|
));
|
|
register_setting($this->option_group, 'eb_redsys_description', array(
|
|
'default' => __('Pay securely via credit card using Redsys.', 'eb-redsys-gateway')
|
|
));
|
|
register_setting($this->option_group, 'eb_redsys_enable_future_payments', array('default' => 'no'));
|
|
register_setting($this->option_group, 'eb_redsys_enable_subscriptions', array('default' => 'no'));
|
|
|
|
// Register sections and fields
|
|
add_settings_section(
|
|
'eb_redsys_general_section',
|
|
__('General Settings', 'eb-redsys-gateway'),
|
|
array($this, 'render_general_section'),
|
|
$this->page_slug
|
|
);
|
|
|
|
add_settings_section(
|
|
'eb_redsys_api_section',
|
|
__('API Credentials', 'eb-redsys-gateway'),
|
|
array($this, 'render_api_section'),
|
|
$this->page_slug
|
|
);
|
|
|
|
add_settings_section(
|
|
'eb_redsys_advanced_section',
|
|
__('Advanced Settings', 'eb-redsys-gateway'),
|
|
array($this, 'render_advanced_section'),
|
|
$this->page_slug
|
|
);
|
|
|
|
// General Fields
|
|
$this->add_field('enabled', 'checkbox', __('Enable/Disable', 'eb-redsys-gateway'), 'general');
|
|
$this->add_field('test_mode', 'checkbox', __('Test Mode', 'eb-redsys-gateway'), 'general');
|
|
$this->add_field('title', 'text', __('Title', 'eb-redsys-gateway'), 'general');
|
|
$this->add_field('description', 'textarea', __('Description', 'eb-redsys-gateway'), 'general');
|
|
|
|
// API Fields
|
|
$this->add_field('merchant_code', 'text', __('Merchant Code (FUC)', 'eb-redsys-gateway'), 'api');
|
|
$this->add_field('terminal', 'text', __('Terminal Number', 'eb-redsys-gateway'), 'api');
|
|
$this->add_field('encryption_key', 'password', __('Encryption Key', 'eb-redsys-gateway'), 'api');
|
|
|
|
// Advanced Fields
|
|
$this->add_field('enable_future_payments', 'checkbox', __('Future Payments', 'eb-redsys-gateway'), 'advanced');
|
|
$this->add_field('enable_subscriptions', 'checkbox', __('Subscriptions', 'eb-redsys-gateway'), 'advanced');
|
|
}
|
|
|
|
/**
|
|
* Add field to settings
|
|
*/
|
|
private function add_field($name, $type, $label, $section) {
|
|
add_settings_field(
|
|
'eb_redsys_' . $name,
|
|
$label,
|
|
array($this, 'render_field'),
|
|
$this->page_slug,
|
|
'eb_redsys_' . $section . '_section',
|
|
array(
|
|
'name' => 'eb_redsys_' . $name,
|
|
'type' => $type,
|
|
'label' => $label
|
|
)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Render field based on type
|
|
*/
|
|
public function render_field($args) {
|
|
$name = $args['name'];
|
|
$type = $args['type'];
|
|
$value = get_option($name);
|
|
|
|
switch ($type) {
|
|
case 'checkbox':
|
|
?>
|
|
<label>
|
|
<input type="checkbox"
|
|
name="<?php echo esc_attr($name); ?>"
|
|
value="yes"
|
|
<?php checked($value, 'yes'); ?>>
|
|
<?php esc_html_e('Enable', 'eb-redsys-gateway'); ?>
|
|
</label>
|
|
<?php
|
|
break;
|
|
|
|
case 'text':
|
|
?>
|
|
<input type="text"
|
|
name="<?php echo esc_attr($name); ?>"
|
|
value="<?php echo esc_attr($value); ?>"
|
|
class="regular-text">
|
|
<?php
|
|
break;
|
|
|
|
case 'password':
|
|
?>
|
|
<input type="password"
|
|
name="<?php echo esc_attr($name); ?>"
|
|
value="<?php echo esc_attr($value); ?>"
|
|
class="regular-text">
|
|
<?php
|
|
break;
|
|
|
|
case 'textarea':
|
|
?>
|
|
<textarea name="<?php echo esc_attr($name); ?>"
|
|
class="large-text"
|
|
rows="3"><?php echo esc_textarea($value); ?></textarea>
|
|
<?php
|
|
break;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Render section descriptions
|
|
*/
|
|
public function render_general_section() {
|
|
echo '<p>' . esc_html__('Configure how Redsys appears on your site.', 'eb-redsys-gateway') . '</p>';
|
|
}
|
|
|
|
public function render_api_section() {
|
|
echo '<p>' . esc_html__('Enter your Redsys API credentials. You can find these in your Redsys merchant dashboard.', 'eb-redsys-gateway') . '</p>';
|
|
}
|
|
|
|
public function render_advanced_section() {
|
|
echo '<p>' . esc_html__('Advanced settings for special payment scenarios.', 'eb-redsys-gateway') . '</p>';
|
|
}
|
|
|
|
/**
|
|
* Add Redsys to Eagle Booking payment methods
|
|
*/
|
|
public function add_payment_method($methods) {
|
|
if (get_option('eb_redsys_enabled') === 'yes') {
|
|
$methods['redsys'] = array(
|
|
'title' => get_option('eb_redsys_title', __('Credit Card (Redsys)', 'eb-redsys-gateway')),
|
|
'description' => get_option('eb_redsys_description'),
|
|
'action_type' => 'redsys'
|
|
);
|
|
}
|
|
return $methods;
|
|
}
|
|
|
|
/**
|
|
* Enqueue admin scripts
|
|
*/
|
|
public function enqueue_admin_scripts($hook) {
|
|
if (strpos($hook, $this->page_slug) !== false) {
|
|
wp_enqueue_style(
|
|
'eb-redsys-admin',
|
|
EB_REDSYS_URL . 'assets/css/admin.css',
|
|
array(),
|
|
EB_REDSYS_VERSION
|
|
);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Render the settings page
|
|
*/
|
|
public function render_settings_page() {
|
|
if (!current_user_can('manage_options')) {
|
|
return;
|
|
}
|
|
?>
|
|
<div class="wrap">
|
|
<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
|
|
|
|
<?php
|
|
if (isset($_GET['settings-updated'])) {
|
|
add_settings_error(
|
|
'eb_redsys_messages',
|
|
'eb_redsys_message',
|
|
__('Settings Saved', 'eb-redsys-gateway'),
|
|
'updated'
|
|
);
|
|
}
|
|
settings_errors('eb_redsys_messages');
|
|
?>
|
|
|
|
<form action="options.php" method="post">
|
|
<?php
|
|
settings_fields($this->option_group);
|
|
do_settings_sections($this->page_slug);
|
|
submit_button();
|
|
?>
|
|
</form>
|
|
|
|
<div class="eb-redsys-info postbox">
|
|
<h3 class="hndle"><?php esc_html_e('Important Information', 'eb-redsys-gateway'); ?></h3>
|
|
<div class="inside">
|
|
<h4><?php esc_html_e('Test Mode', 'eb-redsys-gateway'); ?></h4>
|
|
<p><?php esc_html_e('For testing, use these credentials:', 'eb-redsys-gateway'); ?></p>
|
|
<ul>
|
|
<li><?php esc_html_e('Test Card: 4548 8120 4940 0004', 'eb-redsys-gateway'); ?></li>
|
|
<li><?php esc_html_e('Expiry Date: 12/24', 'eb-redsys-gateway'); ?></li>
|
|
<li><?php esc_html_e('CVV2: 123', 'eb-redsys-gateway'); ?></li>
|
|
</ul>
|
|
|
|
<h4><?php esc_html_e('Getting Started', 'eb-redsys-gateway'); ?></h4>
|
|
<p><?php esc_html_e('To get your credentials:', 'eb-redsys-gateway'); ?></p>
|
|
<ol>
|
|
<li><?php esc_html_e('Log in to your Redsys merchant account', 'eb-redsys-gateway'); ?></li>
|
|
<li><?php esc_html_e('Go to Administration → Technical Configuration', 'eb-redsys-gateway'); ?></li>
|
|
<li><?php esc_html_e('Find your Merchant Code (FUC) and Terminal number', 'eb-redsys-gateway'); ?></li>
|
|
<li><?php esc_html_e('Generate your Encryption Key in the Security section', 'eb-redsys-gateway'); ?></li>
|
|
</ol>
|
|
|
|
<h4><?php esc_html_e('Support', 'eb-redsys-gateway'); ?></h4>
|
|
<p>
|
|
<?php
|
|
printf(
|
|
/* translators: %s: URL */
|
|
esc_html__('For support, please visit our %s.', 'eb-redsys-gateway'),
|
|
'<a href="https://support.informatiq.com" target="_blank">' . esc_html__('support center', 'eb-redsys-gateway') . '</a>'
|
|
);
|
|
?>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
}
|
|
}
|