public function handleNotification(Request $request) { $notification = Notification::createFromRequest($request); if ($notification->isLive() !== $this->adyen->isLive()) { // test notification on live environment or vice versa throw new AdyenException('Received notification is from test environment but extension is in live mode'); } foreach ($notification->getNotificationItems() as $item) { /** @var NotificationRequestItem $item */ if (isset($item->getAdditionalData()->hmacSignature)) { $signature = $item->getAdditionalData()->hmacSignature; // check signature $signatureGenerator = $this->adyen->getSignaturesGenerator(); $generated = $signatureGenerator->generateNotificationSignature($item); if ($signature !== $generated) { throw new InvalidSignatureException($item); } } else { // some reaction to processing not signed notification if (!$this->adyen->acceptUnsignedNotifications()) { throw new InvalidNotificationException('Received notification is unsigned but extension is configured to accept only signed notifications', 0, $item); } } $this->onNotification($this, $item); // standard process of notification if (!$item->isSuccess()) { $this->onFailed($this, $item); //onProblem, //onIssue continue; } $this->onSuccess($this, $item); if ($item->isAuthorised()) { $this->onAuthorised($this, $item); } elseif ($item->isCancelled()) { $this->onCancelled($this, $item); } elseif ($item->isRefund()) { $this->onRefund($this, $item); } else { $this->onOther($this, $item); } } }
/** * @return string */ public function getEndpointUrl() { return $this->context->getHPPEndpointUrl($this->endpoint); }