wip
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Events\EventType;
|
use App\Events\EventType;
|
||||||
|
use App\Models\Payment\OnlinePaymentHistory;
|
||||||
use App\Models\System\Roles\Permission;
|
use App\Models\System\Roles\Permission;
|
||||||
use App\Models\System\Verification;
|
use App\Models\System\Verification;
|
||||||
use App\Nova\Resources\Order\Card\CardTransaction\Actions\DownloadCardTransaction;
|
use App\Nova\Resources\Order\Card\CardTransaction\Actions\DownloadCardTransaction;
|
||||||
@@ -9,6 +10,7 @@ use GuzzleHttp\Psr7\Request as GuzzleRequest;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Stevebauman\Location\Facades\Location;
|
use Stevebauman\Location\Facades\Location;
|
||||||
@@ -392,3 +394,88 @@ function emptyClass(...$arguments): object
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check online payment
|
||||||
|
*
|
||||||
|
* @param string $orderId
|
||||||
|
* @param int|string $username
|
||||||
|
* @param string $password
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function checkOnlinePayment(string $orderId, int|string $username, string $password): mixed
|
||||||
|
{
|
||||||
|
$response = Http::asForm()->post('https://mpi.gov.tm/payment/rest/getOrderStatusExtended.do', [
|
||||||
|
'language' => 'ru',
|
||||||
|
'orderId' => $orderId,
|
||||||
|
'userName' => $username,
|
||||||
|
'password' => $password,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sync with bank system
|
||||||
|
*
|
||||||
|
* @param string $online_payment_order_uuid
|
||||||
|
* @param string $bank_unique_code
|
||||||
|
* @param string $online_payment_terminal_id
|
||||||
|
* @param string $user_deposit_account
|
||||||
|
* @param string $online_payment_auth_ref_num
|
||||||
|
* @param string $online_payment_tmt_amount
|
||||||
|
* @param string $pay_purpose
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function syncWithBankSystem(
|
||||||
|
$online_payment_order_uuid,
|
||||||
|
$bank_unique_code,
|
||||||
|
$online_payment_terminal_id,
|
||||||
|
$user_deposit_account,
|
||||||
|
$online_payment_auth_ref_num,
|
||||||
|
$online_payment_tmt_amount,
|
||||||
|
$pay_purpose
|
||||||
|
): mixed
|
||||||
|
{
|
||||||
|
$ecomId = $online_payment_order_uuid;
|
||||||
|
$agentId = $bank_unique_code;
|
||||||
|
$eposId = $online_payment_terminal_id;
|
||||||
|
$account = $user_deposit_account;
|
||||||
|
$rrn = $online_payment_auth_ref_num;
|
||||||
|
$amount = $online_payment_tmt_amount;
|
||||||
|
$payPurpose = $pay_purpose;
|
||||||
|
|
||||||
|
$curl = curl_init();
|
||||||
|
|
||||||
|
curl_setopt_array($curl, [
|
||||||
|
CURLOPT_URL => 'http://10.3.158.102:8888/api/paytrn/new',
|
||||||
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
|
CURLOPT_ENCODING => '',
|
||||||
|
CURLOPT_MAXREDIRS => 10,
|
||||||
|
CURLOPT_TIMEOUT => 0,
|
||||||
|
CURLOPT_FOLLOWLOCATION => true,
|
||||||
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||||
|
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||||
|
CURLOPT_POSTFIELDS => sprintf('{
|
||||||
|
"ecomId": "%s",
|
||||||
|
"agentId": "%s",
|
||||||
|
"eposId": "%s",
|
||||||
|
"account": "%s",
|
||||||
|
"rrn": "%s",
|
||||||
|
"amount": "%s",
|
||||||
|
"payPurpose": "%s"
|
||||||
|
}', $ecomId, $agentId, $eposId, $account, $rrn, $amount, $payPurpose),
|
||||||
|
CURLOPT_HTTPHEADER => [
|
||||||
|
'Authorization: Basic YWRtaW46UUFad3N4MTIz',
|
||||||
|
'Content-Type: application/json',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = curl_exec($curl);
|
||||||
|
|
||||||
|
curl_close($curl);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|||||||
@@ -73,47 +73,4 @@ class OnlinePaymentController extends Controller
|
|||||||
|
|
||||||
return view(OnlinePaymentRepo::statusView(), $data);
|
return view(OnlinePaymentRepo::statusView(), $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runActions($paymentHistory, $bank, $response, $resource): void
|
|
||||||
{
|
|
||||||
$ecomId = $paymentHistory->orderId;
|
|
||||||
$agentId = $bank->unique_code;
|
|
||||||
$eposId = $response['terminalId'];
|
|
||||||
$account = $resource->parent->sender_datas[0]['deposit_account'];
|
|
||||||
$rrn = $response['authRefNum'];
|
|
||||||
$amount = $resource->tmt_payment_amount;
|
|
||||||
$payPurpose = $resource->created_at->translatedFormat('F').' '.$resource->created_at->format('Y');
|
|
||||||
|
|
||||||
$curl = curl_init();
|
|
||||||
|
|
||||||
curl_setopt_array($curl, [
|
|
||||||
CURLOPT_URL => 'http://10.3.158.102:8888/api/paytrn/new',
|
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
|
||||||
CURLOPT_ENCODING => '',
|
|
||||||
CURLOPT_MAXREDIRS => 10,
|
|
||||||
CURLOPT_TIMEOUT => 0,
|
|
||||||
CURLOPT_FOLLOWLOCATION => true,
|
|
||||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
||||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
|
||||||
CURLOPT_POSTFIELDS => sprintf('{
|
|
||||||
"ecomId": "%s",
|
|
||||||
"agentId": "%s",
|
|
||||||
"eposId": "%s",
|
|
||||||
"account": "%s",
|
|
||||||
"rrn": "%s",
|
|
||||||
"amount": "%s",
|
|
||||||
"payPurpose": "%s"
|
|
||||||
}', $ecomId, $agentId, $eposId, $account, $rrn, $amount, $payPurpose),
|
|
||||||
CURLOPT_HTTPHEADER => [
|
|
||||||
'Authorization: Basic YWRtaW46UUFad3N4MTIz',
|
|
||||||
'Content-Type: application/json',
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
$response = curl_exec($curl);
|
|
||||||
|
|
||||||
curl_close($curl);
|
|
||||||
|
|
||||||
info($response);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Nova\Actions\Sber;
|
namespace App\Nova\Actions\Sber;
|
||||||
|
|
||||||
|
use App\Models\Payment\OnlinePaymentHistory;
|
||||||
|
use App\Nova\Actions\CheckOnlinePayment;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Laravel\Nova\Actions\Action;
|
use Laravel\Nova\Actions\Action;
|
||||||
|
use Laravel\Nova\Actions\ActionResponse;
|
||||||
use Laravel\Nova\Fields\ActionFields;
|
use Laravel\Nova\Fields\ActionFields;
|
||||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||||
|
|
||||||
@@ -30,7 +33,41 @@ class SyncWithSystem extends Action
|
|||||||
*/
|
*/
|
||||||
public function handle(ActionFields $fields, Collection $models)
|
public function handle(ActionFields $fields, Collection $models)
|
||||||
{
|
{
|
||||||
//
|
/** @var \App\Modules\SberPaymentOrder\Models\SberPaymentOrderItem $item */
|
||||||
|
$item = $models->first();
|
||||||
|
|
||||||
|
/** @var \App\Models\Payment\OnlinePaymentHistory $onlinePaymentResource */
|
||||||
|
$onlinePaymentResource = OnlinePaymentHistory::find($item->online_payment_history_id);
|
||||||
|
|
||||||
|
if (! $onlinePaymentResource) {
|
||||||
|
return ActionResponse::danger('Online payment resource tapylmady');
|
||||||
|
}
|
||||||
|
|
||||||
|
$relatedResource = (new $onlinePaymentResource->online_paymantable_type)
|
||||||
|
->find(id: $onlinePaymentResource->online_paymantable_id);
|
||||||
|
|
||||||
|
if (! $relatedResource) {
|
||||||
|
return ActionResponse::danger('Bu resource tapylmady');
|
||||||
|
}
|
||||||
|
|
||||||
|
$username = $relatedResource->branch->billing_sber_username;
|
||||||
|
$password = $relatedResource->branch->billing_sber_password;
|
||||||
|
|
||||||
|
if ($username == '') {
|
||||||
|
return Action::modal('modal-response', [
|
||||||
|
'title' => 'HALKBANK API',
|
||||||
|
'body' => 'Ulanyjy ady bilen açar sözi gabat gelmedi',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = checkOnlinePayment($onlinePaymentResource->orderId, $username, $password);
|
||||||
|
|
||||||
|
// syncWithBankSystem();
|
||||||
|
|
||||||
|
return Action::modal('modal-response', [
|
||||||
|
'title' => 'HALKBANK API',
|
||||||
|
'html' => CheckOnlinePayment::resultHTML($response),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user