Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Colaboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #8  
Antiguo 02-10-2023
Avatar de keys
keys keys is offline
Miembro
 
Registrado: sep 2003
Ubicación: Bilbao
Posts: 1.229
Poder: 24
keys Va por buen camino
Hola a todos. Pongo una función para validar un documento en el servicio VIES de la UE.

Código Delphi [-]
function ComprobarDocumentoVIES(Pais, Documento: string): false;
var
  LRequest: THTTPClient;

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

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

  //Objeto JSON para enviar los datos
  JSONData := TJSONObject.Create;
  JSONData.AddPair('countryCode', Pais);
  JSONData.AddPair('vatNumber', Documento);
  
  try

    Lrequest.ContentType := 'application/json';

    StringStream := TStringStream.Create(JSONData.ToString, TEncoding.UTF8);
    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
         if JSONData.TryGetValue Boolean ('valid', valido) then //esto lo pongo asi por que el chat no me deja poner los simbolos de mayor y menor delante y detrás de boolean;
          begin
            
             result := valido;
           
          end;

      end;

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


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
Suma de números pares que hay entre dos números Daniel2622 Lazarus, FreePascal, Kylix, etc. 21 26-04-2017 22:47:29
Tablas de multiplicar para todos los números entre dos números Daniel2622 Lazarus, FreePascal, Kylix, etc. 3 22-04-2017 00:47:59
Documentos UDF's johan Firebird e Interbase 1 23-03-2010 17:19:01
Documentos XML cone220 Internet 1 03-11-2004 17:49:35
Documentos pdf roman PHP 5 27-09-2004 16:14:23


La franja horaria es GMT +2. Ahora son las 01:36:30.


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