/** * Preauthorization Admin JavaScript * * Handles preauthorization capture and cancellation * * 🤖 Generated with Claude Code (https://claude.ai/code) */ jQuery(document).ready(function($) { // Capture preauthorization $(document).on('click', '.capture-preauth', function() { if (!confirm(ebPreauth.strings.confirmCapture)) { return; } var $button = $(this); var preauthId = $button.data('preauth-id'); var bookingId = $button.data('booking-id'); var originalText = $button.text(); $button.text('Capturing...').prop('disabled', true); $.ajax({ url: ebPreauth.ajaxurl, type: 'POST', data: { action: 'capture_preauth', nonce: ebPreauth.nonce, preauth_id: preauthId, booking_id: bookingId }, success: function(response) { if (response.success) { showNotice('Preauthorization captured successfully!', 'success'); location.reload(); } else { showNotice('Error: ' + response.data, 'error'); } }, error: function() { showNotice('An error occurred while capturing the preauthorization.', 'error'); }, complete: function() { $button.text(originalText).prop('disabled', false); } }); }); // Cancel preauthorization $(document).on('click', '.cancel-preauth', function() { if (!confirm(ebPreauth.strings.confirmCancel)) { return; } var $button = $(this); var preauthId = $button.data('preauth-id'); var bookingId = $button.data('booking-id'); var originalText = $button.text(); $button.text('Cancelling...').prop('disabled', true); $.ajax({ url: ebPreauth.ajaxurl, type: 'POST', data: { action: 'cancel_preauth', nonce: ebPreauth.nonce, preauth_id: preauthId, booking_id: bookingId }, success: function(response) { if (response.success) { showNotice('Preauthorization cancelled successfully!', 'success'); location.reload(); } else { showNotice('Error: ' + response.data, 'error'); } }, error: function() { showNotice('An error occurred while cancelling the preauthorization.', 'error'); }, complete: function() { $button.text(originalText).prop('disabled', false); } }); }); // Show admin notices function showNotice(message, type) { var noticeClass = type === 'success' ? 'notice-success' : 'notice-error'; var $notice = $('
' + message + '