From 48e74555dceb8b6c8c86ba6273d860b35fc3eeda Mon Sep 17 00:00:00 2001 From: indykoning <15870933+indykoning@users.noreply.github.com> Date: Wed, 5 Apr 2023 11:45:22 +0200 Subject: [PATCH] Add package.js (#2) --- README.md | 8 +------- resources/js/components.js | 3 +++ resources/js/eventlisteners.js | 12 ++++++++++++ resources/js/multisafepay.js | 16 +--------------- resources/js/package.js | 2 ++ 5 files changed, 19 insertions(+), 22 deletions(-) create mode 100644 resources/js/components.js create mode 100644 resources/js/eventlisteners.js create mode 100644 resources/js/package.js diff --git a/README.md b/README.md index 6aedd11..516a5e5 100644 --- a/README.md +++ b/README.md @@ -10,16 +10,10 @@ The magento2 core package from MultiSafePay currently contains a bug that preven ## Installation -``` +```bash composer require rapidez/multisafepay ``` -And import the JS into your `resources/js/app.js`: - -``` -import 'Vendor/rapidez/multisafepay/resources/js/multisafepay.js'; -``` - Then, in your magento -> configuration -> multisafepay -> general settings, enable custom return urls for PWA and use the following return URLs: ``` diff --git a/resources/js/components.js b/resources/js/components.js new file mode 100644 index 0000000..298cc6f --- /dev/null +++ b/resources/js/components.js @@ -0,0 +1,3 @@ +import 'Vendor/rapidez/core/resources/js/vue' + +Vue.component('msp-pending', () => import('./components/MSPPending.vue')) diff --git a/resources/js/eventlisteners.js b/resources/js/eventlisteners.js new file mode 100644 index 0000000..5a0bacc --- /dev/null +++ b/resources/js/eventlisteners.js @@ -0,0 +1,12 @@ +document.addEventListener('turbo:load', () => { + window.app.$on('checkout-payment-saved', (data) => { + if (!data.order.payment_method_code.includes('multisafepay_')) { + return; + } + window.app.checkout.doNotGoToTheNextStep = true + let cart = window.app.user ? 'mine' : localStorage.mask; + magentoUser.get(`/multisafepay/${cart}/payment-url/${data.order.id}`).then(response => { + window.location.replace(response.data); + }); + }); +}) diff --git a/resources/js/multisafepay.js b/resources/js/multisafepay.js index 1048b65..74f643e 100644 --- a/resources/js/multisafepay.js +++ b/resources/js/multisafepay.js @@ -1,15 +1 @@ -import MSPPending from './components/MSPPending.vue' -Vue.component('msp-pending', MSPPending) - -document.addEventListener('turbo:load', () => { - window.app.$on('checkout-payment-saved', (data) => { - if (!data.order.payment_method_code.includes('multisafepay_')) { - return; - } - window.app.checkout.doNotGoToTheNextStep = true - let cart = window.app.user ? 'mine' : localStorage.mask; - magentoUser.get(`/multisafepay/${cart}/payment-url/${data.order.id}`).then(response => { - window.location.replace(response.data); - }); - }); -}) +import './package' \ No newline at end of file diff --git a/resources/js/package.js b/resources/js/package.js new file mode 100644 index 0000000..5e0e875 --- /dev/null +++ b/resources/js/package.js @@ -0,0 +1,2 @@ +import './components' +import './eventlisteners' \ No newline at end of file