From 6962ebf50669841e65f87a368ff7d6cac55d9cba Mon Sep 17 00:00:00 2001 From: Spencer Gabhart Date: Thu, 5 May 2022 11:06:42 -0400 Subject: [PATCH] Correct config retrieval for Amazon Sign In --- Controller/Checkout/Config.php | 2 +- Model/CheckoutSessionManagement.php | 2 +- view/frontend/web/js/action/checkout-session-config-load.js | 4 ++-- view/frontend/web/js/amazon-login-button.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Controller/Checkout/Config.php b/Controller/Checkout/Config.php index 429e09f63..fc6294b14 100644 --- a/Controller/Checkout/Config.php +++ b/Controller/Checkout/Config.php @@ -46,7 +46,7 @@ public function __construct( */ public function execute() { - $omitPayloads = isset($this->getRequest()->getParams()['omit_payloads']); + $omitPayloads = filter_var($this->getRequest()->getParams()['omit_payloads'], FILTER_VALIDATE_BOOLEAN); $data = $this->amazonCheckoutSession->getConfig($omitPayloads); return $this->resultJsonFactory->create()->setData($data); } diff --git a/Model/CheckoutSessionManagement.php b/Model/CheckoutSessionManagement.php index 49de814f0..005d9646d 100755 --- a/Model/CheckoutSessionManagement.php +++ b/Model/CheckoutSessionManagement.php @@ -413,7 +413,7 @@ protected function convertToMagentoAddress(array $address, $isShippingAddress = /** * {@inheritdoc} */ - public function getConfig($cartId = null, $omitPayloads = false) + public function getConfig($cartId = null, $omitPayloads = true) { $result = []; $quote = $this->session->getQuoteFromIdOrSession($cartId); diff --git a/view/frontend/web/js/action/checkout-session-config-load.js b/view/frontend/web/js/action/checkout-session-config-load.js index 6510ae6b8..2561af371 100644 --- a/view/frontend/web/js/action/checkout-session-config-load.js +++ b/view/frontend/web/js/action/checkout-session-config-load.js @@ -29,11 +29,11 @@ define([ } return localStorage; }; - return function (callback) { + return function (callback, omitPayloads = true) { var cartId = customerData.get('cart')()['data_id'] || window.checkout.storeId; var config = getLocalStorage().get('config') || false; if (!config) { - remoteStorage.get(url.build('amazon_pay/checkout/config?omit_payloads=true')).done(function (config) { + remoteStorage.get(url.build(`amazon_pay/checkout/config?omit_payloads=${omitPayloads}`)).done(function (config) { getLocalStorage().set('cart_id', cartId); getLocalStorage().set('config', config); diff --git a/view/frontend/web/js/amazon-login-button.js b/view/frontend/web/js/amazon-login-button.js index 8025bfceb..3ce150611 100755 --- a/view/frontend/web/js/amazon-login-button.js +++ b/view/frontend/web/js/amazon-login-button.js @@ -46,7 +46,7 @@ define([ publicKeyId: checkoutSessionConfig['public_key_id'] } }); - }.bind(this)); + }.bind(this), false); }, /**