payment server

This commit is contained in:
gerchek 2022-04-09 09:06:52 +05:00
parent c275a5c9c8
commit 0dda789acb
4 changed files with 183 additions and 23 deletions

View File

@ -57,7 +57,7 @@ class Payment
//$http->noRedirect();
$http->timeout(3000);
$data = [
'orderNumber' => $id,
'orderNumber' => 'hb-'.$id,
'amount' => 1,//1tenne
'currency' => 934,
'description' => 'Täze plastik Kart almak üçin döwlet pajy.',
@ -67,8 +67,8 @@ class Payment
// 'failUrl' => route('paymentReturn', ['is_payment_cancelled' => 1])
//'returnUrl' => 'http://localhost:8000/card-application/payment-result/?is_payment_successful=1',
//'failUrl' => 'http://localhost:8000/card-application/payment-result/?is_payment_cancelled=1',
'returnUrl' => 'http://shahsyotag.halkbank.gov.tm/app/card-application/payment-result/?is_payment_successful=1',
'failUrl' => 'http://shahsyotag.halkbank.gov.tm/app/card-application/payment-result/?is_payment_cancelled=1',
'returnUrl' => 'https://shahsyotag.halkbank.gov.tm/payment-result?status=1&paymentId='.$id,
'failUrl' => 'https://shahsyotag.halkbank.gov.tm/payment-result?status=1&paymentId='.$id,
];
//Log:info($data);
$http->data($data);

View File

