/** * @author EB * @param Application $application * @param ProductsEntity $productsEntity */ private function mapProducts(Application $application, ProductsEntity $productsEntity = null) { if ($productsEntity !== null) { $application->ext_products_options = json_encode($productsEntity->getOptions()); $application->ext_products_groups = $productsEntity->getGroup(); $application->ext_products_default = $productsEntity->getDefault(); } }
/** * @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()); } }
/** * @author EB * @return \PayBreak\Sdk\Entities\Application\ProductsEntity */ private function getProductsEntity() { return \PayBreak\Sdk\Entities\Application\ProductsEntity::make(['group' => 'xx', 'options' => [], 'default' => 'xx-xx']); }
/** * @author EB * @param Request $request * @return ProductsEntity */ public static function createProductsEntity(Request $request) { return ProductsEntity::make(['group' => $request->get('group'), 'options' => [$request->get('product')]]); }