diff --git a/README.md b/README.md index 4a119ad..269115e 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Chargily Pay™ V2 - Requires at least: 2.0 -- WordPress Tested up to: 6.5 -- WooCommerce Tested up to: 8.7.0 -- Stable tag: 2.2.5 +- WordPress Tested up to: 6.6.2 +- WooCommerce Tested up to: 9.4.0 +- Stable tag: 2.3.0 - Requires PHP: 7.0 - License: GPLv2 - License URI: https://www.gnu.org/licenses/gpl-2.0.html diff --git a/assets/css/css-back.css b/assets/css/css-back.css index e9b93b5..ae73ead 100644 --- a/assets/css/css-back.css +++ b/assets/css/css-back.css @@ -10,44 +10,51 @@ span.components-visually-hidden.css-0.e19lxcc00{ width: 1px; overflow-wrap: normal; } - + .css-mkkf9p { - flex: 1 1 auto; + flex: 1 1 auto; } + .css-cn3xcj { - margin-bottom: 12px; + margin-bottom: 12px; } + .css-1pd4mph { - background-color: rgb(255, 255, 255); - color: rgb(30, 30, 30); - position: relative; - box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 0px 1px; - outline: none; - border-radius: calc(1px); + background-color: rgb(255, 255, 255); + color: rgb(30, 30, 30); + position: relative; + box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 0px 1px; + outline: none; + border-radius: calc(1px); } + .css-188a3xf:last-of-type { - border-bottom-left-radius: calc(1px); - border-bottom-right-radius: calc(1px); + border-bottom-left-radius: calc(1px); + border-bottom-right-radius: calc(1px); } + .css-188a3xf:first-of-type { - border-top-left-radius: calc(1px); - border-top-right-radius: calc(1px); + border-top-left-radius: calc(1px); + border-top-right-radius: calc(1px); } + .css-188a3xf { - box-sizing: border-box; - height: auto; - max-height: 100%; - padding: calc(16px) calc(24px); + box-sizing: border-box; + height: auto; + max-height: 100%; + padding: calc(16px) calc(24px); } input#woocommerce_chargily_pay_gateway_api_info.input-text.regular-input { - display: none; + display: none; } + input#woocommerce_chargily_pay_description.input-text.regular-input { - display: none; + display: none; } - input#woocommerce_chargily_pay_gateway_title.input-text.regular-input { - pointer-events: none; - border: 0px; - background-color : #ffffff00; + +input#woocommerce_chargily_pay_gateway_title.input-text.regular-input { + pointer-events: none; + border: 0px; + background-color : #ffffff00; } diff --git a/assets/css/css-front-rtl.css b/assets/css/css-front-rtl.css index ba2b5cf..f686709 100644 --- a/assets/css/css-front-rtl.css +++ b/assets/css/css-front-rtl.css @@ -1,17 +1,17 @@ label.Chargily:before, label:after { - right: 29px; + right: 29px; } a.chlogo { - padding-right: 10px; + padding-right: 10px; } img.edahabiaCardImage { - margin-right: auto; + margin-right: auto; margin-left: inherit; } img.cibCardImage { - margin-right: auto; + margin-right: auto; margin-left: inherit; } diff --git a/assets/css/css-front.css b/assets/css/css-front.css index 36aea3c..1564583 100644 --- a/assets/css/css-front.css +++ b/assets/css/css-front.css @@ -5,11 +5,15 @@ } img.edahabiaCardImage { - margin-left: auto; + margin-left: auto; } img.cibCardImage { - margin-left: auto; + margin-left: auto; +} + +img.appCardImage { + margin-left: auto; } span#radio-control-wc-payment-method-options-chargily_pay__label { @@ -28,6 +32,12 @@ input#chargilyv2_cib { opacity: 0; } +input#chargilyv2_app { + z-index: -1; + position: absolute; + opacity: 0; +} + [type="radio"]:checked~label.Chargily { cursor: pointer; border-color: #16a34a; @@ -86,11 +96,9 @@ label.Chargily { justify-content: space-between; cursor: pointer; position: relative; - /*display: grid;*/ align-items: center; grid-template-columns: 20px auto 100px; grid-gap: 20px; - /*width: 100%;*/ height: 62px; padding: 0 20px; border-radius: 6px; diff --git a/assets/img/qr-code.svg b/assets/img/qr-code.svg new file mode 100644 index 0000000..22f8404 --- /dev/null +++ b/assets/img/qr-code.svg @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/assets/js/checkout.js b/assets/js/checkout.js index b6ca1a2..4f7944b 100644 --- a/assets/js/checkout.js +++ b/assets/js/checkout.js @@ -1,333 +1,517 @@ const { registerPaymentMethod } = window.wc.wcBlocksRegistry; const { createElement, useState, useEffect } = window.wp.element; +const shouldShowPaymentMethods = chargilySettings.show_payment_methods === 'yes'; + +if (!shouldShowPaymentMethods) { + const style = document.createElement('style'); + style.innerHTML = ` + .Chargily-option { + display: none !important; + } + .Chargily-option-no-show { + display: block !important; + } + label.Chargily-label-no-show { + display: flex !important; + gap: 5px !important; + display: flex !important; + justify-content: flex-start !important; + + } + `; + document.head.appendChild(style); +} else { + const style = document.createElement('style'); + style.innerHTML = ` + .Chargily-option-no-show { + display: none !important; + } + `; + document.head.appendChild(style); +} + +(function() { + let attempts = 0; + const maxAttempts = 600; + const intervalTime = 100; + + function chargilyPayDivConstMove() { + const targetSpan = document.querySelector('#radio-control-wc-payment-method-options-chargily_pay__label'); + const shouldShowPaymentMethods = false; + + if (targetSpan) { + if (!shouldShowPaymentMethods) { + const newDiv = document.createElement('div'); + newDiv.className = 'Chargily-option-no-show'; + newDiv.innerHTML = ` + + `; + targetSpan.appendChild(newDiv); + document.querySelectorAll('.Chargily-option').forEach(option => { + option.style.display = 'none'; + }); + document.querySelectorAll('.Chargily-option-no-show').forEach(option => { + option.style.display = 'block'; + }); + document.querySelectorAll('label.Chargily-label-no-show').forEach(option => { + option.style.display = 'flex'; + option.style.justifyContent = 'flex-start'; + }); + } else { + document.querySelectorAll('.Chargily-option-no-show').forEach(option => { + option.style.display = 'nono'; + }); + } + clearInterval(intervalId); + } + attempts++; + if (attempts >= maxAttempts) { + clearInterval(intervalId); + } + } + const intervalId = setInterval(chargilyPayDivConstMove, intervalTime); +})(); const labels = { - en: { - chargilyPay: "Chargily Pay™ (EDAHABIA/CIB) ", - description: "Pay with your EDAHABIA/CIB card", - edahabia: "EDAHABIA", - cib: "CIB Card", - poweredBy: "provided by ", - securePayment: "🔒 Secure E-Payment ", - istestMode: "Test Mode is enabled.", - TestWarningMessage: "You are in Test Mode but your Test API keys are missing.", - TestLinkTextWarningMessage: "Enter your Test API keys.", - LiveWarningMessage: "You are in Live Mode but your Live API keys are missing.", - }, - ar: { - chargilyPay: "شارجيلي باي (الذهبية / CIB) ", - description: "ادفع باستخدام بطاقتك الذهبيالبنكية CIB", - edahabia: "الذهبية", - cib: "البطاقة البنكية Cib", - poweredBy: "بواسطة ", - securePayment: "🔒 بوابة دفع إلكتروني آمنة ", - istestMode: "الTest Mode مفعل.", - TestWarningMessage: "أنت في وضع التجربة ولكن مفاتيح الAPI لوضع التجربة الخاصة بك مفقودة.", - TestLinkTextWarningMessage: "أدخل مفاتيح الAPI اللوضع التجربة الخاصة بك.", - LiveWarningMessage: "أنت في وضع Live ولكن مفاتيح الAPI لوضع الLive الخاصه بك مفقودة.", - }, - fr: { - chargilyPay: "Chargily Pay™ (EDAHABIA/CIB) ", - description: "Payez avec votre carte EDAHABIA/CIB", - edahabia: "EDAHABIA", - cib: "CIB Card", - poweredBy: "🔒 Propulsé par", - securePayment: "Passerelle de paiement électronique sécurisée.", - istestMode: "Le mode Test est activé.", - TestWarningMessage: "Vous êtes en Mode Test mais vos clés API de Mode Test sont manquantes.", - TestLinkTextWarningMessage: "Entrez vos clés API de Mode Test.", - LiveWarningMessage: "Vous êtes en Mode Live mais vos clés API de Mode Live sont manquantes.", - }, + en: { + chargilyPay: chargilySettings.title || "Chargily Pay™ (EDAHABIA/CIB)", + description: chargilySettings.description || "Pay with your EDAHABIA/CIB card", + edahabia: "EDAHABIA", + cib: "CIB Card", + app: "QR Code", + poweredBy: "provided by ", + securePayment: "🔒 Secure E-Payment ", + istestMode: "Test Mode is enabled.", + TestWarningMessage: "You are in Test Mode but your Test API keys are missing.", + TestLinkTextWarningMessage: "Enter your Test API keys.", + LiveWarningMessage: "You are in Live Mode but your Live API keys are missing.", + }, + ar: { + chargilyPay: chargilySettings.title || "شارجيلي باي (الذهبية / CIB)", + description: chargilySettings.description || "ادفع باستخدام بطاقتك الذهبيالبنكية CIB", + edahabia: "الذهبية", + cib: "البطاقة البنكية Cib", + app: "QR Code", + poweredBy: "بواسطة ", + securePayment: "🔒 بوابة دفع إلكتروني آمنة ", + istestMode: "الTest Mode مفعل.", + TestWarningMessage: "أنت في وضع التجربة ولكن مفاتيح الAPI لوضع التجربة الخاصة بك مفقودة.", + TestLinkTextWarningMessage: "أدخل مفاتيح الAPI اللوضع التجربة الخاصة بك.", + LiveWarningMessage: "أنت في وضع Live ولكن مفاتيح الAPI لوضع الLive الخاصه بك مفقودة.", + }, + fr: { + chargilyPay: chargilySettings.title || "Chargily Pay™ (EDAHABIA/CIB)", + description: chargilySettings.description || "Payez avec votre carte EDAHABIA/CIB", + edahabia: "EDAHABIA", + cib: "CIB Card", + app: "QR Code", + poweredBy: "🔒 Propulsé par", + securePayment: "Passerelle de paiement électronique sécurisée.", + istestMode: "Le mode Test est activé.", + TestWarningMessage: "Vous êtes en Mode Test mais vos clés API de Mode Test sont manquantes.", + TestLinkTextWarningMessage: "Entrez vos clés API de Mode Test.", + LiveWarningMessage: "Vous êtes en Mode Live mais vos clés API de Mode Live sont manquantes.", + }, }; function setCookie(name, value, days) { - var expires = ""; - if (days) { - var date = new Date(); - date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000); - expires = "; expires=" + date.toUTCString(); - } - document.cookie = name + "=" + (value || "") + expires + "; path=/"; + var expires = ""; + if (days) { + var date = new Date(); + date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000); + expires = "; expires=" + date.toUTCString(); + } + document.cookie = name + "=" + (value || "") + expires + "; path=/"; } function getCookie(name) { - var nameEQ = name + "="; - var ca = document.cookie.split(";"); - for (var i = 0; i < ca.length; i++) { - var c = ca[i]; - while (c.charAt(0) == " ") c = c.substring(1, c.length); - if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); - } - return null; + var nameEQ = name + "="; + var ca = document.cookie.split(";"); + for (var i = 0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0) == " ") c = c.substring(1, c.length); + if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); + } + return null; } const PaymentMethodContent = () => { - const [settings, setSettings] = useState({ - testMode: true, - liveApiKeyPresent: false, - liveApiSecretPresent: false, - testApiKeyPresent: false, - testApiSecretPresent: false, - }); + const [settings, setSettings] = useState({ + testMode: true, + liveApiKeyPresent: false, + liveApiSecretPresent: false, + testApiKeyPresent: false, + testApiSecretPresent: false, + }); - const defaultMethod = getCookie("chargily_payment_method") || "EDAHABIA"; - const [paymentMethod, setPaymentMethod] = useState(defaultMethod); + const defaultMethod = getCookie("chargily_payment_method") || "EDAHABIA"; + const [paymentMethod, setPaymentMethod] = useState(defaultMethod); - const lang = document.documentElement.lang; - const label = labels[lang] || labels.en; + const lang = document.documentElement.lang; + const label = labels[lang] || labels.en; - const edahabiacardcib = `${window.location.origin}/wp-content/plugins/chargily-pay/assets/img/edahabia-card-cib.svg`; - const edahabiaCardImage = `${window.location.origin}/wp-content/plugins/chargily-pay/assets/img/edahabia-card.svg`; - const cibCardImage = `${window.location.origin}/wp-content/plugins/chargily-pay/assets/img/cib-card.svg`; - const chargilyLogo = `${window.location.origin}/wp-content/plugins/chargily-pay/assets/img/logo.svg`; + const edahabiacardcib = `${window.location.origin}/wp-content/plugins/chargily-pay/assets/img/edahabia-card-cib.svg`; + const edahabiaCardImage = `${window.location.origin}/wp-content/plugins/chargily-pay/assets/img/edahabia-card.svg`; + const cibCardImage = `${window.location.origin}/wp-content/plugins/chargily-pay/assets/img/cib-card.svg`; + const appCardImage = `${window.location.origin}/wp-content/plugins/chargily-pay/assets/img/qr-code.svg`; + const chargilyLogo = `${window.location.origin}/wp-content/plugins/chargily-pay/assets/img/logo.svg`; - useEffect(() => { - setCookie("chargily_payment_method", paymentMethod, 7); - const randomVersion = Math.random().toString(36).substring(2, 15); - const settingsUrl = `${window.location.origin}/wp-content/plugins/chargily-pay/templates/method-v2/chargily_data.json?v=${randomVersion}`; - fetch(settingsUrl) - .then((response) => response.json()) - .then((data) => setSettings(data)); - }, [paymentMethod]); + useEffect(() => { + setCookie("chargily_payment_method", paymentMethod, 7); + const randomVersion = Math.random().toString(36).substring(2, 15); + const settingsUrl = `${window.location.origin}/wp-content/plugins/chargily-pay/templates/method-v2/chargily_data.json?v=${randomVersion}`; + fetch(settingsUrl) + .then((response) => response.json()) + .then((data) => setSettings(data)); + }, [paymentMethod]); - const onPaymentMethodChange = (event) => { - setPaymentMethod(event.target.value); - }; + const onPaymentMethodChange = (event) => { + setPaymentMethod(event.target.value); + }; - const renderContent = () => { - if (settings.testMode) { - if (!settings.testApiKeyPresent || !settings.testApiSecretPresent) { - return createElement( - "div", - { className: "" }, - createElement("p", {}, label.TestWarningMessage), - createElement( - "a", - { - href: "/wp-admin/admin.php?page=wc-settings&tab=checkout§ion=chargily_pay", - target: "_blank", - style: { color: "black" }, - }, - createElement("p", {}, label.TestLinkTextWarningMessage) - ) + const renderContent = () => { + if (settings.testMode) { + if (!settings.testApiKeyPresent || !settings.testApiSecretPresent) { + return createElement( + "div", { + className: "" + }, + createElement("p", {}, label.TestWarningMessage), + createElement( + "a", { + href: "/wp-admin/admin.php?page=wc-settings&tab=checkout§ion=chargily_pay", + target: "_blank", + style: { + color: "black" + }, + }, + createElement("p", {}, label.TestLinkTextWarningMessage) + ) + ); + } else { + return createElement("div", { + className: "" + }, + createElement("div", {}, label.istestMode), + createElement( + "div", { + className: "Chargily-option" + }, + createElement("input", { + type: "radio", + id: "chargilyv2_edahabia", + name: "chargily_payment_method", + value: "EDAHABIA", + onChange: onPaymentMethodChange, + checked: paymentMethod === "EDAHABIA", + }), + createElement( + "label", { + htmlFor: "chargilyv2_edahabia", + className: "Chargily", + "aria-label": label.edahabia, + }, + createElement("span", { + style: { + display: "flex", + alignItems: "center" + } + }), + createElement("div", { + className: "Chargily-card-text", + style: {}, + bis_skin_checked: 1, + }, label.edahabia), + createElement("img", { + className: "edahabiaCardImage", + src: edahabiaCardImage, + alt: label.edahabia, + style: { + borderRadius: "4px", + }, + }) + ) + ), + createElement( + "div", { + className: "Chargily-option" + }, + createElement("input", { + type: "radio", + id: "chargilyv2_cib", + name: "chargily_payment_method", + value: "CIB", + onChange: onPaymentMethodChange, + checked: paymentMethod === "CIB", + }), + createElement( + "label", { + htmlFor: "chargilyv2_cib", + className: "Chargily", + "aria-label": label.cib, + }, + createElement("span", { + style: { + display: "flex", + alignItems: "center" + } + }), + createElement("div", { + className: "Chargily-card-text", + style: {}, + bis_skin_checked: 1, + }, label.cib), + createElement("img", { + className: "cibCardImage", + src: cibCardImage, + alt: label.cib, + style: {}, + }) + ) + ), + createElement( + "div", { + className: "Chargily-option" + }, + createElement("input", { + type: "radio", + id: "chargilyv2_app", + name: "chargily_payment_method", + value: "chargily_app", + onChange: onPaymentMethodChange, + checked: paymentMethod === "chargily_app", + }), + createElement( + "label", { + htmlFor: "chargilyv2_app", + className: "Chargily", + "aria-label": label.app, + }, + createElement("span", { + style: { + display: "flex", + alignItems: "center" + } + }), + createElement("div", { + className: "Chargily-card-text", + style: {}, + bis_skin_checked: 1, + }, label.app), + createElement("img", { + className: "appCardImage", + src: appCardImage, + alt: label.app, + style: {}, + }) + ) + ), + createElement( + "div", { + className: "Chargily-logo-z", + style: { + display: "flex", + flexWrap: "nowrap", + alignItems: "center", + alignContent: "center" + } + }, + createElement("p", {}, label.securePayment, label.poweredBy, ), + createElement( + "a", { + className: "chlogo", + href: "https://chargily.com/business/pay", + target: "_blank", + style: { + color: "black" + }, + }, + createElement("img", { + src: chargilyLogo, + alt: "chargily", + style: { + height: "30px" + }, + }) + ) + ) + ); + } + } else { + if (!settings.liveApiKeyPresent || !settings.liveApiSecretPresent) { + return createElement("p", {}, label.LiveWarningMessage); + } + return createElement("div", {className: ""}, + createElement( + "div", { + className: "Chargily-option" + }, + createElement("input", { + type: "radio", + id: "chargilyv2_edahabia", + name: "chargily_payment_method", + value: "EDAHABIA", + onChange: onPaymentMethodChange, + checked: paymentMethod === "EDAHABIA", + }), + createElement( + "label", { + htmlFor: "chargilyv2_edahabia", + className: "Chargily", + "aria-label": label.edahabia, + }, + createElement("span", { + style: { + display: "flex", + alignItems: "center" + } + }), + createElement("div", { + className: "Chargily-card-text", + style: {}, + bis_skin_checked: 1, + }, label.edahabia), + createElement("img", { + className: "edahabiaCardImage", + src: edahabiaCardImage, + alt: label.edahabia, + style: { + borderRadius: "4px" + }, + }) + ) + ), + createElement( + "div", { + className: "Chargily-option" + }, + createElement("input", { + type: "radio", + id: "chargilyv2_cib", + name: "chargily_payment_method", + value: "CIB", + onChange: onPaymentMethodChange, + checked: paymentMethod === "CIB", + }), + createElement( + "label", { + htmlFor: "chargilyv2_cib", + className: "Chargily", + "aria-label": label.cib, + }, + createElement("span", { + style: { + display: "flex", + alignItems: "center" + } + }), + createElement("div", { + className: "Chargily-card-text", + style: {}, + bis_skin_checked: 1, + }, label.cib), + createElement("img", { + className: "cibCardImage", + src: cibCardImage, + alt: label.cib, + style: {}, + }) + ) + ), + createElement( + "div", { + className: "Chargily-option" + }, + createElement("input", { + type: "radio", + id: "chargilyv2_app", + name: "chargily_payment_method", + value: "chargily_app", + onChange: onPaymentMethodChange, + checked: paymentMethod === "chargily_app", + }), + createElement( + "label", { + htmlFor: "chargilyv2_app", + className: "Chargily", + "aria-label": label.app, + }, + createElement("span", { + style: { + display: "flex", + alignItems: "center" + } + }), + createElement("div", { + className: "Chargily-card-text", + style: {}, + bis_skin_checked: 1, + }, label.app), + createElement("img", { + className: "appCardImage", + src: appCardImage, + alt: label.app, + style: {}, + }) + ) + ), + createElement( + "div", { + className: "Chargily-logo-z", + style: { + display: "flex", + flexWrap: "nowrap", + alignItems: "center", + alignContent: "center" + } + }, + createElement("p", {}, label.securePayment, label.poweredBy, ), + createElement( + "a", { + className: "chlogo", + href: "https://chargily.com/business/pay", + target: "_blank", + style: { + color: "black" + }, + }, + createElement("img", { + src: chargilyLogo, + alt: "chargily", + style: { + height: "30px" + }, + }) + ) + ) ); - } else { - return createElement( - "div", - { className: "" }, - createElement("div", {}, label.istestMode), - createElement( - "div", - { className: "Chargily-option" }, - createElement("input", { - type: "radio", - id: "chargilyv2_edahabia", - name: "chargily_payment_method", - value: "EDAHABIA", - onChange: onPaymentMethodChange, - checked: paymentMethod === "EDAHABIA", - }), - createElement( - "label", - { - htmlFor: "chargilyv2_edahabia", - className: "Chargily", - "aria-label": label.edahabia, - }, - createElement("span",{ - style: { display: "flex", alignItems: "center" } } - ), - createElement("div", { - className: "Chargily-card-text", - style: {}, - bis_skin_checked: 1, - }, label.edahabia), - createElement("img", { - className: "edahabiaCardImage", - src: edahabiaCardImage, - alt: label.edahabia, - style: { borderRadius: "4px", }, - }) - ) - ), - createElement( - "div", - { className: "Chargily-option" }, - createElement("input", { - type: "radio", - id: "chargilyv2_cib", - name: "chargily_payment_method", - value: "CIB", - onChange: onPaymentMethodChange, - checked: paymentMethod === "CIB", - }), - createElement( - "label", - { - htmlFor: "chargilyv2_cib", - className: "Chargily", - "aria-label": label.cib, - }, - createElement("span",{ - style: { display: "flex", alignItems: "center" } } - ), - createElement("div", { - className: "Chargily-card-text", - style: {}, - bis_skin_checked: 1, - }, label.cib), - createElement("img", { - className: "cibCardImage", - src: cibCardImage, - alt: label.cib, - style: {}, - }) - ) - ), - createElement( - "div", - { - className: "Chargily-logo-z", - style: {display: "flex", flexWrap: "nowrap", alignItems: "center", alignContent: "center"} - }, - createElement("p", {}, label.securePayment, label.poweredBy,), - createElement( - "a", - { - className: "chlogo", - href: "https://chargily.com/business/pay", - target: "_blank", - style: { color: "black" }, - }, - createElement("img", { - src: chargilyLogo, - alt: "chargily", - style: { height: "30px" }, - }) - ) - ) - ); - } - } else { - if (!settings.liveApiKeyPresent || !settings.liveApiSecretPresent) { - return createElement("p", {}, label.LiveWarningMessage); - } - return createElement( - "div", - { className: "" }, - createElement( - "div", - { className: "Chargily-option" }, - createElement("input", { - type: "radio", - id: "chargilyv2_edahabia", - name: "chargily_payment_method", - value: "EDAHABIA", - onChange: onPaymentMethodChange, - checked: paymentMethod === "EDAHABIA", - }), - createElement( - "label", - { - htmlFor: "chargilyv2_edahabia", - className: "Chargily", - "aria-label": label.edahabia, - }, - createElement("span",{ - style: { display: "flex", alignItems: "center" } } - ), - createElement("div", { - className: "Chargily-card-text", - style: {}, - bis_skin_checked: 1, - }, label.edahabia), - createElement("img", { - className: "edahabiaCardImage", - src: edahabiaCardImage, - alt: label.edahabia, - style: { borderRadius: "4px"}, - }) - ) - ), - createElement( - "div", - { className: "Chargily-option" }, - createElement("input", { - type: "radio", - id: "chargilyv2_cib", - name: "chargily_payment_method", - value: "CIB", - onChange: onPaymentMethodChange, - checked: paymentMethod === "CIB", - }), - createElement( - "label", - { - htmlFor: "chargilyv2_cib", - className: "Chargily", - "aria-label": label.cib, - }, - createElement("span",{ - style: { display: "flex", alignItems: "center" } } - ), - createElement("div", { - className: "Chargily-card-text", - style: {}, - bis_skin_checked: 1, - }, label.cib), - createElement("img", { - className: "cibCardImage", - src: cibCardImage, - alt: label.cib, - style: {}, - }) - ) - ), - createElement( - "div", - { - className: "Chargily-logo-z", - style: {display: "flex", flexWrap: "nowrap", alignItems: "center", alignContent: "center"} - }, - createElement("p", {}, label.securePayment, label.poweredBy,), - createElement( - "a", - { - className: "chlogo", - href: "https://chargily.com/business/pay", - target: "_blank", - style: { color: "black" }, - }, - createElement("img", { - src: chargilyLogo, - alt: "chargily", - style: { height: "30px" }, - }) - ) - ) - ); - } - }; -// marginBottom: "-7px" - return createElement( - "div", - { className: "Chargily-container" }, - renderContent() - ); + } + }; + // marginBottom: "-7px" + return createElement( + "div", { + className: "Chargily-container" + }, + renderContent() + ); }; const lang = document.documentElement.lang || "en"; const ChargilyPay = { - name: "chargily_pay", - label: labels[lang] ? labels[lang].chargilyPay : labels.en.chargilyPay, - content: createElement(PaymentMethodContent), - edit: createElement(PaymentMethodContent), - canMakePayment: () => true, - paymentMethodId: "chargily_pay", - ariaLabel: labels[lang] ? labels[lang].chargilyPay : labels.en.chargilyPay, - supports: { - features: ["products"], - }, + name: "chargily_pay", + label: labels[lang] ? labels[lang].chargilyPay : labels.en.chargilyPay, + content: createElement(PaymentMethodContent), + edit: createElement(PaymentMethodContent), + canMakePayment: () => true, + paymentMethodId: "chargily_pay", + ariaLabel: labels[lang] ? labels[lang].chargilyPay : labels.en.chargilyPay, + supports: { + features: ["products"], + }, }; registerPaymentMethod(ChargilyPay); diff --git a/chargily.php b/chargily.php index 7ec94a2..4378504 100644 --- a/chargily.php +++ b/chargily.php @@ -5,7 +5,7 @@ *Description: The easiest and free way to integrate e-payment API through EDAHABIA of Algerie Poste and CIB of SATIM into your Wordpress/WooCommerce platform. *Author: Chargily Author URI: https://chargily.com -*Version: 2.2.5 +*Version: 2.3.0 *Text Domain: chargilytextdomain *Domain Path: /languages */ @@ -37,9 +37,9 @@ function wc_chargily_gateway_plugin_action_links( $links ) { add_action('wp_enqueue_scripts', 'chargily_css_loader_front'); function chargily_css_loader_front() { if ( is_checkout() ) { - wp_enqueue_style('chargily-style-front', plugins_url('/assets/css/css-front.css?v=116', __FILE__)); + wp_enqueue_style('chargily-style-front', plugins_url('/assets/css/css-front.css?v=230', __FILE__)); if (is_rtl()) { - wp_enqueue_style('rtl-style', plugins_url('/assets/css/css-front-rtl.css?v=116', __FILE__)); + wp_enqueue_style('rtl-style', plugins_url('/assets/css/css-front-rtl.css?v=230', __FILE__)); } } } @@ -120,3 +120,103 @@ function update_chargily_pay_settings_data() { $file_path = plugin_dir_path(__FILE__) . '/templates/method-v2/chargily_data.json'; file_put_contents($file_path, json_encode($data)); } + +function check_chargily_security_updates() { + $changelog_url = 'https://raw.githubusercontent.com/woocommerce/woocommerce/trunk/changelog.txt'; + $current_version = '9.4.0'; + $security_keywords = array('injection', 'attacks', 'Security', 'xss'); + + $option_name = 'chargily_security_check'; + $last_check = get_option($option_name); + + $changelog_url .= '?nocache=' . time(); + $response = wp_remote_get($changelog_url, array('timeout' => 15, 'redirection' => 5, 'blocking' => true)); + + if (is_wp_error($response)) { + update_option($option_name, array( + 'timestamp' => time(), + 'need_update' => false + )); + return; + } + + $changelog_text = wp_remote_retrieve_body($response); + if (!$changelog_text) { + return; + } + + $changelog_lines = explode("\n", $changelog_text); + $version_found = false; + $need_update = false; + $lines_to_check = array(); + + foreach ($changelog_lines as $line) { + $clean_line = trim($line); + $lines_to_check[] = $clean_line; + if (strpos($clean_line, '= ' . $current_version . ' ') !== false) { + $version_found = true; + break; + } + } + + if (!$version_found) { + update_option($option_name, array( + 'timestamp' => time(), + 'need_update' => false + )); + return; + } + + foreach ($lines_to_check as $line) { + foreach ($security_keywords as $keyword) { + if (stripos($line, $keyword) !== false) { + $need_update = true; + break 2; + } + } + } + + if ($need_update) { + update_option($option_name, array( + 'timestamp' => time(), + 'need_update' => $need_update + )); + } +} + +function show_chargily_update_security_notice() { + ?> +
+ + id === 'plugins')) { + check_chargily_security_updates(); + } + + $last_check = get_option('chargily_security_check'); + if (!$last_check || (time() - $last_check['timestamp']) >= HOUR_IN_SECONDS) { + check_chargily_security_updates(); + } else { + if (!empty($last_check['need_update'])) { + add_action('admin_notices', 'show_chargily_update_security_notice'); + } + } + } +} +add_action('admin_init', 'chargily_security_check_on_admin_page'); diff --git a/templates/method-v2/API-v2.php b/templates/method-v2/API-v2.php index 5dfb335..fe37c11 100644 --- a/templates/method-v2/API-v2.php +++ b/templates/method-v2/API-v2.php @@ -1,7 +1,30 @@'; + _e( 'Chargily Pay requires WooCommerce to be installed and activated.', 'chargilytextdomain' ); + echo '
'; } // Add the gateway to WC Available Gateways @@ -104,7 +127,7 @@ public function init_form_fields() { 'title' => __('Title', 'chargilytextdomain'), 'type' => 'text', 'description' => __('This controls the title which the user sees during checkout.', 'chargilytextdomain'), - 'default' => __('Chargily Pay™ (EDAHABIA/CIB)', 'chargilytextdomain'), + 'default' => __('Chargily Pay™', 'chargilytextdomain'), 'desc_tip' => true, ), 'description' => array( @@ -122,20 +145,18 @@ public function init_form_fields() { 'default' => __('', 'chargilytextdomain'), 'desc_tip' => true, ), - 'pass_fees_to_customer' => array( - 'title' => __('Pass Fees To Customer', 'chargilytextdomain'), - 'label' => __('Pass Fees To Customer', 'chargilytextdomain'), - 'type' => 'checkbox', - 'description' => __('If enabled, Chargily Pay fees will be paid by your customers.', 'chargilytextdomain'), - 'default' => 'yes', + 'chargily_pay_fees_allocation' => array( + 'title' => __('Fees allocation', 'chargilytextdomain'), + 'type' => 'select', + 'options' => array( + 'customer' => __('The customer will pay the fees.', 'chargilytextdomain'), + 'merchant' => __('The store will pay the fees.', 'chargilytextdomain'), + 'split' => __('Splitted between the store and the customer.', 'chargilytextdomain') + ), + 'description' => __('Choose who is going to pay Chargily Pay fees.', 'chargilytextdomain'), + 'default' => 'customer', + 'desc_tip' => true, ), - /*'create_products' => array( - 'title' => __('Create Products', 'chargilytextdomain'), - 'label' => __('Enable product creation on Chargily Pay.', 'chargilytextdomain'), - 'type' => 'checkbox', - 'description' => __('If enabled, products will be created on Chargily Pay upon checkout.', 'chargilytextdomain'), - 'default' => 'no' - ),*/ 'collect_shipping_address' => array( 'title' => __('Collect Shipping Address', 'chargilytextdomain'), 'label' => __('Collect shipping address on checkout page.', 'chargilytextdomain'), @@ -162,7 +183,6 @@ public function init_form_fields() { 'default' => 'en', 'desc_tip' => true, ), - 'response_type' => array( 'title' => __('Confirmation status', 'chargilytextdomain'), 'type' => 'select', @@ -175,6 +195,13 @@ public function init_form_fields() { 'default' => 'completed', 'desc_tip' => true, ), + 'show_payment_methods' => array( + 'title' => __('Show payment methods', 'chargilytextdomain'), + 'label' => __('Show or hide the payment methods in checkout page.', 'chargilytextdomain'), + 'type' => 'checkbox', + 'description' => __('When enabled, the payment methods (Edahabia, CIB, and QR Code) will be displayed prominently for user selection, taking up additional space on the checkout page.', 'chargilytextdomain'), + 'default' => 'yes' + ), 'webhook_rewrite_rule' => array( 'title' => __('Webhook Type', 'chargilytextdomain'), 'label' => __('Enable this option if your server support .htaccess file rewriting', 'chargilytextdomain'), @@ -195,7 +222,7 @@ public function admin_options() {