| Conditions | 3 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | public function __invoke(Request $request): Response |
||
| 25 | { |
||
| 26 | $username = (string)$request->get('username'); |
||
| 27 | $milliSats = (int)$request->get('amount', 0); |
||
| 28 | // TODO: Make it customizable |
||
| 29 | // $backend = (string)$request->get('backend', 'lnbits'); |
||
| 30 | |||
| 31 | try { |
||
| 32 | if ($milliSats === 0) { |
||
| 33 | return new JsonResponse( |
||
| 34 | $this->getFacade()->getCallbackUrl($username), |
||
| 35 | ); |
||
| 36 | } |
||
| 37 | |||
| 38 | return new JsonResponse( |
||
| 39 | $this->getFacade()->generateInvoice($username, $milliSats), |
||
| 40 | ); |
||
| 41 | } catch (Throwable $e) { |
||
| 42 | return new JsonResponse([ |
||
| 43 | 'status' => 'ERROR', |
||
| 44 | 'message' => $e->getMessage(), |
||
| 45 | ], Response::HTTP_BAD_REQUEST); |
||
| 46 | } |
||
| 49 |