Offlinepayment compability invoice unique link feature
This commit is contained in:
@ -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');
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user