Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Internet
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #13  
Antiguo 13-03-2024
Avatar de keys
keys keys is offline
Miembro
 
Registrado: sep 2003
Ubicación: Bilbao
Posts: 1.030
Poder: 22
keys Va por buen camino
Pongo el código por si a alguien le interesa.

Código Delphi [-]

 //Pais son las letras del codigo del pais
function ComprobarDocumentoVIES(Pais, Documento: string): boolean;
var
  LRequest: THTTPClient;

  LResponse: TStringStream;
  JSONData: TJSONObject;
  StringStream: TStringStream;
  valido : Boolean;
begin

  result := false;
  LRequest := THTTPClient.Create;
  LResponse := TStringStream.Create;


  JSONData := TJSONObject.Create;

  JSONData.AddPair('countryCode', Pais);
  JSONData.AddPair('vatNumber', Documento);

  
    Lrequest.ContentType := 'application/json';
    StringStream := TStringStream.Create(JSONData.ToString, TEncoding.UTF8);
    LRequest.SecureProtocols := [THTTPSecureProtocol.TLS12];
    LRequest.Post('https://ec.europa.eu/taxation_customs/vies/rest-api/check-vat-number', StringStream , LResponse);
    JSONData := TJSONObject.ParseJSONValue(LResponse.DataString) as TJSONObject;

    if Assigned(JSONData) then
      begin
        // Obtener el valor del campo deseado de la respuesta que es el valid
         if JSONData.TryGetValue('valid', valido) then
          begin
            result := valido;
          end;
      end;

    JsonData.destroy;
    LResponse.Free;
    LRequest.Free;
    StringStream.Destroy;
 

end;
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Validar un XML r_e_g_2007 Varios 0 05-11-2011 08:00:21
validar RFC.. tebre Varios 12 06-01-2009 18:48:55
Validar Elite237 OOP 1 28-07-2007 23:25:30
Validar Nif Colgueit OOP 12 10-05-2006 02:50:28
validar en qry alcides SQL 2 06-01-2004 18:11:19


La franja horaria es GMT +2. Ahora son las 14:13:20.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi