/** * @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()); } }
/** * @author EB * @return \PayBreak\Sdk\Entities\Application\OrderEntity */ private function getOrderEntity() { return \PayBreak\Sdk\Entities\Application\OrderEntity::make(['reference' => '123456789', 'amount' => 50000, 'description' => 'Test Order', 'validity' => \Carbon\Carbon::now()->addDay()->toDateTimeString(), 'deposit_amount' => 2000]); }
/** * @author EB * @param Request $request * @param Installation $installation * @return OrderEntity */ public static function createOrderEntity(Request $request, Installation $installation) { return OrderEntity::make(['reference' => $request->get('reference'), 'amount' => (int) $request->get('amount'), 'description' => $request->get('description'), 'validity' => Carbon::now()->addSeconds($installation->validity)->toDateTimeString(), 'deposit_amount' => $request->has('deposit') ? $request->get('deposit') * 100 : $request->get('deposit')]); }