Offlinepayment compability invoice unique link feature
This commit is contained in:
parent
3ba1dcbf51
commit
12aa503cf0
@ -12,6 +12,7 @@ use App\Http\Requests\Customer\InvoicePayment as PaymentRequest;
|
||||
use App\Http\Requests\Customer\InvoiceConfirm as ConfirmRequest;
|
||||
|
||||
use App\Models\Income\Invoice;
|
||||
use SignedUrl;
|
||||
|
||||
class OfflinePayment extends Controller
|
||||
{
|
||||
@ -45,6 +46,38 @@ class OfflinePayment extends Controller
|
||||
'html' => $html,
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param Invoice
|
||||
* @param PaymentRequest
|
||||
* @return Response
|
||||
*/
|
||||
public function link(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;
|
||||
}
|
||||
}
|
||||
|
||||
$confirm_action = SignedUrl::sign(url('links/invoices/' . $invoice->id . '/offlinepayment/confirm'), 1);
|
||||
|
||||
$html = view('offlinepayment::link', compact('gateway', 'invoice', 'confirm_action'))->render();
|
||||
|
||||
return response()->json([
|
||||
'code' => $gateway['code'],
|
||||
'name' => $gateway['name'],
|
||||
'description' => $gateway['description'],
|
||||
'redirect' => false,
|
||||
'html' => $html,
|
||||
]);
|
||||
}
|
||||
|
||||
public function confirm(Invoice $invoice, Request $request)
|
||||
{
|
||||
|
@ -11,3 +11,10 @@ Route::group(['middleware' => ['web', 'auth', 'language', 'customermenu', 'permi
|
||||
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' => 'signed-url'], function () {
|
||||
Route::post('invoices/{invoice}/offlinepayment', 'OfflinePayment@link');
|
||||
Route::post('invoices/{invoice}/offlinepayment/confirm', 'OfflinePayment@confirm');
|
||||
});
|
||||
});
|
||||
|
39
modules/OfflinePayment/Resources/views/link.blade.php
Normal file
39
modules/OfflinePayment/Resources/views/link.blade.php
Normal file
@ -0,0 +1,39 @@
|
||||
<h2>{{ $gateway['name'] }}</h2>
|
||||
|
||||
@if ($gateway['description'])
|
||||
<div class="well well-sm">
|
||||
{{ $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') }}" />
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript"><!--
|
||||
$('#button-confirm').on('click', function() {
|
||||
$.ajax({
|
||||
url: '{!! urldecode($confirm_action) !!}',
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
data: {payment_method: '{{ $gateway['code'] }}'},
|
||||
cache: false,
|
||||
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
||||
beforeSend: function() {
|
||||
$('#button-confirm').button('loading');
|
||||
},
|
||||
complete: function() {
|
||||
$('#button-confirm').button('reset');
|
||||
},
|
||||
success: function(data) {
|
||||
if (data['error']) {
|
||||
alert(data['error']);
|
||||
}
|
||||
|
||||
if (data['success']) {
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
//--></script>
|
Loading…
x
Reference in New Issue
Block a user