![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Buscar | Temas de Hoy | Marcar Foros Como Leídos |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
#30
|
|||
|
|||
|
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; |
| Herramientas | Buscar en Tema |
| Desplegado | |
|
|
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 |
|