2019-08-22 00:34:20 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\ClientPortal;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
2019-09-18 04:39:53 +02:00
|
|
|
use App\Models\ClientGatewayToken;
|
2019-08-22 00:34:20 +02:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
2019-09-18 04:39:53 +02:00
|
|
|
use Yajra\DataTables\Facades\DataTables;
|
2019-08-22 00:34:20 +02:00
|
|
|
|
|
|
|
class PaymentMethodController extends Controller
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display a listing of the resource.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
2019-09-18 04:39:53 +02:00
|
|
|
$payment_methods = ClientGatewayToken::whereClientId(auth()->user()->client->id);
|
|
|
|
|
|
|
|
if (request()->ajax()) {
|
|
|
|
|
|
|
|
return DataTables::of($payment_methods)->addColumn('action', function ($invoice) {
|
|
|
|
return '<a href="/client/payment_methods/'. $payment_methods->hashed_id .'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i>'.ctrans('texts.view').'</a>';
|
|
|
|
})
|
|
|
|
->editColumn('status_id', function ($invoice){
|
|
|
|
return Invoice::badgeForStatus($invoice->status);
|
|
|
|
})->editColumn('invoice_date', function ($invoice){
|
|
|
|
return $this->formatDate($invoice->invoice_date, $invoice->client->date_format());
|
|
|
|
})->editColumn('due_date', function ($invoice){
|
|
|
|
return $this->formatDate($invoice->due_date, $invoice->client->date_format());
|
|
|
|
})->editColumn('balance', function ($invoice) {
|
|
|
|
return Number::formatMoney($invoice->balance, $invoice->client);
|
|
|
|
})->editColumn('amount', function ($invoice) {
|
|
|
|
return Number::formatMoney($invoice->amount, $invoice->client);
|
|
|
|
})
|
|
|
|
->rawColumns(['action', 'status_id'])
|
|
|
|
->make(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['html'] = $builder;
|
|
|
|
|
|
|
|
return view('portal.default.payment_methods.index', $data);
|
2019-08-22 00:34:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for creating a new resource.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function create()
|
|
|
|
{
|
2019-09-14 14:34:05 +02:00
|
|
|
$gateway = auth()->user()->client->getCreditCardGateway();
|
|
|
|
|
2019-09-13 07:52:01 +02:00
|
|
|
$data = [
|
|
|
|
'gateway' => $gateway,
|
|
|
|
'token' => false,
|
|
|
|
];
|
|
|
|
|
2019-09-16 06:59:59 +02:00
|
|
|
return $gateway->driver(auth()->user()->client)->authorizeCreditCardView($data);
|
2019-08-22 00:34:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store a newly created resource in storage.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function store(Request $request)
|
|
|
|
{
|
2019-09-16 13:03:25 +02:00
|
|
|
$gateway = auth()->user()->client->getCreditCardGateway();
|
|
|
|
|
|
|
|
return $gateway->driver(auth()->user()->client)->authorizeCreditCardResponse($request);
|
|
|
|
|
2019-08-22 00:34:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the specified resource.
|
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function show($id)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for editing the specified resource.
|
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function edit($id)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the specified resource in storage.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function update(Request $request, $id)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the specified resource from storage.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function destroy()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|