(()=>{"use strict";var e={455(e){e.exports=window.wp.apiFetch}};const t={};function n(o){const a=t[o];if(void 0!==a)return a.exports;const r=t[o]={exports:{}};return e[o](r,r.exports,n),r.exports}n.n=e=>{const t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{if(Array.isArray(t))for(var o=0;o<t.length;){var a=t[o++],r=t[o++];n.o(e,a)?0===r&&o++:0===r?Object.defineProperty(e,a,{enumerable:!0,value:t[o++]}):Object.defineProperty(e,a,{enumerable:!0,get:r})}else for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},n.o=(e,t)=>Object.hasOwn(e,t);var o=n(455),a=n.n(o);!function(){function e(){const e=new URLSearchParams(window.location.search),n=e.get("transaction_id"),o=e.get("token")||"";n?function(e,n){const o=n?`/fair-payments-connector/v1/payments/${e}/status?token=${encodeURIComponent(n)}`:`/fair-payments-connector/v1/payments/${e}/status`;a()({path:o,method:"GET"}).then(e=>{!function(e){const n=e.status;let o="",a="info";switch(n){case"paid":case"completed":o=`Thank you! Your payment of ${e.amount} ${e.currency} has been successfully processed.`,a="success";break;case"pending_payment":case"pending":o=`Your payment of ${e.amount} ${e.currency} is being processed. You will receive a confirmation shortly.`,a="info";break;case"failed":case"expired":case"canceled":o=`Your payment of ${e.amount} ${e.currency} was not completed. Please try again.`,a="error";break;case"draft":o="Your payment is still being initialized. Please wait...",a="info";break;default:o=`Payment status: ${n}`,a="info"}e.testmode&&(o+=" (Test Mode)"),t(o,a)}(e)}).catch(e=>{console.error("Fair Payments Connector: Failed to fetch transaction status",e),function(e){t(e.message||"Failed to retrieve payment status. Please contact support.","error")}(e)})}(n,o):console.error("Fair Payments Connector: No transaction_id found in URL")}function t(e,t){const n=document.createElement("div");n.className=`fair-payments-connector-notification fair-payments-connector-notification--${t}`,n.setAttribute("role","alert"),n.setAttribute("aria-live","polite");const o=document.createElement("p");o.textContent=e,n.appendChild(o);const a=document.createElement("button");a.textContent="×",a.className="fair-payments-connector-notification__dismiss",a.setAttribute("aria-label","Dismiss notification"),a.addEventListener("click",()=>{n.remove()}),n.appendChild(a);const r=document.querySelector("body");r.insertBefore(n,r.firstChild),"success"!==t&&"info"!==t||setTimeout(()=>{n.parentNode&&(n.classList.add("fair-payments-connector-notification--fade-out"),setTimeout(()=>n.remove(),500))},1e4)}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}()})();
//# sourceMappingURL=payment-callback.js.map