Skip to content

Commit bced502

Browse files
Workaround for Issue with Hyva Checkout post 1.3.0 (#191)
This code finds the magewire component, but the workaround is required because the component may not be immediately available when the script is executed. This is related to an issue in Hyva Checkout 1.3.0 or later. This is currently the suggested workaround provided by Hyva: https://gitlab.hyva.io/hyva-checkout/checkout/-/issues/418
1 parent d966016 commit bced502

10 files changed

+151
-22
lines changed

src/view/frontend/templates/component/payment/apple-pay-hosted-processor.phtml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,25 @@ use Magento\Framework\View\Element\Template;
1616
</style>
1717
<script>
1818
(() => {
19-
window.addEventListener('checkout:payment:method-activate', event => {
19+
window.addEventListener('checkout:payment:method-activate', async event => {
2020
if (event.detail.method !== 'rvvup_APPLE_PAY') {
2121
return;
2222
}
2323

24-
const component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
24+
/*
25+
This code finds the magewire component, but the workaround is required because the component may not be
26+
immediately available when the script is executed. This is related to an issue in Hyva Checkout 1.3.0 or
27+
later. This is currently the suggested workaround provided by Hyva:
28+
https://gitlab.hyva.io/hyva-checkout/checkout/-/issues/418
29+
*/
30+
let component;
31+
try {
32+
component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
33+
} catch (error) {
34+
await Livewire.onLoad(() => {
35+
component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
36+
});
37+
}
2538
hyvaCheckout.payment.activate('rvvup_APPLE_PAY', {
2639
placeOrderViaJs() {
2740
return document.querySelector('[wire\\:key="rvvup_APPLE_PAY"].active') !== null;

src/view/frontend/templates/component/payment/apple-pay-inline-processor.phtml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ use Magento\Framework\View\Element\Template;
9797
}
9898
});
9999

100-
window.addEventListener('checkout:payment:method-activate', event => {
100+
window.addEventListener('checkout:payment:method-activate', async event => {
101101
let placeOrderButton = getPlaceOrderButton();
102102
const divId = "rvvup-apple-pay-button";
103103

@@ -112,7 +112,20 @@ use Magento\Framework\View\Element\Template;
112112

113113
$applePaySelected = true;
114114

115-
const component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
115+
/*
116+
This code finds the magewire component, but the workaround is required because the component may not be
117+
immediately available when the script is executed. This is related to an issue in Hyva Checkout 1.3.0 or
118+
later. This is currently the suggested workaround provided by Hyva:
119+
https://gitlab.hyva.io/hyva-checkout/checkout/-/issues/418
120+
*/
121+
let component;
122+
try {
123+
component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
124+
} catch (error) {
125+
await Livewire.onLoad(() => {
126+
component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
127+
});
128+
}
116129
hyvaCheckout.payment.activate('rvvup_APPLE_PAY', {
117130
initialize() {
118131
placeOrderButton.classList.add('rvvup_APPLE_PAY_place_order_button');

src/view/frontend/templates/component/payment/card-inline-processor.phtml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,25 @@ use Magento\Framework\View\Element\Template;
2929
});
3030
});
3131

32-
window.addEventListener('checkout:payment:method-activate', event => {
32+
window.addEventListener('checkout:payment:method-activate', async event => {
3333
if (event.detail.method !== 'rvvup_CARD') {
3434
return;
3535
}
3636

37-
const component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
38-
37+
/*
38+
This code finds the magewire component, but the workaround is required because the component may not be
39+
immediately available when the script is executed. This is related to an issue in Hyva Checkout 1.3.0 or
40+
later. This is currently the suggested workaround provided by Hyva:
41+
https://gitlab.hyva.io/hyva-checkout/checkout/-/issues/418
42+
*/
43+
let component;
44+
try {
45+
component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
46+
} catch (error) {
47+
await Livewire.onLoad(() => {
48+
component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
49+
});
50+
}
3951
hyvaCheckout.payment.activate('rvvup_CARD', {
4052
initialize() {
4153
ST = SecureTrading({

src/view/frontend/templates/component/payment/card-modal-processor.phtml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,25 @@ use Magento\Framework\Escaper;
1212
<div wire:ignore>
1313
<script>
1414
(() => {
15-
window.addEventListener('checkout:payment:method-activate', event => {
15+
window.addEventListener('checkout:payment:method-activate', async event => {
1616
if (event.detail.method !== 'rvvup_CARD') {
1717
return;
1818
}
1919

20-
const component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
20+
/*
21+
This code finds the magewire component, but the workaround is required because the component may not be
22+
immediately available when the script is executed. This is related to an issue in Hyva Checkout 1.3.0 or
23+
later. This is currently the suggested workaround provided by Hyva:
24+
https://gitlab.hyva.io/hyva-checkout/checkout/-/issues/418
25+
*/
26+
let component;
27+
try {
28+
component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
29+
} catch (error) {
30+
await Livewire.onLoad(() => {
31+
component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
32+
});
33+
}
2134
hyvaCheckout.payment.activate('rvvup_CARD', {
2235
placeOrderViaJs() {
2336
return document.querySelector('[wire\\:key="rvvup_CARD"].active') !== null;

src/view/frontend/templates/component/payment/clearpay-processor.phtml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22
declare(strict_types=1);
33

4-
use Magento\Framework\View\Element\Template;
54
use Magento\Framework\Escaper;
5+
use Magento\Framework\View\Element\Template;
66

77
/** @var Template $block */
88
/** @var Escaper $escaper */
@@ -12,12 +12,25 @@ use Magento\Framework\Escaper;
1212
<div wire:ignore>
1313
<script>
1414
(() => {
15-
window.addEventListener('checkout:payment:method-activate', event => {
15+
window.addEventListener('checkout:payment:method-activate', async event => {
1616
if (event.detail.method !== 'rvvup_CLEARPAY') {
1717
return;
1818
}
1919

20-
const component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
20+
/*
21+
This code finds the magewire component, but the workaround is required because the component may not be
22+
immediately available when the script is executed. This is related to an issue in Hyva Checkout 1.3.0 or
23+
later. This is currently the suggested workaround provided by Hyva:
24+
https://gitlab.hyva.io/hyva-checkout/checkout/-/issues/418
25+
*/
26+
let component;
27+
try {
28+
component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
29+
} catch (error) {
30+
await Livewire.onLoad(() => {
31+
component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
32+
});
33+
}
2134
hyvaCheckout.payment.activate('rvvup_CLEARPAY', {
2235

2336
placeOrderViaJs() {

src/view/frontend/templates/component/payment/crypto-processor.phtml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,25 @@ use Magento\Framework\Escaper;
1111
<div wire:ignore>
1212
<script>
1313
(() => {
14-
window.addEventListener('checkout:payment:method-activate', event => {
14+
window.addEventListener('checkout:payment:method-activate', async event => {
1515
if (event.detail.method !== 'rvvup_CRYPTO') {
1616
return;
1717
}
1818

19-
const component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
19+
/*
20+
This code finds the magewire component, but the workaround is required because the component may not be
21+
immediately available when the script is executed. This is related to an issue in Hyva Checkout 1.3.0 or
22+
later. This is currently the suggested workaround provided by Hyva:
23+
https://gitlab.hyva.io/hyva-checkout/checkout/-/issues/418
24+
*/
25+
let component;
26+
try {
27+
component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
28+
} catch (error) {
29+
await Livewire.onLoad(() => {
30+
component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
31+
});
32+
}
2033
hyvaCheckout.payment.activate('rvvup_CRYPTO', {
2134
placeOrderViaJs() {
2235
return document.querySelector('[wire\\:key="rvvup_CRYPTO"].active') !== null;

src/view/frontend/templates/component/payment/fake-processor.phtml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,25 @@ use Magento\Framework\Escaper;
1111
<div wire:ignore>
1212
<script>
1313
(() => {
14-
window.addEventListener('checkout:payment:method-activate', event => {
14+
window.addEventListener('checkout:payment:method-activate', async event => {
1515
if (event.detail.method !== 'rvvup_FAKE_PAYMENT_METHOD') {
1616
return;
1717
}
1818

19-
const component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
19+
/*
20+
This code finds the magewire component, but the workaround is required because the component may not be
21+
immediately available when the script is executed. This is related to an issue in Hyva Checkout 1.3.0 or
22+
later. This is currently the suggested workaround provided by Hyva:
23+
https://gitlab.hyva.io/hyva-checkout/checkout/-/issues/418
24+
*/
25+
let component;
26+
try {
27+
component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
28+
} catch (error) {
29+
await Livewire.onLoad(() => {
30+
component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
31+
});
32+
}
2033
hyvaCheckout.payment.activate('rvvup_FAKE_PAYMENT_METHOD', {
2134
placeOrderViaJs() {
2235
return document.querySelector('[wire\\:key="rvvup_FAKE_PAYMENT_METHOD"].active') !== null;

src/view/frontend/templates/component/payment/google-pay-processor.phtml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,25 @@ use Magento\Framework\Escaper;
1212
<div wire:ignore>
1313
<script>
1414
(() => {
15-
window.addEventListener('checkout:payment:method-activate', event => {
15+
window.addEventListener('checkout:payment:method-activate', async event => {
1616
if (event.detail.method !== 'rvvup_GOOGLE_PAY') {
1717
return;
1818
}
1919

20-
const component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
20+
/*
21+
This code finds the magewire component, but the workaround is required because the component may not be
22+
immediately available when the script is executed. This is related to an issue in Hyva Checkout 1.3.0 or
23+
later. This is currently the suggested workaround provided by Hyva:
24+
https://gitlab.hyva.io/hyva-checkout/checkout/-/issues/418
25+
*/
26+
let component;
27+
try {
28+
component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
29+
} catch (error) {
30+
await Livewire.onLoad(() => {
31+
component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
32+
});
33+
}
2134
hyvaCheckout.payment.activate('rvvup_GOOGLE_PAY', {
2235
placeOrderViaJs() {
2336
return document.querySelector('[wire\\:key="rvvup_GOOGLE_PAY"].active') !== null;

src/view/frontend/templates/component/payment/klarna-processor.phtml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,25 @@ use Magento\Framework\Escaper;
1212
<div wire:ignore>
1313
<script>
1414
(() => {
15-
window.addEventListener('checkout:payment:method-activate', event => {
15+
window.addEventListener('checkout:payment:method-activate', async event => {
1616
if (event.detail.method !== 'rvvup_KLARNA') {
1717
return;
1818
}
1919

20-
const component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
20+
/*
21+
This code finds the magewire component, but the workaround is required because the component may not be
22+
immediately available when the script is executed. This is related to an issue in Hyva Checkout 1.3.0 or
23+
later. This is currently the suggested workaround provided by Hyva:
24+
https://gitlab.hyva.io/hyva-checkout/checkout/-/issues/418
25+
*/
26+
let component;
27+
try {
28+
component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
29+
} catch (error) {
30+
await Livewire.onLoad(() => {
31+
component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
32+
});
33+
}
2134
hyvaCheckout.payment.activate('rvvup_KLARNA', {
2235
placeOrderViaJs() {
2336
return document.querySelector('[wire\\:key="rvvup_KLARNA"].active') !== null;

src/view/frontend/templates/component/payment/yapily-processor.phtml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,25 @@ use Magento\Framework\Escaper;
1212
<div wire:ignore>
1313
<script>
1414
(() => {
15-
window.addEventListener('checkout:payment:method-activate', event => {
15+
window.addEventListener('checkout:payment:method-activate', async event => {
1616
if (event.detail.method !== 'rvvup_YAPILY') {
1717
return;
1818
}
1919

20-
const component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
20+
/*
21+
This code finds the magewire component, but the workaround is required because the component may not be
22+
immediately available when the script is executed. This is related to an issue in Hyva Checkout 1.3.0 or
23+
later. This is currently the suggested workaround provided by Hyva:
24+
https://gitlab.hyva.io/hyva-checkout/checkout/-/issues/418
25+
*/
26+
let component;
27+
try {
28+
component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
29+
} catch (error) {
30+
await Livewire.onLoad(() => {
31+
component = Magewire.find('<?= $escaper->escapeJs($block->getNameInLayout()) ?>');
32+
});
33+
}
2134
hyvaCheckout.payment.activate('rvvup_YAPILY', {
2235
placeOrderViaJs() {
2336
return document.querySelector('[wire\\:key="rvvup_YAPILY"].active') !== null;

0 commit comments

Comments
 (0)