Skip to content

Commit

Permalink
Fixed an issue where changing the delivery status would cause an exce…
Browse files Browse the repository at this point in the history
…ption. Fixed an issue where Apple Pay would show up on not-supported devices.
  • Loading branch information
Reinder committed Jun 25, 2020
1 parent f1d40ce commit 984486f
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 14 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "kiener/mollie-payments-plugin",
"description": "Mollie Payments",
"version": "v1.0.14",
"version": "v1.0.15",
"type": "shopware-platform-plugin",
"license": "MIT",
"authors": [
Expand Down
2 changes: 1 addition & 1 deletion src/Factory/MollieApiFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function getClient(?string $salesChannelId = null, ?Context $context = nu

// @todo Add plugin version variable
$this->apiClient->addVersionString(
'MollieShopware6/1.0.14'
'MollieShopware6/1.0.15'
);
} catch (Exception $e) {
$this->logger->error($e->getMessage(), [$e]);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/Resources/app/storefront/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import MollieCreditCardComponents
import MollieIDealIssuer
from './mollie-payments/plugins/ideal-issuer.plugin';

import MollieApplePayPaymentMethod
from './mollie-payments/plugins/apple-pay-payment-method.plugin';

// Register them via the existing PluginManager
const PluginManager = window.PluginManager;
PluginManager.register('MollieCreditCardComponents', MollieCreditCardComponents);
PluginManager.register('MollieIDealIssuer', MollieIDealIssuer);
PluginManager.register('MollieIDealIssuer', MollieIDealIssuer);
PluginManager.register('MollieApplePayPaymentMethod', MollieApplePayPaymentMethod);
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import Plugin from 'src/plugin-system/plugin.class';

export default class MollieApplePayPaymentMethod extends Plugin {
getClosest(elem, selector) {
// Element.matches() polyfill
if (!Element.prototype.matches) {
Element.prototype.matches =
Element.prototype.matchesSelector ||
Element.prototype.mozMatchesSelector ||
Element.prototype.msMatchesSelector ||
Element.prototype.oMatchesSelector ||
Element.prototype.webkitMatchesSelector ||
function(s) {
let matches = (this.document || this.ownerDocument).querySelectorAll(s), i = matches.length;
// eslint-disable-next-line no-empty
while (--i >= 0 && matches.item(i) !== this) {}
return i > -1;
};
}

// Get the closest matching element
for (; elem && elem !== document; elem = elem.parentNode) {
if (elem.matches(selector)) {
return elem;
}
}

return null;
}

init() {
const element = document.querySelector('.payment-method-input.applepay');
const rootElement = this.getClosest(element, '.payment-method');

if (
!!rootElement
&& !!rootElement.classList
) {
// eslint-disable-next-line no-undef
if (!window.ApplePaySession || !window.ApplePaySession.canMakePayments()) {
rootElement.classList.add('d-none');
}
}
}
}
Loading

0 comments on commit 984486f

Please sign in to comment.