Merge pull request #683 from cuneytsenturk/offlinepayment-dev
Offline Payment re-factoring
This commit is contained in:
commit
76aa41f8fb
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'name' => 'OfflinePayment',
|
||||
|
||||
];
|
@ -4,7 +4,6 @@ namespace Modules\OfflinePayment\Http\Controllers;
|
||||
|
||||
use App\Events\InvoicePaid;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
@ -16,11 +15,12 @@ use SignedUrl;
|
||||
|
||||
class OfflinePayment extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param Invoice
|
||||
* @param PaymentRequest
|
||||
* @return Response
|
||||
* @return JSON
|
||||
*/
|
||||
public function show(Invoice $invoice, PaymentRequest $request)
|
||||
{
|
||||
@ -46,11 +46,12 @@ class OfflinePayment extends Controller
|
||||
'html' => $html,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param $invoice
|
||||
* @param $request
|
||||
* @return Response
|
||||
* @return JSON
|
||||
*/
|
||||
public function link(Invoice $invoice, PaymentRequest $request)
|
||||
{
|
||||
|
@ -12,6 +12,7 @@ use Modules\OfflinePayment\Http\Requests\SettingDelete as DRequest;
|
||||
|
||||
class Settings extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
@ -66,7 +67,7 @@ class Settings extends Controller
|
||||
|
||||
Artisan::call('cache:clear');
|
||||
|
||||
return redirect('apps/offlinepayment/settings');
|
||||
return redirect()->route('offlinepayment.edit');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,18 +1,30 @@
|
||||
<?php
|
||||
|
||||
Route::group(['middleware' => ['web', 'auth', 'language', 'adminmenu', 'permission:read-admin-panel'], 'prefix' => 'apps/offlinepayment', 'namespace' => 'Modules\OfflinePayment\Http\Controllers'], function () {
|
||||
Route::get('settings', 'Settings@edit');
|
||||
Route::post('settings', 'Settings@update');
|
||||
Route::post('settings/get', 'Settings@get');
|
||||
Route::post('settings/delete', 'Settings@delete');
|
||||
Route::group([
|
||||
'middleware' => 'admin',
|
||||
'prefix' => 'apps/offlinepayment',
|
||||
'namespace' => 'Modules\OfflinePayment\Http\Controllers'
|
||||
], function () {
|
||||
Route::get('settings', 'Settings@edit')->name('offlinepayment.edit');
|
||||
Route::post('settings', 'Settings@update')->name('offlinepayment.update');
|
||||
Route::post('settings/get', 'Settings@get')->name('offlinepayment.get');
|
||||
Route::post('settings/delete', 'Settings@delete')->name('offlinepayment.delete');
|
||||
});
|
||||
|
||||
Route::group(['middleware' => ['web', 'auth', 'language', 'customermenu', 'permission:read-customer-panel'], 'prefix' => 'customers', 'namespace' => 'Modules\OfflinePayment\Http\Controllers'], function () {
|
||||
Route::group([
|
||||
'middleware' => ['web', 'auth', 'language', 'customermenu', 'permission:read-customer-panel'],
|
||||
'prefix' => 'customers',
|
||||
'namespace' => 'Modules\OfflinePayment\Http\Controllers'
|
||||
], function () {
|
||||
Route::get('invoices/{invoice}/offlinepayment', 'OfflinePayment@show');
|
||||
Route::post('invoices/{invoice}/offlinepayment/confirm', 'OfflinePayment@confirm');
|
||||
});
|
||||
|
||||
Route::group(['middleware' => ['web', 'language'], 'prefix' => 'links', 'namespace' => 'Modules\OfflinePayment\Http\Controllers'], function () {
|
||||
Route::group([
|
||||
'middleware' => ['web', 'language'],
|
||||
'prefix' => 'links',
|
||||
'namespace' => 'Modules\OfflinePayment\Http\Controllers'
|
||||
], function () {
|
||||
Route::group(['middleware' => 'signed-url'], function () {
|
||||
Route::post('invoices/{invoice}/offlinepayment', 'OfflinePayment@link');
|
||||
Route::post('invoices/{invoice}/offlinepayment/confirm', 'OfflinePayment@confirm');
|
||||
|
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\OfflinePayment\Events\Handlers;
|
||||
namespace Modules\OfflinePayment\Listeners;
|
||||
|
||||
use App\Events\AdminMenuCreated;
|
||||
use Auth;
|
||||
use App\Events\AdminMenuCreated;
|
||||
|
||||
class OfflinePaymentAdminMenu
|
||||
{
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
@ -22,7 +23,7 @@ class OfflinePaymentAdminMenu
|
||||
// Add child to existing item
|
||||
$item = $event->menu->whereTitle(trans_choice('general.settings', 2));
|
||||
|
||||
$item->url('apps/offlinepayment/settings', trans('offlinepayment::offlinepayment.offlinepayment'), 4, ['icon' => 'fa fa-angle-double-right']);
|
||||
$item->url('apps/offlinepayment/settings', trans('offlinepayment::general.title'), 4, ['icon' => 'fa fa-angle-double-right']);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\OfflinePayment\Events\Handlers;
|
||||
namespace Modules\OfflinePayment\Listeners;
|
||||
|
||||
use App\Events\PaymentGatewayListing;
|
||||
|
@ -3,13 +3,12 @@
|
||||
namespace Modules\OfflinePayment\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Database\Eloquent\Factory;
|
||||
|
||||
use App\Events\AdminMenuCreated;
|
||||
use Modules\OfflinePayment\Events\Handlers\OfflinePaymentAdminMenu;
|
||||
use Modules\OfflinePayment\Listeners\OfflinePaymentAdminMenu;
|
||||
|
||||
use App\Events\PaymentGatewayListing;
|
||||
use Modules\OfflinePayment\Events\Handlers\OfflinePaymentGateway;
|
||||
use Modules\OfflinePayment\Listeners\OfflinePaymentGateway;
|
||||
|
||||
class OfflinePaymentServiceProvider extends ServiceProvider
|
||||
{
|
||||
@ -28,14 +27,10 @@ class OfflinePaymentServiceProvider extends ServiceProvider
|
||||
public function boot()
|
||||
{
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
$this->registerFactories();
|
||||
$this->registerMigrations();
|
||||
|
||||
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
|
||||
|
||||
$this->app['events']->listen(AdminMenuCreated::class, OfflinePaymentAdminMenu::class);
|
||||
$this->app['events']->listen(PaymentGatewayListing::class, OfflinePaymentGateway::class);
|
||||
$this->registerEvents();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -48,21 +43,6 @@ class OfflinePaymentServiceProvider extends ServiceProvider
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register config.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerConfig()
|
||||
{
|
||||
$this->publishes([
|
||||
__DIR__.'/../Config/config.php' => config_path('offlinepayment.php'),
|
||||
], 'config');
|
||||
$this->mergeConfigFrom(
|
||||
__DIR__.'/../Config/config.php', 'offlinepayment'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*
|
||||
@ -99,15 +79,15 @@ class OfflinePaymentServiceProvider extends ServiceProvider
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an additional directory of factories.
|
||||
* @source https://github.com/sebastiaanluca/laravel-resource-flow/blob/develop/src/Modules/ModuleServiceProvider.php#L66
|
||||
*/
|
||||
public function registerFactories()
|
||||
public function registerMigrations()
|
||||
{
|
||||
if (! app()->environment('production')) {
|
||||
app(Factory::class)->load(__DIR__ . '/Database/factories');
|
||||
}
|
||||
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
|
||||
}
|
||||
|
||||
public function registerEvents()
|
||||
{
|
||||
$this->app['events']->listen(AdminMenuCreated::class, OfflinePaymentAdminMenu::class);
|
||||
$this->app['events']->listen(PaymentGatewayListing::class, OfflinePaymentGateway::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
21
modules/OfflinePayment/Resources/lang/en-GB/general.php
Normal file
21
modules/OfflinePayment/Resources/lang/en-GB/general.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'title' => 'Offline Payments',
|
||||
|
||||
'add_new' => 'Add New',
|
||||
'edit' => 'Edit: :method',
|
||||
|
||||
'form' => [
|
||||
'code' => 'Code',
|
||||
'customer' => 'Show to Customer',
|
||||
'order' => 'Order'
|
||||
],
|
||||
|
||||
'payment_gateways' => 'Offline Payment Methods',
|
||||
|
||||
'confirm' => 'Confirm',
|
||||
'loading' => 'Loading',
|
||||
|
||||
];
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'offlinepayment' => 'Offline Payments',
|
||||
'add_new' => 'Add New',
|
||||
'edit' => 'Edit: :method',
|
||||
'code' => 'Code',
|
||||
'customer' => 'Show to Customer',
|
||||
'order' => 'Order',
|
||||
'payment_gateways' => 'Offline Payment Methods',
|
||||
|
||||
'confirm' => 'Confirm',
|
||||
'loading' => 'Loading',
|
||||
|
||||
];
|
@ -4,4 +4,4 @@
|
||||
<div class="well well-sm">
|
||||
{{ $gateway['description'] }}
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
|
@ -1,29 +1,29 @@
|
||||
@extends('layouts.admin')
|
||||
|
||||
@section('title', trans('offlinepayment::offlinepayment.offlinepayment'))
|
||||
@section('title', trans('offlinepayment::general.title'))
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="box box-success">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ trans('offlinepayment::offlinepayment.add_new') }}</h3>
|
||||
<h3 class="box-title">{{ trans('offlinepayment::general.add_new') }}</h3>
|
||||
<!-- /.box-tools -->
|
||||
</div>
|
||||
<!-- /.box-header -->
|
||||
|
||||
{!! Form::open(['url' => 'apps/offlinepayment/settings', 'files' => true, 'role' => 'form']) !!}
|
||||
{!! Form::open(['route' => 'offlinepayment.update', 'files' => true, 'role' => 'form', 'class' => 'form-loading-button']) !!}
|
||||
|
||||
<div class="box-body">
|
||||
<div id="install-loading"></div>
|
||||
|
||||
{{ Form::textGroup('name', trans('general.name'), 'id-card-o', ['required' => 'required'], null, 'col-md-12') }}
|
||||
|
||||
{{ Form::textGroup('code', trans('offlinepayment::offlinepayment.code'), 'key', ['required' => 'required'], null, 'col-md-12') }}
|
||||
{{ Form::textGroup('code', trans('offlinepayment::general.form.code'), 'key', ['required' => 'required'], null, 'col-md-12') }}
|
||||
|
||||
{{ Form::radioGroup('customer', trans('offlinepayment::offlinepayment.customer'), '', ['required' => 'required'], 0, 'col-md-12') }}
|
||||
{{ Form::radioGroup('customer', trans('offlinepayment::general.form.customer'), '', ['required' => 'required'], 0, 'col-md-12') }}
|
||||
|
||||
{{ Form::textGroup('order', trans('offlinepayment::offlinepayment.order'), 'sort', [], null, 'col-md-12') }}
|
||||
{{ Form::textGroup('order', trans('offlinepayment::general.form.order'), 'sort', [], null, 'col-md-12') }}
|
||||
|
||||
{{ Form::textareaGroup('description', trans('general.description')) }}
|
||||
</div>
|
||||
@ -38,22 +38,25 @@
|
||||
</div>
|
||||
<!-- /.box -->
|
||||
</div>
|
||||
|
||||
<div class="col-md-8">
|
||||
<!-- Default box -->
|
||||
<div class="box box-success">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ trans('offlinepayment::offlinepayment.payment_gateways') }}</h3>
|
||||
<h3 class="box-title">{{ trans('offlinepayment::general.payment_gateways') }}</h3>
|
||||
<!-- /.box-tools -->
|
||||
</div>
|
||||
<!-- /.box-header -->
|
||||
<div class="box-body">
|
||||
<div id="delete-loading"></div>
|
||||
|
||||
<div class="table table-responsive">
|
||||
<table class="table table-striped table-hover" id="tbl-items">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col-md-3">{{ trans('general.name') }}</th>
|
||||
<th class="col-md-4">{{ trans('offlinepayment::offlinepayment.code') }}</th>
|
||||
<th class="col-md-2 text-center">{{ trans('offlinepayment::offlinepayment.order') }}</th>
|
||||
<th class="col-md-4">{{ trans('offlinepayment::general.form.code') }}</th>
|
||||
<th class="col-md-2 text-center">{{ trans('offlinepayment::general.form.order') }}</th>
|
||||
<th class="col-md-3">{{ trans('general.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -86,13 +89,14 @@
|
||||
|
||||
@push('stylesheet')
|
||||
<style type="text/css">
|
||||
.install-loading-bar {
|
||||
#install-loading.active, #delete-loading.active {
|
||||
font-size: 35px;
|
||||
position: absolute;
|
||||
z-index: 500;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgb(136, 136, 136);
|
||||
opacity: 0.2;
|
||||
-moz-border-radius-bottomleft: 1px;
|
||||
@ -106,7 +110,11 @@
|
||||
position: absolute;
|
||||
margin: auto;
|
||||
color: #fff;
|
||||
padding: 28% 40%;
|
||||
padding: 45% 40%;
|
||||
}
|
||||
|
||||
#delete-loading .install-loading-spin {
|
||||
padding: 8% 40%;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
@ -115,22 +123,25 @@
|
||||
<script type="text/javascript">
|
||||
var text_yes = '{{ trans('general.yes') }}';
|
||||
var text_no = '{{ trans('general.no') }}';
|
||||
var code = '';
|
||||
var tr = '';
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.method-edit').on('click', function() {
|
||||
var code = $(this).attr('id').replace('edit-', '');
|
||||
code = $(this).attr('id').replace('edit-', '');
|
||||
|
||||
$.ajax({
|
||||
url: '{{ url("apps/offlinepayment/settings/get") }}',
|
||||
url: '{{ route("offlinepayment.get") }}',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {code: code},
|
||||
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
||||
beforeSend: function() {
|
||||
$('#install-loading').addClass('active');
|
||||
$('#install-loading').html('<span class="install-loading-bar"><span class="install-loading-spin"><i class="fa fa-spinner fa-spin"></i></span></span>');
|
||||
$('.install-loading-bar').css({"height": $('.col-md-4.no-padding-left').height() - 23});
|
||||
},
|
||||
complete: function() {
|
||||
$('#install-loading').removeClass('active');
|
||||
$('#install-loading .install-loading-bar').remove();
|
||||
},
|
||||
success: function(json) {
|
||||
@ -160,20 +171,30 @@
|
||||
});
|
||||
|
||||
$('.method-delete').on('click', function() {
|
||||
var code = $(this).attr('id').replace('delete-', '');
|
||||
code = $(this).attr('id').replace('delete-', '');
|
||||
tr = $(this).parent().parent();
|
||||
|
||||
$.ajax({
|
||||
url: '{{ url("apps/offlinepayment/settings/delete") }}',
|
||||
url: '{{ route("offlinepayment.delete") }}',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {code: code},
|
||||
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
||||
beforeSend: function() {
|
||||
$('#delete-loading').addClass('active');
|
||||
$('#delete-loading').html('<span class="install-loading-bar"><span class="install-loading-spin"><i class="fa fa-spinner fa-spin"></i></span></span>');
|
||||
},
|
||||
complete: function() {
|
||||
//$('#delete-loading').removeClass('active');
|
||||
//$('#delete-loading .install-loading-bar').remove();
|
||||
},
|
||||
success: function(json) {
|
||||
if (json['error']) {
|
||||
}
|
||||
|
||||
if (json['success']) {
|
||||
$('#method-' + code).remove();
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -5,9 +5,10 @@
|
||||
{{ $gateway['description'] }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="buttons">
|
||||
<div class="pull-right">
|
||||
<input type="button" value="{{ trans('offlinepayment::offlinepayment.confirm') }}" id="button-confirm" class="btn btn-success" data-loading-text="{{ trans('offlinepayment::offlinepayment.loading') }}" />
|
||||
<input type="button" value="{{ trans('offlinepayment::general.confirm') }}" id="button-confirm" class="btn btn-success" data-loading-text="{{ trans('offlinepayment::general.loading') }}" />
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript"><!--
|
||||
|
@ -5,9 +5,10 @@
|
||||
{{ $gateway['description'] }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="buttons">
|
||||
<div class="pull-right">
|
||||
<input type="button" value="{{ trans('offlinepayment::offlinepayment.confirm') }}" id="button-confirm" class="btn btn-success" data-loading-text="{{ trans('offlinepayment::offlinepayment.loading') }}" />
|
||||
<input type="button" value="{{ trans('offlinepayment::general.confirm') }}" id="button-confirm" class="btn btn-success" data-loading-text="{{ trans('offlinepayment::general.loading') }}" />
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript"><!--
|
||||
|
@ -2,8 +2,8 @@
|
||||
"name": "OfflinePayment",
|
||||
"alias": "offlinepayment",
|
||||
"description": "",
|
||||
"version": "1.0.0",
|
||||
"category": "payment-gateways",
|
||||
"version": "1.0.1",
|
||||
"category": "payment-gateway",
|
||||
"keywords": [],
|
||||
"active": 1,
|
||||
"order": 0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user