{"id":746,"date":"2026-01-07T10:19:09","date_gmt":"2026-01-07T10:19:09","guid":{"rendered":"https:\/\/fm-connect1.fortmindz.in\/wp-godwin-pinto\/?page_id=746"},"modified":"2026-01-30T18:07:33","modified_gmt":"2026-01-30T18:07:33","slug":"sole-trader","status":"publish","type":"page","link":"https:\/\/fm-connect1.fortmindz.in\/wp-godwin-pinto\/sole-trader\/","title":{"rendered":"Sole Trader Signup"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"746\" class=\"elementor elementor-746\" data-elementor-post-type=\"page\">\n\t\t\t\t<div class=\"elementor-element elementor-element-319226c e-flex e-con-boxed e-con e-parent\" data-id=\"319226c\" data-element_type=\"container\" data-settings=\"{&quot;background_background&quot;:&quot;classic&quot;,&quot;shape_divider_top&quot;:&quot;waves&quot;,&quot;shape_divider_bottom&quot;:&quot;waves&quot;}\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-shape elementor-shape-top\" aria-hidden=\"true\" data-negative=\"false\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 1000 100\" preserveAspectRatio=\"none\">\n\t<path class=\"elementor-shape-fill\" d=\"M421.9,6.5c22.6-2.5,51.5,0.4,75.5,5.3c23.6,4.9,70.9,23.5,100.5,35.7c75.8,32.2,133.7,44.5,192.6,49.7\n\tc23.6,2.1,48.7,3.5,103.4-2.5c54.7-6,106.2-25.6,106.2-25.6V0H0v30.3c0,0,72,32.6,158.4,30.5c39.2-0.7,92.8-6.7,134-22.4\n\tc21.2-8.1,52.2-18.2,79.7-24.2C399.3,7.9,411.6,7.5,421.9,6.5z\"\/>\n<\/svg>\t\t<\/div>\n\t\t\t\t<div class=\"elementor-shape elementor-shape-bottom\" aria-hidden=\"true\" data-negative=\"false\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 1000 100\" preserveAspectRatio=\"none\">\n\t<path class=\"elementor-shape-fill\" d=\"M421.9,6.5c22.6-2.5,51.5,0.4,75.5,5.3c23.6,4.9,70.9,23.5,100.5,35.7c75.8,32.2,133.7,44.5,192.6,49.7\n\tc23.6,2.1,48.7,3.5,103.4-2.5c54.7-6,106.2-25.6,106.2-25.6V0H0v30.3c0,0,72,32.6,158.4,30.5c39.2-0.7,92.8-6.7,134-22.4\n\tc21.2-8.1,52.2-18.2,79.7-24.2C399.3,7.9,411.6,7.5,421.9,6.5z\"\/>\n<\/svg>\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-ad27de3 e-con-full e-flex e-con e-child\" data-id=\"ad27de3\" data-element_type=\"container\">\n\t\t\t\t<div class=\"elementor-element elementor-element-d688140 elementor-absolute elementor-widget elementor-widget-image\" data-id=\"d688140\" data-element_type=\"widget\" data-settings=\"{&quot;_position&quot;:&quot;absolute&quot;}\" data-widget_type=\"image.default\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"66\" height=\"66\" src=\"https:\/\/fm-connect1.fortmindz.in\/wp-godwin-pinto\/wp-content\/uploads\/2025\/11\/Frame-16.png\" class=\"attachment-full size-full wp-image-69\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-664cff2 e-flex e-con-boxed e-con e-parent\" data-id=\"664cff2\" data-element_type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-60f8493 elementor-widget elementor-widget-shortcode\" data-id=\"60f8493\" data-element_type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t\t\t\t<div class=\"elementor-shortcode\">\r\n<div class=\"formouter\">\r\n    <div class=\"form-container\">\r\n        <div id=\"formSection\" class=\"\">\r\n            <div class=\"form-header\">\r\n                <h1 class=\"form-title\">Sole Trader Registration<\/h1>\r\n                <div class=\"progress-steps\"> \r\n                    <span class=\"step-indicator active\"><\/span> \r\n                    <span class=\"step-indicator\"><\/span> \r\n                    <span class=\"step-indicator\"><\/span> \r\n                <\/div>\r\n            <\/div>\r\n            <div style=\"margin: 20px 0; padding: 15px; background: #fff3cd; border: 1px solid #ffecb5; border-radius: 8px; text-align: center;\">\r\n                <label style=\"font-weight: bold; cursor: pointer;\">\r\n                    <input type=\"checkbox\" id=\"testModeToggle\" onchange=\"toggleTestMode(this.checked)\" style=\"vertical-align: middle;\">\r\n                    TEST MODE: Disable Postcode Lookups (No API calls \/ No credits used)\r\n                <\/label>\r\n                <p style=\"margin: 8px 0 0; font-size: 0.9em; color: #856404;\">\r\n                    Use this while testing the form repeatedly. Turn OFF before going live.\r\n                <\/p>\r\n            <\/div>\r\n            <form id=\"multistepForm1\" novalidate enctype=\"multipart\/form-data\">\r\n                <div class=\"step active\" data-step=\"1\">\r\n                    <!-- Personal & Business Details -->\r\n                    <div class=\"input-group-row\">\r\n                        <div class=\"input-field\">\r\n                            <label for=\"firstName\" class=\"visually-hidden\">Your first name<\/label>\r\n                            <input type=\"text\" id=\"firstName\" name=\"firstName\" placeholder=\"Your first name\" required>\r\n                            <div class=\"error-message\" id=\"error-firstName\"><\/div>\r\n                        <\/div>\r\n                        <div class=\"input-field\">\r\n                            <label for=\"surname\" class=\"visually-hidden\">Surname<\/label>\r\n                            <input type=\"text\" id=\"surname\" name=\"surname\" placeholder=\"Surname\" required>\r\n                            <div class=\"error-message\" id=\"error-surname\"><\/div>\r\n                        <\/div>\r\n                    <\/div>\r\n                    <div class=\"input-group-row\">\r\n                        <div class=\"input-field\">\r\n                            <label for=\"businessName\" class=\"visually-hidden\">Name of business<\/label>\r\n                            <input type=\"text\" id=\"businessName\" name=\"businessName\" placeholder=\"Name of business\" required>\r\n                            <div class=\"error-message\" id=\"error-businessName\"><\/div>\r\n                        <\/div>\r\n                        <div class=\"input-field\">\r\n                            <label for=\"natureOfBusiness\" class=\"visually-hidden\">Nature of business<\/label>\r\n                            <input type=\"text\" id=\"natureOfBusiness\" name=\"natureOfBusiness\" placeholder=\"Nature of business\" required>\r\n                            <div class=\"error-message\" id=\"error-natureOfBusiness\"><\/div>\r\n                        <\/div>\r\n                    <\/div>\r\n\r\n                    <!-- Postcode Lookup (Step 1 only) -->\r\n                    <div class=\"addresswrap\">\r\n                        <div class=\"address-lookup-group\" id=\"postcodeLookupContext\"><\/div>\r\n                        \r\n                        <!-- Manual entry checkbox -->\r\n                        <div class=\"checkbox-manual\">\r\n                            <input type=\"checkbox\" id=\"enterManual\">\r\n                            <label for=\"enterManual\">Enter address manually<\/label>\r\n                        <\/div>\r\n                        <div class=\"error-message\" id=\"error-addresswrap\"><\/div>\r\n                    <\/div>\r\n                    <!-- Address fields -->\r\n                    <div class=\"address-fields\">\r\n                        <div class=\"input-group-row\">\r\n                            <div class=\"input-field\">\r\n                                <input type=\"text\" id=\"houseName\" name=\"houseName\" placeholder=\"House No. or Name\" required>\r\n                                <div class=\"error-message\" id=\"error-houseName\"><\/div>\r\n                            <\/div>\r\n                            <div class=\"input-field\">\r\n                                <input type=\"text\" id=\"streetName\" name=\"streetName\" placeholder=\"Street name\" required>\r\n                                <div class=\"error-message\" id=\"error-streetName\"><\/div>\r\n                            <\/div>\r\n                        <\/div>\r\n                        <div class=\"input-group-row\">\r\n                            <div class=\"input-field\">\r\n                                <input type=\"text\" id=\"city\" name=\"city\" placeholder=\"City name\">\r\n                                <div class=\"error-message\" id=\"error-city\"><\/div>\r\n                            <\/div>\r\n                            <div class=\"input-field\">\r\n                                <input type=\"text\" id=\"postCode\" name=\"postCode\" placeholder=\"Post Code\" required>\r\n                                <div class=\"error-message\" id=\"error-postCode\"><\/div>\r\n                            <\/div>\r\n                        <\/div>\r\n                        <div class=\"input-group-row\">\r\n                            <input type=\"text\" id=\"country\" name=\"country\" placeholder=\"Country\" value=\"United Kingdom\" required>\r\n                            <div class=\"error-message\" id=\"error-country\"><\/div>\r\n                        <\/div>\r\n                    <\/div>\r\n\r\n                    <!-- Moving from another accountant -->\r\n                    <p class=\"question\">Are you moving from another accountant?<\/p>\r\n                    <div class=\"radio-group radio-accountant\">\r\n                        <input type=\"radio\" id=\"accountantYes\" name=\"movingAccountant\" value=\"yes\">\r\n                        <label for=\"accountantYes\">Yes<\/label>\r\n                        <input type=\"radio\" id=\"accountantNo\" name=\"movingAccountant\" value=\"no\" checked>\r\n                        <label for=\"accountantNo\">No<\/label>\r\n                    <\/div>\r\n                    <div class=\"displayforanotheraccountantyes\" style=\"display: none;\">\r\n                        <div class=\"input-group-row accountant-details\">\r\n                            <div class=\"input-field\">\r\n                                <input type=\"text\" id=\"accountantName\" name=\"accountantName\" placeholder=\"Name of accountant\" required>\r\n                                <div class=\"error-message\" id=\"error-accountantName\"><\/div>\r\n                            <\/div>\r\n                            <div class=\"input-field\">\r\n                                <input type=\"email\" id=\"accountantEmail\" name=\"accountantEmail\" placeholder=\"Email of accountant\" required>\r\n                                <div class=\"error-message\" id=\"error-accountantEmail\"><\/div> \r\n                            <\/div>\r\n                        <\/div>\r\n                    <\/div>\r\n                <\/div>\r\n\r\n                <div class=\"step\" data-step=\"2\">\r\n                    <!-- Personal Details -->\r\n                    <div class=\"input-group-row\">\r\n                        <div class=\"input-field w50\">\r\n                            <label for=\"userDOB\" class=\"visually-hidden\">Date of Birth<\/label>\r\n                            <input type=\"date\" id=\"userDOB\" name=\"userDOB\" required>\r\n                            <div class=\"error-message\" id=\"error-userDOB\"><\/div>\r\n                        <\/div>\r\n                        <div class=\"input-field w50\">\r\n                            <label for=\"userPhone\" class=\"visually-hidden\">Phone number<\/label>\r\n                            <input type=\"tel\" id=\"userPhone\" name=\"userPhone\" placeholder=\"Phone number\" required>\r\n                            <div class=\"error-message\" id=\"error-userPhone\"><\/div>\r\n                        <\/div>\r\n                    <\/div>\r\n\r\n                    <div class=\"input-group-row\">\r\n                        \r\n                        <div class=\"input-field gender-group w50\">\r\n                            <p class=\"gender-label\">Gender<\/p>\r\n                            <div class=\"radio-group-horizontal\">\r\n                                <span><input type=\"radio\" id=\"genderMale\" name=\"gender\" value=\"Male\"><label for=\"genderMale\">Male<\/label><\/span>\r\n                                <span><input type=\"radio\" id=\"genderFemale\" name=\"gender\" value=\"Female\"><label for=\"genderFemale\">Female<\/label><\/span>\r\n                                <span><input type=\"radio\" id=\"genderOther\" name=\"gender\" value=\"Other\"><label for=\"genderOther\">Other<\/label><\/span>\r\n                                <div class=\"error-message\" id=\"error-gender\"><\/div>\r\n                            <\/div>\r\n                        <\/div>\r\n                        <div class=\"input-field w50\">\r\n                            <label for=\"taxRefference\" class=\"visually-hidden\">Unique Tax Reference<\/label>\r\n                            <input type=\"text\" id=\"taxRefference\" name=\"taxRefference\" placeholder=\"Unique Tax Reference (UTR)\" required>\r\n                            <div class=\"error-message\" id=\"error-taxRefference\"><\/div>\r\n                        <\/div>\r\n                    <\/div>\r\n\r\n                    <p class=\"question\">Any pending convictions?<\/p>\r\n                    <div class=\"radio-group conviction-group\">\r\n                        <input type=\"radio\" id=\"convictionsYes\" name=\"convictions\" value=\"yes\">\r\n                        <label for=\"convictionsYes\">Yes<\/label>\r\n                        <input type=\"radio\" id=\"convictionsNo\" name=\"convictions\" value=\"no\" checked>\r\n                        <label for=\"convictionsNo\">No<\/label>\r\n                        <div class=\"error-message\" id=\"error-convictions\"><\/div>\r\n                    <\/div>\r\n\r\n                    <!-- <p class=\"question\">Will this pension be signing the form?<\/p>\r\n                    <div class=\"radio-group pension-group\">\r\n                        <input type=\"radio\" id=\"pensionSignYes\" name=\"pensionSign\" value=\"yes\">\r\n                        <label for=\"pensionSignYes\">Yes<\/label>\r\n                        <input type=\"radio\" id=\"pensionSignNo\" name=\"pensionSign\" value=\"no\" checked>\r\n                        <label for=\"pensionSignNo\">No<\/label>\r\n                        <div class=\"error-message\" id=\"error-pensionSign\"><\/div>\r\n                    <\/div>\r\n\r\n\r\n                    <div id=\"pensionDetails\" style=\"display: none;\">\r\n                        <div class=\"input-group-row\">\r\n                            <div class=\"input-field w50\">\r\n                                <input type=\"text\" id=\"pensionName\" name=\"pensionName\" placeholder=\"Name\" required>\r\n                                <div class=\"error-message\" id=\"error-pensionName\"><\/div>\r\n                            <\/div>\r\n                            <div class=\"input-field w50\">\r\n                                <input type=\"email\" id=\"pensionEmail\" name=\"pensionEmail\" placeholder=\"Email of current accountant\" required>\r\n                                <div class=\"error-message\" id=\"error-pensionEmail\"><\/div>\r\n                            <\/div>\r\n                        <\/div>\r\n                    <\/div> -->\r\n\r\n                    <!-- Terms -->\r\n                    <div class=\"checkbox-terms\">\r\n                        <!-- <p>If you require any services from a previous period an additional fee will be quoted to complete this work <a href=\"terms-conditions\" target=\"_blank\">Terms and Conditions<\/a><\/p> -->\r\n                        <input type=\"checkbox\" id=\"terms\" name=\"terms\" required>\r\n                        <label for=\"terms\">I have read, understood and agree to the <a href=\"https:\/\/fm-connect1.fortmindz.in\/wp-godwin-pinto\/terms-conditions\" target=\"_blank\">full terms and conditions<\/a><\/label>\r\n                        <div class=\"error-message\" id=\"error-terms\"><\/div>\r\n                    <\/div>\r\n                <\/div>\r\n\r\n                <div class=\"step\" data-step=\"3\">\r\n                    <div class=\"col-outer payment-section\">\r\n                        <div class=\"col\">\r\n                            <div class=\"tabcontainer\">\r\n                                <div class=\"payment-element\" id=\"payment-element\" style=\"min-height: 300px;\"><\/div>\r\n                                <div id=\"payment-errors\" role=\"alert\" style=\"color: #fa755a; margin-top: 10px; min-height: 20px;\"><\/div>\r\n                            <\/div>\r\n\r\n                        <\/div>\r\n\r\n                        <div class=\"col\">\r\n                            <div class=\"monthly\"><\/div>\r\n                            <div class=\"breakdown\">\r\n                                <p>Monthly fee breakdown<\/p>\r\n                            <\/div>\r\n                            <div class=\"table\">\r\n                                <ul>\r\n                                    <li><span>Accounts Package<\/span><span>\u00a349<\/span><\/li>\r\n                                    <li><span>Bookkeeping<\/span><span>\u00a329<\/span><\/li>\r\n                                    <li><span>VAT returns<\/span><span>\u00a315<\/span><\/li>\r\n                                    <li><span>Payroll<\/span><span>\u00a310<\/span><\/li>\r\n                                    <li class=\"total\"><span>Total<\/span><span>\u00a3103<\/span><\/li>\r\n                                <\/ul>\r\n                            <\/div>\r\n                        <\/div>\r\n                    <\/div>\r\n\r\n                    <div class=\"checkbox-terms mb-28\">\r\n                        <input type=\"checkbox\" id=\"terms-last\" name=\"terms-last-step\" required>\r\n                        <label for=\"terms-last\">I understand that Stripe will be collecting payments on behalf of AccTek Ltd and confirm that I am the account holder and the only person required to authorise debits from this account.<\/label>\r\n                        <div class=\"error-message\" id=\"error-terms-last\"><\/div>\r\n                    <\/div>\r\n\r\n                    <div class=\"sign\">                    \r\n                        <div class=\"signature-upload-container\">\r\n                            <input type=\"file\" id=\"signatureUpload\" name=\"signatureUpload\" accept=\"image\/*\" >\r\n                            \r\n                            \r\n                            <div id=\"signaturePreviewContainer\">\r\n                                <!-- Preview will appear here -->\r\n                            <\/div>\r\n                        <\/div>\r\n                        <p>Your Signature above<\/p>\r\n\r\n                    <\/div>\r\n                <\/div>\r\n                <div class=\"form-navigation\">\r\n                    <button type=\"button\" class=\"previous-btn\" id=\"previousBtn\" style=\"display: none;\">Back<\/button>\r\n                    <button type=\"button\" class=\"next-btn\" id=\"nextBtn\">Next<\/button>\r\n                    <button type=\"submit\" class=\"submit-btn\" id=\"submitBtn\" style=\"display: none;\" name=\"submit\">Submit<\/button>\r\n                <\/div>\r\n            <\/form>\r\n        <\/div>\r\n        <!-- Thank You Section (shown only on success) -->\r\n        <div id=\"thankYouSection\" class=\"hidden\">\r\n            <div class=\"thank-you-section\">\r\n                <img decoding=\"async\" src=\"https:\/\/fm-connect1.fortmindz.in\/wp-godwin-pinto\/wp-content\/themes\/hello-theme-child-master\/assets\/images\/thank-you-envelope.png\" alt=\"Thank you\">\r\n                \r\n                <h2>Thank you<\/h2>\r\n                \r\n                <p>\r\n                    Thank you for submitting your registration form! One of our admin team will be in contact with you shortly to confirm your registration and get set up with your accountant.\r\n                <\/p>\r\n                \r\n                <button id=\"downloadPdfBtn\">\r\n                    Save as PDF\r\n                <\/button>\r\n            <\/div>\r\n        <\/div>\r\n\r\n        \r\n    <\/div>\r\n<\/div>\r\n\r\n<style type=\"text\/css\">\r\n    .address-fields.visible {\r\n        display: block; \/* Show when we add this class *\/\r\n    }\r\n    \/* Ensure errors inside horizontal radio groups don't break layout *\/\r\n    .radio-group-horizontal .error-message {\r\n        width: 100%;\r\n        display: none; \/* Default hidden *\/\r\n        margin-top: 8px;\r\n    }\r\n\r\n    .radio-group-horizontal .error-message.visible {\r\n        display: block !important; \/* Force show *\/\r\n    }\r\n\r\n    .hidden{display: none;}\r\n    \r\n    \/* ==================== ERROR MESSAGES ==================== *\/\r\n    .error-message {\r\n        color: #fa755a;\r\n        font-size: 0.85rem;\r\n        margin-top: 4px;\r\n        \/* FIX: Default to HIDDEN. JS will make it 'block' when needed. *\/\r\n        display: none; \r\n    }\r\n\r\n    \/* Specific class to FORCE visibility (used by JS) *\/\r\n    .error-message.visible {\r\n        display: block !important;\r\n    }\r\n\r\n    .input-error {\r\n        border-color: #fa755a !important;\r\n        background-color: #fff5f5;\r\n    }\r\n    .input-error:focus {\r\n        outline: 2px solid #fa755a;\r\n    }\r\n\r\n    \/* ==================== ADDRESS FIELDS ==================== *\/\r\n    .address-fields-director {\r\n        \/* Ensure they are hidden by default *\/\r\n        display: none;\r\n    }\r\n\r\n    \/* Show when active class is present *\/\r\n    .address-fields-director.active {\r\n        display: block;\r\n    }\r\n\r\n    \/* CRITICAL: FORCE HIDE IF CLASS IS PRESENT *\/\r\n    .address-fields-director.initially-hidden {\r\n        display: none !important;\r\n    }\r\n    \r\n    input[readonly] {\r\n        background-color: #f8f9fa;\r\n        cursor: not-allowed;\r\n    }\r\n\r\n    \/* ==================== STEPS ==================== *\/\r\n    .step {\r\n        display: none !important;\r\n        opacity: 0;\r\n        transition: opacity 0.3s ease;\r\n    }\r\n\r\n    .step.active {\r\n        display: block !important;\r\n        opacity: 1;\r\n    }\r\n\r\n    .step.force-active {\r\n        display: block !important;\r\n        opacity: 1 !important;\r\n    }\r\n\r\n    .step-indicator.force-active {\r\n        background-color: #2c7a2c !important;\r\n        opacity: 1 !important;\r\n    }\r\n\r\n    #nextBtn, #previousBtn {\r\n        cursor: pointer;\r\n    }\r\n    \r\n    \/* General helper *\/\r\n    .force-visible {\r\n        display: block !important;\r\n    }\r\n\r\n    .address-fields {\r\n        display: none; \r\n    }\r\n\r\n    \/* Visual highlight for a director entry that failed validation *\/\r\n    .director-entry.validation-error {\r\n        border: 1px solid #fa755a !important;\r\n        background-color: #fff5f5;\r\n        padding: 15px !important;\r\n        border-radius: 8px;\r\n        margin-bottom: 20px;\r\n    }\r\n<\/style>\r\n<script src=\"https:\/\/js.stripe.com\/v3\/\"><\/script>\r\n<!-- <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/@ideal-postcodes\/postcode-lookup-bundled@2\"><\/script> -->\r\n<script src=\"https:\/\/cdn.jsdelivr.net\/npm\/@ideal-postcodes\/postcode-lookup-bundled@2\/dist\/postcode-lookup.min.js\"><\/script>\r\n<!-- jsPDF Library -->\r\n<script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/jspdf\/2.5.1\/jspdf.umd.min.js\"><\/script>\r\n<script src=\"https:\/\/html2canvas.hertzen.com\/dist\/html2canvas.min.js\"><\/script>\r\n\r\n\r\n\r\n<script type=\"text\/javascript\">\r\n    const ajaxurl = 'https:\/\/fm-connect1.fortmindz.in\/wp-godwin-pinto\/wp-admin\/admin-ajax.php';\r\n    const ajaxNonce = 'c26bbb9a49';\r\n<\/script>\r\n\r\n<script type=\"text\/javascript\">\r\ndocument.addEventListener(\"DOMContentLoaded\", function () {\r\n    \/\/ ==================== CONSTANTS ====================\r\n    const form = document.getElementById('multistepForm1');\r\n    const steps = document.querySelectorAll('.step');\r\n    const prevBtn = document.getElementById('previousBtn');\r\n    const nextBtn = document.getElementById('nextBtn');\r\n    const submitBtn = document.getElementById('submitBtn');\r\n\r\n    \/\/ Stripe variables\r\n    let stripe = null;\r\n    let elements = null;\r\n    let paymentElement = null;\r\n    let clientSecret = null;\r\n\r\n    \/\/ Test mode\r\n    window.isTestMode = false;\r\n\r\n    \/\/ ==================== TEST MODE TOGGLE ====================\r\n    window.toggleTestMode = function(checked) {\r\n        window.isTestMode = checked;\r\n        console.log('Test Mode:', window.isTestMode ? 'ON' : 'OFF');\r\n        initPostcodeLookup(); \/\/ Re-initialize lookup based on mode\r\n    };\r\n\r\n    \/\/ ==================== POSTCODE LOOKUP ====================\r\n    let postcodeLookupController = null;\r\n    function initPostcodeLookup() {\r\n        if (postcodeLookupController) {\r\n            postcodeLookupController.removeAll();\r\n            postcodeLookupController = null;\r\n        }\r\n\r\n        const context = document.getElementById('postcodeLookupContext');\r\n        const addressFields = document.querySelector('.address-fields');\r\n        const manualCheckbox = document.getElementById('enterManual');\r\n\r\n        if (!context) return;\r\n\r\n        if (typeof IdealPostcodes !== \"undefined\" && !window.isTestMode) {\r\n            postcodeLookupController = IdealPostcodes.PostcodeLookup.setup({\r\n                apiKey: \"ak_test\", \/\/ change to your real key in production\r\n                context: \"#postcodeLookupContext\",\r\n                outputFields: {\r\n                    line_1: \"#houseName\",\r\n                    line_2: \"#streetName\",\r\n                    post_town: \"#city\",\r\n                    postcode: \"#postCode\"\r\n                },\r\n                onAddressSelected: function(address) {\r\n                    \/\/ When user selects an address -> show fields\r\n                    addressFields.classList.add('visible');\r\n                    \r\n                    \/\/ Ensure fields are readonly since they came from lookup\r\n                    document.querySelectorAll('.address-fields input:not(#country)').forEach(el => {\r\n                        el.setAttribute('readonly', 'readonly');\r\n                    });\r\n                    \r\n                    \/\/ Clear the addresswrap error if it exists\r\n                    const errorWrap = document.getElementById('error-addresswrap');\r\n                    if (errorWrap) errorWrap.style.display = 'none';\r\n                }\r\n            });\r\n            \/\/context.style.display = 'block';\r\n            \/\/ Keep fields hidden until an address is selected\r\n            addressFields.classList.remove('visible');\r\n        } else {\r\n            context.style.display = 'none';\r\n            \/\/ In test mode or no lookup \u2192 show fields immediately\r\n            addressFields.classList.add('visible');\r\n        }\r\n    }\r\n    initPostcodeLookup();\r\n\r\n    \/\/ ==================== MANUAL ADDRESS TOGGLE ====================\r\n    const manualCheckbox = document.getElementById('enterManual');\r\n    if (manualCheckbox) {\r\n        manualCheckbox.addEventListener('change', function () {\r\n            const context = document.getElementById('postcodeLookupContext');\r\n            const addressFields = document.querySelector('.address-fields');\r\n            const addressInputs = document.querySelectorAll('.address-fields input:not(#country)');\r\n            const errorWrap = document.getElementById('error-addresswrap');\r\n\r\n            if (this.checked) {\r\n                \/\/ Manual entry \u2192 hide lookup, show fields, enable inputs\r\n                if (context) context.style.display = 'none';\r\n                addressFields.classList.add('visible');\r\n                addressInputs.forEach(el => {\r\n                    el.removeAttribute('readonly');\r\n                    el.value = ''; \/\/ Optional: clear previous lookup values\r\n                });\r\n                \/\/ Clear error\r\n                if (errorWrap) errorWrap.style.display = 'none';\r\n            } else {\r\n                \/\/ Back to lookup mode\r\n                if (context && !window.isTestMode) {\r\n                    context.style.display = 'block';\r\n                    initPostcodeLookup(); \/\/ Re-init to ensure listener is active\r\n                }\r\n                \/\/ Only show fields if they already have values, otherwise wait for selection\r\n                const hasValues = Array.from(addressInputs).some(input => input.value.trim() !== '');\r\n                if (hasValues) {\r\n                    addressFields.classList.add('visible');\r\n                } else {\r\n                    addressFields.classList.remove('visible');\r\n                }\r\n                addressInputs.forEach(el => {\r\n                    if (!el.value.trim()) {\r\n                        el.setAttribute('readonly', 'readonly');\r\n                    }\r\n                });\r\n            }\r\n        });\r\n    }\r\n\r\n    \/\/ ==================== MOVING FROM ANOTHER ACCOUNTANT ====================\r\n    document.querySelectorAll('input[name=\"movingAccountant\"]').forEach(radio => {\r\n        radio.addEventListener('change', function () {\r\n            document.querySelector('.displayforanotheraccountantyes').style.display =\r\n                this.value === 'yes' ? 'block' : 'none';\r\n        });\r\n    });\r\n\r\n    \/\/ Force \"No\" on load\r\n    window.addEventListener('load', () => {\r\n        const noRadio = document.getElementById('accountantNo');\r\n        if (noRadio) {\r\n            noRadio.checked = true;\r\n            noRadio.dispatchEvent(new Event('change'));\r\n        }\r\n    });\r\n\r\n    \/\/ ==================== PENSION SIGNING TOGGLE ====================\r\n    document.querySelectorAll('input[name=\"pensionSign\"]').forEach(radio => {\r\n        radio.addEventListener('change', function () {\r\n            document.getElementById('pensionDetails').style.display =\r\n                this.value === 'yes' ? 'block' : 'none';\r\n        });\r\n    });\r\n\r\n    \/\/ Force \"No\" on load\r\n    window.addEventListener('load', () => {\r\n        const pensionNo = document.getElementById('pensionSignNo');\r\n        if (pensionNo) pensionNo.checked = true;\r\n        document.getElementById('pensionDetails').style.display = 'none';\r\n    });\r\n\r\n    \/\/ ==================== FORM NAVIGATION ====================\r\n    nextBtn.addEventListener('click', function(e) {\r\n        e.preventDefault();\r\n        e.stopImmediatePropagation();\r\n\r\n        \/\/ 1. FORCE CLEAR all previous errors first\r\n        clearAllErrors(); \r\n        \/\/ Also remove inline styles from previous errors\r\n        document.querySelectorAll('.input-error').forEach(el => {\r\n            el.style.borderColor = '';\r\n            el.style.backgroundColor = '';\r\n        });\r\n        document.querySelectorAll('.error-message').forEach(el => {\r\n            el.style.display = 'none';\r\n        });\r\n\r\n        \/\/ 2. RUN VALIDATION\r\n        const isValid = validateCurrentStep();\r\n\r\n        if (isValid === false) {\r\n            console.log('>>> VALIDATION FAILED. STOPPING NAVIGATION. <<<');\r\n            nextBtn.style.boxShadow = '0 0 0 3px #fa755a';\r\n            setTimeout(() => nextBtn.style.boxShadow = '', 800);\r\n            return; \/\/ STOP\r\n        }\r\n\r\n        console.log('>>> VALIDATION PASSED. MOVING TO NEXT STEP. <<<');\r\n\r\n        \/\/ 3. PROCEED TO NEXT STEP\r\n        const currentStepEl = document.querySelector('.step.active');\r\n        if (!currentStepEl) {\r\n            console.error(\"No active step found\");\r\n            return;\r\n        }\r\n\r\n        const currentStepNum = parseInt(currentStepEl.dataset.step, 10);\r\n        const targetStepNum = currentStepNum + 1;\r\n        const nextStepEl = document.querySelector(`.step[data-step=\"${targetStepNum}\"]`);\r\n\r\n        if (nextStepEl) {\r\n            \/\/ Switch Steps\r\n            currentStepEl.classList.remove('active');\r\n            currentStepEl.classList.remove('force-active');\r\n            \r\n            nextStepEl.classList.add('active');\r\n            nextStepEl.classList.add('force-active');\r\n\r\n            \/\/ Update Progress\r\n            updateProgressIndicators(targetStepNum);\r\n\r\n            \/\/ Buttons\r\n            document.getElementById('previousBtn').style.display = 'block';\r\n            if (targetStepNum === 3) {\r\n                nextBtn.style.display = 'none';\r\n                document.getElementById('submitBtn').style.display = 'block';\r\n            } else {\r\n                nextBtn.style.display = 'block';\r\n                document.getElementById('submitBtn').style.display = 'none';\r\n            }\r\n\r\n            \/\/ Restore & Scroll\r\n            \/\/setTimeout(restoreFormData, 100); \r\n            window.scrollTo({ top: 0, behavior: 'smooth' });\r\n        }\r\n    });\r\n\r\n    prevBtn.addEventListener('click', function(e) {\r\n        \/*const current = document.querySelector('.step.active');\r\n        const prev = current.previousElementSibling;\r\n        if (prev && prev.classList.contains('step')) {\r\n            current.classList.remove('active');\r\n            prev.classList.add('active');\r\n            if (prev.dataset.step === '1') prevBtn.style.display = 'none';\r\n            nextBtn.style.display = 'block';\r\n            submitBtn.style.display = 'none';\r\n        }*\/\r\n        e.preventDefault();\r\n        e.stopImmediatePropagation();\r\n\r\n        const currentStepEl = document.querySelector('.step.active');\r\n        if (!currentStepEl) return;\r\n\r\n        const currentStepNum = parseInt(currentStepEl.dataset.step, 10);\r\n        const targetStepNum = currentStepNum - 1;\r\n\r\n        const prevStepEl = document.querySelector(`.step[data-step=\"${targetStepNum}\"]`);\r\n\r\n        if (prevStepEl) {\r\n            currentStepEl.classList.remove('active');\r\n            currentStepEl.classList.remove('force-active');\r\n            prevStepEl.classList.add('active');\r\n            prevStepEl.classList.add('force-active');\r\n\r\n            updateProgressIndicators(targetStepNum);\r\n\r\n            document.getElementById('previousBtn').style.display = targetStepNum === 1 ? 'none' : 'block';\r\n            document.getElementById('nextBtn').style.display = 'block';\r\n            document.getElementById('submitBtn').style.display = 'none';\r\n\r\n           \r\n\r\n            window.scrollTo({ top: 0, behavior: 'smooth' });\r\n        } else {\r\n            console.warn('Previous step not found');\r\n        }\r\n    });\r\n\r\n    function updateProgressIndicators(stepNumber) {\r\n        const indicators = document.querySelectorAll('.progress-steps .step-indicator');\r\n        indicators.forEach((dot, index) => {\r\n            if (index + 1 <= stepNumber) {\r\n                dot.classList.add('active');\r\n                dot.classList.add('force-active');\r\n            } else {\r\n                dot.classList.remove('active');\r\n                dot.classList.remove('force-active');\r\n            }\r\n        });\r\n        console.log(`Progress indicators updated to step ${stepNumber}`);\r\n    }\r\n\r\n    \/\/ ==================== BASIC VALIDATION HELPERS ====================\r\n    function showError(fieldId, message) {\r\n        let errorEl = document.getElementById(`error-${fieldId}`);\r\n        if (!errorEl) {\r\n            const field = document.getElementById(fieldId);\r\n            if (field) {\r\n                errorEl = document.createElement('div');\r\n                errorEl.className = 'error-message';\r\n                errorEl.id = `error-${fieldId}`;\r\n                field.parentNode.appendChild(errorEl);\r\n            }\r\n        }\r\n        if (errorEl) {\r\n            errorEl.textContent = message;\r\n            errorEl.style.display = 'block';\r\n        }\r\n        \/\/ Check if element exists before adding class\r\n        const fieldEl = document.getElementById(fieldId);\r\n        if(fieldEl) fieldEl.classList.add('input-error');\r\n    }\r\n\r\n    function clearError(fieldId) {\r\n        const errorEl = document.getElementById(`error-${fieldId}`);\r\n        if (errorEl) {\r\n            errorEl.textContent = '';\r\n            errorEl.style.display = 'none';\r\n        }\r\n        const fieldEl = document.getElementById(fieldId);\r\n        if(fieldEl) fieldEl.classList.remove('input-error');\r\n    }\r\n\r\n    function clearAllErrors() {\r\n        document.querySelectorAll('.error-message').forEach(el => {\r\n            el.textContent = '';\r\n            el.style.display = 'none';\r\n        });\r\n        document.querySelectorAll('.input-error').forEach(el => el.classList.remove('input-error'));\r\n    }\r\n\r\n    function validateCurrentStep() {\r\n        \/\/ clearAllErrors(); \/\/ Removed: Call this inside the button click to strictly follow requested flow\r\n        \r\n        const currentStepEl = document.querySelector('.step.active');\r\n        if (!currentStepEl) return true;\r\n\r\n        const step = currentStepEl.dataset.step;\r\n        let isValid = true;\r\n\r\n        \/\/ --- STEP 1 VALIDATION ---\r\n        if (step === '1') {\r\n            const requiredIds = ['firstName', 'surname', 'businessName', 'natureOfBusiness'];\r\n            \r\n            \/\/ Check text inputs\r\n            requiredIds.forEach(id => {\r\n                const val = document.getElementById(id).value.trim();\r\n                if (!val) {\r\n                    showError(id, 'This field is required');\r\n                    isValid = false;\r\n                }\r\n            });\r\n\r\n            \/\/ Address Validation Logic\r\n            \/\/ --- SPECIFIC ADDRESS WRAP VALIDATION LOGIC ---\r\n            const addressFields = document.querySelector('.address-fields');\r\n            const isAddressVisible = addressFields && addressFields.classList.contains('visible');\r\n            const errorContainer = document.getElementById('error-addresswrap');\r\n\r\n            if (!isAddressVisible) {\r\n                \/\/ Logic: If address fields are NOT visible, user has NOT selected an address \r\n                \/\/ AND has NOT checked \"Enter address manually\".\r\n                \r\n                if (errorContainer) {\r\n                    errorContainer.textContent = 'Please search and select an address, or check \"Enter address manually\".';\r\n                    errorContainer.style.display = 'block';\r\n                }\r\n                \r\n                \/\/ Optional: Highlight the address wrap area briefly to draw attention\r\n                const wrap = document.querySelector('.addresswrap');\r\n                if(wrap) {\r\n                    wrap.style.boxShadow = \"0 0 0 3px #fa755a\";\r\n                    setTimeout(() => wrap.style.boxShadow = \"\", 1000);\r\n                }\r\n                \r\n                isValid = false;\r\n            } else {\r\n                \/\/ Address fields ARE visible. Now we check the fields inside.\r\n                \r\n                \/\/ If Manual Entry is checked -> check fields normally.\r\n                \/\/ If Postcode Lookup was used -> fields are readonly (should be filled), \r\n                \/\/ but we check Postcode just in case.\r\n                \r\n                const postCodeVal = document.getElementById('postCode').value.trim();\r\n                if (!postCodeVal) {\r\n                    showError('postCode', 'Postcode is required');\r\n                    isValid = false;\r\n                }\r\n            }\r\n            \/\/ --- ACCOUNTANT VALIDATION (Step 1) ---\r\n            const movingAccountantYes = document.getElementById('accountantYes');\r\n            if (movingAccountantYes && movingAccountantYes.checked) {\r\n                \/\/ Only validate these if \"Yes\" is selected\r\n                const accName = document.getElementById('accountantName').value.trim();\r\n                const accEmail = document.getElementById('accountantEmail').value.trim();\r\n\r\n                if (!accName) {\r\n                    showError('accountantName', 'Please enter the accountant\\'s name');\r\n                    isValid = false;\r\n                }\r\n\r\n                if (!accEmail) {\r\n                    showError('accountantEmail', 'Please enter the accountant\\'s email');\r\n                    isValid = false;\r\n                } else {\r\n                    \/\/ Optional: Simple email format check\r\n                    const emailPattern = \/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$\/;\r\n                    if (!emailPattern.test(accEmail)) {\r\n                        showError('accountantEmail', 'Please enter a valid email address');\r\n                        isValid = false;\r\n                    }\r\n                }\r\n            }\r\n        }\r\n\r\n        \/\/ --- STEP 2 VALIDATION ---\r\n        if (step === '2') {\r\n            const requiredIds = ['userDOB', 'userPhone', 'taxRefference'];\r\n            requiredIds.forEach(id => {\r\n                const val = document.getElementById(id).value.trim();\r\n                if (!val) {\r\n                    showError(id, 'This field is required');\r\n                    isValid = false;\r\n                }\r\n            });\r\n\r\n            \/\/ Gender\r\n            if (!document.querySelector('input[name=\"gender\"]:checked')) {\r\n                showError('gender', 'Please select your gender');\r\n                isValid = false;\r\n            }\r\n\r\n            \/\/ Pension Sign Validation\r\n            const pensionSignYes = document.getElementById('pensionSignYes');\r\n            \/\/ Check if the \"Yes\" radio button exists AND is checked\r\n            if (pensionSignYes && pensionSignYes.checked) {\r\n                \r\n                \/\/ Get values from the hidden fields\r\n                const penName = document.getElementById('pensionName').value.trim();\r\n                const penEmail = document.getElementById('pensionEmail').value.trim();\r\n\r\n                \/\/ Validate Name\r\n                if (!penName) {\r\n                    showError('pensionName', 'Please enter the pension name');\r\n                    isValid = false;\r\n                }\r\n\r\n                \/\/ Validate Email\r\n                if (!penEmail) {\r\n                    showError('pensionEmail', 'Please enter the pension email');\r\n                    isValid = false;\r\n                } else {\r\n                    \/\/ Simple email format check\r\n                    const emailPattern = \/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$\/;\r\n                    if (!emailPattern.test(penEmail)) {\r\n                        showError('pensionEmail', 'Please enter a valid email address');\r\n                        isValid = false;\r\n                    }\r\n                }\r\n            }\r\n\r\n            \/\/ Terms\r\n            if (!document.getElementById('terms').checked) {\r\n                showError('terms', 'You must agree to the terms and conditions');\r\n                isValid = false;\r\n            }\r\n        }\r\n\r\n        if (step === '3') {\r\n            \/\/ Terms\r\n            if (!document.getElementById('terms-last').checked) {\r\n                showError('terms-last', 'You must agree to the terms and conditions');\r\n                isValid = false;\r\n            }\r\n        }\r\n\r\n        \/\/ Scroll to first error if validation failed\r\n        if (!isValid) {\r\n            \/\/ If the address wrap error is showing, scroll there\r\n            const addressError = document.getElementById('error-addresswrap');\r\n            if (addressError && addressError.style.display === 'block') {\r\n                addressError.scrollIntoView({ behavior: 'smooth', block: 'center' });\r\n            } else {\r\n                \/\/ Otherwise scroll to first generic input error\r\n                const firstError = document.querySelector('.input-error');\r\n                if (firstError) {\r\n                    firstError.scrollIntoView({ behavior: 'smooth', block: 'center' });\r\n                }\r\n            }\r\n        }\r\n        return isValid;\r\n    }\r\n\r\n    \/\/ ==================== FORM PERSISTENCE ====================\r\n    form.addEventListener('input', function () {\r\n        const data = {};\r\n        const formData = new FormData(form);\r\n        for (let [key, value] of formData.entries()) {\r\n            data[key] = value;\r\n        }\r\n        sessionStorage.setItem('soleTraderFormData', JSON.stringify(data));\r\n    });\r\n\r\n    window.addEventListener('load', function () {\r\n        const saved = sessionStorage.getItem('soleTraderFormData');\r\n        if (saved) {\r\n            const data = JSON.parse(saved);\r\n            Object.keys(data).forEach(key => {\r\n                const els = form.querySelectorAll(`[name=\"${key}\"]`);\r\n                els.forEach(el => {\r\n                    if (el.type === 'file') return; \/\/ skip file\r\n                    if (el.type === 'radio' || el.type === 'checkbox') {\r\n                        el.checked = el.value === data[key];\r\n                    } else {\r\n                        el.value = data[key];\r\n                    }\r\n                });\r\n            });\r\n            \/\/ Trigger change events for conditional fields\r\n            document.querySelectorAll('input[name=\"movingAccountant\"]').forEach(r => r.dispatchEvent(new Event('change')));\r\n            document.querySelectorAll('input[name=\"pensionSign\"]').forEach(r => r.dispatchEvent(new Event('change')));\r\n        }\r\n    });\r\n\r\n    \/\/ ==================== SIGNATURE UPLOAD ====================\r\n    const signatureInput = document.getElementById('signatureUpload');\r\n    const previewContainer = document.getElementById('signaturePreviewContainer');\r\n    \/\/const signatureError = document.getElementById('error-signature');\r\n\r\n    if (signatureInput) {\r\n        signatureInput.addEventListener('change', function (e) {\r\n            const file = e.target.files[0];\r\n            \/\/signatureError.textContent = '';\r\n            if (!file) {\r\n                previewContainer.innerHTML = '';\r\n                sessionStorage.removeItem('signatureDataURL');\r\n                return;\r\n            }\r\n            \/*if (!file.type.startsWith('image\/')) {\r\n                signatureError.textContent = 'Please upload an image file';\r\n                signatureInput.value = '';\r\n                return;\r\n            }\r\n            if (file.size > 3 * 1024 * 1024) {\r\n                signatureError.textContent = 'Image must be smaller than 3MB';\r\n                signatureInput.value = '';\r\n                return;\r\n            }*\/\r\n            const reader = new FileReader();\r\n            reader.onload = function (ev) {\r\n                const img = document.createElement('img');\r\n                img.src = ev.target.result;\r\n                img.style.maxWidth = '450px';\r\n                img.style.maxHeight = '160px';\r\n                img.style.marginTop = '15px';\r\n                previewContainer.innerHTML = '';\r\n                previewContainer.appendChild(img);\r\n                sessionStorage.setItem('signatureDataURL', ev.target.result);\r\n            };\r\n            reader.readAsDataURL(file);\r\n        });\r\n    }\r\n\r\n    \/\/ Restore signature preview on load\r\n    window.addEventListener('load', () => {\r\n        const savedSig = sessionStorage.getItem('signatureDataURL');\r\n        if (savedSig && previewContainer) {\r\n            const img = document.createElement('img');\r\n            img.src = savedSig;\r\n            img.style.maxWidth = '450px';\r\n            img.style.maxHeight = '160px';\r\n            img.style.marginTop = '15px';\r\n            previewContainer.innerHTML = '';\r\n            previewContainer.appendChild(img);\r\n        }\r\n    });\r\n\r\n    \/\/ ==================== STRIPE PAYMENT SETUP ====================\r\n    const mode = 'test'; \/\/ change to 'live' when ready\r\n    fetch(ajaxurl, {\r\n        method: 'POST',\r\n        headers: { 'Content-Type': 'application\/x-www-form-urlencoded' },\r\n        body: new URLSearchParams({\r\n            action: 'get_stripe_keys',\r\n            security: ajaxNonce,\r\n            mode: mode\r\n        })\r\n    })\r\n    .then(res => res.json())\r\n    .then(result => {\r\n        if (!result.success) throw new Error(result.data?.message || 'Key error');\r\n        stripe = Stripe(result.data.publishable_key);\r\n\r\n        return fetch(ajaxurl, {\r\n            method: 'POST',\r\n            headers: { 'Content-Type': 'application\/x-www-form-urlencoded' },\r\n            body: new URLSearchParams({\r\n                action: 'get_stripe_client_secret',\r\n                security: ajaxNonce,\r\n                mode: mode\r\n            })\r\n        });\r\n    })\r\n    .then(res => res.json())\r\n    .then(result => {\r\n        if (!result.success) throw new Error(result.data?.message || 'Secret error');\r\n        clientSecret = result.data.clientSecret;\r\n\r\n        const options = {\r\n            clientSecret,\r\n            layout: { type: 'tabs', defaultCollapsed: false },\r\n            paymentMethods: { applePay: 'always', googlePay: 'always' }\r\n        };\r\n        elements = stripe.elements(options);\r\n        paymentElement = elements.create('payment');\r\n        paymentElement.mount('#payment-element');\r\n\r\n        paymentElement.on('change', event => {\r\n            document.getElementById('payment-errors').textContent = event.error ? event.error.message : '';\r\n        });\r\n    })\r\n    .catch(err => {\r\n        console.error(err);\r\n        document.body.insertAdjacentHTML('beforeend',\r\n            '<div style=\"background:#f44336;color:white;padding:20px;text-align:center;\">Payment system failed to load.<\/div>');\r\n    });\r\n\r\n    \/\/ ==================== FINAL SUBMIT ====================\r\n    submitBtn.addEventListener('click', async function (e) {\r\n        e.preventDefault();\r\n\r\n        clearAllErrors();\r\n\r\n        \/\/ Terms checkbox\r\n        if (!document.getElementById('terms-last').checked) {\r\n            document.getElementById('error-terms-last').textContent = 'You must agree to the payment terms';\r\n            return;\r\n        }\r\n\r\n        \r\n\r\n        if (!stripe || !elements || !clientSecret) {\r\n            alert('Payment system not ready');\r\n            return;\r\n        }\r\n\r\n        submitBtn.disabled = true;\r\n        submitBtn.textContent = 'Processing...';\r\n\r\n        const { error: submitError } = await elements.submit();\r\n        if (submitError) {\r\n            alert(submitError.message);\r\n            submitBtn.disabled = false;\r\n            submitBtn.textContent = 'Submit';\r\n            return;\r\n        }\r\n\r\n        const { error } = await stripe.confirmPayment({\r\n            elements,\r\n            clientSecret,\r\n            confirmParams: {\r\n                return_url: window.location.href + '?payment=success&payment_intent=' + clientSecret.split('_secret_')[0]\r\n            }\r\n        });\r\n\r\n        if (error) {\r\n            alert(error.message);\r\n            submitBtn.disabled = false;\r\n            submitBtn.textContent = 'Submit';\r\n        }\r\n        \/\/ Success \u2192 redirect handled by Stripe\r\n    });\r\n\r\n    \/\/ ==================== HUBSPOT SUBMISSION ON SUCCESS ====================\r\n    if (window.location.search.includes('payment=success')) {\r\n        (function() {\r\n            const saved = sessionStorage.getItem('soleTraderFormData');\r\n            if (!saved) {\r\n                console.warn('No form data for HubSpot');\r\n                return;\r\n            }\r\n            const data = JSON.parse(saved);\r\n            const transactionId = new URLSearchParams(window.location.search).get('payment_intent') || 'Test-Mode';\r\n            const signatureURL = sessionStorage.getItem('signatureDataURL') || '';\r\n\r\n            function getHubspotUtk() {\r\n                const cookies = document.cookie.split(';');\r\n                for (let cookie of cookies) {\r\n                    cookie = cookie.trim();\r\n                    if (cookie.startsWith('hubspotutk=')) {\r\n                        return cookie.substring(11);\r\n                    }\r\n                }\r\n                return '';\r\n            }\r\n\r\n            const hsFields = [\r\n                { name: \"firstname\", value: data.firstName || '' },\r\n                { name: \"lastname\", value: data.surname || '' },\r\n                { name: \"name_of_business\", value: data.businessName || '' },\r\n                { name: \"nature_of_business\", value: data.natureOfBusiness || '' },\r\n                { name: \"phone\", value: data.userPhone || '' },\r\n                { name: \"date_of_birth\", value: data.userDOB || '' },\r\n                { name: \"gender\", value: data.gender || '' },\r\n                { name: \"unique_tax_reference\", value: data.taxRefference || '' },\r\n                { name: \"pending_convictions_\", value: data.convictions === 'yes' ? 'Yes' : 'No' },\r\n                { name: \"pension_signing_\", value: data.pensionSign === 'yes' ? 'Yes' : 'No' },\r\n                { name: \"pension_accountant_name\", value: data.pensionName || '' },\r\n                { name: \"pension_accountant_email\", value: data.pensionEmail || '' },\r\n                { name: \"house_name\", value: data.houseName || '' },\r\n                { name: \"address\", value: data.streetName || '' },\r\n                { name: \"city\", value: data.city || '' },\r\n                { name: \"country\", value: 'United Kingdom' },\r\n                { name: \"zip\", value: data.postCode || '' },\r\n                { name: \"another_account\", value: data.movingAccountant === 'yes' ? 'Yes' : 'No' },\r\n                { name: \"accountant_name\", value: data.accountantName || '' },\r\n                { name: \"email\", value: data.accountantEmail || '' },\r\n                { name: \"transaction_id\", value: transactionId },\r\n                { name: \"signature\", value: signatureURL || '' }\r\n            ];\r\n\r\n            const payload = {\r\n                fields: hsFields,\r\n                context: {\r\n                    hutk: getHubspotUtk(),\r\n                    pageUri: window.location.href,\r\n                    pageName: document.title\r\n                }\r\n            };\r\n\r\n            fetch('https:\/\/api-eu1.hsforms.com\/submissions\/v3\/integration\/submit\/147342664\/daa2d0b8-ad49-490b-beda-417d282a3be3', {\r\n                method: 'POST',\r\n                headers: { 'Content-Type': 'application\/json' },\r\n                body: JSON.stringify(payload)\r\n            })\r\n            .then(res => console.log(res.ok ? 'HubSpot submission successful' : 'HubSpot submission failed'))\r\n            .catch(err => console.error('HubSpot error:', err));\r\n        })();\r\n    }\r\n\r\n    \/\/ ==================== PDF DOWNLOAD (Sole Trader Version) ====================\r\n    document.getElementById('downloadPdfBtn').addEventListener('click', async function () {\r\n        const { jsPDF } = window.jspdf;\r\n        const saved = sessionStorage.getItem('soleTraderFormData');\r\n        if (!saved) {\r\n            alert('No form data found. Please submit the form again.');\r\n            return;\r\n        }\r\n\r\n        const data = JSON.parse(saved);\r\n        const urlParams = new URLSearchParams(window.location.search);\r\n        const transactionId = urlParams.get('payment_intent') || 'Test-Mode';\r\n\r\n        const pdfContent = document.createElement('div');\r\n        pdfContent.style.padding = '40px';\r\n        pdfContent.style.fontFamily = 'Arial, sans-serif';\r\n        pdfContent.style.background = 'white';\r\n        pdfContent.style.color = '#333';\r\n        pdfContent.style.maxWidth = '800px';\r\n        pdfContent.style.margin = '0 auto';\r\n        pdfContent.style.lineHeight = '1.6';\r\n        pdfContent.style.fontSize = '14px';\r\n\r\n        \/\/ Signature section\r\n        const signatureDataURL = sessionStorage.getItem('signatureDataURL');\r\n        const signatureSection = signatureDataURL\r\n            ? `<div style=\"margin-top: 80px; text-align: center; page-break-inside: avoid;\">\r\n                 <p style=\"font-size: 18px; font-weight: bold; margin-bottom: 30px;\">Signed by: ${data.firstName || ''} ${data.surname || ''}<\/p>\r\n                 <img decoding=\"async\" src=\"${signatureDataURL}\" style=\"max-height: 140px; max-width: 500px; background: white; border-bottom: 2px solid #333;\" alt=\"Signature\">\r\n                 <p style=\"margin-top: 20px; font-style: italic; color: #555;\">\r\n                     Signature Date: ${new Date().toLocaleDateString('en-GB')}\r\n                 <\/p>\r\n               <\/div>`\r\n            : `<div style=\"margin-top: 80px; text-align: center; color: #999;\">\r\n                 <p><em>No signature uploaded<\/em><\/p>\r\n               <\/div>`;\r\n\r\n        pdfContent.innerHTML = `\r\n            <h1 style=\"text-align:center; color:#2c7a2c; font-size:30px; margin-bottom:10px;\">Sole Trader Registration Confirmation<\/h1>\r\n            <p style=\"text-align:center; font-size:18px;\"><strong>Transaction ID:<\/strong> ${transactionId}<\/p>\r\n            <p style=\"text-align:center; font-size:16px;\">Date: ${new Date().toLocaleDateString('en-GB')}<\/p>\r\n            <hr style=\"margin:40px 0; border:0; border-top:2px solid #2c7a2c;\">\r\n\r\n            <h2 style=\"color:#2c7a2c; font-size:22px; margin-top:30px;\">Personal Details<\/h2>\r\n            <p><strong>First Name:<\/strong> ${data.firstName || ''}<\/p>\r\n            <p><strong>Surname:<\/strong> ${data.surname || ''}<\/p>\r\n            <p><strong>Date of Birth:<\/strong> ${data.userDOB || ''}<\/p>\r\n            <p><strong>Gender:<\/strong> ${data.gender || ''}<\/p>\r\n            <p><strong>Phone Number:<\/strong> ${data.userPhone || ''}<\/p>\r\n            <p><strong>Unique Tax Reference (UTR):<\/strong> ${data.taxRefference || ''}<\/p>\r\n            <p><strong>Pending Convictions:<\/strong> ${data.convictions === 'yes' ? 'Yes' : 'No'}<\/p>\r\n\r\n            <h2 style=\"color:#2c7a2c; font-size:22px; margin-top:40px;\">Business Details<\/h2>\r\n            <p><strong>Business Name:<\/strong> ${data.businessName || ''}<\/p>\r\n            <p><strong>Nature of Business:<\/strong> ${data.natureOfBusiness || ''}<\/p>\r\n\r\n            <h2 style=\"color:#2c7a2c; font-size:22px; margin-top:40px;\">Business Address<\/h2>\r\n            <p><strong>House No. or Name:<\/strong> ${data.houseName || ''}<\/p>\r\n            <p><strong>Street:<\/strong> ${data.streetName || ''}<\/p>\r\n            <p><strong>City:<\/strong> ${data.city || ''}<\/p>\r\n            <p><strong>Post Code:<\/strong> ${data.postCode || ''}<\/p>\r\n            <p><strong>Country:<\/strong> United Kingdom<\/p>\r\n\r\n            ${data.movingAccountant === 'yes' ? `\r\n            <h2 style=\"color:#2c7a2c; font-size:22px; margin-top:40px;\">Previous Accountant<\/h2>\r\n            <p><strong>Moving from another accountant:<\/strong> Yes<\/p>\r\n            <p><strong>Accountant Name:<\/strong> ${data.accountantName || ''}<\/p>\r\n            <p><strong>Accountant Email:<\/strong> ${data.accountantEmail || ''}<\/p>\r\n            ` : ''}\r\n\r\n            ${data.pensionSign === 'yes' ? `\r\n            <h2 style=\"color:#2c7a2c; font-size:22px; margin-top:40px;\">Pension Signatory<\/h2>\r\n            <p><strong>Name:<\/strong> ${data.pensionName || ''}<\/p>\r\n            <p><strong>Email:<\/strong> ${data.pensionEmail || ''}<\/p>\r\n            ` : ''}\r\n\r\n            ${signatureSection}\r\n\r\n            <div style=\"margin-top:80px; text-align:center; color:#777; font-size:14px;\">\r\n                <p>Thank you for registering with us as a sole trader.<\/p>\r\n                <p>One of our team will be in contact shortly to confirm your setup.<\/p>\r\n                <p><strong>AccTek Ltd<\/strong><\/p>\r\n            <\/div>\r\n        `;\r\n\r\n        \/\/ Render hidden content for PDF\r\n        document.body.appendChild(pdfContent);\r\n        pdfContent.style.position = 'absolute';\r\n        pdfContent.style.left = '-9999px';\r\n        pdfContent.style.top = '0';\r\n        pdfContent.style.width = '800px';\r\n\r\n        const canvas = await html2canvas(pdfContent, {\r\n            scale: 2,\r\n            useCORS: true,\r\n            logging: false\r\n        });\r\n\r\n        const imgData = canvas.toDataURL('image\/png');\r\n        const pdf = new jsPDF('p', 'mm', 'a4');\r\n        const pdfWidth = pdf.internal.pageSize.getWidth();\r\n        const pdfHeight = pdf.internal.pageSize.getHeight();\r\n        const imgWidth = pdfWidth - 30;\r\n        const imgHeight = (canvas.height * imgWidth) \/ canvas.width;\r\n\r\n        let heightLeft = imgHeight;\r\n        let position = 15;\r\n\r\n        pdf.addImage(imgData, 'PNG', 15, position, imgWidth, imgHeight);\r\n        heightLeft -= pdfHeight - 30;\r\n\r\n        while (heightLeft > 0) {\r\n            position = heightLeft - imgHeight + 15;\r\n            pdf.addPage();\r\n            pdf.addImage(imgData, 'PNG', 15, position, imgWidth, imgHeight);\r\n            heightLeft -= pdfHeight - 30;\r\n        }\r\n\r\n        pdf.save(`Sole-Trader-Registration-${transactionId}.pdf`);\r\n\r\n        \/\/ Cleanup\r\n        document.body.removeChild(pdfContent);\r\n        sessionStorage.removeItem('soleTraderFormData');\r\n        sessionStorage.removeItem('signatureDataURL');\r\n    });\r\n});\r\n<\/script><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"content-type":"","footnotes":""},"class_list":["post-746","page","type-page","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/fm-connect1.fortmindz.in\/wp-godwin-pinto\/wp-json\/wp\/v2\/pages\/746","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fm-connect1.fortmindz.in\/wp-godwin-pinto\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/fm-connect1.fortmindz.in\/wp-godwin-pinto\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/fm-connect1.fortmindz.in\/wp-godwin-pinto\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fm-connect1.fortmindz.in\/wp-godwin-pinto\/wp-json\/wp\/v2\/comments?post=746"}],"version-history":[{"count":5,"href":"https:\/\/fm-connect1.fortmindz.in\/wp-godwin-pinto\/wp-json\/wp\/v2\/pages\/746\/revisions"}],"predecessor-version":[{"id":969,"href":"https:\/\/fm-connect1.fortmindz.in\/wp-godwin-pinto\/wp-json\/wp\/v2\/pages\/746\/revisions\/969"}],"wp:attachment":[{"href":"https:\/\/fm-connect1.fortmindz.in\/wp-godwin-pinto\/wp-json\/wp\/v2\/media?parent=746"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}