-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
KrasnoshchokBohdan
wants to merge
16
commits into
magento:2.4-develop
Choose a base branch
from
KrasnoshchokBohdan:fix-for-issue-37983
base: 2.4-develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
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 223ac0b
Merge branch '2.4-develop' into fix-for-issue-37983
KrasnoshchokBohdan ff67a1d
magento/magento2#37983: Place order with disabled Payment method working
KrasnoshchokBohdan a67ba55
Merge remote-tracking branch 'origin/fix-for-issue-37983' into fix-fo…
KrasnoshchokBohdan 21a6a7a
Merge branch '2.4-develop' into fix-for-issue-37983
KrasnoshchokBohdan c646ff8
magento/magento2#37983: Place order with disabled Payment method working
KrasnoshchokBohdan acac8c1
Merge branch '2.4-develop' into fix-for-issue-37983
KrasnoshchokBohdan 7fdd389
Merge branch '2.4-develop' into fix-for-issue-37983
KrasnoshchokBohdan 10b3948
Merge branch '2.4-develop' into fix-for-issue-37983
engcom-Hotel d59e8bb
Merge branch '2.4-develop' into fix-for-issue-37983
engcom-Hotel 8e66f2a
Update app/code/Magento/QuoteGraphQl/Model/Cart/PlaceOrder.php
KrasnoshchokBohdan 5f3e54b
magento/magento2#37983: Place order with disabled Payment method working
KrasnoshchokBohdan 889e4d5
magento/magento2#37983: Place order with disabled Payment method working
KrasnoshchokBohdan 65e9413
Merge branch '2.4-develop' into fix-for-issue-37983
KrasnoshchokBohdan 3e70809
Merge branch '2.4-develop' into fix-for-issue-37983
engcom-Hotel bd491a5
magento/magento2#37983: Place order with disabled Payment method working
KrasnoshchokBohdan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
|
@@ -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.')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.