From bac3ebd2e92d87c53605494452a54d577269ef54 Mon Sep 17 00:00:00 2001 From: Marcus Dahl Date: Mon, 18 Mar 2024 14:17:47 +0100 Subject: [PATCH] fix: frontend scripts not properly loaded --- README.txt | 3 +++ assets/build/index.asset.php | 2 +- assets/build/index.js | 33 ++++++++++-------------- assets/build/index.js.map | 2 +- includes/wc-gateway-vipps-recurring.php | 2 +- src/pages/PaymentRedirectPage.jsx | 34 ++++++++++++------------- woo-vipps-recurring.php | 4 +-- 7 files changed, 39 insertions(+), 41 deletions(-) diff --git a/README.txt b/README.txt index bed30af..38856a7 100755 --- a/README.txt +++ b/README.txt @@ -161,6 +161,9 @@ Alternatively you could look into using WooCommerce "Early renewals": [https://d == Changelog == += 1.20.1 = +* Fixed: Frontend scripts were not properly loaded. + = 1.20.0 = * Added: Webhooks. To enable webhooks you just need to save your settings one more time. A webhook will be automatically set-up. * Added: Try to detect whether to use Vipps or MobilePay branding. diff --git a/assets/build/index.asset.php b/assets/build/index.asset.php index 972b146..1f20ade 100644 --- a/assets/build/index.asset.php +++ b/assets/build/index.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-element', 'wp-i18n'), 'version' => '84c5c9476111a1286299'); + array('react', 'wp-api-fetch', 'wp-element', 'wp-i18n'), 'version' => '913e8eaa2781e094eb4f'); diff --git a/assets/build/index.js b/assets/build/index.js index de3ba22..fc0a2be 100644 --- a/assets/build/index.js +++ b/assets/build/index.js @@ -53,25 +53,20 @@ function PaymentRedirectPage() { logo } = window.VippsMobilePaySettings; const searchParams = new URLSearchParams(window.location.search); - - // const [response, setResponse] = useState(null) - // - // const intervalHandler = setInterval(() => { - // apiFetch({ - // path: `/vipps-mobilepay-recurring/v1/orders/status/${searchParams.get( - // 'order_id')}?key=${searchParams.get('key')}`, method: 'GET', - // }).then(response => setResponse(response)) - // }, 1000) - // - // useEffect(() => { - // if (!response || response.status === 'PENDING') { - // return - // } - // - // clearInterval(intervalHandler) - // window.location.href = response.redirect_url - // }, [response]) - + const [response, setResponse] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.useState)(null); + const intervalHandler = setInterval(() => { + _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_2___default()({ + path: `/vipps-mobilepay-recurring/v1/orders/status/${searchParams.get('order_id')}?key=${searchParams.get('key')}`, + method: 'GET' + }).then(response => setResponse(response)); + }, 1000); + (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.useEffect)(() => { + if (!response || response.status === 'PENDING') { + return; + } + clearInterval(intervalHandler); + window.location.href = response.redirect_url; + }, [response]); return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { className: 'vipps-recurring-payment-redirect-page' }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { diff --git a/assets/build/index.js.map b/assets/build/index.js.map index e347af9..d159573 100644 --- a/assets/build/index.js.map +++ b/assets/build/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","mappings":";;;;;;;;;;;;;;;;AAAwD;AAEzC,SAASE,SAASA,CAACC,OAAO,EAAEC,SAAS,EAAE;EACpD,IAAIJ,0DAAU,EAAE;IACd,MAAMK,IAAI,GAAGL,8DAAU,CAACG,OAAO,CAAC;IAChCE,IAAI,CAACJ,MAAM,CAACG,SAAS,CAAC;EACxB,CAAC,MAAM;IACLH,0DAAM,CAACG,SAAS,EAAED,OAAO,CAAC;EAC5B;AACF;;;;;;;;;;;;;;;;;;;;;;;ACTwD;AACb;AACP;AAErB,SAASO,mBAAmBA,CAAA,EAAI;EAC9C,MAAM;IAAEC;EAAK,CAAC,GAAGC,MAAM,CAACC,sBAAsB;EAC9C,MAAMC,YAAY,GAAG,IAAIC,eAAe,CAACH,MAAM,CAACI,QAAQ,CAACC,MAAM,CAAC;;EAEhE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA,OAAQC,oDAAA;IAAKC,SAAS,EAAE;EAAwC,GAC9DD,oDAAA;IAAKC,SAAS,EAAE;EAAmD,GAClED,oDAAA;IACCC,SAAS,EAAE;EAA4D,GACvED,oDAAA;IACCC,SAAS,EAAE;EAAkE,GAC7ED,oDAAA;IAAKE,GAAG,EAAET,IAAK;IAACU,GAAG,EAAC;EAAM,CAAC,CACvB,CAAC,EACNH,oDAAA;IACCC,SAAS,EAAE;EAAqE,GAChFD,oDAAA;IACCC,SAAS,EAAE;EAA8E,CAAC,CACvF,CAAC,EACND,oDAAA;IACCC,SAAS,EAAE;EAAkE,GAC7ED,oDAAA,YACET,mDAAE,CAAC,sCAAsC,EACzC,kDAAkD,CACjD,CAAC,EAEJS,oDAAA,YACET,mDAAE,CAAC,iCAAiC,EACpC,kDAAkD,CACjD,CACC,CACD,CACD,CACD,CAAC;AACR;;;;;;;;;;;ACtDA;;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;;;;;;;;;ACNqB;AACoB;AACqB;AAE9D,IAAIa,QAAQ,CAACC,cAAc,CAAC,+BAA+B,CAAC,EAAE;EAC5DrB,2DAAS,CAACoB,QAAQ,CAACE,aAAa,CAAC,gCAAgC,CAAC,EAAEN,oDAAA,CAACR,kEAAmB,MAAC,CAAC,CAAC;AAC7F,C","sources":["webpack://vipps-mobilepay-recurring-payments/./src/lib/create-app.js","webpack://vipps-mobilepay-recurring-payments/./src/pages/PaymentRedirectPage.jsx","webpack://vipps-mobilepay-recurring-payments/./src/main.scss","webpack://vipps-mobilepay-recurring-payments/external window \"React\"","webpack://vipps-mobilepay-recurring-payments/external window [\"wp\",\"apiFetch\"]","webpack://vipps-mobilepay-recurring-payments/external window [\"wp\",\"element\"]","webpack://vipps-mobilepay-recurring-payments/external window [\"wp\",\"i18n\"]","webpack://vipps-mobilepay-recurring-payments/webpack/bootstrap","webpack://vipps-mobilepay-recurring-payments/webpack/runtime/compat get default export","webpack://vipps-mobilepay-recurring-payments/webpack/runtime/define property getters","webpack://vipps-mobilepay-recurring-payments/webpack/runtime/hasOwnProperty shorthand","webpack://vipps-mobilepay-recurring-payments/webpack/runtime/make namespace object","webpack://vipps-mobilepay-recurring-payments/./src/index.js"],"sourcesContent":["import { createRoot, render } from \"@wordpress/element\";\n\nexport default function createApp(element, component) {\n if (createRoot) {\n const root = createRoot(element);\n root.render(component);\n } else {\n render(component, element);\n }\n}\n","import { useEffect, useState } from '@wordpress/element'\nimport apiFetch from '@wordpress/api-fetch'\nimport { __ } from '@wordpress/i18n'\n\nexport default function PaymentRedirectPage () {\n\tconst { logo } = window.VippsMobilePaySettings\n\tconst searchParams = new URLSearchParams(window.location.search)\n\n\t// const [response, setResponse] = useState(null)\n\t//\n\t// const intervalHandler = setInterval(() => {\n\t// \tapiFetch({\n\t// \t\tpath: `/vipps-mobilepay-recurring/v1/orders/status/${searchParams.get(\n\t// \t\t\t'order_id')}?key=${searchParams.get('key')}`, method: 'GET',\n\t// \t}).then(response => setResponse(response))\n\t// }, 1000)\n\t//\n\t// useEffect(() => {\n\t// \tif (!response || response.status === 'PENDING') {\n\t// \t\treturn\n\t// \t}\n\t//\n\t// \tclearInterval(intervalHandler)\n\t// \twindow.location.href = response.redirect_url\n\t// }, [response])\n\n\treturn (
\n\t\t\t
\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\"Logo\"/\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t

\n\t\t\t\t\t\t\t{__('Verifying your payment. Please wait.',\n\t\t\t\t\t\t\t\t'vipps-recurring-payments-gateway-for-woocommerce')}\n\t\t\t\t\t\t

\n\n\t\t\t\t\t\t

\n\t\t\t\t\t\t\t{__('You will be redirected shortly.',\n\t\t\t\t\t\t\t\t'vipps-recurring-payments-gateway-for-woocommerce')}\n\t\t\t\t\t\t

\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t)\n}\n","// extracted by mini-css-extract-plugin\nexport {};","module.exports = window[\"React\"];","module.exports = window[\"wp\"][\"apiFetch\"];","module.exports = window[\"wp\"][\"element\"];","module.exports = window[\"wp\"][\"i18n\"];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import \"./main.scss\";\nimport createApp from \"./lib/create-app\";\nimport PaymentRedirectPage from \"./pages/PaymentRedirectPage\";\n\nif (document.getElementById(\"vipps-mobilepay-recurring-app\")) {\n createApp(document.querySelector(\"#vipps-mobilepay-recurring-app\"), );\n}\n"],"names":["createRoot","render","createApp","element","component","root","useEffect","useState","apiFetch","__","PaymentRedirectPage","logo","window","VippsMobilePaySettings","searchParams","URLSearchParams","location","search","createElement","className","src","alt","document","getElementById","querySelector"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"index.js","mappings":"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","sources":["webpack://vipps-mobilepay-recurring-payments/./src/lib/create-app.js","webpack://vipps-mobilepay-recurring-payments/./src/pages/PaymentRedirectPage.jsx","webpack://vipps-mobilepay-recurring-payments/./src/main.scss","webpack://vipps-mobilepay-recurring-payments/external window \"React\"","webpack://vipps-mobilepay-recurring-payments/external window [\"wp\",\"apiFetch\"]","webpack://vipps-mobilepay-recurring-payments/external window [\"wp\",\"element\"]","webpack://vipps-mobilepay-recurring-payments/external window [\"wp\",\"i18n\"]","webpack://vipps-mobilepay-recurring-payments/webpack/bootstrap","webpack://vipps-mobilepay-recurring-payments/webpack/runtime/compat get default export","webpack://vipps-mobilepay-recurring-payments/webpack/runtime/define property getters","webpack://vipps-mobilepay-recurring-payments/webpack/runtime/hasOwnProperty shorthand","webpack://vipps-mobilepay-recurring-payments/webpack/runtime/make namespace object","webpack://vipps-mobilepay-recurring-payments/./src/index.js"],"sourcesContent":["import { createRoot, render } from \"@wordpress/element\";\n\nexport default function createApp(element, component) {\n if (createRoot) {\n const root = createRoot(element);\n root.render(component);\n } else {\n render(component, element);\n }\n}\n","import { useEffect, useState } from '@wordpress/element'\nimport apiFetch from '@wordpress/api-fetch'\nimport { __ } from '@wordpress/i18n'\n\nexport default function PaymentRedirectPage () {\n\tconst { logo } = window.VippsMobilePaySettings\n\tconst searchParams = new URLSearchParams(window.location.search)\n\n\tconst [response, setResponse] = useState(null)\n\n\tconst intervalHandler = setInterval(() => {\n\t\tapiFetch({\n\t\t\tpath: `/vipps-mobilepay-recurring/v1/orders/status/${searchParams.get(\n\t\t\t\t'order_id')}?key=${searchParams.get('key')}`, method: 'GET',\n\t\t}).then(response => setResponse(response))\n\t}, 1000)\n\n\tuseEffect(() => {\n\t\tif (!response || response.status === 'PENDING') {\n\t\t\treturn\n\t\t}\n\n\t\tclearInterval(intervalHandler)\n\t\twindow.location.href = response.redirect_url\n\t}, [response])\n\n\treturn (
\n\t\t\t
\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\"Logo\"/\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t

