Skip to content
Merged
Changes from 1 commit
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: 10 additions & 3 deletions Observer/AdyenCcDataAssignObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ public function execute(Observer $observer)

// Remove the following information from the previous payment
$paymentInfo->unsAdditionalInformation(AdyenPaymentMethodDataAssignObserver::BRAND_CODE);

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

The removal of BRAND_CODE remains unconditional. If this observer is re-triggered for a non-CC payment method (e.g., during placeOrder), it will wipe out the brand_code set by other observers. To fully prevent data loss during re-triggers, this removal should also be made conditional on whether the current request is actually providing CC data, or moved after the $additionalData check.

$paymentInfo->unsAdditionalInformation(self::CC_TYPE);
$paymentInfo->unsAdditionalInformation(self::NUMBER_OF_INSTALLMENTS);
$paymentInfo->unsAdditionalInformation(self::COMBO_CARD_TYPE);

// Get additional data array
$additionalData = $data->getData(PaymentInterface::KEY_ADDITIONAL_DATA);
Expand All @@ -117,6 +114,16 @@ public function execute(Observer $observer)
self::$approvedAdditionalDataKeys
);

// 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);
}
}
Comment thread
shubhamk67 marked this conversation as resolved.

// JSON decode state data from the frontend or fetch it from the DB entity with the quote ID
if (!empty($additionalData[self::STATE_DATA])) {
$stateData = json_decode((string)$additionalData[self::STATE_DATA], true);
Expand Down
Loading