Skip to content

Commit

Permalink
fixed controller issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aemaddin committed Nov 28, 2019
1 parent 0aaff25 commit b9f9d10
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
5 changes: 3 additions & 2 deletions config/knet.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
| The merchant URL where Payment Gateway send the authorization response
|
*/
'response_url' => env('KENT_RESPONSE_URL', '/knet/response'),
'response_url' => env('KENT_RESPONSE_URL') ?? url('/knet/response'),

/*
|--------------------------------------------------------------------------
Expand All @@ -56,7 +56,8 @@
| error while processing the transaction.
|
*/
'error_url' => env('KENT_ERROR_URL', '/knet/error'),
'error_url' => env('KENT_ERROR_URL') ?? url('/knet/error'),
'success_url' => env('KENT_SUCCESS_URL', '/'),

/*
|--------------------------------------------------------------------------
Expand Down
9 changes: 2 additions & 7 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
use Illuminate\Support\Facades\Route;

Route::prefix('knet')->group(function () {
Route::post('/response', 'Asciisd\Knet\Http\Controllers\KnetController@response')->name('knet.response');

Route::middleware('auth')->group(function() {
Route::get('/', 'Asciisd\Knet\Http\Controllers\KnetController@index')->name('knet');
Route::post('/', 'Asciisd\Knet\Http\Controllers\KnetController@charge')->name('knet.charge');
Route::post('/error', 'Asciisd\Knet\Http\Controllers\KnetController@error')->name('knet.error');
});
Route::post('/response', 'Asciisd\Knet\Http\Controllers\KnetController@handleKnet')->name('knet.response');
Route::post('/error', 'Asciisd\Knet\Http\Controllers\KnetController@error')->name('knet.error');
});
5 changes: 5 additions & 0 deletions src/HasKnet.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ public function pay($amount, array $options = [])

return $payment;
}

public function knetTransactions()
{
return $this->hasMany(KnetTransaction::class);
}
}
7 changes: 1 addition & 6 deletions src/Http/Controllers/KnetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function handleKnet(Request $request)
*/
protected function successMethod($parameters = [])
{
return Response('knet response handled', 200);
return redirect(config('knet.success_url'));
}

/**
Expand All @@ -63,9 +63,4 @@ protected function missingMethod($parameters = [])
{
return new Response;
}

public function charge(Request $request)
{
return $request->user()->pay($request->input('amount'));
}
}
4 changes: 2 additions & 2 deletions src/KnetTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class KnetTransaction extends Model
* @var array
*/
protected $fillable = [
'error_text', 'paymentid', 'paid', 'result', 'auth', 'avr', 'ref', 'tranid', 'postdate', 'trackid',
'udf1', 'udf2', 'udf3', 'udf4', 'udf5', 'amt', 'error', 'auth_resp_code', 'livemode', 'trackid'
'user_id', 'error_text', 'paymentid', 'paid', 'result', 'auth', 'avr', 'ref', 'tranid', 'postdate', 'trackid',
'udf1', 'udf2', 'udf3', 'udf4', 'udf5', 'amt', 'error', 'auth_resp_code', 'livemode', 'trackid', 'url'
];

/**
Expand Down

0 comments on commit b9f9d10

Please sign in to comment.