/**
  * @author EA, EB
  * @param ApplicationEntity $application
  * @param string $token
  * @return ApplicationEntity
  * @throws SdkException
  */
 public function initialiseAssistedApplication(ApplicationEntity $application, $token)
 {
     $api = $this->getApiFactory()->makeApiClient($token);
     try {
         $response = $api->post('/v4/initialize-assisted-application', $application->toArray(true));
         $application->setId($response['application']);
         $application->setResumeUrl($response['url']);
         $application->setUser($response['user']);
         return $application;
     } catch (ErrorResponseException $e) {
         $this->logWarning('ApplicationGateway::initialiseAssistedApplication[' . $e->getCode() . ']: ' . $e->getMessage());
         throw new SdkException($e->getMessage());
     } catch (\Exception $e) {
         $this->logError('ApplicationGateway::initialiseAssistedApplication[' . $e->getCode() . ']: ' . $e->getMessage());
         throw new SdkException('Problem Initialising Assisted Application on Provider API');
     }
 }
 /**
  * @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());
     }
 }
Ejemplo n.º 3
0
 /**
  * @author WN
  * @param ApplicationEntity $applicationEntity
  * @param Application $application
  */
 public function mapApplication(ApplicationEntity $applicationEntity, Application $application)
 {
     $application->ext_current_status = $applicationEntity->getCurrentStatus();
     $this->mapOrder($application, $applicationEntity->getOrder());
     $this->mapProducts($application, $applicationEntity->getProducts());
     $this->mapFulfilment($application, $applicationEntity->getFulfilment());
     $this->mapCustomer($application, $applicationEntity->getCustomer());
     $this->mapApplicationAddress($application, $applicationEntity->getApplicationAddress());
     $this->mapApplicant($application, $applicationEntity->getApplicant());
     $this->mapFinance($application, $applicationEntity->getFinance());
     $this->mapCancellation($application, $applicationEntity->getCancellation());
     $application->ext_resume_url = $applicationEntity->getResumeUrl();
     $application->ext_metadata = json_encode($applicationEntity->getMetadata());
     $application->ext_user = $applicationEntity->getUser();
 }