Fix order creation issues for logged-in customer #133
Closed
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.
We met with the issue in the Magento VIPPS payment module. It's not possible to place VIPPS order through Klarna Checkout if customer is logged in to Magento. The correct behavior is to create Magento order BEFORE the customer is redirected to Vipps payment page. But there is an issue in the code which prevents order creation for Magento logged-in customers, and the order for such customers is created only AFTER payment is done when the customer is redirected back to Magento.
Problem is in 2 places and it exists in the latest module version:
$quote->getCheckoutMethod()
function needstrue
argument in\Vipps\Payment\Controller\Payment\Klarna\InitRegular::placeOrder(quote)
,\Vipps\Payment\Controller\Payment\Klarna\InitRegular::setCheckoutMethod(quote)
and\Vipps\Payment\Controller\Payment\InitExpress::initiatePayment()
. Vipps module recognizes "customer", "guest" and "register" checkout methods. But for logged-in customer:$quote->getCheckoutMethod() = 'login_in';
when
$quote->getCheckoutMethod(true) = 'customer';
(see
\Magento\Quote\Model\Quote::getCheckoutMethod(originalMethod)
).$this->paymentInformationManagement->savePaymentInformationAndPlaceOrder()
for "customer" needs$quoteId
, not$maskedQuoteId
in\Vipps\Payment\Controller\Payment\Klarna\InitRegular::placeOrder(quote)
.