/** * @author SL * @param Request $request * @param $installation * @param $product * @return array|\Illuminate\Http\Response */ public function getCreditInformationForProduct(Request $request, $installation, $product) { try { if (!$request->has('deposit', 'order_amount')) { throw new Exception('Input field "deposit" and "order_amount" are both required.'); } $inst = Installation::findOrFail(['ext_id' => $installation])->first(); return $this->productGateway->getCreditInfo($inst->ext_id, $product, $inst->merchant->token, ['deposit_amount' => $request->input('deposit'), 'order_amount' => $request->input('order_amount')]); } catch (\Exception $e) { return $this->apiResponseFromException($e); } }
/** * @author EB */ public function testGetDisclosureAsHtml() { $installation = Installation::query()->find(1); $installation->update(['disclosure' => '## Test Two']); $disclosure = Installation::findOrFail(1)->getDisclosureAsHtml(); $this->assertEquals('<h2>Test Two</h2>', $disclosure); }
/** * @author EB, SL * * @param int $id * @return GroupEntity * @throws RedirectException */ private function fetchProducts($id) { try { $installation = Installation::findOrFail($id); return $this->productGateway->getProductGroupsWithProducts($installation->ext_id, $installation->merchant->token); } catch (\Exception $e) { if ($e->getMessage() !== 'Products are empty') { throw $this->redirectWithException(URL::previous(), $e->getMessage(), $e); } return GroupEntity::make([]); } }