We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit 55431848 authored by Rik ter Beek's avatar Rik ter Beek Committed by Alexandros Moraitis

Feature/update version applepay (#509)

* Update applepay version

* Working on applepay check

* Add check for applePay version
parent 03db9708
......@@ -24,6 +24,7 @@
define(
[
'jquery',
'ko',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/view/payment/default',
'Magento_Checkout/js/action/place-order',
......@@ -34,8 +35,10 @@ define(
'Magento_Ui/js/model/messages',
'mage/translate',
],
function ($, quote, Component, placeOrderAction, additionalValidators, urlBuilder, storage, url, Messages, $t) {
function ($, ko, quote, Component, placeOrderAction, additionalValidators, urlBuilder, storage, url, Messages, $t) {
'use strict';
var canMakeApplePayPayments = ko.observable(false);
var applePayVersion = 6;
return Component.extend({
self: this,
defaults: {
......@@ -78,11 +81,12 @@ define(
var request = {
countryCode: quote.billingAddress().countryId,
currencyCode: quote.totals().quote_currency_code,
supportedNetworks: ['visa', 'masterCard', 'amex', 'discover'],
supportedNetworks: ['visa', 'masterCard', 'amex', 'discover', 'maestro', 'vPay', 'jcb', 'elo'],
merchantCapabilities: ['supports3DS'],
total: {label: $t('Grand Total'), amount: quote.totals().base_grand_total}
};
var session = new ApplePaySession(2, request);
var session = new ApplePaySession(applePayVersion, request);
session.onvalidatemerchant = function (event) {
var promise = self.performValidation(event.validationURL);
promise.then(function (merchantSession) {
......@@ -139,7 +143,16 @@ define(
return window.checkoutConfig.payment.adyen.showLogo;
},
isApplePayAllowed: function () {
if (window.ApplePaySession) {
var self = this;
// validate if applepay is allowed, it will be picked up by the isApplePayVisible method
var promise = window.ApplePaySession.canMakePaymentsWithActiveCard(self.getMerchantIdentifier());
promise.then(function (canMakePayments) {
if (canMakePayments)
canMakeApplePayPayments(true);
});
if (window.ApplePaySession && window.ApplePaySession.supportsVersion(applePayVersion) ) {
return true;
}
return false;
......@@ -177,6 +190,12 @@ define(
deferred.resolve(true);
}
);
},
isApplePayVisible: function() {
return canMakeApplePayPayments();
},
getMerchantIdentifier: function() {
return window.checkoutConfig.payment.adyen_apple_pay.merchant_identifier;
}
});
}
......
......@@ -22,7 +22,7 @@
*/
-->
<!-- ko if: isApplePayAllowed() -->
<div class="payment-method" data-bind="css: {'_active': (getCode() == isChecked())}">
<div class="payment-method" data-bind="css: {'_active': (getCode() == isChecked())}, visible: isApplePayVisible()">
<div class="payment-method-title field choice">
<input type="radio"
name="payment[method]"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment