Portalum / Portalum.Zvt

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

testing against Hobex simulator no async method will ever return #32

Closed obelixA closed 1 year ago

obelixA commented 1 year ago

NuGet Package Version

2.17.0

Payment service provider

Hobex

Payment terminal

Hobex Terminal Simulator

Communication Logs

Hobex simulator protocol:

2023-01-30 01:43:51,997 - Init SSL Trust Store 2023-01-30 01:43:52,193 - Initializing TecsClient V1.5.3 2023-01-30 01:43:52,193 - TID: 03510002, Password: , Host: tca.hobex.at, Port: 9991, Timeout: 180000, SSL: true, Language: DE 2023-01-30 01:43:56,298 - The transaction protocol is set to ZVTClientSimulator. 2023-01-30 01:43:56,300 - Started Gateway on Port 20007, allowing 0 connections. 2023-01-30 01:43:56,301 - Waiting for connection... 2023-01-30 01:44:35,164 - IP /127.0.0.1:55608 connected, starting ZVTClientSimulator protocol implementation. 2023-01-30 01:44:35,166 - ZVT Client Config 2023-01-30 01:44:35,166 - ----------------- 2023-01-30 01:44:35,167 - Terminal ID (TID): 000101 2023-01-30 01:44:35,167 - Use codepage437: true 2023-01-30 01:44:35,169 - Use reference: false 2023-01-30 01:44:35,169 - Use trace number (0=no, 1=long, 2=short): 1 2023-01-30 01:44:35,169 - PrintByBlocks: true 2023-01-30 01:44:35,170 - Short customer receipt: false 2023-01-30 01:44:35,171 - Seasons Greetings: NO 2023-01-30 01:44:35,171 - Terminal language: DE 2023-01-30 01:44:35,171 - No wait time while terminal compute: false 2023-01-30 01:44:35,174 - Config-Byte: 00 2023-01-30 01:44:35,175 - Waiting for connection... 2023-01-30 01:44:35,176 - Protocol handles data reading... 2023-01-30 01:44:54,764 - [RECV - HEX] << 0600100000008809780301060626040A0206D3 2023-01-30 01:44:54,765 - ZVTClientSimulator started... 2023-01-30 01:44:54,767 - [REQ >>] 0600100000008809780301060626040A0206D3 2023-01-30 01:44:54,767 - Evaluate request string for consistency... 2023-01-30 01:44:55,023 - got registration 2023-01-30 01:44:55,023 - Check APDU length 2023-01-30 01:44:55,024 - APDU length ok 2023-01-30 01:44:55,025 - [SEND - HEX] >> 800000 2023-01-30 01:44:55,025 - Password: 000000 2023-01-30 01:44:55,026 - ConfigByte: 88 2023-01-30 01:44:55,026 - Currency: 0978 2023-01-30 01:44:55,026 - Service-Byte: 01 2023-01-30 01:44:55,027 - Got TLV-Container, will send TLV container after transaction.. 2023-01-30 01:44:55,239 - [SEND - HEX] >> 060F052900000101 2023-01-30 01:44:55,248 - [RECV - HEX] << 800000 2023-01-30 01:44:55,248 - Protocol handles data reading...

More information

`

public delegate void Logit( string message ); public event Logit OnLogit;

public async Task<decimal> Pay( decimal sum ) {
        if( !_comm.IsConnected ) {
            if( !_comm.ConnectAsync().Result ) {
                return -9999999; // kein Erfolg
            }
        }

        var completionInfo = new CompletionInfo();
        using var zvtClient = new ZvtClient( _comm );
        RegistrationConfig rc = new RegistrationConfig();
        rc.AllowAdministrationViaPaymentTerminal = true;
        rc.AllowStartPaymentViaPaymentTerminal = true;
        rc.ReceiptPrintoutForAdministrationFunctionsViaPaymentTerminal = true;
        rc.ReceiptPrintoutForPaymentFunctionsViaPaymentTerminal = true;
        rc.SendIntermediateStatusInformation = true;
        await zvtClient.RegistrationAsync( rc );
        zvtClient.StatusInformationReceived += (statusInformation) => OnLogit?.Invoke( statusInformation.ErrorMessage );
        zvtClient.IntermediateStatusInformationReceived += (msg) => OnLogit?.Invoke( msg );
        zvtClient.LineReceived += (printLineInfo) => OnLogit?.Invoke( printLineInfo.Text );
        zvtClient.ReceiptReceived += (receiptInfo) => OnLogit?.Invoke( receiptInfo.Content );
        zvtClient.CompletionStartReceived += ( statusInformation ) => {
            OnLogit?.Invoke( "completen start received for card type " + statusInformation.CardType );
            //completionInfo.State = CompletionInfoState.Wait;
            // here you would start your asynchronous completion process, i.e. start dispensing a water bottle
            completionInfo.State = CompletionInfoState.Successful;
        };
        zvtClient.CompletionDecisionRequested += () => completionInfo;
        var res = zvtClient.PaymentAsync( sum ).Result;
        return -9999998; // stellt Erfolg dar - später mal das Trinkgeld - ist eins weniger als "kein Erfolg"
    }

`

the communication starts and seems ok. But if I do await zvtClient.RegistrationAsync( rc ) or if I comment it out and it comes to var res = zvtClient.PaymentAsync( sum ).Result; the call will never come back.

tinohager commented 1 year ago

Good morning to you. For me, the code you posted does not seem to be implemented quite correctly. But we do not provide free support here. But you are welcome to ask for paid support.

obelixA commented 1 year ago

The code is adapted from the examples on GitHub. If it is not correct, can you provide a working example, please? Thanks in advance Achim

tinohager commented 1 year ago

The problem should now be solved after our joint analysis