Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Proyecto SIF/Veri*Factu/Ley Antifraude > General/Noticias
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

 
 
Herramientas Buscar en Tema Desplegado
  #30  
Antiguo 10-07-2025
novatico novatico is offline
Miembro
 
Registrado: dic 2022
Posts: 370
Poder: 4
novatico Va por buen camino
Le he pedido a la IA que me pase el código y me saca ésto.. Ni idea de si es correcto.

uses
System.Net.HttpClient, System.Net.HttpClientComponent, System.JSON, System.SysUtils, System.Classes, Vcl.Dialogs;

procedure CheckVAT;
var
CountryCode, VatNumber, Url: string;
HttpClient: THTTPClient;
Response: IHTTPResponse;
JsonValue: TJSONValue;
JSONObject: TJSONObject;
IsValid: Boolean;
Name, Address, ErrorMsg: string;
begin
CountryCode := 'LU'; // Ej. 'ES', 'DE', etc.
VatNumber := '20260743';

Url := Format('https://ec.europa.eu/taxation_customs/vies/rest-api/ms/%s/vat/%s', [CountryCode, VatNumber]);

HttpClient := THTTPClient.Create;
try
Response := HttpClient.Get(Url);
if Response.StatusCode = 200 then
begin
JsonValue := TJSONObject.ParseJSONValue(Response.ContentAsString);
if Assigned(JsonValue) then
begin
JSONObject := JsonValue as TJSONObject;
IsValid := JSONObject.GetValue<Boolean>('isValid');

if IsValid then
begin
Name := JSONObject.GetValue<string>('name');
Address := JSONObject.GetValue<string>('address').Replace('\n', sLineBreak);
ShowMessage('VAT válido.' + sLineBreak +
'Nombre: ' + Name + sLineBreak +
'Dirección: ' + Address);
end
else
begin
ErrorMsg := JSONObject.GetValue<string>('userError');
ShowMessage('VAT no válido. Mensaje: ' + ErrorMsg);
end;
end;
end
else
ShowMessage('Error HTTP: ' + Response.StatusCode.ToString);
except
on E: Exception do
ShowMessage('Excepción: ' + E.Message);
end;
HttpClient.Free;
end;
Responder Con Cita
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

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
Verificación de RUC Peru. F3niX Varios 7 26-05-2017 04:36:50
Rutina de verificacion de campos JosepMiquel Varios 3 08-12-2007 19:43:19
Búsqueda sin imagen de verificación kuan-yiu La Taberna 8 13-11-2007 18:22:10
Verificación de los datos grabados en CD o DVD rretamar API de Windows 24 16-01-2007 06:32:47
Verificación de dni luna Varios 4 29-05-2004 21:33:46


La franja horaria es GMT +2. Ahora son las 13:29:48.


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