\n\t\t\t\t\t\t\t{__('Verifying your payment. Please wait.',\n\t\t\t\t\t\t\t\t'vipps-recurring-payments-gateway-for-woocommerce')}\n\t\t\t\t\t\t

\n\n\t\t\t\t\t\t

\n\t\t\t\t\t\t\t{__('You will be redirected shortly.',\n\t\t\t\t\t\t\t\t'vipps-recurring-payments-gateway-for-woocommerce')}\n\t\t\t\t\t\t

\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t)\n}\n","// extracted by mini-css-extract-plugin\nexport {};","module.exports = window[\"React\"];","module.exports = window[\"wp\"][\"apiFetch\"];","module.exports = window[\"wp\"][\"element\"];","module.exports = window[\"wp\"][\"i18n\"];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import \"./main.scss\";\nimport createApp from \"./lib/create-app\";\nimport PaymentRedirectPage from \"./pages/PaymentRedirectPage\";\n\nif (document.getElementById(\"vipps-mobilepay-recurring-app\")) {\n createApp(document.querySelector(\"#vipps-mobilepay-recurring-app\"), );\n}\n"],"names":["createRoot","render","createApp","element","component","root","useEffect","useState","apiFetch","__","PaymentRedirectPage","logo","window","VippsMobilePaySettings","searchParams","URLSearchParams","location","search","response","setResponse","intervalHandler","setInterval","path","get","method","then","status","clearInterval","href","redirect_url","createElement","className","src","alt","document","getElementById","querySelector"],"sourceRoot":""} \ No newline at end of file diff --git a/includes/wc-gateway-vipps-recurring.php b/includes/wc-gateway-vipps-recurring.php index a80786e..2814b72 100755 --- a/includes/wc-gateway-vipps-recurring.php +++ b/includes/wc-gateway-vipps-recurring.php @@ -142,7 +142,7 @@ public function __construct() { $this->title = $this->get_form_fields()['brand']['options'][ $this->brand ]; $this->description = str_replace( '{brand}', $this->title, $this->get_option( 'description' ) ); $this->enabled = $this->get_option( 'enabled' ); - $this->test_mode = $this->get_option( 'test_mode' ); + $this->test_mode = $this->get_option( 'test_mode' ) === "yes"; $this->merchant_serial_number = $this->get_option( 'merchant_serial_number' ); $this->secret_key = $this->get_option( 'secret_key' ); $this->client_id = $this->get_option( 'client_id' ); diff --git a/src/pages/PaymentRedirectPage.jsx b/src/pages/PaymentRedirectPage.jsx index 16f3d32..340c1db 100644 --- a/src/pages/PaymentRedirectPage.jsx +++ b/src/pages/PaymentRedirectPage.jsx @@ -6,23 +6,23 @@ export default function PaymentRedirectPage () { const { logo } = window.VippsMobilePaySettings const searchParams = new URLSearchParams(window.location.search) - // const [response, setResponse] = useState(null) - // - // const intervalHandler = setInterval(() => { - // apiFetch({ - // path: `/vipps-mobilepay-recurring/v1/orders/status/${searchParams.get( - // 'order_id')}?key=${searchParams.get('key')}`, method: 'GET', - // }).then(response => setResponse(response)) - // }, 1000) - // - // useEffect(() => { - // if (!response || response.status === 'PENDING') { - // return - // } - // - // clearInterval(intervalHandler) - // window.location.href = response.redirect_url - // }, [response]) + const [response, setResponse] = useState(null) + + const intervalHandler = setInterval(() => { + apiFetch({ + path: `/vipps-mobilepay-recurring/v1/orders/status/${searchParams.get( + 'order_id')}?key=${searchParams.get('key')}`, method: 'GET', + }).then(response => setResponse(response)) + }, 1000) + + useEffect(() => { + if (!response || response.status === 'PENDING') { + return + } + + clearInterval(intervalHandler) + window.location.href = response.redirect_url + }, [response]) return (
diff --git a/woo-vipps-recurring.php b/woo-vipps-recurring.php index a4c93a4..e7137e3 100755 --- a/woo-vipps-recurring.php +++ b/woo-vipps-recurring.php @@ -5,7 +5,7 @@ * Description: Offer recurring payments with Vipps MobilePay for WooCommerce Subscriptions * Author: Everyday AS * Author URI: https://everyday.no - * Version: 1.20.0 + * Version: 1.20.1 * Requires at least: 6.1 * Tested up to: 6.5 * WC tested up to: 8.6 @@ -17,7 +17,7 @@ // phpcs:disable WordPress.Files.FileName -define( 'WC_VIPPS_RECURRING_VERSION', '1.20.0' ); +define( 'WC_VIPPS_RECURRING_VERSION', '1.20.1' ); add_action( 'plugins_loaded', 'woocommerce_gateway_vipps_recurring_init' );