wip
This commit is contained in:
@@ -34,61 +34,13 @@ class SyncWithSystem extends Action
|
||||
/** @var \App\Modules\SberPaymentOrder\Models\SberPaymentOrderItem $orderItem */
|
||||
$orderItem = $models->first();
|
||||
|
||||
$result = getSberCredentials($orderItem);
|
||||
syncWithAzatAPI($orderItem);
|
||||
|
||||
if (isset($result['error'])) {
|
||||
$this->handleError($result);
|
||||
return $this->handleError($result);
|
||||
}
|
||||
|
||||
/** @var \App\Models\Payment\OnlinePaymentHistory $onlinePaymentResource */
|
||||
$onlinePaymentResource = $result['onlinePaymentResource'];
|
||||
|
||||
/** @var \App\Modules\SberPaymentOrder\Models\SberPaymentOrder $sberPaymentOrder */
|
||||
$sberPaymentOrder = $result['relatedResource'];
|
||||
|
||||
$response = checkOnlinePayment($onlinePaymentResource->orderId, $result['username'], $result['password']);
|
||||
|
||||
if ($response['errorCode'] != 0) {
|
||||
return Action::modal('modal-response', [
|
||||
'title' => 'HALKBANK API',
|
||||
'body' => $response['errorMessage'],
|
||||
]);
|
||||
}
|
||||
|
||||
$systemRawResponse = syncWithBankSystem(
|
||||
online_payment_order_uuid: $onlinePaymentResource->orderId,
|
||||
bank_unique_code: $sberPaymentOrder->branch->unique_code,
|
||||
online_payment_terminal_id: $response['terminalId'],
|
||||
user_deposit_account: number_format($sberPaymentOrder->sender_deposit_account, 0, '', ''),
|
||||
online_payment_auth_ref_num: $response['authRefNum'],
|
||||
online_payment_tmt_amount: $orderItem->tmt_payment_amount,
|
||||
pay_purpose: $orderItem->created_at->translatedFormat('F').' '.$orderItem->created_at->format('Y')
|
||||
);
|
||||
|
||||
if ($systemRawResponse == null) {
|
||||
return Action::modal('modal-response', [
|
||||
'title' => 'SYSTEM API',
|
||||
'body' => 'Connection issue to SYSTEM',
|
||||
]);
|
||||
}
|
||||
|
||||
$systemResponse = json_decode($systemRawResponse);
|
||||
|
||||
$success = false;
|
||||
if (is_object($systemResponse)) {
|
||||
$success = $systemResponse->errCode == 0;
|
||||
} else {
|
||||
$success = $systemResponse['errCode'] == 0;
|
||||
}
|
||||
|
||||
$orderItem->update([
|
||||
'synced_with_system' => $success ? true : false,
|
||||
]);
|
||||
|
||||
return Action::modal('modal-response', [
|
||||
'title' => 'SYSTEM API',
|
||||
'html' => $success ? 'Success' : 'Fail',
|
||||
]);
|
||||
return ActionResponse::message('Sync with system success');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user