Skip to content

[ECP-9943] Fix installment data loss during GraphQL placeOrder#3291

Merged
shubhamk67 merged 1 commit into
mainfrom
ECP-9943
Apr 14, 2026
Merged

[ECP-9943] Fix installment data loss during GraphQL placeOrder#3291
shubhamk67 merged 1 commit into
mainfrom
ECP-9943

Conversation

@shubhamk67

Copy link
Copy Markdown
Contributor

Description
This PR fixes an issue in GraphQL headless checkout where the placeOrder mutation re-triggers AdyenCcDataAssignObserver without the original additional payment data, causing fields like number_of_installments to be cleared.

Fixes #2346

@shubhamk67 shubhamk67 requested a review from a team as a code owner April 13, 2026 09:33
@shubhamk67 shubhamk67 added the Fix Indicates a bug fix label Apr 13, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request modifies the AdyenCcDataAssignObserver to prevent the loss of payment information during checkout by removing unconditional calls to unset additional information. While the change correctly addresses the data loss issue, the newly added conditional unsetting logic is redundant. Since Magento's setAdditionalInformation method automatically overwrites existing keys and skips missing ones, the explicit unsetting of these keys before the update loop is unnecessary and can be removed to simplify the implementation.

Comment on lines +114 to +123
// Remove each CC-specific field from the previous payment only if the incoming
// data contains a replacement for that specific field. This prevents the placeOrder
// mutation from clearing data that was set by setPaymentMethodOnCart.
$ccSpecificKeys = [self::CC_TYPE, self::NUMBER_OF_INSTALLMENTS, self::COMBO_CARD_TYPE];
foreach ($ccSpecificKeys as $ccKey) {
if (array_key_exists($ccKey, $additionalData)) {
$paymentInfo->unsAdditionalInformation($ccKey);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This block is redundant and can be removed. The primary fix for the data loss issue is the removal of the unconditional unsAdditionalInformation calls at the start of the execute method (previously lines 103-105).

In Magento 2, setAdditionalInformation (called later in this method at line 155) automatically overwrites existing values for the same key. Therefore, explicitly unsetting the keys before setting them again provides no benefit. If a key is missing from the current request's $additionalData, it will simply be skipped by the loop at line 154, effectively preserving the existing value in $paymentInfo, which is the desired behavior to prevent data loss.

@sonarqubecloud

Copy link
Copy Markdown

@shubhamk67 shubhamk67 merged commit ddba05f into main Apr 14, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Fix Indicates a bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ECP-9943] number_of_installments is missing on GraphQl payments

3 participants