wip
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Ecommerce\Product\Order\Order;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
@@ -14,6 +15,12 @@ class OnlinePaymentController extends Controller
|
||||
'orderId' => ['required', 'string']
|
||||
]);
|
||||
|
||||
$resource = Order::query()->where('halkbank_id', $request->orderId)->first();
|
||||
|
||||
if (! $resource) {
|
||||
return $this->view(false, 'Sargyt tapylmady');
|
||||
}
|
||||
|
||||
$response = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatusExtended.do', [
|
||||
'language' => 'ru',
|
||||
'orderId' => $request->orderId,
|
||||
@@ -22,14 +29,7 @@ class OnlinePaymentController extends Controller
|
||||
]);
|
||||
|
||||
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',
|
||||
]);
|
||||
return $this->data(false, 'Näsazlyk, operator bilen habarlaşyň');
|
||||
}
|
||||
|
||||
$payment_status = $response['paymentAmountInfo']['depositedAmount'] > 0;
|
||||
@@ -37,25 +37,29 @@ class OnlinePaymentController extends Controller
|
||||
// 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',
|
||||
]);
|
||||
return $this->view(
|
||||
status: $payment_status,
|
||||
message: $payment_status ? 'Töleg geçdi' : 'Töleg geçmedi',
|
||||
pnr: $response['orderNumber'],
|
||||
price_amount: number_format($response['amount']),
|
||||
);
|
||||
}
|
||||
|
||||
public function view($data): View
|
||||
{
|
||||
public function view(
|
||||
$status = false,
|
||||
$message,
|
||||
string $pnr = '-',
|
||||
string $branch_name = 'MM.COM.TM',
|
||||
int|string $price_amount = '-',
|
||||
string $return_url = 'https://mm.com.tm/orders',
|
||||
): View {
|
||||
return view('oninepayment.status', [
|
||||
'success' => $data['success'],
|
||||
'title' => '',
|
||||
'pnr' => '',
|
||||
'branch_name' => '',
|
||||
'price_amount' => '',
|
||||
'return_url' => '',
|
||||
'success' => $status,
|
||||
'title' => $message,
|
||||
'pnr' => $pnr,
|
||||
'branch_name' => $branch_name,
|
||||
'price_amount' => $price_amount,
|
||||
'return_url' => $return_url,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user