Commit 5e9598fd authored by attilak's avatar attilak

Fix loggedIn user retrieving payment methods

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