Commit a7c2e56c authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Erreur d'envoi : Gestion de l'erreur d'envoi vers ESUP et ajout d'un cas...

Erreur d'envoi : Gestion de l'erreur d'envoi vers ESUP et ajout d'un cas particulier pour permettre la relance
+ On test un retour d'entier côté ESUP (stoqué sous forme de chaîne)
parent 06290bf2
Loading
Loading
Loading
Loading
Loading
+18
Changes for src/Service/ProcessService.php: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -263,6 +263,7 @@ class ProcessService
     */
    public function trigger(Process $process, bool $forceFirstSend = false): void
    {
        $this->getLoggerService()->info("-------------------------------------------------");
        $this->getLoggerService()->info("trigger $process : " . $process->getStatusText());
        $this->getLoggerService()->info("step : " . $process->getCurrentStep());
        if( $process->getCurrentStep() === 0 ){
@@ -292,15 +293,32 @@ class ProcessService

        // Envoi (etape 1)
        if ($process->isTriggerable()) {
            $this->getLoggerService()->info(" ! Triggerable");
            try {
                $processStep = $process->getStep();

                $this->getLoggerService()->info(" - processStep: $processStep");
                $this->getLoggerService()->info(" - processStep statut: ".$processStep->getStatusText());

                if ($processStep->getStatus() == Signature::STATUS_SIGNATURE_DRAFT) {
                    $this->getSignatureService()->sendSignature($processStep->getSignature());
                    $this->triggerProcessEvent($process, ProcessEvent::EVENT_TYPE_STEP);
                    return;
                }

                if ($processStep->getStatus() == Signature::STATUS_SIGNATURE_ERROR) {
                    // On se base sur le REMOTEID pour déterminer
                    // si on a bien un document envoyé
                    if( !$processStep->getSignature()->getDocumentRemotekey()) {
                        $this->getLoggerService()->info(" - processStep en erreur sans REMOTEID, on réenvoi");
                        $this->getSignatureService()->sendSignature($processStep->getSignature());
                        $this->triggerProcessEvent($process, ProcessEvent::EVENT_TYPE_STEP);
                        return;
                    }
                    // Si on a un remoteID, le status d'erreur
                    // est lié à un retour d'erreur du parapheur
                }

                $this->getSignatureService()->updateStatusSignature($processStep->getSignature());

                if ($processStep->getStatus() == Signature::STATUS_SIGNATURE_REJECT) {
+2 −2
Changes for src/Service/SignatureService.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -592,7 +592,7 @@ class SignatureService
                        "[update] Impossible de mettre à jour le statut depuis le parapheur : "
                        . $e->getMessage()
                    );
                    throw new SignatureException("Impossible de mettre à jour le statut depuis le parapheur");
                    throw new SignatureException("Impossible de mettre à jour le statut depuis le parapheur : " . $e->getMessage());
                }

                $statusChanged = $signature->getStatus() !== $status;
@@ -973,7 +973,7 @@ class SignatureService
                $this->getLoggerService()->critical($msg . " : " . $e->getMessage());
                $signature->setStatus(Signature::STATUS_SIGNATURE_ERROR);
                $this->getObjectManager()->flush();
                throw new SignatureException($msg);
                throw new SignatureException($e->getMessage());
            }

            // Enregistrement des informations d'envoi en local
+7
Changes for src/Strategy/Letterfile/Esup/EsupLetterfileStrategy.php: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -111,6 +111,13 @@ class EsupLetterfileStrategy implements ILetterfileStrategy

    public function getSignatureInfos(Signature $signature): ResponseInfos
    {
        $remoteKey = $signature->getDocumentRemotekey();

        if (!ctype_digit((string) $remoteKey) || (int) $remoteKey <= 0) {
            $msg = "Signature : L'identifiant de document '".$signature->getDocumentRemotekey()."' enregistré est invalide, contactez l'administrateur pour relancer le processus.";
            $this->getLoggerService()->error("Bad ESUP ID stored : '" . $signature->getDocumentRemotekey() . "'");
            throw new SignatureCurlException($msg);
        }
        return $this->getSignRequestInfo($signature->getDocumentRemotekey());
    }

+6 −1
Changes for src/Strategy/Letterfile/Tools/CurlAccess.php: 6 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ class CurlAccess
        $this->logger->debug("CURL [post] $url");
        $this->headers[] = 'User-Agent: Opera/9.80 (Windows NT 6.2; Win64; x64) Presto/2.12.388 Version/12.15';
        $this->headers[] = 'Referer: http://someaddress.tld';
        $this->headers[] = 'Content-Type: multipart/form-data';
        // $this->headers[] = 'Content-Type: multipart/form-data';
        $posted = $post;
        foreach ($documents as $key=>$path) {
            $cfile = curl_file_create($path,'application/pdf',$key);
@@ -128,6 +128,11 @@ class CurlAccess
        curl_setopt($curl, CURLOPT_POSTFIELDS, $posted); // post images
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); // if any redirection after upload

        // DEBUG (En cas de proxy capricieux)
        // curl_setopt($curl, CURLOPT_PROXY, '');
        // curl_setopt($curl, CURLOPT_VERBOSE, true);


        $result=curl_exec ($curl);

        $this->archive($result, $url, $posted);