Saltar a contenido

Inicio Rápido

Puede realizar su primer timbrado siguiendo estos pasos. Consulte la referencia del servicio Web para más información. Para este proceso, utilizaremos el XML de Ingreso con CFDI Relacionados del siguiente ejemplo.

<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://csfacturacion.com/cd/prueba/timbre4/timbrarv5",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "<cfdi:Comprobante> </cfdi:Comprobante>",
  CURLOPT_HTTPHEADER => [
    "Content-Type: text/xml",
    "pwdws: $user",
    "tipo: TIMBRE",
    "usrws:$pass"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
HttpRequest request = HttpRequest.newBuilder()
  .uri(URI.create("https://csfacturacion.com/cd/prueba/timbre4/timbrarv5"))
  .header("usrws", "USER")
  .header("pwdws", "PASSWD")
  .header("tipo", "TIMBRE")
  .header("Content-Type", "text/xml")
  .method("POST", HttpRequest.BodyPublishers.ofString("<cfdi:Comprobante> </cfdi:Comprobante>"))
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
var client = new RestClient("https://csfacturacion.com/cd/prueba/timbre4/timbrarv5");
var request = new RestRequest(Method.POST);
request.AddHeader("usrws", "USER");
request.AddHeader("pwdws", "PASSWD");
request.AddHeader("tipo", "TIMBRE");
request.AddHeader("Content-Type", "text/xml");
request.AddParameter("text/xml", "<cfdi:Comprobante> </cfdi:Comprobante>", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
curl --request POST \
  --url https://csfacturacion.com/cd/timbre4/timbrarv5 \
  --header 'Content-Type: text/xml' \
  --header 'pwdws: password' \
  --header 'tipo: XML' \
  --header 'usrws: user' \
  --data '<cfdi:Comprobante> </cfdi:Comprobante> 
POST /timbre4/timbrarv5 HTTP/1.1
Usrws: user
Pwdws: password
Tipo: XML
Content-Type: text/xml
Host: csfacturacion.com
Content-Length: 5132
<cfdi:Comprobante> </cfdi:Comprobante> 

Respuesta:

A continuación, se muestra un ejemplo de la respuesta del servicio con un timbre (es decir, el CFDI paso todas las validaciones):

HTTP/1.1 200 OK
Server: nginx/1.19.2
Date: Mon, 31 Jan 2022 19:34:30 GMT
Content-Type: text/plain; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
uuid: C9BB6983-6261-D449-8B44-BD8B57AC926E
codigo: 000
Strict-Transport-Security: max-age=31536000; includeSubDomains

Timbre Fiscal Digital:

<tfd:TimbreFiscalDigital xmlns:tfd="http://www.sat.gob.mx/TimbreFiscalDigital" 
xsi:schemaLocation="http://www.sat.gob.mx/TimbreFiscalDigital http://www.sat.gob.mx/sitio_internet/cfd/TimbreFiscalDigital/TimbreFiscalDigitalv11.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 Version="1.1" UUID="378D32F0-401A-7F46-BAAC-A11155857021" 
 FechaTimbrado="2023-02-14T14:27:09" 
 RfcProvCertif="SPR190613I52" 
 SelloCFD="OFTd8BtoC9X1q/aBFeVevfAc8NmFvyH4VC8nOafcsAImzhADBwauFhFAKpSRTrFogSszEiXAx1Ns1Ho68veLwuTFbF1mUsL8IW9OvQ4Zo2VTWpTHWbRiobryeNpg4iN9x6XBKqN3MX0++gUukGw/XGKTT+gmeo+3H0Hs1os+KY0IQzCPfQEEs3lRtArZjjESQ8ph5O05Xrl0+1sXzpMziknir86N4LPjljvmy6GCrTLbZeHK6AKf/lAOtNQlOVn20kf899OsgB8SAF8MthassvadSYdYZOr9LMQjynzVtZ0dD2pe+29+4wGZmhl33lXMipYLk2SS2+XG+lEMyYKkzQ==" 
 NoCertificadoSAT="30001000000400002495" 
 SelloSAT="qW7e7mIRpY9HPbCeo0+narq5ZPtIaPShkqOLvzKtzhrHYNyW13pJI7mBjq0t8dIW2WmIQF2nhJmGNIwPueH1opNxy/mpsBdha+X2X3XYJ5999uZkUbQxy9C9/t85+IwaWA5ssu3dY1Ny6tlW0kzP92tbol8qWh9u5RnO1S1Fuvz4Hs+ougG7MQiqloy6WeXWNIA5wgYadcqliZNxpCYGk3Uz4M778z+HREKt6ocZKK0CTWHLr7ws1uA77/snsEFtR7Ya4MFYXmn+joffQ/JsKXOFS9LnJAt9EJGXafIdSzPunrW8Pv93UioSJzY/U7a5M7kBLhNoXFf+IfP24HetCw=="  
 />