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

Asd 687 #3

Merged
merged 2 commits into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 11 additions & 31 deletions Api/CheckoutSessionManagementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,57 +21,37 @@
interface CheckoutSessionManagementInterface
{
/**
* @param mixed $cartId
* @return mixed
*/
public function getConfig($cartId);
public function getConfig();

/**
* @param mixed $cartId
* @param mixed $checkoutSessionId
* @param mixed $amazonSessionId
* @return mixed
*/
public function storeCheckoutSession($cartId, $checkoutSessionId);
public function getShippingAddress($amazonSessionId);

/**
* @param mixed $cartId
* @param mixed $amazonSessionId
* @return mixed
*/
public function getShippingAddress($cartId);
public function getBillingAddress($amazonSessionId);

/**
* @param mixed $cartId
* @return mixed
*/
public function getBillingAddress($cartId);

/**
* @param mixed $cartId
* @return string
*/
public function getPaymentDescriptor($cartId);

/**
* @param mixed $cartId
* @return void
*/
public function cancelCheckoutSession($cartId);

/**
* @param mixed $cartId
* @param mixed $amazonSessionId
* @return string
*/
public function getCheckoutSession($cartId);
public function getPaymentDescriptor($amazonSessionId);

/**
* @param mixed $cartId
* @param mixed $amazonSessionId
* @return string
*/
public function updateCheckoutSession($cartId);
public function updateCheckoutSession($amazonSessionId);

/**
* @param mixed $cartId
* @param mixed $amazonSessionId
* @return int
*/
public function completeCheckoutSession($cartId);
public function completeCheckoutSession($amazonSessionId);
}
35 changes: 0 additions & 35 deletions Api/CheckoutSessionRepositoryInterface.php

This file was deleted.

90 changes: 0 additions & 90 deletions Api/Data/CheckoutSessionInterface.php

This file was deleted.

12 changes: 9 additions & 3 deletions Controller/Checkout/CompleteSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class CompleteSession extends \Magento\Framework\App\Action\Action
*/
private $amazonCheckoutSession;

/**
* @var \Amazon\Pay\Model\CheckoutSessionManagement
*/
private $amazonCheckoutSessionManagement;

/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
Expand Down Expand Up @@ -59,13 +64,15 @@ 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,
\Magento\Framework\Stdlib\CookieManagerInterface $cookieManager,
\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
ExceptionLogger $exceptionLogger = null
) {
parent::__construct($context);
$this->amazonCheckoutSession = $amazonCheckoutSession;
$this->amazonCheckoutSessionManagement = $checkoutSessionManagement;
$this->exceptionLogger = $exceptionLogger ?: ObjectManager::getInstance()->get(ExceptionLogger::class);
$this->cookieManager = $cookieManager;
$this->cookieMetadataFactory = $cookieMetadataFactory;
Expand All @@ -81,9 +88,9 @@ public function execute()
try {
// Bypass cache check in \Magento\PageCache\Model\DepersonalizeChecker
$this->getRequest()->setParams(['ajax' => 1]);
$result = $this->amazonCheckoutSession->completeCheckoutSession();
$amazonCheckoutSessionId = $this->getRequest()->getParam('amazonCheckoutSessionId');
$result = $this->amazonCheckoutSessionManagement->completeCheckoutSession($amazonCheckoutSessionId);
if (!$result['success']) {
$this->amazonCheckoutSession->clearCheckoutSessionId();
$this->messageManager->addErrorMessage($result['message']);

return $this->_redirect('checkout/cart', ['_scope' => $scope]);
Expand All @@ -96,7 +103,6 @@ public function execute()
]);
} catch (\Exception $e) {
$this->exceptionLogger->logException($e);
$this->amazonCheckoutSession->clearCheckoutSessionId();
$this->messageManager->addErrorMessage($e->getMessage());
}

Expand Down
5 changes: 0 additions & 5 deletions Controller/Login/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ public function execute()
$checkoutSessionId
);

$this->checkoutSessionManagement->storeCheckoutSession(
$this->session->getQuote()->getId(),
$checkoutSessionId
);

if (!$this->amazonConfig->isLwaEnabled()) {
$userInfo = $checkoutSession['buyer'];
if ($userInfo && isset($userInfo['email'])) {
Expand Down
24 changes: 0 additions & 24 deletions CustomerData/CheckoutSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,4 @@ public function getConfig()
{
return $this->checkoutSessionManagement->getConfig($this->session->getQuote());
}

/**
* Clear Amazon Checkout Session Id
*/
public function clearCheckoutSessionId()
{
$this->checkoutSessionManagement->cancelCheckoutSession($this->session->getQuote());
}

/**
* Get Amazon Checkout Session Id
*/
public function getCheckoutSessionId()
{
return $this->checkoutSessionManagement->getCheckoutSession($this->session->getQuote());
}

/**
* Complete Amazon Checkout Session
*/
public function completeCheckoutSession()
{
return $this->checkoutSessionManagement->completeCheckoutSession($this->session->getQuote());
}
}
7 changes: 2 additions & 5 deletions Gateway/Request/AuthorizationSaleRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,8 @@ public function __construct(
public function build(array $buildSubject)
{
$payment = $this->subjectReader->readPayment($buildSubject)->getPayment();
try {
$amazonCheckoutSessionId = $this->sessionManagement->getCheckoutSession($payment->getOrder()->getQuoteId());
} catch (NoSuchEntityException $e) {
$amazonCheckoutSessionId = null;
}

$amazonCheckoutSessionId = $payment->getAdditionalInformation('amazon_session_id');

if ($payment->getAmazonDisplayInvoiceAmount()) {
$total = $payment->getAmazonDisplayInvoiceAmount();
Expand Down
Loading