Untitled
unknown
plain_text
2 years ago
1.6 kB
4
Indexable
Never
protected function action(): Response { $data = $this->getFormData(); $body = []; // bank $bank = $this->bankRepository->findByUuid($data->bankId); foreach ($data as $k => $v) { $body[$k] = $v; } if (empty($body["vaId"])) { $body["vaId"] = Uuid::uuid4();; } unset($body["bankId"]); $body["bank"] = $bank; $va = new Va($body); $va = $this->vaRepository->add($va); $this->logger->info("Bank `" . $va->getAccountNumber() . " was created."); if (!is_numeric($va->getAccountName())) { throw new \Exception("Bad request: " . 400); } $now = new \DateTime(); $newExpiredDate = new \DateTime('now + 3 week'); $institutionCode = $_ENV["BRI_INSTITUTION_CODE"]; $briva = new Briva([ "clientId" => $_ENV['BRI_CLIENT_ID'], "clientSecret" => $_ENV['BRI_CLIENT_SECRET'], "institutionCode" => $institutionCode, "brivaNo" => $va->getBank()->getVaCode(), "endpoint" => $_ENV["BRIVA_ENDPOINT"], "nama" => $va->getAccountName(), "custCode" => $va->getPhone(), "keterangan" => "perubahan expire", "amount" => "0", "expiredDate" => $newExpiredDate->format("Y-m-d H:i:s") ]); $queryResult = $briva->editVA(); $va->setExpiredAt($newExpiredDate); $va->setLastChecked($now); $this->vaRepository->update($va); $this->logger->info($queryResult); $brivaAccount = json_decode($queryResult); // $this->respondWithData(json_encode($brivaAccount, JSON_PRETTY_PRINT)); return $this->respondWithData(json_encode($brivaAccount, JSON_PRETTY_PRINT)); }