Blame view

modules/OfflinePayment/Http/Controllers/OfflinePayment.php 1.22 KB
b7c7a5f6   Alexey Boroda   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  <?php
  
  namespace Modules\OfflinePayment\Http\Controllers;
  
  use App\Events\InvoicePaid;
  
  use Illuminate\Http\Response;
  use Illuminate\Routing\Controller;
  
  use App\Http\Requests\Customer\InvoicePayment as PaymentRequest;
  use App\Http\Requests\Customer\InvoiceConfirm as ConfirmRequest;
  
  use App\Models\Income\Invoice;
  
  class OfflinePayment extends Controller
  {
      /**
       * Show the form for editing the specified resource.
       * @param Invoice
       * @param PaymentRequest
       * @return Response
       */
      public function show(Invoice $invoice, PaymentRequest $request)
      {
          $gateway = [];
  
          $payment_methods = json_decode(setting('offlinepayment.methods'), true);
  
          foreach ($payment_methods as $payment_method) {
              if ($payment_method['code'] == $request['payment_method']) {
                  $gateway = $payment_method;
  
                  break;
              }
          }
  
          $html = view('offlinepayment::show', compact('gateway', 'invoice'))->render();
  
          return response()->json([
              'code' => $gateway['code'],
              'name' => $gateway['name'],
              'description' => $gateway['description'],
              'redirect' => false,
              'html' => $html,
          ]);
      }
  }