This commit is contained in:
2024-01-28 20:11:32 +05:00
parent a592a1ba8f
commit 0e970d7e23
4 changed files with 29 additions and 46 deletions

View File

@@ -13,39 +13,36 @@ class OnlinePaymentRepo
{
/**
* Pay card order
*
* @param [type] $resource
*/
public function payCardOrder($resource): array
{
$orderNumber = $this->generateOrderNumber($resource);
try {
$paymentResponse = Http::get('https://mpi.gov.tm/payment/rest/register.do', [
'orderNumber' => $orderNumber,
'amount' => "00" . $resource->priceAmount(),
'currency' => 934,
'language' => 'ru',
'userName' => $resource->branch->billing_username,
'password' => $resource->branch->billing_password,
'returnUrl' => urlencode(route('online-payment-store')),
'pageView' => 'DESKTOP',
'description' => urlencode('Kart tölegi'),
]);
} catch(Exception $exception) {
Log::channel('halkbank_payment_error')->error('Payment error', [
'response' => [
'body' => $paymentResponse->body(),
],
'exception' => [
'file' => $exception->getFile(),
'line' => $exception->getLine(),
'message' => $exception->getMessage(),
]
]);
$paymentResponse = Http::get('https://mpi.gov.tm/payment/rest/register.do', [
'orderNumber' => $orderNumber,
'amount' => '00'.$resource->priceAmount(),
'currency' => 934,
'language' => 'ru',
'userName' => $resource->branch->billing_username,
'password' => $resource->branch->billing_password,
'returnUrl' => urlencode(route('online-payment-store')),
'pageView' => 'DESKTOP',
'description' => urlencode('Kart tölegi'),
])->onError(function ($response) {
Log::channel('halkbank_payment_error')
->error('Payment error', [
'response' => [
'body' => $response->body(),
],
]);
});
if ($paymentResponse->failed()) {
return [
'status' => 'success',
'url' => ''
'status' => 'failed',
'url' => '',
];
}
@@ -61,12 +58,12 @@ class OnlinePaymentRepo
'errorUrl' => route('online-payment-store'),
'api_client' => config('app.url'),
'username' => $resource->branch->billing_username,
'paymentStatus' => OrderRepo::PENDING
'paymentStatus' => OrderRepo::PENDING,
]);
return [
'status' => 'success',
'url' => $paymentResponse['formUrl']
'url' => $paymentResponse['formUrl'],
];
}