Commit 5e9598fd authored by attilak's avatar attilak

Fix loggedIn user retrieving payment methods

parent 0cfc5323
...@@ -27,14 +27,16 @@ define( ...@@ -27,14 +27,16 @@ define(
'Magento_Checkout/js/model/payment/renderer-list', 'Magento_Checkout/js/model/payment/renderer-list',
'Adyen_Payment/js/model/adyen-payment-service', 'Adyen_Payment/js/model/adyen-payment-service',
'Adyen_Payment/js/model/adyen-configuration', 'Adyen_Payment/js/model/adyen-configuration',
'Magento_Checkout/js/model/quote' 'Magento_Checkout/js/model/quote',
'Magento_Customer/js/model/customer'
], ],
function ( function (
Component, Component,
rendererList, rendererList,
adyenPaymentService, adyenPaymentService,
adyenConfiguration, adyenConfiguration,
quote quote,
customer
) { ) {
'use strict'; 'use strict';
rendererList.push( rendererList.push(
...@@ -70,6 +72,8 @@ define( ...@@ -70,6 +72,8 @@ define(
/** Add view logic here if needed */ /** Add view logic here if needed */
return Component.extend({ return Component.extend({
initialize: function () { initialize: function () {
var self = this;
this._super(); this._super();
if (this.isGooglePayEnabled()) { if (this.isGooglePayEnabled()) {
...@@ -79,7 +83,15 @@ define( ...@@ -79,7 +83,15 @@ define(
document.head.appendChild(googlepayscript); document.head.appendChild(googlepayscript);
} }
if (customer.isLoggedIn()) {
self.setAdyenPaymentMethods();
}
quote.shippingAddress.subscribe(function() { quote.shippingAddress.subscribe(function() {
self.setAdyenPaymentMethods();
})
},
setAdyenPaymentMethods: function() {
adyenPaymentService.retrieveAvailablePaymentMethods().done(function (response) { adyenPaymentService.retrieveAvailablePaymentMethods().done(function (response) {
var responseJson = JSON.parse(response); var responseJson = JSON.parse(response);
var paymentMethodsResponse = responseJson.paymentMethodsResponse; var paymentMethodsResponse = responseJson.paymentMethodsResponse;
...@@ -113,7 +125,6 @@ define( ...@@ -113,7 +125,6 @@ define(
adyenConfiguration.getCheckoutEnvironment() adyenConfiguration.getCheckoutEnvironment()
); );
}) })
})
}, },
isGooglePayEnabled: function() { isGooglePayEnabled: function() {
return window.checkoutConfig.payment.adyenGooglePay.active; return window.checkoutConfig.payment.adyenGooglePay.active;
......
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