Skip to content

magento/magento2#37983: Place order with disabled Payment method working #39937

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

Open
wants to merge 16 commits into
base: 2.4-develop
Choose a base branch
from
Open
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
ac44646
magento/magento2#37983: Place order with disabled Payment method working
KrasnoshchokBohdan May 26, 2025
223ac0b
Merge branch '2.4-develop' into fix-for-issue-37983
KrasnoshchokBohdan May 26, 2025
ff67a1d
magento/magento2#37983: Place order with disabled Payment method working
KrasnoshchokBohdan Jun 3, 2025
a67ba55
Merge remote-tracking branch 'origin/fix-for-issue-37983' into fix-fo…
KrasnoshchokBohdan Jun 3, 2025
21a6a7a
Merge branch '2.4-develop' into fix-for-issue-37983
KrasnoshchokBohdan Jun 3, 2025
c646ff8
magento/magento2#37983: Place order with disabled Payment method working
KrasnoshchokBohdan Jun 12, 2025
acac8c1
Merge branch '2.4-develop' into fix-for-issue-37983
KrasnoshchokBohdan Jun 12, 2025
7fdd389
Merge branch '2.4-develop' into fix-for-issue-37983
KrasnoshchokBohdan Jun 23, 2025
10b3948
Merge branch '2.4-develop' into fix-for-issue-37983
engcom-Hotel Jul 4, 2025
d59e8bb
Merge branch '2.4-develop' into fix-for-issue-37983
engcom-Hotel Jul 11, 2025
8e66f2a
Update app/code/Magento/QuoteGraphQl/Model/Cart/PlaceOrder.php
KrasnoshchokBohdan Jul 12, 2025
5f3e54b
magento/magento2#37983: Place order with disabled Payment method working
KrasnoshchokBohdan Jul 12, 2025
889e4d5
magento/magento2#37983: Place order with disabled Payment method working
KrasnoshchokBohdan Jul 15, 2025
65e9413
Merge branch '2.4-develop' into fix-for-issue-37983
KrasnoshchokBohdan Jul 15, 2025
3e70809
Merge branch '2.4-develop' into fix-for-issue-37983
engcom-Hotel Jul 16, 2025
bd491a5
magento/magento2#37983: Place order with disabled Payment method working
KrasnoshchokBohdan Jul 19, 2025
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
24 changes: 22 additions & 2 deletions app/code/Magento/QuoteGraphQl/Model/Cart/PlaceOrder.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2015 Adobe
* All Rights Reserved.
*/
declare(strict_types=1);

Expand Down Expand Up @@ -58,6 +58,26 @@ public function execute(Quote $cart, string $maskedCartId, int $userId): int
$cartId = (int)$cart->getId();
$paymentMethod = $this->paymentManagement->get($cartId);

// Get a list of available payment methods for the cart
$availablePaymentMethods = $this->paymentManagement->getList($cartId);
$payment = $cart->getPayment();
$paymentMethodCode = $payment?->getMethod();
$isPaymentMethodAvailable = false;

// Check if the selected payment method is in the available methods list
if ($paymentMethodCode && $availablePaymentMethods) {
foreach ($availablePaymentMethods as $availableMethod) {
if ($availableMethod->getCode() === $paymentMethodCode) {
$isPaymentMethodAvailable = true;
break;
}
}
}

if (!$isPaymentMethodAvailable) {
throw new LocalizedException(__('The requested Payment Method is not available.'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message could be more specific by including the requested payment method code: "The requested Payment Method '{code}' is not available."

And also consider adding a debug log when a disabled payment method is detected to help track these attempts.

}

return (int)$this->cartManagement->placeOrder($cartId, $paymentMethod);
}
}