/**
  * @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());
     }
 }
Example #2
0
 /**
  * @author WN
  * @param ApplicantEntity $applicantEntity
  * @param Application $application
  */
 private function mapApplicant(Application $application, ApplicantEntity $applicantEntity = null)
 {
     if ($applicantEntity !== null) {
         $application->ext_applicant_title = $applicantEntity->getTitle();
         $application->ext_applicant_first_name = $applicantEntity->getFirstName();
         $application->ext_applicant_last_name = $applicantEntity->getLastName();
         $application->ext_applicant_date_of_birth = $applicantEntity->getDateOfBirth();
         $application->ext_applicant_email_address = $applicantEntity->getEmailAddress();
         $application->ext_applicant_phone_home = $applicantEntity->getPhoneHome();
         $application->ext_applicant_phone_mobile = $applicantEntity->getPhoneMobile();
         $application->ext_applicant_postcode = $applicantEntity->getPostcode();
     }
 }
 /**
  * @author EB
  * @return \PayBreak\Sdk\Entities\Application\ApplicantEntity
  */
 private function getApplicantEntity()
 {
     return \PayBreak\Sdk\Entities\Application\ApplicantEntity::make(['title' => 'Mr', 'first_name' => 'Test', 'last_name' => 'Tester', 'date_of_birth' => \Carbon\Carbon::now()->subYears(20)->toDateString(), 'email_address' => '*****@*****.**', 'phone_home' => 03333333333, 'phone_mobile' => 07777777777, 'postcode' => 'TE55TP']);
 }
 /**
  * @author EB
  * @param Request $request
  * @return ApplicantEntity
  */
 public static function createApplicantEntity(Request $request)
 {
     return ApplicantEntity::make(['title' => $request->get('title'), 'first_name' => $request->get('first_name'), 'last_name' => $request->get('last_name'), 'email_address' => $request->has('applicant_email') ? $request->get('applicant_email') : $request->get('email'), 'phone_home' => $request->get('phone_home'), 'phone_mobile' => $request->get('phone_mobile'), 'postcode' => $request->get('postcode')]);
 }