/** * To return a registration session container from the storage. * * @param string $sessionId * * @return CardRegistrationSession * * @throws \RuntimeException */ public function getRegistrationSessionFromId($sessionId) { if ($this->storageService->has(self::SESSION_PREFIX . $sessionId)) { return $this->storageService->get(self::SESSION_PREFIX . $sessionId); } throw new \RuntimeException('Error, registration session is invalid'); }
/** * @param string $transactionId * @param Response $response * * @return $this */ public function processMangoPayReturn($transactionId, Response $response) { $payIn = $this->mangoPayPayInsApi->Get($transactionId); if (!$payIn instanceof PayIn) { throw new BadMangoReturnException('Error, return for ' . $transactionId . ' from Mango is invalid'); } $session = $this->storageService->get(self::SESSION_PREFIX . $transactionId); if ('SUCCEEDED' === $payIn->Status) { $this->eventDispatched->dispatch(MangoPayEvents::SECURE_FLOW_SUCCESS, new SecureFlowEvent($payIn, $response, $session)); } else { $this->eventDispatched->dispatch(MangoPayEvents::SECURE_FLOW_ERROR, new SecureFlowEvent($payIn, $response, $session)); } }