/** * @author WN * @param Application $application * @param OrderEntity $orderEntity */ private function mapOrder(Application $application, OrderEntity $orderEntity = null) { if ($orderEntity !== null) { $application->ext_order_reference = $orderEntity->getReference(); $application->ext_order_amount = $orderEntity->getAmount(); $application->ext_order_description = $orderEntity->getDescription(); $application->ext_order_validity = $orderEntity->getValidity(); } }
/** * @author WN, EB * @param string $email * @param Location $location * @param OrderEntity $orderEntity * @param ProductsEntity $productsEntity * @param ApplicantEntity $applicantEntity * @param User $requester * @return Application * @throws Exception */ public function initialiseAssistedApplication($email, Location $location, OrderEntity $orderEntity, ProductsEntity $productsEntity, ApplicantEntity $applicantEntity, User $requester) { $applicationParams = ['email' => $email, 'installation' => $location->installation->ext_id, 'order' => $orderEntity->toArray(), 'products' => $productsEntity->toArray(true), 'fulfilment' => ['method' => 'collection', 'location' => $location->reference], 'applicant' => $applicantEntity->toArray()]; $application = ApplicationEntity::make($applicationParams); $this->logInfo('IniAssistedApp: Application reference[' . $orderEntity->getReference() . '] ready to be initialised', ['application' => $application->toArray()]); try { $newApplication = $this->applicationGateway->initialiseAssistedApplication($application, $location->installation->merchant->token); $this->logInfo('IniAssistedApp: Application reference[' . $orderEntity->getReference() . '] successfully initialised at provider with ID[' . $newApplication->getId() . ']'); $app = $this->createNewLocal($newApplication, $location->installation->id, $requester->id, $location->id); $this->logInfo('IniAssistedApp: Application reference[' . $orderEntity->getReference() . '] successfully stored in the local system'); return $app; } catch (\Exception $e) { $this->logError('IniAssistedApp: ' . $e->getMessage()); throw new Exception($e->getMessage()); } }