@ -7,10 +7,104 @@ use Atash\Contact\Models\ContactClass;
use Atash\Contact\Models\CreditClass;
use Atash\Contact\Models\OnlineCard as CardApp;
use Atash\Contact\Classes\Payment;
use Validator;
Route::group(['prefix' => 'api'], function() {
Route::post('reset', function (Request $request) {
$rules = [
'code' => 'required',
'password' => 'required|between:' . UserModel::getMinPasswordLength() . ',255'
];
$validation = Validator::make(post(), $rules);
if ($validation->fails()) {
throw new ValidationException($validation);
}
$errorFields = ['code' => Lang::get(/*Invalid activation code supplied.*/'rainlab.user::lang.account.invalid_activation_code')];
/*
* Break up the code parts
*/
$parts = explode('!', post('code'));
if (count($parts) != 2) {
throw new ValidationException($errorFields);
}
list($userId, $code) = $parts;
if (!strlen(trim($userId)) || !strlen(trim($code)) || !$code) {
throw new ValidationException($errorFields);
}
if (!$user = Auth::findUserById($userId)) {
throw new ValidationException($errorFields);
}
if (!$user->attemptResetPassword($code, post('password'))) {
throw new ValidationException($errorFields);
}
// Check needed for compatibility with legacy systems
if (method_exists(\RainLab\User\Classes\AuthManager::class, 'clearThrottleForUserId')) {
Auth::clearThrottleForUserId($user->id);
}
return response()->json([
'data' => 'success',
]);
});
Route::post('restore', function (Request $request) {
$rules = [
'email' => 'required|email|between:6,255'
];
$validation = Validator::make(post(), $rules);
if ($validation->fails()) {
throw new ValidationException($validation);
}
$user = UserModel::findByEmail(post('email'));
// if (!$user || $user->is_guest) {
// throw new ApplicationException(Lang::get(/*A user was not found with the given credentials.*/'rainlab.user::lang.account.invalid_user'));
// }
$code = implode('!', [$user->id, $user->getResetPasswordCode()]);
// $params = [
// $this->property('paramCode') => $code
// ];
// if ($pageName = $this->property('resetPage')) {
// $url = $this->pageUrl($pageName, $params);
// }
// else {
// $url = $this->currentPageUrl($params);
// }
// if (strpos($url, $code) === false) {
// $url .= '?reset=' . $code;
// }
// $link = $url;
$data = [
'name' => $user->name,
'username' => $user->username,
'link' => 'https://shahsyotag.halkbank.gov.tm/sign-in',
'code' => $code
];
Mail::send('rainlab.user::mail.restore', $data, function($message) use ($user) {
$message->to($user->email, $user->full_name);
});
return response()->json([
'data' => 'success',
]);
});
Route::post('login', function (Request $request) {
if (Settings::get('is_login_disabled'))
App::abort(404, 'Page not found');
@ -285,7 +379,7 @@ Route::group(['prefix' => 'api'], function() {
Mail::send('vdomah.jwtauth::mail.message', $vars, function($message) {
$message->to('digital.tps2018@@gmail.com', 'Admin Person');
$message->to('digital.tps2018@gmail.com', 'Admin Person');
$message->subject('This is a reminder');
});
@ -369,6 +463,63 @@ Route::group(['prefix' => 'api'], function() {
return Response::json(compact('data'));
})->middleware('\Tymon\JWTAuth\Middleware\GetUserFromToken');
// Check online payment successfull or failed
Route::get('check-payment', function() {
$payment_id = \Input::get('paymentId');
$payment = CardApp::find($payment_id);
$order_id = \Input::get('orderId');
if(is_null($payment)) {
return response()->json(['status' => 'not_found'], 404);
}
if($payment && \Input::get('status') === '1' && $order_id === $payment->order_id) {
$responce = json_decode(Payment::getOrderStatus($payment->order_id), true);
if( $responce['ErrorCode'] == 0
&& $responce['OrderStatus'] == 2) {
CardApp::where('order_id',$order_id)->update(['payed' => true]);
//todo mail send
try{
Mail::send('vdomah.jwtauth::mail.card', $payment->toArray(), function($message) {
$message->to('digital.tps2018@gmail.com', 'Admin Person');
// $message->subject('This is a reminder');
//$message->attach(
// $file->getRealPath(),array(
// 'as'=>$file->getClientOriginalName(),
// 'mime'=>$file->getMimeType()
// )
//);
});
} catch(\Throwable $e){
\Log::info($e);
return response()->json(['status' => 'success'], 201);
}
return response()->json(['status' => 'success'], 201);
} else {
return response()->json(['status' => 'failed'], 500);
}
} else {
return response()->json(['status' => 'failed'], 500);
}
});
Route::post('online_card', function() {
@ -410,24 +561,10 @@ Route::group(['prefix' => 'api'], function() {
// $data['file'] = \Input::file('file');
$application = CardApp::create($data);
Mail::send('vdomah.jwtauth::mail.card', $data, function($message) {
$message->to('digital.tps2018@gmail.com', 'Admin Person');
// $message->subject('This is a reminder');
//$message->attach(
// $file->getRealPath(),array(
// 'as'=>$file->getClientOriginalName(),
// 'mime'=>$file->getMimeType()
// )
//);
});
$application_id = time();
// dd($application->id);
$response = Payment::registerOrder('hb-'.$application->id);
$response = Payment::registerOrder($application->id);
// dd($response);
// if($response)
@ -456,7 +593,8 @@ Mail::send('vdomah.jwtauth::mail.card', $data, function($message) {
$application->order_id = $result['orderId'];
$application->save();
// $this->sendNotification($application);
return Redirect::to($result['formUrl']);
return response()->json($result['formUrl'], 201);
//return Redirect::to($result['formUrl']);
}
else{
throw new AjaxException($result['errorMessage']);
@ -464,7 +602,7 @@ Mail::send('vdomah.jwtauth::mail.card', $data, function($message) {
}
return Response::json(compact('data'));
//return Redirect::to($result['formUrl']);
})->middleware('\Tymon\JWTAuth\Middleware\GetUserFromToken');
});

View File

@ -0,0 +1,22 @@
subject = "Requested Password Reset"
description = "User requests a password reset"
==
Hello {{ name }}
Somebody has requested a password reset for your account, if this was not you, please ignore this email.
Use this activation code to restore your password:
{% partial 'promotion' body %}
{{ code }}
{% endpartial %}
You can use the following link:
{% partial 'button' url=link type='positive' body %}
Restore password
{% endpartial %}
{% partial 'subcopy' body %}
**This is an automatic message. Please do not reply to it.**
{% endpartial %}

View File

@ -1,2 +1,2 @@
<h1>The demo</h1>
<p>This is the <a href="http://octobercms.com">October CMS</a> demo theme that explores the core features. You will find files used by this theme in the <strong>themes/demo</strong> directory of your installation.</p>
<p>This is 123 the <a href="http://octobercms.com">October CMS</a> demo theme that explores the core features. You will find files used by this theme in the <strong>themes/demo</strong> directory of your installation.</p>