Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spc merge v5.17.0 #1233

Open
wants to merge 52 commits into
base: spc
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
1e019dc
ASD-1123 - Center PDP button on mobile views
sgabhart22 Jul 27, 2023
8827186
ASD-1112 moves order placement to before redirect to ap WIP
dallin-beargroup Sep 7, 2023
d18afe6
ASD-1112 fixes bugs for express checkout after ap redirect
dallin-beargroup Sep 7, 2023
470d3f9
ASD-1112 places order for APB flow
dallin-beargroup Sep 13, 2023
60eaa3f
Merge branch 'master' into ASD-1112
dallin-beargroup Sep 20, 2023
cab93b1
ASD-1112 updates place order controller to use app interface
dallin-beargroup Sep 21, 2023
24638b7
ASD-1112 improves error handling around order placement call
dallin-beargroup Sep 21, 2023
29ad5c4
ASD-1112 injects missing request interface
dallin-beargroup Sep 21, 2023
4520bbd
ASD-1112 minor logging updates and bug fixes
dallin-beargroup Sep 21, 2023
f9496e1
ASD-1112 minor fixes and updates
dallin-beargroup Sep 25, 2023
11c30ee
ASD-1112 quoteId log bug
dallin-beargroup Sep 28, 2023
30442ef
ASD-1112b refactors complete checkout session method
dallin-beargroup Sep 29, 2023
69f0499
ASD-1112b fixes typos and keys
dallin-beargroup Sep 29, 2023
f6df1ed
ASD-1112 fixes error handling bugs
dallin-beargroup Sep 29, 2023
1bfb56b
ASD-1112 fixes place order failure return bug
dallin-beargroup Oct 3, 2023
6dc0f65
ASD-1112 adjusts var init and updates spacing
dallin-beargroup Oct 4, 2023
f7e4726
ASD-1152: Added CheckoutSessionDetailsV2 resolver for GraphQl.
lcouget Oct 26, 2023
9d9a0cf
ASD-1152: fixed schema type.
lcouget Oct 27, 2023
0f2bec1
ASD-1152: checkoutSessionDetailsV2 schema updated.
lcouget Oct 31, 2023
12be79f
Merge remote-tracking branch 'origin/master' into ASD-1112
jaybeckr Nov 1, 2023
bcabd72
ASD-1152: ChackoutSessionDetails output schema updated.
lcouget Nov 1, 2023
3a175b3
ASD-1112 phpcs updates
dallin-beargroup Nov 3, 2023
c5a5712
ASD-1112_mftf restores error message call for mftf
dallin-beargroup Nov 6, 2023
c6af1c6
ASD-1112_mftf phpcs fixes
dallin-beargroup Nov 6, 2023
9376754
Fix setup:upgrade error when using prefixed tables
SamJUK Jun 28, 2023
40c1f45
Merge branch 'bg-integration' into asd-1162
sgabhart22 Nov 6, 2023
b1aeb38
ASD-1157 refactors init iosc
dallin-beargroup Nov 10, 2023
085a98b
ASD-1157 removes <a> wrapper in favor of decoupled AP button
dallin-beargroup Nov 11, 2023
30ee52e
ASD-1157 renames apb detection method, updates comment
dallin-beargroup Nov 13, 2023
fc9f4da
ASD-1112 adds restore quote calls, fixes error messages
dallin-beargroup Nov 15, 2023
70d5c7c
Merge branch 'asd-1162' into integration
sgabhart22 Nov 27, 2023
8a62896
Merge branch 'ASD-1152' into integration
sgabhart22 Nov 27, 2023
51a49ea
#1191 use session from usercontext instead of empty one
bheindl May 23, 2023
4d50862
Add amazon_payment_region graphQl option
dimitriBouteille Oct 28, 2023
48e5bea
Merge branch 'ASD-1157' into integration
dallin-beargroup Dec 8, 2023
e9449e3
ASD-1152 fixes phpcs warnings
dallin-beargroup Dec 8, 2023
053df2d
Merge branch 'ASD-1152' into integration
dallin-beargroup Dec 8, 2023
e237275
Merge branch 'asd-1123' into integration
sgabhart22 Dec 8, 2023
404da00
asd-1104 adds upgrade check for existing CV2 to prevent overwrite
dallin-beargroup Jul 18, 2023
2deecba
Version bump to 5.17.0 and update changelog
sgabhart22 Dec 8, 2023
b3aee7d
Revert "Merge branch 'ASD-1152' into integration"
sgabhart22 Mar 19, 2024
821665a
Fixes phpcs errors
dallin-beargroup Jan 19, 2024
260146c
ASD-1177 - Fixes handling of Auto Key Exchange payload type
sgabhart22 Mar 19, 2024
eb53cab
ASD-1187 adds controller to handle cancel scenarios
jajajaime Mar 22, 2024
2568e19
ASD-1187 removes unnecessary comments
jajajaime Mar 22, 2024
c06790c
Update spacing for phpcs
jaybeckr Mar 19, 2024
e586ce0
Merge remote-tracking branch 'origin/ASD-1187' into release/5.17.0
jaybeckr Mar 25, 2024
18e06b7
Codesniff changes
jaybeckr Mar 25, 2024
026f2c2
ASD-1047 - updates to mftf, scrolling to buttons and waiting before c…
jaybeckr Mar 25, 2024
690bee9
Apply ASD-1180 patch
sgabhart22 Apr 8, 2024
c0ab4af
Remove unused members, whitespace cleanup
sgabhart22 Apr 9, 2024
1f69c01
Merge branch 'release/5.17.0' into spc
sgabhart22 Apr 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Change Log

