Changeset 3467072
- Timestamp:
- 02/22/2026 07:20:51 PM (2 weeks ago)
- Location:
- payplus-payment-gateway/trunk
- Files:
-
- 7 edited
-
CHANGELOG.md (modified) (1 diff)
-
block/dist/js/woocommerce-blocks/blocks.js (modified) (4 diffs)
-
block/dist/js/woocommerce-blocks/blocks.min.js (modified) (1 diff)
-
hashes.json (modified) (3 diffs)
-
includes/blocks/class-wc-payplus-blocks-support.php (modified) (1 diff)
-
payplus-payment-gateway.php (modified) (4 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
payplus-payment-gateway/trunk/CHANGELOG.md
r3466884 r3467072 2 2 3 3 All notable changes to this project will be documented in this file. 4 5 ## [8.1.1] - 23-02-2026 - (Speed) 6 7 - Fix - TV power-down effect in Blocks Checkout is now driven by the plugin setting rather than CSS positioning, ensuring it triggers reliably regardless of theme styles. 8 - Tweak - Blocks Checkout popup and same-page iframe modes now open instantly — the PayPlus payment page link is fetched asynchronously after checkout submission instead of blocking the Store API response. 4 9 5 10 ## [8.1.0] - 22-02-2026 - (Bill) -
payplus-payment-gateway/trunk/block/dist/js/woocommerce-blocks/blocks.js
r3466884 r3467072 115 115 // 1. Feature is enabled (popupTvEffect setting) 116 116 // 2. .pp_iframe container exists 117 // 3. The iframe is actually in popup mode (position: fixed, not relative)117 // 3. viewMode is popupIframe (trust the setting, not the CSS) 118 118 if ( 119 119 payPlusGateWay && 120 120 payPlusGateWay.popupTvEffect && 121 payPlusGateWay.viewMode === 'popupIframe' && 121 122 jQuery('.pp_iframe').length > 0 122 123 ) { 124 _payplusTvEffectInProgress = true; 125 _payplusPollDone = true; // Stop polling from redirecting 126 123 127 var $popup = jQuery('.pp_iframe'); 124 128 125 // Check if the iframe is actually displayed as a popup (fixed positioning) 126 // samePageIframe uses position: relative, popupIframe uses position: fixed 127 var isActuallyPopup = $popup.css('position') === 'fixed'; 129 // FORCE the correct popup positioning (in case something overrode it) 130 $popup.css({ 131 'position': 'fixed', 132 'top': '50%', 133 'left': '50%', 134 'transform': 'translate(-50%, -50%)', 135 'z-index': '100000' 136 }); 128 137 129 if (isActuallyPopup) { 130 _payplusTvEffectInProgress = true; 131 _payplusPollDone = true; // Stop polling from redirecting 132 133 // Add TV closing class to the .pp_iframe container div (popup only) 134 $popup.addClass('tv-closing-blocks'); 135 136 // Force a reflow to ensure CSS is applied 137 $popup[0].offsetHeight; 138 139 // Wait for animation to complete (1000ms) then redirect 140 setTimeout(function() { 141 window.location.href = url; 142 }, 1050); 143 144 // IMPORTANT: Return without redirecting immediately 145 return; 146 } 138 // Add TV closing class to the .pp_iframe container div 139 $popup.addClass('tv-closing-blocks'); 140 141 // Force a reflow to ensure CSS is applied 142 $popup[0].offsetHeight; 143 144 // Wait for animation to complete (1000ms) then redirect 145 setTimeout(function() { 146 window.location.href = url; 147 }, 1050); 148 149 // IMPORTANT: Return without redirecting immediately 150 return; 147 151 } 148 152 … … 340 344 loader.appendChild(loaderContent); 341 345 342 // Add early loading indicator for Place Order button343 function addEarlyLoadingIndicator() {344 const placeOrderButton = document.querySelector(345 ".wc-block-checkout__actions_row button"346 );347 348 if (placeOrderButton && !placeOrderButton.hasAttribute('data-payplus-listener')) {349 placeOrderButton.setAttribute('data-payplus-listener', 'true');350 placeOrderButton.addEventListener("click", function () {351 const activePaymentMethod = payment.getActivePaymentMethod();352 353 // Check if it's a PayPlus payment method354 if (activePaymentMethod && activePaymentMethod.includes("payplus-payment-gateway")) {355 // Show loading immediately356 const overlay = document.createElement("div");357 overlay.id = "early-payplus-overlay";358 overlay.style.cssText = `359 position: fixed;360 top: 0;361 left: 0;362 width: 100%;363 height: 100%;364 background-color: rgba(0, 0, 0, 0.5);365 z-index: 999999;366 display: flex;367 align-items: center;368 justify-content: center;369 `;370 371 const loadingContainer = document.createElement("div");372 loadingContainer.style.cssText = `373 background: white;374 padding: 30px 50px;375 border-radius: 12px;376 text-align: center;377 color: #333;378 box-shadow: 0 8px 32px rgba(0,0,0,0.3);379 min-width: 300px;380 `;381 382 const loadingText = document.createElement("div");383 loadingText.style.cssText = `384 font-size: 18px;385 font-weight: 500;386 margin-bottom: 15px;387 `;388 389 const loadingDots = document.createElement("div");390 loadingDots.style.cssText = `391 font-size: 24px;392 color: #007cba;393 `;394 395 loadingContainer.appendChild(loadingText);396 loadingContainer.appendChild(loadingDots);397 overlay.appendChild(loadingContainer);398 document.body.appendChild(overlay);399 400 // Animate dots401 let dotCount = 0;402 const animateDots = () => {403 dotCount = (dotCount % 3) + 1;404 loadingDots.textContent = '.'.repeat(dotCount);405 };406 const dotInterval = setInterval(animateDots, 400);407 408 // Check if it's hosted fields payment method409 if (activePaymentMethod === "payplus-payment-gateway-hostedfields") {410 // For hosted fields: show "Processing your payment now..."411 loadingText.textContent = (window.payplus_i18n && window.payplus_i18n.processing_payment)412 ? window.payplus_i18n.processing_payment413 : "Processing your payment now";414 } else {415 // For other PayPlus methods: Phase 1: Generating payment page (1-1.5 seconds)416 loadingText.textContent = (window.payplus_i18n && window.payplus_i18n.generating_page)417 ? window.payplus_i18n.generating_page418 : "Generating payment page";419 const phase1Duration = Math.random() * 1000 + 4000; // 4-5 seconds420 421 setTimeout(() => {422 // Phase 2: Loading payment page (until store.isComplete() is true)423 loadingText.textContent = (window.payplus_i18n && window.payplus_i18n.loading_page)424 ? window.payplus_i18n.loading_page425 : "Loading payment page";426 }, phase1Duration);427 }428 429 // Only remove when store actually completes or error occurs430 const checkForCompletion = setInterval(() => {431 // Check if checkout is complete or has error432 if (store.isComplete() || store.hasError()) {433 clearInterval(dotInterval);434 clearInterval(checkForCompletion);435 const earlyOverlay = document.getElementById("early-payplus-overlay");436 if (earlyOverlay) {437 earlyOverlay.remove();438 }439 }440 }, 100);441 442 // Safety cleanup after 15 seconds (extended time)443 setTimeout(() => {444 clearInterval(dotInterval);445 clearInterval(checkForCompletion);446 const earlyOverlay = document.getElementById("early-payplus-overlay");447 if (earlyOverlay) {448 earlyOverlay.remove();449 }450 }, 15000);451 }452 });453 }454 }455 456 // Try to add the early loading indicator immediately and periodically457 addEarlyLoadingIndicator();458 const intervalId = setInterval(() => {459 addEarlyLoadingIndicator();460 }, 1000);461 462 // Clear interval after 10 seconds to avoid memory leaks463 setTimeout(() => {464 clearInterval(intervalId);465 }, 10000);466 467 346 function startObserving(event) { 468 347 console.log("observer started"); … … 689 568 // Call the function to handle the target element 690 569 if (isIframe) { 691 if ( 692 payment.getPaymentResult().paymentDetails 693 .paymentPageLink?.length > 0 694 ) { 695 console.log( 696 "paymentPageLink", 697 payment.getPaymentResult() 698 .paymentDetails.paymentPageLink 699 ); 700 startIframe( 701 payment.getPaymentResult() 702 .paymentDetails.paymentPageLink, 703 overlay, 704 loader 705 ); 706 // Start polling for order status (fallback for redirect) 707 var paymentDetails = payment.getPaymentResult().paymentDetails; 570 var paymentDetails = payment.getPaymentResult().paymentDetails; 571 572 if (paymentDetails.payplus_iframe_async) { 573 // Async mode: Store API returned instantly (no PayPlus HTTP call yet). 574 // Show the iframe container immediately, then fetch the link via AJAX. 575 startOrderStatusPoll({ 576 order_id: paymentDetails.order_id, 577 order_received_url: paymentDetails.order_received_url 578 }); 579 // Show overlay/container right away with a blank src. 580 startIframe('about:blank', overlay, loader); 581 // Now fetch the actual PayPlus payment page link. 582 jQuery.ajax({ 583 type: 'POST', 584 url: payplus_script.ajax_url, 585 data: { 586 action: 'payplus_get_iframe_link', 587 _ajax_nonce: payplus_script.frontNonce, 588 order_id: paymentDetails.order_id, 589 order_key: paymentDetails.order_key, 590 }, 591 success: function(resp) { 592 if (resp.success && resp.data && resp.data.payment_page_link) { 593 var iframe = document.getElementById('pp_iframe'); 594 if (iframe) { 595 iframe.src = resp.data.payment_page_link; 596 } 597 } else { 598 var errMsg = (resp.data && resp.data.message) 599 ? resp.data.message 600 : ((window.payplus_i18n && window.payplus_i18n.payment_page_failed) 601 ? window.payplus_i18n.payment_page_failed 602 : 'Error: the payment page failed to load.'); 603 alert(errMsg); 604 location.reload(); 605 } 606 }, 607 error: function() { 608 alert((window.payplus_i18n && window.payplus_i18n.payment_page_failed) 609 ? window.payplus_i18n.payment_page_failed 610 : 'Error: the payment page failed to load.'); 611 location.reload(); 612 } 613 }); 614 } else if (paymentDetails.paymentPageLink && paymentDetails.paymentPageLink.length > 0) { 615 // Legacy sync path — link already in paymentDetails. 616 console.log("paymentPageLink", paymentDetails.paymentPageLink); 617 startIframe(paymentDetails.paymentPageLink, overlay, loader); 708 618 if (paymentDetails.order_id && paymentDetails.order_received_url) { 709 619 startOrderStatusPoll({ … … 712 622 }); 713 623 } 714 // Disconnect the observer to stop observing further changes715 624 } else { 716 625 alert( 717 (window.payplus_i18n && window.payplus_i18n.payment_page_failed) 718 ? window.payplus_i18n.payment_page_failed 626 (window.payplus_i18n && window.payplus_i18n.payment_page_failed) 627 ? window.payplus_i18n.payment_page_failed 719 628 : "Error: the payment page failed to load." 720 629 ); -
payplus-payment-gateway/trunk/block/dist/js/woocommerce-blocks/blocks.min.js
r3466884 r3467072 1 const{CHECKOUT_STORE_KEY:CHECKOUT_STORE_KEY}=window.wc.wcBlocksData,{PAYMENT_STORE_KEY:PAYMENT_STORE_KEY}=window.wc.wcBlocksData,store=wp.data.select(CHECKOUT_STORE_KEY),payment=wp.data.select(PAYMENT_STORE_KEY),hasOrder=store.hasOrder(),isCheckout=!!document.querySelector('div[data-block-name="woocommerce/checkout"]');if(isCheckout||hasOrder){console.log("checkout page?",isCheckout),console.log("has order?",hasOrder);store.getCustomerId(),store.getAdditionalFields(),store.getOrderId();const e=window.wc.wcSettings.getPaymentMethodData("payplus-payment-gateway");function addScriptApple(){if(isMyScriptLoaded(e.importApplePayScript)){const t=document.createElement("script");t.src=e.importApplePayScript,document.body.append(t)}}function isMyScriptLoaded(e){for(var t=document.getElementsByTagName("script"), n=t.length;n--;)if(t[n].src==e)return!1;return!0}let t=window.wc.wcSettings.getPaymentMethodData("payplus-payment-gateway").gateways;t=e.isSubscriptionOrder?["payplus-payment-gateway"]:t,t=e.isSubscriptionOrder&&e.isLoggedIn?["payplus-payment-gateway","payplus-payment-gateway-hostedfields"]:t;let n=[];const o=window.React;for(let i=0;i<e.customIcons?.length;i++)n[i]=(0,o.createElement)("img",{src:e.customIcons[i],style:{maxHeight:"35px",height:"45px"}});const a=(0,o.createElement)("div",{className:"payplus-icons",style:{display:"flex",flexWrap:"wrap",width:"100%",maxWidth:"100%",gap:"5px"}},n);let s=!!e.customIcons[0]?.length;Object.keys(e.hasSavedTokens).length;const l=e.hideMainPayPlusGateway;if(e.hostedFieldsIsMain){const{dispatch:r}=window.wp.data,c=window.wc.wcBlocksData.PAYMENT_STORE_KEY,p="payplus-payment-gateway-hostedfields";try{r(c).__internalSetActivePaymentMethod(p)}catch(d){}}var _payplusPollDone=!1,_payplusTvEffectInProgress=!1;function redirectWithTvEffect(t){if(!_payplusTvEffectInProgress){if(e&&e.popupTvEffect&&jQuery(".pp_iframe").length>0){var n=jQuery(".pp_iframe");if("fixed"===n.css("position"))return _payplusTvEffectInProgress=!0,_payplusPollDone=!0,n.addClass("tv-closing-blocks"),n[0].offsetHeight,void setTimeout(function(){window.location.href=t},1050)}window.location.href=t}}function startOrderStatusPoll(t){if(t&&t.order_id&&t.order_received_url){var n=t.order_received_url,o="";try{var a=new URL(n,window.location.origin);o=a.searchParams.get("key")||""}catch(e){return}if(o){var s=0;i();var l=setInterval(function(){_payplusPollDone?clearInterval(l):i()},150)}}function i(){_payplusPollDone||s++>600||jQuery.ajax({url:e.ajax_url||window.payplus_script?.ajax_url,type:"POST",data:{action:"payplus_check_order_redirect",_ajax_nonce:e.frontNonce||window.payplus_script?.frontNonce,order_id:t.order_id,order_key:o},dataType:"json",success:function(e){if(!_payplusPollDone&&e&&e.success&&e.data&&e.data.status){var t=e.data.status;"processing"!==t&&"completed"!==t&&"wc-processing"!==t&&"wc-completed"!==t||(_payplusPollDone=!0,redirectWithTvEffect(e.data.redirect_url||n))}}})}}function startIframe(t,n,o){document.body.appendChild(n),n.appendChild(o);const a=payment.getActivePaymentMethod(),s=window.wc.wcSettings.getPaymentMethodData(a)[a+"-settings"];var l=document.createElement("iframe");l.id="pp_iframe",l.name="payplus-iframe",l.width="95%",l.height="100%",l.style.border="0",l.style.display="block",l.style.margin="auto",l.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms allow-popups allow-top-navigation"),l.src=t;let i=document.querySelectorAll(".pp_iframe"),r=document.querySelector(`#radio-control-wc-payment-method-options-${a}`).nextElementSibling.querySelector(".pp_iframe");if(-1!==["samePageIframe","popupIframe"].indexOf(s.displayMode)){if("payplus-payment-gateway"!==a)for(let e=0;e<i.length;e++){const t=i[e].parentNode.parentNode;if(t){t.id.includes(a)&&(r=i[e])}}switch(s.displayMode=window.innerWidth<=768&&"samePageIframe"===s.displayMode?"popupIframe":s.displayMode,s.displayMode){case"samePageIframe":r.style.position="relative",r.style.height=s.iFrameHeight,n.style.display="none";break;case"popupIframe":r.style.width=window.innerWidth<=768?"98%":s.iFrameWidth||"40%",r.style.height=s.iFrameHeight,r.style.position="fixed",r.style.top="50%",r.style.left="50%",r.style.paddingBottom=window.innerWidth<=768?"20px":"10px",r.style.paddingTop=window.innerWidth<=768?"20px":"10px",r.style.backgroundColor="white",r.style.transform="translate(-50%, -50%)",r.style.zIndex=1e5,r.style.boxShadow="10px 10px 10px 10px grey",r.style.borderRadius="5px",document.body.style.overflow="hidden",document.getElementsByClassName("blocks-payplus_loader")[0].style.display="none"}r.style.display="block",r.style.border="none",r.style.overflow="scroll",r.style.msOverflowStyle="none",r.style.scrollbarWidth="none",r.firstElementChild.style.display="block",r.firstElementChild.style.cursor="pointer",r.firstElementChild.addEventListener("click",e=>{e.preventDefault(),r.style.display="none";var t=window.location.href;new URLSearchParams(t);location.reload()}),r.appendChild(l),e.importApplePayScript&&addScriptApple()}}function multiPassIcons(e,t=null){null===t&&(t=document.querySelector("#radio-control-wc-payment-method-options-payplus-payment-gateway-multipass"));const n=wcSettings.paymentMethodSortOrder.includes("payplus-payment-gateway-multipass");if(e&&n&&Object.keys(wcSettings.paymentMethodData["payplus-payment-gateway"].multiPassIcons).length>0){const n=wcSettings.paymentMethodData["payplus-payment-gateway"].multiPassIcons;if(t){let t=function(e){let t=document.querySelectorAll("img");for(let n of t)if(n.src.includes(e))return n;return null}("multipassLogo.png");if(t){t.src;let o=0;const a=Object.keys(n).map(e=>n[e]);!function e(){const n=a[o];!function(e,t){e&&t?(e.style.transition="opacity 0.5s",e.style.opacity=0,setTimeout(()=>{e.src=t,e.style.opacity=1},500)):console.log("Image or new source not found.")}(t,n),o=(o+1)%a.length,Object.keys(wcSettings.paymentMethodData["payplus-payment-gateway"].multiPassIcons).length>1&&setTimeout(e,2e3)}(),e=!1}}}}window.addEventListener("message",function(e){if(e.data&&"payplus_redirect"===e.data.type&&e.data.url)try{new URL(e.data.url,window.location.origin).origin===window.location.origin&&(_payplusPollDone=!0,redirectWithTvEffect(e.data.url))}catch(e){}}),(()=>{const e=window.React,n=window.wc.wcBlocksRegistry,o=window.wp.i18n,l=window.wc.wcSettings,i=window.wp.htmlEntities,r=t,c=e=>(0,i.decodeEntities)(e.description||""),p=t=>{const{PaymentMethodLabel:n}=t.components;return(0,e.createElement)("div",{className:"payplus-method",style:{width:"100%"}},(0,e.createElement)(n,{text:t.text,icon:""!==t.icon?(0,e.createElement)("img",{style:{width:"64px",height:"32px",maxHeight:"100%",margin:"0px 10px",objectPosition:"center"},src:t.icon}):null}),(0,e.createElement)("div",{className:"pp_iframe"},(0,e.createElement)("button",{className:"closeFrame",id:"closeFrame",style:{position:"absolute",top:"0px",fontSize:"20px",right:"0px",border:"none",color:"black",backgroundColor:"transparent",display:"none"}},"x")),t.icon.search("PayPlusLogo.svg")>0&&s?a:null)};(()=>{for(let t=0;t<r.length;t++){const a=r[t],s=(0,l.getPaymentMethodData)(a,{}),d=(0,o.__)("Pay with Debit or Credit Card","payplus-payment-gateway"),y=(0,i.decodeEntities)(s?.title||"")||d,m={name:a,label:(0,e.createElement)(p,{text:y,icon:s.icon}),content:(0,e.createElement)(c,{description:s.description}),edit:(0,e.createElement)(c,{description:s.description}),canMakePayment:()=>!0,ariaLabel:y,supports:{showSaveOption:"payplus-payment-gateway"===a&&s.showSaveOption,features:s.supports}};(0,n.registerPaymentMethod)(m)}})()})(),document.addEventListener("DOMContentLoaded",function(){let e=!0;window.wc.wcSettings;var n=document.createElement("div");n.class="blocks-payplus_loader";const o=document.createElement("div");o.className="blocks-payplus_loader";const a=document.createElement("div");a.className="blocks-loader";const s=document.createElement("div");s.className="blocks-loader-background";const i=document.createElement("div");function r(){const e=document.querySelector(".wc-block-checkout__actions_row button");e&&!e.hasAttribute("data-payplus-listener")&&(e.setAttribute("data-payplus-listener","true"),e.addEventListener("click",function(){const e=payment.getActivePaymentMethod();if(e&&e.includes("payplus-payment-gateway")){const t=document.createElement("div");t.id="early-payplus-overlay",t.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.5);\n z-index: 999999;\n display: flex;\n align-items: center;\n justify-content: center;\n ";const n=document.createElement("div");n.style.cssText="\n background: white;\n padding: 30px 50px;\n border-radius: 12px;\n text-align: center;\n color: #333;\n box-shadow: 0 8px 32px rgba(0,0,0,0.3);\n min-width: 300px;\n ";const o=document.createElement("div");o.style.cssText="\n font-size: 18px;\n font-weight: 500;\n margin-bottom: 15px;\n ";const a=document.createElement("div");a.style.cssText="\n font-size: 24px;\n color: #007cba;\n ",n.appendChild(o),n.appendChild(a),t.appendChild(n),document.body.appendChild(t);let s=0;const l=setInterval(()=>{s=s%3+1,a.textContent=".".repeat(s)},400);if("payplus-payment-gateway-hostedfields"===e)o.textContent=window.payplus_i18n&&window.payplus_i18n.processing_payment?window.payplus_i18n.processing_payment:"Processing your payment now";else{o.textContent=window.payplus_i18n&&window.payplus_i18n.generating_page?window.payplus_i18n.generating_page:"Generating payment page";const e=1e3*Math.random()+4e3;setTimeout(()=>{o.textContent=window.payplus_i18n&&window.payplus_i18n.loading_page?window.payplus_i18n.loading_page:"Loading payment page"},e)}const i=setInterval(()=>{if(store.isComplete()||store.hasError()){clearInterval(l),clearInterval(i);const e=document.getElementById("early-payplus-overlay");e&&e.remove()}},100);setTimeout(()=>{clearInterval(l),clearInterval(i);const e=document.getElementById("early-payplus-overlay");e&&e.remove()},15e3)}}))}i.className="blocks-loader-text",s.appendChild(i),a.appendChild(s),o.appendChild(a),n.appendChild(o),r();const c=setInterval(()=>{r()},1e3);setTimeout(()=>{clearInterval(c)},1e4),setTimeout(function(){console.log("observer started");const o=document.createElement("div");o.style.backgroundColor="rgba(0, 0, 0, 0.5)",o.id="overlay",o.style.position="fixed",o.style.height="100%",o.style.width="100%",o.style.top="0",o.style.zIndex="5",setTimeout(()=>{let t=document.querySelector("#radio-control-wc-payment-method-options-payplus-payment-gateway-multipass");e&&t&&(multiPassIcons(e,t),e=!1)},3e3),payPlusCC=document.querySelector("#radio-control-wc-payment-method-options-payplus-payment-gateway");const a=new MutationObserver((e,a)=>{const s=payment.getActivePaymentMethod();if(0===s.search("payplus-payment-gateway-hostedfields")){const e=document.getElementsByClassName("pp_iframe_h")[0];if(e&&(e.style.display="flex",!e.querySelector(".payplus-hosted-place-order"))){const t=document.querySelector(".wc-block-checkout__actions_row button"),n=e.querySelector("#ppLogo"),o=window.wc.wcSettings.getPaymentMethodData("payplus-payment-gateway-hostedfields"),a=o&&"yes"===o.show_hide_submit_button;if(t&&n&&a){const e=document.createElement("button");e.className="btn btn-primary payplus-hosted-place-order wp-element-button wc-block-components-button wp-element-button contained",e.type="button",e.textContent=t.textContent,e.style.cssText="\n margin-top: 15px;\n margin-bottom: 15px;\n margin-right: auto;\n margin-left: auto;\n width: 90%;\n background-color: rgb(0, 0, 0);\n color: white;\n border: none;\n border-radius: 10px;\n padding: 12px 24px;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n ",e.addEventListener("click",function(e){e.preventDefault(),t.click()}),n.parentNode.insertBefore(e,n)}}}else{const e=document.getElementsByClassName("pp_iframe_h")[0];e&&(e.style.display="none")}if(l){const e=document.querySelector("#radio-control-wc-payment-method-options-payplus-payment-gateway")?.closest(".wc-block-components-radio-control-accordion-option");e&&(e.style.display="none")}if(store.hasError())try{let e=payment.getPaymentResult();if(null==e||""===e)throw new Error("Payment result is empty, null, or undefined.");console.log("Payment result:",e);let t=document.querySelectorAll(".pp_iframe")[0];t.style.width=window.innerWidth<=768?"95%":"55%",t.style.height="200px",t.style.position="fixed",t.style.backgroundColor="white",t.style.display="flex",t.style.alignItems="center",t.style.textAlign="center",t.style.justifyContent="center",t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)",t.style.zIndex=1e5,t.style.boxShadow="10px 10px 10px 10px grey",t.style.borderRadius="25px",t.innerHTML=void 0!==e.paymentDetails.errorMessage?e.paymentDetails.errorMessage+"<br>"+(window.payplus_i18n&&window.payplus_i18n.click_to_close?window.payplus_i18n.click_to_close:"Click this to close."):e.message+"<br>"+(window.payplus_i18n&&window.payplus_i18n.click_to_close?window.payplus_i18n.click_to_close:"Click this to close."),t.addEventListener("click",e=>{e.preventDefault(),t.style.display="none",location.reload()}),console.log(e.paymentDetails.errorMessage),void 0!==e.paymentDetails.errorMessage?alert(e.paymentDetails.errorMessage):alert(e.message),a.disconnect()}catch(e){console.error("An error occurred:",e.message)}if(store.isComplete()){if(a.disconnect(),0===s.search("payplus-payment-gateway-hostedfields")){hf.SubmitPayment(),document.body.style.overflow="hidden",document.body.style.backgroundColor="white",document.body.style.opacity="0.7",document.querySelector(".blocks-payplus_loader_hosted").style.display="block";return document.querySelectorAll('input[type="radio"], input').forEach(e=>{e.disabled=!0}),void hf.Upon("pp_responseFromServer",e=>{e.detail.errors&&location.reload()})}if(0===s.search("payplus-payment-gateway")&&0!==s.search("payplus-payment-gateway-pos-emv")){const e=window.wc.wcSettings.getPaymentMethodData(s)[s+"-settings"],l=-1!==["samePageIframe","popupIframe"].indexOf(e.displayMode);if(console.log("isIframe?",l),-1!==t.indexOf(payment.getActivePaymentMethod())&&0===payment.getActiveSavedToken().length){if(console.log("isComplete: "+store.isComplete()),l)if(payment.getPaymentResult().paymentDetails.paymentPageLink?.length>0){console.log("paymentPageLink",payment.getPaymentResult().paymentDetails.paymentPageLink),startIframe(payment.getPaymentResult().paymentDetails.paymentPageLink,o,n);var i=payment.getPaymentResult().paymentDetails;i.order_id&&i.order_received_url&&startOrderStatusPoll({order_id:i.order_id,order_received_url:i.order_received_url})}else alert(window.payplus_i18n&&window.payplus_i18n.payment_page_failed?window.payplus_i18n.payment_page_failed:"Error: the payment page failed to load."),location.reload();a.disconnect()}}}}),s=document.body;a.observe(s,{childList:!0,subtree:!0})}(),1e3)})}1 const{CHECKOUT_STORE_KEY:CHECKOUT_STORE_KEY}=window.wc.wcBlocksData,{PAYMENT_STORE_KEY:PAYMENT_STORE_KEY}=window.wc.wcBlocksData,store=wp.data.select(CHECKOUT_STORE_KEY),payment=wp.data.select(PAYMENT_STORE_KEY),hasOrder=store.hasOrder(),isCheckout=!!document.querySelector('div[data-block-name="woocommerce/checkout"]');if(isCheckout||hasOrder){console.log("checkout page?",isCheckout),console.log("has order?",hasOrder);store.getCustomerId(),store.getAdditionalFields(),store.getOrderId();const e=window.wc.wcSettings.getPaymentMethodData("payplus-payment-gateway");function addScriptApple(){if(isMyScriptLoaded(e.importApplePayScript)){const t=document.createElement("script");t.src=e.importApplePayScript,document.body.append(t)}}function isMyScriptLoaded(e){for(var t=document.getElementsByTagName("script"),a=t.length;a--;)if(t[a].src==e)return!1;return!0}let t=window.wc.wcSettings.getPaymentMethodData("payplus-payment-gateway").gateways;t=e.isSubscriptionOrder?["payplus-payment-gateway"]:t,t=e.isSubscriptionOrder&&e.isLoggedIn?["payplus-payment-gateway","payplus-payment-gateway-hostedfields"]:t;let a=[];const o=window.React;for(let r=0;r<e.customIcons?.length;r++)a[r]=(0,o.createElement)("img",{src:e.customIcons[r],style:{maxHeight:"35px",height:"45px"}});const n=(0,o.createElement)("div",{className:"payplus-icons",style:{display:"flex",flexWrap:"wrap",width:"100%",maxWidth:"100%",gap:"5px"}},a);let s=!!e.customIcons[0]?.length;Object.keys(e.hasSavedTokens).length;const l=e.hideMainPayPlusGateway;if(e.hostedFieldsIsMain){const{dispatch:i}=window.wp.data,p=window.wc.wcBlocksData.PAYMENT_STORE_KEY,c="payplus-payment-gateway-hostedfields";try{i(p).__internalSetActivePaymentMethod(c)}catch(d){}}var _payplusPollDone=!1,_payplusTvEffectInProgress=!1;function redirectWithTvEffect(t){if(!_payplusTvEffectInProgress){if(e&&e.popupTvEffect&&"popupIframe"===e.viewMode&&jQuery(".pp_iframe").length>0){_payplusTvEffectInProgress=!0,_payplusPollDone=!0;var a=jQuery(".pp_iframe");return a.css({position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)","z-index":"100000"}),a.addClass("tv-closing-blocks"),a[0].offsetHeight,void setTimeout(function(){window.location.href=t},1050)}window.location.href=t}}function startOrderStatusPoll(t){if(t&&t.order_id&&t.order_received_url){var a=t.order_received_url,o="";try{var n=new URL(a,window.location.origin);o=n.searchParams.get("key")||""}catch(e){return}if(o){var s=0;r();var l=setInterval(function(){_payplusPollDone?clearInterval(l):r()},150)}}function r(){_payplusPollDone||s++>600||jQuery.ajax({url:e.ajax_url||window.payplus_script?.ajax_url,type:"POST",data:{action:"payplus_check_order_redirect",_ajax_nonce:e.frontNonce||window.payplus_script?.frontNonce,order_id:t.order_id,order_key:o},dataType:"json",success:function(e){if(!_payplusPollDone&&e&&e.success&&e.data&&e.data.status){var t=e.data.status;"processing"!==t&&"completed"!==t&&"wc-processing"!==t&&"wc-completed"!==t||(_payplusPollDone=!0,redirectWithTvEffect(e.data.redirect_url||a))}}})}}function startIframe(t,a,o){document.body.appendChild(a),a.appendChild(o);const n=payment.getActivePaymentMethod(),s=window.wc.wcSettings.getPaymentMethodData(n)[n+"-settings"];var l=document.createElement("iframe");l.id="pp_iframe",l.name="payplus-iframe",l.width="95%",l.height="100%",l.style.border="0",l.style.display="block",l.style.margin="auto",l.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms allow-popups allow-top-navigation"),l.src=t;let r=document.querySelectorAll(".pp_iframe"),i=document.querySelector(`#radio-control-wc-payment-method-options-${n}`).nextElementSibling.querySelector(".pp_iframe");if(-1!==["samePageIframe","popupIframe"].indexOf(s.displayMode)){if("payplus-payment-gateway"!==n)for(let e=0;e<r.length;e++){const t=r[e].parentNode.parentNode;if(t){t.id.includes(n)&&(i=r[e])}}switch(s.displayMode=window.innerWidth<=768&&"samePageIframe"===s.displayMode?"popupIframe":s.displayMode,s.displayMode){case"samePageIframe":i.style.position="relative",i.style.height=s.iFrameHeight,a.style.display="none";break;case"popupIframe":i.style.width=window.innerWidth<=768?"98%":s.iFrameWidth||"40%",i.style.height=s.iFrameHeight,i.style.position="fixed",i.style.top="50%",i.style.left="50%",i.style.paddingBottom=window.innerWidth<=768?"20px":"10px",i.style.paddingTop=window.innerWidth<=768?"20px":"10px",i.style.backgroundColor="white",i.style.transform="translate(-50%, -50%)",i.style.zIndex=1e5,i.style.boxShadow="10px 10px 10px 10px grey",i.style.borderRadius="5px",document.body.style.overflow="hidden",document.getElementsByClassName("blocks-payplus_loader")[0].style.display="none"}i.style.display="block",i.style.border="none",i.style.overflow="scroll",i.style.msOverflowStyle="none",i.style.scrollbarWidth="none",i.firstElementChild.style.display="block",i.firstElementChild.style.cursor="pointer",i.firstElementChild.addEventListener("click",e=>{e.preventDefault(),i.style.display="none";var t=window.location.href;new URLSearchParams(t);location.reload()}),i.appendChild(l),e.importApplePayScript&&addScriptApple()}}function multiPassIcons(e,t=null){null===t&&(t=document.querySelector("#radio-control-wc-payment-method-options-payplus-payment-gateway-multipass"));const a=wcSettings.paymentMethodSortOrder.includes("payplus-payment-gateway-multipass");if(e&&a&&Object.keys(wcSettings.paymentMethodData["payplus-payment-gateway"].multiPassIcons).length>0){const a=wcSettings.paymentMethodData["payplus-payment-gateway"].multiPassIcons;if(t){let t=function(e){let t=document.querySelectorAll("img");for(let a of t)if(a.src.includes(e))return a;return null}("multipassLogo.png");if(t){t.src;let o=0;const n=Object.keys(a).map(e=>a[e]);!function e(){const a=n[o];!function(e,t){e&&t?(e.style.transition="opacity 0.5s",e.style.opacity=0,setTimeout(()=>{e.src=t,e.style.opacity=1},500)):console.log("Image or new source not found.")}(t,a),o=(o+1)%n.length,Object.keys(wcSettings.paymentMethodData["payplus-payment-gateway"].multiPassIcons).length>1&&setTimeout(e,2e3)}(),e=!1}}}}window.addEventListener("message",function(e){if(e.data&&"payplus_redirect"===e.data.type&&e.data.url)try{new URL(e.data.url,window.location.origin).origin===window.location.origin&&(_payplusPollDone=!0,redirectWithTvEffect(e.data.url))}catch(e){}}),(()=>{const e=window.React,a=window.wc.wcBlocksRegistry,o=window.wp.i18n,l=window.wc.wcSettings,r=window.wp.htmlEntities,i=t,p=e=>(0,r.decodeEntities)(e.description||""),c=t=>{const{PaymentMethodLabel:a}=t.components;return(0,e.createElement)("div",{className:"payplus-method",style:{width:"100%"}},(0,e.createElement)(a,{text:t.text,icon:""!==t.icon?(0,e.createElement)("img",{style:{width:"64px",height:"32px",maxHeight:"100%",margin:"0px 10px",objectPosition:"center"},src:t.icon}):null}),(0,e.createElement)("div",{className:"pp_iframe"},(0,e.createElement)("button",{className:"closeFrame",id:"closeFrame",style:{position:"absolute",top:"0px",fontSize:"20px",right:"0px",border:"none",color:"black",backgroundColor:"transparent",display:"none"}},"x")),t.icon.search("PayPlusLogo.svg")>0&&s?n:null)};(()=>{for(let t=0;t<i.length;t++){const n=i[t],s=(0,l.getPaymentMethodData)(n,{}),d=(0,o.__)("Pay with Debit or Credit Card","payplus-payment-gateway"),y=(0,r.decodeEntities)(s?.title||"")||d,m={name:n,label:(0,e.createElement)(c,{text:y,icon:s.icon}),content:(0,e.createElement)(p,{description:s.description}),edit:(0,e.createElement)(p,{description:s.description}),canMakePayment:()=>!0,ariaLabel:y,supports:{showSaveOption:"payplus-payment-gateway"===n&&s.showSaveOption,features:s.supports}};(0,a.registerPaymentMethod)(m)}})()})(),document.addEventListener("DOMContentLoaded",function(){let e=!0;window.wc.wcSettings;var a=document.createElement("div");a.class="blocks-payplus_loader";const o=document.createElement("div");o.className="blocks-payplus_loader";const n=document.createElement("div");n.className="blocks-loader";const s=document.createElement("div");s.className="blocks-loader-background";const r=document.createElement("div");r.className="blocks-loader-text",s.appendChild(r),n.appendChild(s),o.appendChild(n),a.appendChild(o),setTimeout(function(){console.log("observer started");const o=document.createElement("div");o.style.backgroundColor="rgba(0, 0, 0, 0.5)",o.id="overlay",o.style.position="fixed",o.style.height="100%",o.style.width="100%",o.style.top="0",o.style.zIndex="5",setTimeout(()=>{let t=document.querySelector("#radio-control-wc-payment-method-options-payplus-payment-gateway-multipass");e&&t&&(multiPassIcons(e,t),e=!1)},3e3),payPlusCC=document.querySelector("#radio-control-wc-payment-method-options-payplus-payment-gateway");const n=new MutationObserver((e,n)=>{const s=payment.getActivePaymentMethod();if(0===s.search("payplus-payment-gateway-hostedfields")){const e=document.getElementsByClassName("pp_iframe_h")[0];if(e&&(e.style.display="flex",!e.querySelector(".payplus-hosted-place-order"))){const t=document.querySelector(".wc-block-checkout__actions_row button"),a=e.querySelector("#ppLogo"),o=window.wc.wcSettings.getPaymentMethodData("payplus-payment-gateway-hostedfields"),n=o&&"yes"===o.show_hide_submit_button;if(t&&a&&n){const e=document.createElement("button");e.className="btn btn-primary payplus-hosted-place-order wp-element-button wc-block-components-button wp-element-button contained",e.type="button",e.textContent=t.textContent,e.style.cssText="\n margin-top: 15px;\n margin-bottom: 15px;\n margin-right: auto;\n margin-left: auto;\n width: 90%;\n background-color: rgb(0, 0, 0);\n color: white;\n border: none;\n border-radius: 10px;\n padding: 12px 24px;\n font-size: 16px;\n font-weight: 600;\n cursor: pointer;\n ",e.addEventListener("click",function(e){e.preventDefault(),t.click()}),a.parentNode.insertBefore(e,a)}}}else{const e=document.getElementsByClassName("pp_iframe_h")[0];e&&(e.style.display="none")}if(l){const e=document.querySelector("#radio-control-wc-payment-method-options-payplus-payment-gateway")?.closest(".wc-block-components-radio-control-accordion-option");e&&(e.style.display="none")}if(store.hasError())try{let e=payment.getPaymentResult();if(null==e||""===e)throw new Error("Payment result is empty, null, or undefined.");console.log("Payment result:",e);let t=document.querySelectorAll(".pp_iframe")[0];t.style.width=window.innerWidth<=768?"95%":"55%",t.style.height="200px",t.style.position="fixed",t.style.backgroundColor="white",t.style.display="flex",t.style.alignItems="center",t.style.textAlign="center",t.style.justifyContent="center",t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)",t.style.zIndex=1e5,t.style.boxShadow="10px 10px 10px 10px grey",t.style.borderRadius="25px",t.innerHTML=void 0!==e.paymentDetails.errorMessage?e.paymentDetails.errorMessage+"<br>"+(window.payplus_i18n&&window.payplus_i18n.click_to_close?window.payplus_i18n.click_to_close:"Click this to close."):e.message+"<br>"+(window.payplus_i18n&&window.payplus_i18n.click_to_close?window.payplus_i18n.click_to_close:"Click this to close."),t.addEventListener("click",e=>{e.preventDefault(),t.style.display="none",location.reload()}),console.log(e.paymentDetails.errorMessage),void 0!==e.paymentDetails.errorMessage?alert(e.paymentDetails.errorMessage):alert(e.message),n.disconnect()}catch(e){console.error("An error occurred:",e.message)}if(store.isComplete()){if(n.disconnect(),0===s.search("payplus-payment-gateway-hostedfields")){hf.SubmitPayment(),document.body.style.overflow="hidden",document.body.style.backgroundColor="white",document.body.style.opacity="0.7",document.querySelector(".blocks-payplus_loader_hosted").style.display="block";return document.querySelectorAll('input[type="radio"], input').forEach(e=>{e.disabled=!0}),void hf.Upon("pp_responseFromServer",e=>{e.detail.errors&&location.reload()})}if(0===s.search("payplus-payment-gateway")&&0!==s.search("payplus-payment-gateway-pos-emv")){const e=window.wc.wcSettings.getPaymentMethodData(s)[s+"-settings"],l=-1!==["samePageIframe","popupIframe"].indexOf(e.displayMode);if(console.log("isIframe?",l),-1!==t.indexOf(payment.getActivePaymentMethod())&&0===payment.getActiveSavedToken().length){if(console.log("isComplete: "+store.isComplete()),l){var r=payment.getPaymentResult().paymentDetails;r.payplus_iframe_async?(startOrderStatusPoll({order_id:r.order_id,order_received_url:r.order_received_url}),startIframe("about:blank",o,a),jQuery.ajax({type:"POST",url:payplus_script.ajax_url,data:{action:"payplus_get_iframe_link",_ajax_nonce:payplus_script.frontNonce,order_id:r.order_id,order_key:r.order_key},success:function(e){if(e.success&&e.data&&e.data.payment_page_link){var t=document.getElementById("pp_iframe");t&&(t.src=e.data.payment_page_link)}else{var a=e.data&&e.data.message?e.data.message:window.payplus_i18n&&window.payplus_i18n.payment_page_failed?window.payplus_i18n.payment_page_failed:"Error: the payment page failed to load.";alert(a),location.reload()}},error:function(){alert(window.payplus_i18n&&window.payplus_i18n.payment_page_failed?window.payplus_i18n.payment_page_failed:"Error: the payment page failed to load."),location.reload()}})):r.paymentPageLink&&r.paymentPageLink.length>0?(console.log("paymentPageLink",r.paymentPageLink),startIframe(r.paymentPageLink,o,a),r.order_id&&r.order_received_url&&startOrderStatusPoll({order_id:r.order_id,order_received_url:r.order_received_url})):(alert(window.payplus_i18n&&window.payplus_i18n.payment_page_failed?window.payplus_i18n.payment_page_failed:"Error: the payment page failed to load."),location.reload())}n.disconnect()}}}}),s=document.body;n.observe(s,{childList:!0,subtree:!0})}(),1e3)})} -
payplus-payment-gateway/trunk/hashes.json
r3466884 r3467072 1 1 { 2 "\/payplus-payment-gateway.php": " b963815ce094ce015de830edcc78a0cdd9640bbc4a24223b4fa3f0effeb78382",2 "\/payplus-payment-gateway.php": "c58d8f7cd876c0101b6813f8c83fe6371566b8531ba3d07bb9f8e3fabc64b029", 3 3 "\/index.php": "c491dec192c55a18cd5d9ec23375720d58d40455dc685e7e4093c1198cc76b89", 4 "\/CHANGELOG.md": " 371680de37be548bfeb20f63af0a9c12b00f2b7028a78bdf80077310c5851882",5 "\/includes\/blocks\/class-wc-payplus-blocks-support.php": " af5aa46660b85c66f7d7bc7c1868a6ae1eaedf000e4e2e6c050efec70657018a",4 "\/CHANGELOG.md": "6f2d4699d4c170d342a1eead5f0313f7e7419b03e3dfbf0391dcc0909a64a3c5", 5 "\/includes\/blocks\/class-wc-payplus-blocks-support.php": "77d80e167b0f4165d13a6797dd1ddcbf05b6bcf1471a7af77f956bee7bca0319", 6 6 "\/includes\/wc_payplus_express_checkout.php": "0e227cc783f67068b2f23fd4e1045ac6b2b2969c483a11e8661a3ea3fa8c3b7d", 7 7 "\/includes\/wc_payplus_invoice.php": "6e3442e8336ec9b2a0532170982937ee555dd590f14c3aedfcb27e0ba8e0215f", … … 27 27 "\/languages\/payplus-payment-gateway.pot": "8869bece7da90f4afeafadf4ca2dfcf350f753bbe0663db16a083f1e0de8035d", 28 28 "\/templates\/hostedFields.php": "640574751191114c65fc137aa7b4ad7011452ce43043be1bd3ec0c4f6db26676", 29 "\/readme.txt": " 3af8cbc94f0042add2253ea288a01513420afc8fcc9145b273452c2206385c64",29 "\/readme.txt": "d6029fee0d6f4c8752014625d570c93ed6d6b2ac85f8f3ea732a41a919686935", 30 30 "\/assets\/css\/alertify.min.css": "12e60b6d60e45a69e3dc0f442bb4005eb47fba5ceb42fc6435cd8b4867a3f69d", 31 31 "\/assets\/css\/admin.scss": "02157f910d6c8f917da018bac5fed1022046b427e2a5a9174fc5cc68182070c5", … … 128 128 "\/assets\/js\/checkout.js": "635705ba52e88f13b98513150905251d909154d250c1f9f7db2276ec7e81f6c3", 129 129 "\/block\/dist\/css\/woocommerce-blocks\/style.css": "5b51b0d574ac6e17118924b59c0d2bdabd115a9db88b28d514146804e4204326", 130 "\/block\/dist\/js\/woocommerce-blocks\/blocks.min.js": "6 fd47b50ce0fd31bf7a198cf4aaf6827493e6ee3d1df4f4be4f76a4e2845e29d",131 "\/block\/dist\/js\/woocommerce-blocks\/blocks.js": " 088b9e440630ae4d42e877f8183e8805b54d87250f9ecf74ce85e187a9becd8b",130 "\/block\/dist\/js\/woocommerce-blocks\/blocks.min.js": "6c8388ec42d972b7836dce168d11ac8e538b4474c38ff309cad09852f24477d5", 131 "\/block\/dist\/js\/woocommerce-blocks\/blocks.js": "23c64e838089651cc8b97e59b721e74463fb71e4478279c4a2c77593fe466f8f", 132 132 "\/block\/dist\/js\/woocommerce-blocks\/blocks.asset.php": "ee27901c649cc184a359223c715ba3faffcaaee6e5fcd4ad896a09128b113325" 133 133 } -
payplus-payment-gateway/trunk/includes/blocks/class-wc-payplus-blocks-support.php
r3466884 r3467072 472 472 } 473 473 474 // THIS IS THE BOTTLENECK - External API call474 // Build the payment payload locally — this is fast (no HTTP call). 475 475 $payload = $main_gateway->generatePaymentLink($this->orderId, is_admin(), null, $subscription = false, $custom_more_info = '', $move_token = false, ['chargeDefault' => $chargeDefault, 'hideOtherPayments' => $hideOtherPayments, 'isSubscriptionOrder' => $this->isSubscriptionOrder]); 476 WC_PayPlus_Meta_Data::update_meta($order, ['payplus_payload' => $payload]); 477 478 // ANOTHER BOTTLENECK - Remote HTTP request 479 $response = WC_PayPlus_Statics::payPlusRemote($main_gateway->payment_url, $payload); 480 476 477 // Save the payload and everything the async AJAX handler will need later. 478 // The slow payPlusRemote() HTTP call is intentionally deferred to that handler. 479 WC_PayPlus_Meta_Data::update_meta($order, [ 480 'payplus_payload' => $payload, 481 'payplus_payment_url' => $main_gateway->payment_url, 482 'payplus_async_method' => $context->payment_method, 483 ]); 484 if (isset($data['wc-payplus-payment-gateway-new-payment-method'])) { 485 WC_PayPlus_Meta_Data::update_meta($order, [ 486 'save_payment_method' => $data['wc-payplus-payment-gateway-new-payment-method'], 487 ]); 488 } 489 490 // Return immediately so the Store API responds in < 1 s instead of 7-10 s. 491 // The JS will call payplus_get_iframe_link via AJAX to get the actual link. 481 492 $payment_details = $result->payment_details; 482 $payment_details['order_id'] = $this->orderId; 483 $payment_details['secret_key'] = $this->secretKey; 484 485 $responseArray = json_decode(wp_remote_retrieve_body($response), true); 486 487 if ($responseArray['results']['status'] === 'error' || !isset($responseArray['results']) && isset($responseArray['message'])) { 488 $payment_details['errorMessage'] = isset($responseArray['results']['description']) ? wp_strip_all_tags($responseArray['results']['description']) : $responseArray['message']; 489 } else { 490 // Set page_order_awaiting_payment when payment page is opened (for non-hosted fields) 491 if ($context->payment_method !== 'payplus-payment-gateway-hostedfields' && WC()->session) { 492 WC()->session->set('page_order_awaiting_payment', $this->orderId); 493 } 494 495 $orderMeta = [ 496 'payplus_page_request_uid' => $responseArray['data']['page_request_uid'], 497 'payplus_payment_page_link' => $responseArray['data']['payment_page_link'] 498 ]; 499 500 isset($data['wc-payplus-payment-gateway-new-payment-method']) ? $orderMeta['save_payment_method'] = $data['wc-payplus-payment-gateway-new-payment-method'] : null; 501 502 503 WC_PayPlus_Meta_Data::update_meta($order, $orderMeta); 504 505 $payment_details['paymentPageLink'] = $responseArray['data']['payment_page_link']; 506 $payment_details['order_received_url'] = $order->get_checkout_order_received_url(); 507 } 493 $payment_details['order_id'] = $this->orderId; 494 $payment_details['order_key'] = $order->get_order_key(); 495 $payment_details['secret_key'] = $this->secretKey; 496 $payment_details['order_received_url'] = $order->get_checkout_order_received_url(); 497 $payment_details['payplus_iframe_async'] = true; 498 508 499 $result->set_payment_details($payment_details); 509 !isset($payment_details['errorMessage']) ? $result->set_status('pending') : $result->set_status('failure');500 $result->set_status('pending'); 510 501 } 511 502 } -
payplus-payment-gateway/trunk/payplus-payment-gateway.php
r3466884 r3467072 5 5 * Description: Accept credit/debit card payments or other methods such as bit, Apple Pay, Google Pay in one page. Create digitally signed invoices & much more. 6 6 * Plugin URI: https://www.payplus.co.il/wordpress 7 * Version: 8.1. 07 * Version: 8.1.1 8 8 * Tested up to: 6.9 9 9 * Requires Plugins: woocommerce … … 20 20 define('PAYPLUS_PLUGIN_URL_ASSETS_IMAGES', PAYPLUS_PLUGIN_URL . "assets/images/"); 21 21 define('PAYPLUS_PLUGIN_DIR', dirname(__FILE__)); 22 define('PAYPLUS_VERSION', '8.1.0');23 define('PAYPLUS_VERSION_DB', 'payplus_8_1_0');22 define('PAYPLUS_VERSION', '8.1.1'); 23 define('PAYPLUS_VERSION_DB', 'payplus_8_1_1'); 24 24 define('PAYPLUS_TABLE_PROCESS', 'payplus_payment_process'); 25 25 class WC_PayPlus … … 95 95 add_action('wp_ajax_payplus_check_order_redirect', [$this, 'ajax_payplus_check_order_redirect']); 96 96 add_action('wp_ajax_nopriv_payplus_check_order_redirect', [$this, 'ajax_payplus_check_order_redirect']); 97 98 // AJAX endpoint: fetch PayPlus payment page link asynchronously (Blocks iframe modes) 99 add_action('wp_ajax_payplus_get_iframe_link', [$this, 'ajax_get_iframe_link']); 100 add_action('wp_ajax_nopriv_payplus_get_iframe_link', [$this, 'ajax_get_iframe_link']); 97 101 98 102 //end custom hook … … 1158 1162 'status' => $status, 1159 1163 'redirect_url' => $redirect_url, 1164 ]); 1165 } 1166 1167 /** 1168 * Async AJAX handler for Blocks Checkout iframe modes. 1169 * 1170 * During checkout submission, add_payment_request_order_meta() builds the payload 1171 * (fast, local) and saves it to order meta, then returns immediately — without 1172 * making the slow external PayPlus HTTP call. This handler picks up the saved 1173 * payload and runs payPlusRemote() after the checkout form has already unblocked, 1174 * so the 7-10 s PayPlus API delay is hidden behind the loading overlay. 1175 */ 1176 public function ajax_get_iframe_link() 1177 { 1178 check_ajax_referer('frontNonce', '_ajax_nonce'); 1179 1180 $order_id = isset($_REQUEST['order_id']) ? absint($_REQUEST['order_id']) : 0; 1181 $order_key = isset($_REQUEST['order_key']) ? sanitize_text_field(wp_unslash($_REQUEST['order_key'])) : ''; 1182 1183 if (!$order_id || !$order_key) { 1184 wp_send_json_error(['message' => 'Invalid order']); 1185 } 1186 1187 $order = wc_get_order($order_id); 1188 if (!$order || $order->get_order_key() !== $order_key) { 1189 wp_send_json_error(['message' => 'Order not found']); 1190 } 1191 1192 $payload = WC_PayPlus_Meta_Data::get_meta($order, 'payplus_payload'); 1193 $payment_url = WC_PayPlus_Meta_Data::get_meta($order, 'payplus_payment_url'); 1194 1195 if (empty($payload) || empty($payment_url)) { 1196 wp_send_json_error(['message' => 'Payment data missing — please retry checkout']); 1197 } 1198 1199 // This is the only slow line: the external PayPlus HTTP request. 1200 $response = WC_PayPlus_Statics::payPlusRemote($payment_url, $payload); 1201 $responseArray = json_decode(wp_remote_retrieve_body($response), true); 1202 1203 if (!isset($responseArray['results']) || $responseArray['results']['status'] === 'error') { 1204 $msg = isset($responseArray['results']['description']) 1205 ? wp_strip_all_tags($responseArray['results']['description']) 1206 : (isset($responseArray['message']) ? $responseArray['message'] : 'Unknown PayPlus error'); 1207 wp_send_json_error(['message' => $msg]); 1208 } 1209 1210 $link = $responseArray['data']['payment_page_link']; 1211 1212 // Persist IPN-matching data now that we have it. 1213 WC_PayPlus_Meta_Data::update_meta($order, [ 1214 'payplus_page_request_uid' => $responseArray['data']['page_request_uid'], 1215 'payplus_payment_page_link' => $link, 1216 ]); 1217 1218 // Set session so cart restoration works correctly. 1219 $async_method = WC_PayPlus_Meta_Data::get_meta($order, 'payplus_async_method'); 1220 if ($async_method !== 'payplus-payment-gateway-hostedfields' && WC()->session) { 1221 WC()->session->set('page_order_awaiting_payment', $order_id); 1222 } 1223 1224 wp_send_json_success([ 1225 'payment_page_link' => $link, 1226 'order_id' => $order_id, 1227 'order_key' => $order_key, 1228 'order_received_url' => $order->get_checkout_order_received_url(), 1160 1229 ]); 1161 1230 } -
payplus-payment-gateway/trunk/readme.txt
r3466884 r3467072 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 8.1. 07 Stable tag: 8.1.1 8 8 PlugIn URL: https://www.payplus.co.il/wordpress 9 9 License: GPLv2 or later … … 87 87 == Changelog == 88 88 89 == 8.1.1 - 23-02-2026 = 90 91 - Fix - TV power-down effect in Blocks Checkout is now driven by the plugin setting rather than CSS positioning, ensuring it triggers reliably regardless of theme styles. 92 - Tweak - Blocks Checkout popup and same-page iframe modes now open instantly — the PayPlus payment page link is fetched asynchronously after checkout submission instead of blocking the Store API response. 93 89 94 == 8.1.0 - 22-02-2026 = 90 95
Note: See TracChangeset
for help on using the changeset viewer.