Skip to content

Commit 681fde9

Browse files
Hyva Checkout 1.3.0+ Compatibility (CSP Support) (#174)
* Additional constraints required as part of 1.3.0> Hyva Checkout * Make module compatible with Hyva and Alpine CSP * Update E2E workflow to support Hyva's latest version requirements * Fixes@
1 parent 57991d4 commit 681fde9

23 files changed

+70
-22
lines changed

.github/workflows/e2e.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
include:
21-
- MAGENTO_VERSION: 2.4.5
22-
HYVA_CHECKOUT_VERSION: 1.1.29
23-
- MAGENTO_VERSION: 2.4.6
24-
HYVA_CHECKOUT_VERSION: 1.1.29
2521
- MAGENTO_VERSION: 2.4.7
2622
HYVA_CHECKOUT_VERSION: 1.1.29
2723
- MAGENTO_VERSION: 2.4.7
2824
HYVA_CHECKOUT_VERSION: 1.2.0
25+
- MAGENTO_VERSION: 2.4.7
26+
HYVA_CHECKOUT_VERSION: ^1.3.0
2927

3028
env:
3129
MAGENTO_VERSION: ${{ matrix.MAGENTO_VERSION }}

Test/End-2-End/Pages/VisitCheckoutPayment.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {expect} from "@playwright/test";
1+
import { expect } from "@playwright/test";
22
import Cart from "../Components/Cart";
3-
import {v7 as uuidv7} from 'uuid';
3+
import { v7 as uuidv7 } from "uuid";
44

55
export default class VisitCheckoutPayment {
66
constructor(page) {
@@ -14,7 +14,7 @@ export default class VisitCheckoutPayment {
1414

1515
await this.page
1616
.getByLabel("Email address", { exact: true })
17-
.fill(uuidv7() + "@example.com");
17+
.fill(uuidv7() + "@example.com");
1818
await this.page.getByLabel("First name").fill("John");
1919
await this.page.getByLabel("Last name").fill("Doe");
2020
await this.page.getByLabel("Street address").fill("123 Main St");

Test/End-2-End/clearpay.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {expect, test} from "@playwright/test";
1+
import { expect, test } from "@playwright/test";
22
import VisitCheckoutPayment from "./Pages/VisitCheckoutPayment";
33
import Cart from "./Components/Cart";
4-
import {v7 as uuidv7} from 'uuid';
4+
import { v7 as uuidv7 } from "uuid";
55
// This test is quite far, but the Clearpay modal is quite a bit flakey. It sometimes works, sometimes doesn't.
66
test.skip("Can place an order", async ({ page, browser }) => {
77
const visitCheckoutPayment = new VisitCheckoutPayment(page);
@@ -23,7 +23,7 @@ test.skip("Can place an order", async ({ page, browser }) => {
2323

2424
await frame
2525
.getByLabel("Email or mobile number")
26-
.fill(uuidv7() + "@example.com");
26+
.fill(uuidv7() + "@example.com");
2727
await frame.getByRole("button", { name: "Continue" }).click();
2828

2929
await frame

Test/End-2-End/pay_by_bank.spec.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ test("Can place an order using pay by bank", async ({ page, browser }) => {
3131
);
3232
});
3333

34-
35-
test("Prevent close is handled on bank selection screen and can only be closed by pressing 'x'", async ({page}) => {
34+
test("Prevent close is handled on bank selection screen and can only be closed by pressing 'x'", async ({
35+
page,
36+
}) => {
3637
const visitCheckoutPayment = new VisitCheckoutPayment(page);
3738
await visitCheckoutPayment.visit();
3839

@@ -41,7 +42,7 @@ test("Prevent close is handled on bank selection screen and can only be closed b
4142
* failure to open popup modal
4243
*/
4344
await page.waitForTimeout(3000);
44-
await page.getByRole("button", {name: "Place order"}).click();
45+
await page.getByRole("button", { name: "Place order" }).click();
4546

4647
const frame = page.frameLocator("iframe.rvvup-modal");
4748
await expect(frame.getByLabel("Mock Bank")).toBeVisible();

Test/End-2-End/paypal.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ test("Can place an order from the product page using PayPal", async ({
7171
"You are currently paying with PayPal. If you want to cancel this process",
7272
);
7373

74-
const children = await page.$$("#payment-methods ol > li, #payment-method-list > div");
74+
const children = await page.$$(
75+
"#payment-methods ol > li, #payment-method-list > div",
76+
);
7577
await expect(children.length).toBe(1);
7678

7779
await page.getByRole("button", { name: "Place order" }).click();

docker/scripts/configure-hyva.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ composer config repositories.hyva-themes/magento2-email-module git git@gitlab.hy
1111
composer config repositories.hyva-themes/magento2-default-theme git git@gitlab.hyva.io:hyva-themes/magento2-default-theme.git
1212
composer config repositories.hyva-themes/magento2-compat-module-fallback git git@gitlab.hyva.io:hyva-themes/magento2-compat-module-fallback.git
1313
composer config repositories.hyva-themes/magento2-order-cancellation-webapi git git@gitlab.hyva.io:hyva-themes/magento2-order-cancellation-webapi.git
14+
composer config repositories.hyva-themes/magento2-mollie-theme-bundle git git@gitlab.hyva.io:hyva-themes/hyva-compat/magento2-mollie-theme-bundle.git
1415
composer config repositories.hyva-themes/hyva-checkout git git@gitlab.hyva.io:hyva-checkout/checkout.git
1516
if [ "$HYVA_CHECKOUT_VERSION" == "latest" ] || [ -z "$HYVA_CHECKOUT_VERSION" ]; then
1617
composer require --prefer-source hyva-themes/magento2-default-theme hyva-themes/magento2-hyva-checkout

src/view/frontend/templates/cart/paypal.phtml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* @var \Magento\Framework\Escaper $escaper
44
* @var \Rvvup\PaymentsHyvaCheckout\Block\Paypal $block
55
* @var \Rvvup\Payments\ViewModel\PayPal $paypalViewModel
6+
* @var Hyva\Theme\ViewModel\HyvaCsp $hyvaCsp
67
*/
78
$paypalViewModel = $block->getData('rvvup_payments_paypal_view_model');
89

@@ -20,8 +21,8 @@ if ($paypalViewModel === null ||
2021
?>
2122

2223
<div class="rvvup-paypal-express grow z-0"
23-
x-data="rvvupPayPalExpressButton()"
24-
x-init="initRvvup()"
24+
x-data="rvvupPayPalExpressButton"
25+
x-init="initRvvup"
2526
wire:ignore>
2627
<div class="<?= $block->getNameInLayout() ?>-container"></div>
2728
</div>
@@ -181,4 +182,6 @@ if ($paypalViewModel === null ||
181182
},
182183
}
183184
}
185+
window.addEventListener('alpine:init', () => Alpine.data('rvvupPayPalExpressButton', rvvupPayPalExpressButton), {once: true});
184186
</script>
187+
<?php $hyvaCsp->registerInlineScript() ?>

src/view/frontend/templates/component/messaging/error.phtml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use Rvvup\PaymentsHyvaCheckout\Block\Checkout\Messaging;
77

88
/** @var Messaging $block */
99
/** @var Escaper $escaper */
10+
/** @var Hyva\Theme\ViewModel\HyvaCsp $hyvaCsp */
1011

1112
$error = $block->getRvvupError();
1213
?>
@@ -22,6 +23,7 @@ $error = $block->getRvvupError();
2223
]);
2324
});
2425
</script>
26+
<?php $hyvaCsp->registerInlineScript() ?>
2527
<?php endif; ?>
2628

2729
<script>
@@ -38,3 +40,4 @@ $error = $block->getRvvupError();
3840
}
3941
});
4042
</script>
43+
<?php $hyvaCsp->registerInlineScript() ?>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use Magento\Framework\View\Element\Template;
66

77
/** @var Template $block */
88
/** @var Escaper $escaper */
9+
/** @var Hyva\Theme\ViewModel\HyvaCsp $hyvaCsp */
910
?>
1011
<div wire:ignore>
1112
<style>
@@ -44,4 +45,5 @@ use Magento\Framework\View\Element\Template;
4445
}
4546
})();
4647
</script>
48+
<?php $hyvaCsp->registerInlineScript() ?>
4749
</div>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use Magento\Framework\View\Element\Template;
77
/** @var Template $block */
88
/** @var Escaper $escaper */
99
/** @var \Rvvup\PaymentsHyvaCheckout\Magewire\Checkout\Payment\ApplePayProcessor $magewire */
10+
/** @var Hyva\Theme\ViewModel\HyvaCsp $hyvaCsp */
1011
?>
1112
<div id="rvvup-apple-pay-inline" data-quoteamount="<?php echo $magewire->quoteAmount; ?>" data-quotecurrency="<?php echo $magewire->quoteCurrency; ?>">
1213
<style>
@@ -129,4 +130,5 @@ use Magento\Framework\View\Element\Template;
129130
});
130131
})();
131132
</script>
133+
<?php $hyvaCsp->registerInlineScript() ?>
132134
</div>

0 commit comments

Comments
 (0)