-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed an issue where changing the delivery status would cause an exce…
…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
Showing
6 changed files
with
59 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Resources/app/storefront/dist/storefront/js/mollie-payments.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-payment-method.plugin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.