Skip to content

Commit

Permalink
Merge pull request #1159 from buckaroo-it/BP-4146-Don-t-require-CSP-i…
Browse files Browse the repository at this point in the history
…f-it-is-disabled

BP-4146-Don-t-require-CSP-if-it-is-disabled
  • Loading branch information
vegimcarkaxhija authored Jan 30, 2025
2 parents 10cef65 + 038b610 commit cd381e7
Show file tree
Hide file tree
Showing 18 changed files with 149 additions and 301 deletions.
10 changes: 0 additions & 10 deletions Block/Cart/BuckarooConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,4 @@ public function getBuckarooConfigJson()
$configProvider = $this->configProviderFactory->get('buckaroo_fee');
return $this->jsonEncoder->serialize($configProvider->getConfig());
}

/**
* Get CSP nonce
*
* @return string
*/
public function getCspNonce()
{
return $this->getData('cspNonce') ?: '';
}
}
10 changes: 0 additions & 10 deletions Block/Checkout/Success.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,4 @@ public function __construct(
);
$this->currentCustomer = $currentCustomer;
}

/**
* Get CSP nonce
*
* @return string
*/
public function getCspNonce()
{
return $this->getData('cspNonce') ?: '';
}
}
63 changes: 0 additions & 63 deletions Factory/CspNonceProviderFactory.php

This file was deleted.

63 changes: 0 additions & 63 deletions Helper/CustomCspNonceProvider.php

This file was deleted.

46 changes: 0 additions & 46 deletions Observer/AddCspNonce.php

This file was deleted.

26 changes: 0 additions & 26 deletions etc/frontend/events.xml

This file was deleted.

4 changes: 2 additions & 2 deletions view/frontend/templates/cart/buckaroo_config.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
* @license https://tldrlegal.com/license/mit-license
*/

/** @var string $cspNonce */
/** @var string $block */
?>
<div id="buckaroo-fee-cart" data-bind="scope:'buckarooFeeCart'">
<!-- ko template: getTemplate() --><!-- /ko -->
<script nonce="<?= $block->getCspNonce() ?>">
<script>
window.buckarooConfig = <?= /* @noEscape */ $block->getBuckarooConfigJson(); ?>;
</script>
</div>
6 changes: 3 additions & 3 deletions view/frontend/templates/catalog/product/view/applepay.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
* @license https://tldrlegal.com/license/mit-license
*/

/** @var string $cspNonce */
/** @var string $block */
?>
<?php if ($block->canShowButton('Product')): ?>
<div id="apple-pay-catalog-product-view-component" data-bind="scope:'applepayproductcomponent'">
<div id="apple-pay-catalog-product-view-component" data-bind="scope:'applepayproductcomponent'">
<!-- ko template: getTemplate() --><!-- /ko -->

<script nonce="<?= $cspNonce ?>">
<script>
if ('undefined' === typeof window.checkoutConfig) {
window.checkoutConfig = <?= /* @noEscape */ ($block->getApplepayConfig()); ?>;
window.isCustomerLoggedIn = window.checkoutConfig.isCustomerLoggedIn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* @license https://tldrlegal.com/license/mit-license
*/

/** @var string $block */

if ($block->canShowButton('Product')): ?>

<div id="fast-checkout-ideal-btn-component" data-bind="scope: 'fastCheckoutIdeal'">
Expand Down
3 changes: 2 additions & 1 deletion view/frontend/templates/catalog/product/view/idin.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/
/** @var string $block */
?>
<?php if ($block->canShowProductIdin()): ?>
<div id="buckaroo_idin_product" style="background: #d4eded; padding: 10px; display: inline-block; width: 100%; ">
Expand All @@ -25,4 +26,4 @@
<span data-bind="i18n: 'You must be 18 or older to pay for the products below'"
style="height: 50px; display: block; float: left; line-height: 50px; margin-left: 11px; "></span>
</div>
<?php endif; ?>
<?php endif; ?>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/
/** @var string $block */
?>
<?php if ($block->canShowButton('Product')): ?>
<div id="paypal-express-button-component" data-bind="scope:'paypalExpress'">
Expand All @@ -30,7 +31,10 @@
"paypalExpress": {
"component":"buckaroo/paypal-express/button",
"template":"Buckaroo_Magento2/catalog/product/view/paypal-express",
"data": <?= /* @noEscape */ json_encode($block->getConfig()); ?>
"config": {
"data": <?= /* @noEscape */ json_encode($block->getConfig()); ?>,
"page": "product"
}
}
}
}
Expand Down
40 changes: 23 additions & 17 deletions view/frontend/templates/checkout/cart/applepay.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,31 @@
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/
/** @var string $block */
?>
<?php if ($block->canShowButton('Cart')): ?>
<div class="box-tocart">
<div class="fieldset">
<div class="actions">
<div id="apple-pay-wrapper" data-bind="afterRender: showPayButton"></div>
</div>
</div>
<div id="apple-pay-catalog-cart-view-component" data-bind="scope:'buckarooApplepayCart'">
<!-- ko template: getTemplate() --><!-- /ko -->
<script>
if ('undefined' === typeof window.checkoutConfig) {
window.checkoutConfig = <?= /* @noEscape */ $block->getCheckoutConfig(); ?>;
window.isCustomerLoggedIn = window.checkoutConfig.isCustomerLoggedIn;
}
</script>

<script type="text/x-magento-init">
{
"[data-bind='scope:buckarooApplepayCart']": {
"Magento_Ui/js/core/app": {
"components": {
"buckarooApplepayCart": {
"component": "buckaroo/applepay/checkout-cart"
}
}
}
}
}
</script>
</div>

<script>
if ('undefined' === typeof window.checkoutConfig) {
window.checkoutConfig = <?= /* @noEscape */ $block->getCheckoutConfig(); ?>;
window.isCustomerLoggedIn = window.checkoutConfig.isCustomerLoggedIn;
}
showPayButton = function() {
require(['jquery', 'buckaroo/applepay/checkout-cart'], function (jQuery, applepayPay) {
applepayPay.showPayButton('cart');
});
}
</script>
<?php endif; ?>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/
/** @var string $block */

if ($block->canShowButton('Cart')): ?>

Expand Down
Loading

0 comments on commit cd381e7

Please sign in to comment.