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

Fix undefined variables in \Amazon\Pay\Model\CheckoutSessionManagement #1237

Closed
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
13 changes: 8 additions & 5 deletions Model/CheckoutSessionManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ protected function addCaptureComment($payment, $chargeId)
* Cancel order
*
* @param OrderInterface $order
* @param CartInterface $quote
* @param CartInterface|null $quote
* @param string $reasonMessage
* @return void
*/
Expand Down Expand Up @@ -711,7 +711,7 @@ public function cancelOrder($order, $quote, $reasonMessage = '')

$order->save();

if ($this->subscriptionManager->hasSubscription($quote)) {
if ($quote instanceof CartInterface && $this->subscriptionManager->hasSubscription($quote)) {
$this->subscriptionManager->cancel($order);
}
}
Expand Down Expand Up @@ -754,6 +754,9 @@ public function completeCheckoutSession($amazonSessionId, $cartId = null)
'success' => false
];

$quote = null;
$order = null;

try {
$orderId = $orderResult['order_id'];
$order = $this->orderRepository->get($orderId);
Expand All @@ -778,10 +781,10 @@ public function completeCheckoutSession($amazonSessionId, $cartId = null)
$result['success'] = true;

} catch (\Exception $e) {
$this->closeChargePermission($amazonSessionId, $order, $e);
if ($order instanceof OrderInterface) {
$this->closeChargePermission($amazonSessionId, $order, $e);

// cancel order
if (isset($order)) {
// cancel order
$this->cancelOrder($order, $quote);
$this->magentoCheckoutSession->restoreQuote();
}
Expand Down