From 405ef7a69ceeb767a51ac187759737f8b6496a1b Mon Sep 17 00:00:00 2001 From: root Date: Fri, 20 Feb 2026 14:16:54 +0100 Subject: [PATCH] adjust link bank account functionality --- application/controllers/Gestion.php | 43 ++++++++++++++++---- application/views/gestion_agency_banking.php | 5 ++- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/application/controllers/Gestion.php b/application/controllers/Gestion.php index 8ec647aa..ebd13087 100755 --- a/application/controllers/Gestion.php +++ b/application/controllers/Gestion.php @@ -2721,15 +2721,20 @@ class Gestion extends CI_Controller public function validate_link_request() { if ($this->isLogged()) { $id = $this->input->post('id_transaction'); - $iban = $this->input->post('iban'); + $iban = $this->input->post('iban'); + + log_message('info', 'Validation de la demande de rattachement ID_transaction ' . $id); + + // Démarrage transaction + $this->db->trans_begin(); // Appel API - $url = WALLET_SERVICE_URL . '/wallets/users/validate_link_user_bank_account'; - + $url = WALLET_SERVICE_URL . '/wallets/users/validate_link_user_bank_account'; + log_message('info', 'URL API pour rattachement : ' . $url); $body = [ - 'iban' => $iban, - 'id_transaction' => $id + 'id_transaction' => $id, + 'iban' => $iban ]; $payload = json_encode($body); @@ -2745,16 +2750,38 @@ class Gestion extends CI_Controller )); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + // Désactivation SSL pour test local si besoin + // curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); + // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); + $result = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); + log_message('info', 'API Response for Link ID '.$id.' : HTTP Code = '.$httpCode.', Result = '.$result); + if ($result && ($httpCode >= 200 && $httpCode < 300)) { - echo json_encode(['success' => 'ok', 'message' => 'Rattachement validé avec succès.']); + $this->db->trans_commit(); + + // SUCCÈS + echo json_encode([ + 'success' => 'ok', + 'message' => 'Rattachement de compte validé avec succès.' + ]); + exit; + } else { + $this->db->trans_rollback(); log_message('error', 'Erreur API Link ID '.$id.' : '.$result); - echo json_encode(['success' => 'false', 'message' => 'Erreur API (' . $httpCode . ')', 'api_error' => $result]); - } json_encode(['success' => 'false', 'message' => 'Erreur DB Locale']); + + // ERREUR API + echo json_encode([ + 'success' => 'ok', + 'message' => 'Erreur API (' . $httpCode . ')', + 'api_error' => $result + ]); + exit; + } } } diff --git a/application/views/gestion_agency_banking.php b/application/views/gestion_agency_banking.php index db3fa3af..4dab6045 100755 --- a/application/views/gestion_agency_banking.php +++ b/application/views/gestion_agency_banking.php @@ -499,7 +499,7 @@ - + @@ -887,8 +887,9 @@ $(document).ready(function () { $("#btn-validate-link").prop('disabled', false).html('lang->line("btn_validate"); ?>'); } }, - error: function () { + error: function (error) { toastr.error("lang->line('error_server_500'); ?>"); + console.error("AJAX Error: ", error); $("#btn-validate-link").prop('disabled', false).html('lang->line("btn_validate"); ?>'); } });