wip
This commit is contained in:
@@ -348,6 +348,23 @@ if (! function_exists('calculateProductPriceAmount')) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Halkbank credentials
|
||||
*
|
||||
* @return int|string|array{username: int|string, password: string}
|
||||
*/
|
||||
function halkbankCredentials(string $key = ''): int|string|array
|
||||
{
|
||||
return match($key) {
|
||||
'username' => 516122500260,
|
||||
'password' => 'MrZsO9wfgWOBjf4',
|
||||
default => [
|
||||
'username' => 516122500260,
|
||||
'password' => 'MrZsO9wfgWOBjf4',
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create halkbank order
|
||||
*
|
||||
@@ -363,8 +380,8 @@ function createHalkbankOrder($price = 123): array
|
||||
'amount' => $price,
|
||||
'currency' => 934,
|
||||
'language' => 'ru',
|
||||
'userName' => 516122500260,
|
||||
'password' => 'MrZsO9wfgWOBjf4',
|
||||
'userName' => halkbankCredentials('username'),
|
||||
'password' => halkbankCredentials('password'),
|
||||
'returnUrl' => route('online-payment-store'),
|
||||
'pageView' => 'DESKTOP',
|
||||
'description' => 'MM.COM.TM',
|
||||
|
||||
61
app/Http/Controllers/OnlinePaymentController.php
Normal file
61
app/Http/Controllers/OnlinePaymentController.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class OnlinePaymentController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'orderId' => ['required', 'string']
|
||||
]);
|
||||
|
||||
$response = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatusExtended.do', [
|
||||
'language' => 'ru',
|
||||
'orderId' => $request->orderId,
|
||||
'userName' => halkbankCredentials('username'),
|
||||
'password' => halkbankCredentials('password'),
|
||||
]);
|
||||
|
||||
if ($response->failed()) {
|
||||
return $this->data([
|
||||
'success' => false,
|
||||
'title' => 'Näsazlyk, operator bilen habarlaşyň',
|
||||
'pnr' => '-',
|
||||
'branch_name' => 'MM.COM.TM',
|
||||
'price_amount' => '-',
|
||||
'return_url' => 'https://mm.com.tm/orders',
|
||||
]);
|
||||
}
|
||||
|
||||
$payment_status = $response['paymentAmountInfo']['depositedAmount'] > 0;
|
||||
|
||||
// Update resource
|
||||
$resource->update(['paid' => $payment_status]);
|
||||
|
||||
return $this->view([
|
||||
'success' => $payment_status,
|
||||
'title' => $payment_status ? 'Töleg geçdi' : 'Töleg geçmedi',
|
||||
'pnr' => $response['orderNumber'],
|
||||
'branch_name' => 'MM.COM.TM',
|
||||
'price_amount' => number_format($response['amount']),
|
||||
'return_url' => 'https://mm.com.tm/orders',
|
||||
]);
|
||||
}
|
||||
|
||||
public function view($data): View
|
||||
{
|
||||
return view('oninepayment.status', [
|
||||
'success' => $data['success'],
|
||||
'title' => '',
|
||||
'pnr' => '',
|
||||
'branch_name' => '',
|
||||
'price_amount' => '',
|
||||
'return_url' => '',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user