## 5.17.0
* Changed sequence of placing Magento order/processing Amazon payment to reduce likelihood of
transactions with no associated order IDs in Seller Central
* Fixed KeyUpgrade patch error when the database tables are prefixed
* Fixed overwriting of existent CV2 configs on KeyUpgrade
* Improved behavior of PDP button (ensure product is added to cart before initiating Amazon checkout)
* Fixed unresponsive PDP button on Safari mobile
* Fixed non-centered PDP button on mobile view
* Fixed incorrect type casting when decrypting Auto Key Exchange payloads
* Fixed updateCheckoutSession call in headless environments when the session helper returns
a new/empty quote (thanks, @bheindl!)
* Changed response format of checkout session details GraphQL query to adhere to best practices
(thanks, @dimitriBouteille!)
* Added Amazon Pay payment region to storeConfig GraphQL query (thanks again, @dimitriBouteiile!)

## 5.16.1
* Remove platform/module version information from button payloads
* Fixed admin display bug regarding upgrading legacy keys when a CV2 public key ID already exists
Expand Down
2 changes: 2 additions & 0 deletions Command/Async/ProcessCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
/** @var \Amazon\Pay\Model\Async $item */
$this->asyncUpdater->processPending($item);
}

return Command::SUCCESS;
}
}
2 changes: 2 additions & 0 deletions Command/Sales/AmazonChargePermissionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$verified = $referenceID == $orderId;
$output->writeln(var_export($verified));
}

return Command::SUCCESS;
}
}
105 changes: 105 additions & 0 deletions Controller/Checkout/Cancel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php

namespace Amazon\Pay\Controller\Checkout;

use Amazon\Pay\Model\CheckoutSessionManagement;
use Magento\Checkout\Model\Session;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Message\ManagerInterface;
use Magento\Sales\Model\Order;
use Amazon\Pay\Gateway\Config\Config;

