wip
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Nova\Actions\Sber;
|
||||
|
||||
use App\Models\Payment\OnlinePaymentHistory;
|
||||
use App\Nova\Actions\CheckOnlinePayment;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
@@ -36,35 +35,16 @@ class SyncWithSystem extends Action
|
||||
/** @var \App\Modules\SberPaymentOrder\Models\SberPaymentOrderItem $item */
|
||||
$item = $models->first();
|
||||
|
||||
$result = getSberCredentials($item);
|
||||
|
||||
if (isset($result['error'])) {
|
||||
$this->handleError($result);
|
||||
}
|
||||
|
||||
/** @var \App\Models\Payment\OnlinePaymentHistory $onlinePaymentResource */
|
||||
$onlinePaymentResource = OnlinePaymentHistory::find($item->online_payment_history_id);
|
||||
$onlinePaymentResource = $result['onlinePaymentResource'];
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
if (! $relatedResource->branch) {
|
||||
return ActionResponse::danger('Şahamça bilen birikdirilmedik');
|
||||
}
|
||||
|
||||
$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);
|
||||
$response = checkOnlinePayment($onlinePaymentResource->orderId, $result['username'], $result['password']);
|
||||
|
||||
// syncWithBankSystem();
|
||||
|
||||
@@ -84,4 +64,21 @@ class SyncWithSystem extends Action
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle error
|
||||
*
|
||||
* @param array $result
|
||||
*/
|
||||
private function handleError(array $result): mixed
|
||||
{
|
||||
if ($result['type'] === 'modal') {
|
||||
return Action::modal('modal-response', [
|
||||
'title' => 'HALKBANK API',
|
||||
'body' => $result['error'],
|
||||
]);
|
||||
}
|
||||
|
||||
return ActionResponse::danger($result['error']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user