1212
1313namespace Adyen \Payment \Helper \Webhook ;
1414
15+ use Adyen \Payment \Api \CleanupAdditionalInformationInterface ;
1516use Adyen \Payment \Api \Repository \AdyenNotificationRepositoryInterface ;
1617use Adyen \Payment \Helper \AdyenOrderPayment ;
1718use Adyen \Payment \Helper \CaseManagement ;
@@ -41,6 +42,7 @@ class AuthorisationWebhookHandler implements WebhookHandlerInterface
4142 * @param PaymentMethods $paymentMethodsHelper
4243 * @param CartRepositoryInterface $cartRepository
4344 * @param AdyenNotificationRepositoryInterface $notificationRepository
45+ * @param CleanupAdditionalInformationInterface $cleanupAdditionalInformation
4446 */
4547 public function __construct (
4648 private readonly AdyenOrderPayment $ adyenOrderPaymentHelper ,
@@ -52,7 +54,8 @@ public function __construct(
5254 private readonly Invoice $ invoiceHelper ,
5355 private readonly PaymentMethods $ paymentMethodsHelper ,
5456 private readonly CartRepositoryInterface $ cartRepository ,
55- private readonly AdyenNotificationRepositoryInterface $ notificationRepository
57+ private readonly AdyenNotificationRepositoryInterface $ notificationRepository ,
58+ private readonly CleanupAdditionalInformationInterface $ cleanupAdditionalInformation
5659 ) { }
5760
5861 /**
@@ -113,6 +116,9 @@ private function handleSuccessfulAuthorisation(Order $order, Notification $notif
113116 // Set authorized amount in sales_order_payment
114117 $ order ->getPayment ()->setAmountAuthorized ($ order ->getGrandTotal ());
115118 $ order ->getPayment ()->setBaseAmountAuthorized ($ order ->getBaseGrandTotal ());
119+
120+ // Clean-up the data temporarily stored in `additional_information`
121+ $ this ->cleanupAdditionalInformation ->execute ($ order ->getPayment ());
116122 } else {
117123 $ this ->orderHelper ->addWebhookStatusHistoryComment ($ order , $ notification );
118124 }
@@ -186,6 +192,9 @@ private function handleFailedAuthorisation(Order $order, Notification $notificat
186192 $ order ->setState (Order::STATE_NEW );
187193 }
188194
195+ // Clean-up the data temporarily stored in `additional_information`
196+ $ this ->cleanupAdditionalInformation ->execute ($ order ->getPayment ());
197+
189198 return $ this ->orderHelper ->holdCancelOrder ($ order , true );
190199 }
191200
0 commit comments