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('= $this->lang->line("btn_validate"); ?>');
}
},
- error: function () {
+ error: function (error) {
toastr.error("= $this->lang->line('error_server_500'); ?>");
+ console.error("AJAX Error: ", error);
$("#btn-validate-link").prop('disabled', false).html('= $this->lang->line("btn_validate"); ?>');
}
});