class Cancel implements HttpGetActionInterface
{
/**
* @var RequestInterface
*/
protected $request;

/**
* @var ResultFactory
*/
protected $resultFactory;

/**
* @var Session
*/
protected $magentoCheckoutSession;

/**
* @var CheckoutSessionManagement
*/
protected $checkoutSessionManagement;

/**
* @var ManagerInterface
*/
protected $messageManager;

/**
* @param RequestInterface $request
* @param ResultFactory $resultFactory
* @param Session $magentoCheckoutSession
* @param CheckoutSessionManagement $checkoutSessionManagement
* @param ManagerInterface $messageManager
*/
public function __construct(
RequestInterface $request,
ResultFactory $resultFactory,
Session $magentoCheckoutSession,
CheckoutSessionManagement $checkoutSessionManagement,
ManagerInterface $messageManager
) {
$this->request = $request;
$this->resultFactory = $resultFactory;
$this->magentoCheckoutSession = $magentoCheckoutSession;
$this->checkoutSessionManagement = $checkoutSessionManagement;
$this->messageManager = $messageManager;
}

/**
* Handle cancelling Amazon Pay orders when necessary
*
* @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface
* @throws \Magento\Framework\Exception\LocalizedException
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function execute()
{
$redirectParam = $this->request->getParam('redirect');
$result = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);

// redirect to cart if no redirect param provided
if (empty($redirectParam)) {
return $result->setPath('checkout/cart');
}

// check if there is an order still in the session, then and cancel it
if ($order = $this->magentoCheckoutSession->getLastRealOrder()) {
if (!empty($order->getData())
&& $order->getState() !== Order::STATE_CANCELED
&& $order->getPayment()
&& (
$order->getPayment()->getMethod() === Config::CODE ||
$order->getPayment()->getMethod() === Config::VAULT_CODE
)
) {
$quote = $this->magentoCheckoutSession->getQuote();

if (!$quote->getIsActive()) {
$this->checkoutSessionManagement->cancelOrder($order, $quote);

$this->magentoCheckoutSession->restoreQuote();

$this->messageManager->addErrorMessage(__('This transaction was cancelled. Please try again.'));
}
}
}

$result = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);

return $result->setUrl(base64_decode($redirectParam)); // phpcs:ignore Magento2.Functions.DiscouragedFunction
}
}
12 changes: 3 additions & 9 deletions Controller/Checkout/CompleteSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@

class CompleteSession extends \Magento\Framework\App\Action\Action
{
/**
* @var \Amazon\Pay\CustomerData\CheckoutSession
*/
private $amazonCheckoutSession;
protected const GENERIC_COMPLETE_CHECKOUT_ERROR_MESSAGE = 'Unable to complete Amazon Pay checkout.';

/**
* @var \Amazon\Pay\Model\CheckoutSessionManagement
Expand Down Expand Up @@ -58,10 +55,9 @@ class CompleteSession extends \Magento\Framework\App\Action\Action
private $cookieMetadataFactory;

/**
* CompleteCheckout constructor.
* CompleteSession constructor
*
* @param \Magento\Framework\App\Action\Context $context
* @param \Amazon\Pay\CustomerData\CheckoutSession $amazonCheckoutSession
* @param \Amazon\Pay\Model\CheckoutSessionManagement $checkoutSessionManagement
* @param \Amazon\Pay\Model\AmazonConfig $amazonConfig
* @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
Expand All @@ -71,7 +67,6 @@ class CompleteSession extends \Magento\Framework\App\Action\Action
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Amazon\Pay\CustomerData\CheckoutSession $amazonCheckoutSession,
\Amazon\Pay\Model\CheckoutSessionManagement $checkoutSessionManagement,
\Amazon\Pay\Model\AmazonConfig $amazonConfig,
\Magento\Framework\Stdlib\CookieManagerInterface $cookieManager,
Expand All @@ -80,7 +75,6 @@ public function __construct(
ExceptionLogger $exceptionLogger = null
) {
parent::__construct($context);
$this->amazonCheckoutSession = $amazonCheckoutSession;
$this->amazonCheckoutSessionManagement = $checkoutSessionManagement;
$this->amazonConfig = $amazonConfig;
$this->exceptionLogger = $exceptionLogger ?: ObjectManager::getInstance()->get(ExceptionLogger::class);
Expand Down Expand Up @@ -115,7 +109,7 @@ public function execute()
]);
} catch (\Exception $e) {
$this->exceptionLogger->logException($e);
$this->messageManager->addErrorMessage($e->getMessage());
$this->messageManager->addErrorMessage(self::GENERIC_COMPLETE_CHECKOUT_ERROR_MESSAGE);
}

return $this->_redirect('checkout/cart', [
Expand Down
100 changes: 100 additions & 0 deletions Controller/Checkout/PlaceOrder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php
/**
* Copyright © Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
namespace Amazon\Pay\Controller\Checkout;

use Amazon\Pay\Model\CheckoutSessionManagement;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\App\ObjectManager;
use Amazon\Pay\Logger\ExceptionLogger;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Framework\Message\ManagerInterface;

class PlaceOrder implements HttpPostActionInterface
{
/**
* @var CheckoutSessionManagement
*/
private $amazonCheckoutSessionManagement;

/**
* @var JsonFactory
*/
private $jsonFactory;

/**
* @var ManagerInterface
*/
protected $messageManager;

/**
* @var ExceptionLogger
*/
private $exceptionLogger;

/**
* @var RequestInterface
*/
protected $request;

/**
* PlaceOrder constructor.
*
* @param CheckoutSessionManagement $checkoutSessionManagement
* @param JsonFactory $jsonFactory
* @param ManagerInterface $messageManager
* @param RequestInterface $request
* @param ExceptionLogger|null $exceptionLogger
*/
public function __construct(
CheckoutSessionManagement $checkoutSessionManagement,
JsonFactory $jsonFactory,
ManagerInterface $messageManager,
RequestInterface $request,
ExceptionLogger $exceptionLogger = null
) {
$this->amazonCheckoutSessionManagement = $checkoutSessionManagement;
$this->exceptionLogger = $exceptionLogger ?: ObjectManager::getInstance()->get(ExceptionLogger::class);
$this->messageManager = $messageManager;
$this->request = $request;
$this->jsonFactory = $jsonFactory;
}

/**
* Execute PlaceOrder Controller
*
* @inheirtdoc
*/
public function execute()
{
$result = ['success' => false];
try {
// Bypass cache check in \Magento\PageCache\Model\DepersonalizeChecker
$this->request->setParams(['ajax' => 1]);
$amazonCheckoutSessionId = $this->request->getParam('amazonCheckoutSessionId');

$result = $this->amazonCheckoutSessionManagement->placeOrder($amazonCheckoutSessionId);
if (!$result['success']) {
$this->messageManager->addErrorMessage($result['message']);
}
} catch (\Exception $e) {
$this->exceptionLogger->logException($e);
$this->messageManager->addErrorMessage($e->getMessage());
}
$jsonResult = $this->jsonFactory->create();
return $jsonResult->setData($result);
}
}
2 changes: 1 addition & 1 deletion Helper/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public function getQuoteFromIdOrSession($cartId = null)
// we only really want to utilize masked ids here unless retrieved elsewhere
if (empty($cartId) || is_numeric($cartId)) {
$quote = $this->getQuote();
if (!$quote) {
if (!$quote || !$quote->getId()) {
// here we'll check the user context for any available cart data before moving on
$userContextCartId = $this->getCartIdViaUserContext();
if ($userContextCartId !== null) {
Expand Down
10 changes: 8 additions & 2 deletions Model/Adapter/AmazonPayAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -772,11 +772,17 @@ public function signButton($payload, $storeId = null)
protected function getCheckoutCancelUrl()
{
$checkoutCancelUrl = $this->amazonConfig->getCheckoutCancelUrl();

if (empty($checkoutCancelUrl)) {
return $this->getDefaultCancelUrl();
$cancelUrl = $this->getDefaultCancelUrl();
} else {
$cancelUrl = $this->url->getUrl($checkoutCancelUrl);
}

return $this->url->getUrl($checkoutCancelUrl);
return $this->url->getUrl(
'amazon_pay/checkout/cancel',
['redirect' => base64_encode($cancelUrl)]
);
}

/**
Expand Down