Portalum / Portalum.Zvt

A .NET Zvt Library for Payment Terminals (C#)
MIT License
88 stars 36 forks source link

Not able to call EndOfDayAsync(); #15

Closed DevRaeph closed 2 years ago

DevRaeph commented 2 years ago

Hey there,

first of all, thank you very much for offering this open source. Everything is working fine except EndOfDayAsync() mehtod.

When i'm calling it, i receive following LOG output.

Can you maybe tell me what i'm doing wrong? Thank you very much!

image

tinohager commented 2 years ago

Which payment service provider do they use? Can they provide the source codes of their call? The EndOfDay works for us. Can you also provide the complete communication log? Do they use the Library or the ControlPanel?

DevRaeph commented 2 years ago

Hey, thx for your quick replay.

We tried to use your library via serial port to connect to our terminal. The ControlPanel only supports lan connections.

The terminal i tried to use is following: https://www.cardcomplete.com/fuer-unternehmen/bezahlloesungen/terminaluebersicht/unattended-nfc-all-one/

every other command is working perfectly and as expected, also the payment with receipt as return is throwing no errors at all. Only the EndOfDay part is throwing an unknown error as you see above. I saw no other errors than this, i can try to look for further responses or errors tomorrow morning :)

tinohager commented 2 years ago

This terminal also support ethernet i have the same here

DevRaeph commented 2 years ago

i know :) we first tried to test a other terminal but this was blocked by the provider i later recognised ^^ tomorrow we will check this terminal via ethernet if there's any difference :) with the tester tool everything worked fine, thats why i opend this issue. Maybe it's my fault. I'll check this tomorrow

tinohager commented 2 years ago

basically a little source code at issue is not bad :) blind debugging is not my expertise

DevRaeph commented 2 years ago

i'm sorry :) for sure i'll send you my tests tomorrow morning :)

DevRaeph commented 2 years ago

Okey i really don't know what i'm doing wrong now ^^ yesterday the payment worked perfectely today every payment failed.

I'm using .Net Core 3.1 on Windows 11

Now here's my testing source atm:

Startup:

private async void Form1_Load(object sender, EventArgs e)
        {
            AllocConsole();

            myDevice = new SerialPortDeviceCommunication("COM4");
            if (!await myDevice.ConnectAsync())
            {
                return;
            }

            using var loggerFactory = LoggerFactory.Create(builder =>
            {
                builder.AddConsole().SetMinimumLevel(LogLevel.Debug);
            });

            var deviceCommunicationLogger = loggerFactory.CreateLogger<TcpNetworkDeviceCommunication>();
            var zvtClientLogger = loggerFactory.CreateLogger<ZvtClient>();

            var clientConfig = new ZvtClientConfig
            {
                Language = Language.German,
                Password = 0101
            };

            myZvtClient = new ZvtClient(myDevice, zvtClientLogger, clientConfig);

            myZvtClient.ReceiptReceived += (receipt) => Console.WriteLine(receipt.Content);
            myZvtClient.IntermediateStatusInformationReceived += (intermediateStatusInformation) => Console.WriteLine(intermediateStatusInformation);
            myZvtClient.StatusInformationReceived += (statusInformation) => Console.WriteLine(statusInformation.ErrorMessage);
        }

Device Registration:

   private async void registerDevice_Click(object sender, EventArgs e)
        {

            var regConfig = new RegistrationConfig
            { 
                ReceiptPrintoutForPaymentFunctionsViaPaymentTerminal = false,
                ReceiptPrintoutForAdministrationFunctionsViaPaymentTerminal = false,
                SendIntermediateStatusInformation = true,
            };

             var response = await myZvtClient.RegistrationAsync(regConfig);
             Console.WriteLine(response.State);
        }

Make Payment:

        private async void makePayment_Click(object sender, EventArgs e)
        {
            string amount = paymentAmount.Text;
            var convertDecimal = Decimal.Parse(amount,NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture);
            var response = await myZvtClient.PaymentAsync(convertDecimal);
            Console.WriteLine(response.State);
        }

EndOfDay:

        private async void endOfDayAction_Click(object sender, EventArgs e)
        {
            var response = await myZvtClient.EndOfDayAsync();
            Console.WriteLine(response.State);
            Console.WriteLine(response.ErrorMessage);
        }

Edit: Now if i'm trying to make a payment i get follwing Console output:

info: Portalum.Zvt.ZvtClient[0]
      PaymentAsync - Execute with amount of:0,01
dbug: Portalum.Zvt.ZvtClient[0]
      SendCommandAsync - Send command to PT
Karte einstecken
Vorgang wird bearbeitet bitte warten...
dbug: Portalum.Zvt.ZvtClient[0]
      ProcessApdu - 'Abort' received with message:abort via timeout or abort-key
Abort

With the TManager from Hypercom it is working

tinohager commented 2 years ago

Please download the ControlPanel project and replace in MainWindow.xaml.cs

the tcp code

var loggerCommunication = this._loggerFactory.CreateLogger<SerialPortDeviceCommunication>();
this._deviceCommunication = new SerialPortDeviceCommunication(
    comPort: "COM9",
    baudRate: 9600,
    parity: Parity.None,
    dataBits: 8,
    stopBits: StopBits.Two,
    logger: loggerCommunication);
DevRaeph commented 2 years ago

Where can i find the donwload for this project, i only see the .exe download.

tinohager commented 2 years ago

image

DevRaeph commented 2 years ago

oh crap.. my bad i'm sorry, didn't see that everything is combined in the repo ^^ sure one sec i'll try :)

DevRaeph commented 2 years ago

still get "Tagesende nicht erfolgreich" when i'm trying to exec EndOfDay: Console output:

EndOfDay (06 50) sent
info: Portalum.Zvt.ZvtClient[0]
      EndOfDayAsync - Execute
dbug: Portalum.Zvt.ZvtClient[0]
      SendCommandAsync - Send command to PT
Please wait...
PT is sending post-bookings
Please wait...
Please wait...
dbug: Portalum.Zvt.ZvtClient[0]
      ProcessApdu - 'Completion' received

i've copied every function of your code into my forms project cause on my machine i've only installed default minimal .NET Core and .Net Framework.

Edit: i tried now to connect via TCP/IP but i can't figuare out what the port of this device is. It's not 20007 or 20008.

tinohager commented 2 years ago

You must call CardComplete and have the terminal changed over by support

DevRaeph commented 2 years ago

okey i'll try that :)

DevRaeph commented 2 years ago

i do not know exactly why, but today it's working without any problems. The only thing i recognised is that the Terminal have to be logged off for the EndOfDay function. i can't tell why this happend, maybe something on the Terminal side. The funny part is, that the test tool named "T-Manager" worked perfectly the whole day.

Nevermind, thanks a lot for your effort!