Ver Mensaje Individual
  #17  
Antiguo 26-02-2025
Maska10 Maska10 is offline
Miembro
 
Registrado: abr 2020
Posts: 50
Reputación: 7
Maska10 Va por buen camino
Aquí os dejo el código, la primera función es solo para pasar el array of char a String, la segunda función es la que creo que buscais:

Código Delphi [-]
function tfrmentradassalidascaja.ArrayToString(const a: array of Char): string;
begin
  if Length(a)>0 then
    SetString(Result, PChar(@a[0]), Length(a))
  else
    Result := '';
end;


procedure tfrmentradassalidascaja.enviadatafono(Sender: TObject);
type
  TIniTpvpcLatente = Function(cComercio,cTerminal,cClaveFirma,cConfPuerto,cVersion: string) : integer;stdcall;
  TOperPinPad = function(cImporte, cFactura, cTipoOper :string; var cXmlResp :array of Char; iTamMaxResp : integer) : integer;stdcall;
var
  DLLHandle: THandle;
  IniTpvpcLatente: TIniTpvpcLatente;
  OperPinPad: TOperPinPad;
  respuesta: integer;
  strrespuesta, codcomercio,terminal,firma,importe,venta: string;
  Str2: array[0..29999] of Char;

begin

  codcomercio:='45465464';
  firma:='assadfsadfasdfsadfsadf';
  terminal:='1';
  importe:='20.50';
  venta:='Fact1001';

  DLLHandle := LoadLibrary('dllTpvpcLatente.dll');
  try
    if DLLHandle <= 0 then
      begin
      ShowMessage('Error, conector dllTpvcLatente.dll no encontrado');
      exit;
      end;


    @IniTpvpcLatente := GetProcAddress(DLLHandle, 'fnDllIniTpvpcLatente');
    @OperPinPad := GetProcAddress(DLLHandle, PChar('fnDllOperPinPad'));

    if Assigned(IniTpvpcLatente) then
    begin
           respuesta:=IniTpvpcLatente(codcomercio,terminal,firma,'','');
           if respuesta < 0 then
              begin
              showmessage('Error de comunicación con el Datafono/Tpv/PinPad, código de error: ' + inttostr(respuesta));
              Exit;
              end;

           strrespuesta:='';
           respuesta:=OperPinPad(importe,venta,'PAGO',Str2,30000);
           if respuesta < 0 then
              begin
              showmessage('Error al enviar la orden al Datafono/Tpv/PinPad, código de error: ' + inttostr(respuesta));
              Exit;
              end;

           strrespuesta:=ArrayToString(Str2);


           if pos('Autorizada',strrespuesta)> 0 then
              begin
              // aceptada
        showmessage('Operación Aceptada');
              end
           else
              begin
              // denegada
              showmessage('Operación Denegada');
              exit;
              end;

    end
    else
      begin
      ShowMessage('Error, procedimiento/Funcion no encontrado');
      end;

  except
     on E : Exception do
     begin
       ShowMessage('Exception class name = '+E.ClassName);
       ShowMessage('Exception message = '+E.Message);
     end;
  end;

end;

Última edición por Casimiro Noteví fecha: 26-02-2025 a las 20:34:39.
Responder Con Cita