Fixed Offline Payment method for Customer
This commit is contained in:
54
modules/OfflinePayment/Http/Controllers/OfflinePayment.php
Normal file
54
modules/OfflinePayment/Http/Controllers/OfflinePayment.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
|
||||
public function confirm(Invoice $invoice, ConfirmRequest $request)
|
||||
{
|
||||
$result = event(new InvoicePaid($invoice, $request));
|
||||
|
||||
return response()->json($result);
|
||||
}
|
||||
}
|
30
modules/OfflinePayment/Http/Requests/Show.php
Normal file
30
modules/OfflinePayment/Http/Requests/Show.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\OfflinePayment\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class Show extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'payment_method' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
@ -6,3 +6,8 @@ Route::group(['middleware' => ['web', 'auth', 'language', 'adminmenu', 'permissi
|
||||
Route::post('settings/get', 'Settings@get');
|
||||
Route::post('settings/delete', 'Settings@delete');
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'customers', 'namespace' => 'Modules\OfflinePayment\Http\Controllers'], function () {
|
||||
Route::get('invoices/{invoice}/offlinepayment', 'OfflinePayment@show');
|
||||
Route::post('invoices/{invoice}/offlinepayment/confirm', 'OfflinePayment@confirm');
|
||||
});
|
||||
|
Reference in New Issue
Block a user