diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 89aad30e2f5da..aabc9ae7beda6 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -550,13 +550,17 @@ $db->begin(); + if (empty($newcu)) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; + } else { $sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account"; $sql.= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."'"; $sql.= " WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! - + } + $resql = $db->query($sql); $num = $db->num_rows($resql); - if (empty($num)) + if (empty($num) && !empty($newcu)) { $societeaccount = new SocieteAccount($db); $societeaccount->fk_soc = $object->id;