diff --git a/modules/OfflinePayment/Http/Controllers/OfflinePayment.php b/modules/OfflinePayment/Http/Controllers/OfflinePayment.php index b8127da6d..075760465 100644 --- a/modules/OfflinePayment/Http/Controllers/OfflinePayment.php +++ b/modules/OfflinePayment/Http/Controllers/OfflinePayment.php @@ -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) { diff --git a/modules/OfflinePayment/Http/routes.php b/modules/OfflinePayment/Http/routes.php index 98282096e..c2c27f400 100644 --- a/modules/OfflinePayment/Http/routes.php +++ b/modules/OfflinePayment/Http/routes.php @@ -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'); + }); +}); diff --git a/modules/OfflinePayment/Resources/views/link.blade.php b/modules/OfflinePayment/Resources/views/link.blade.php new file mode 100644 index 000000000..9ddcc5455 --- /dev/null +++ b/modules/OfflinePayment/Resources/views/link.blade.php @@ -0,0 +1,39 @@ +