fiskaly / fiskaly-sdk-dotnet

fiskaly Cloud-TSE SDK for .NET and Xamarin
https://developer.fiskaly.com
MIT License
6 stars 4 forks source link

PLEASE, help me - FinishTransaction #34

Closed phileas1969 closed 3 years ago

phileas1969 commented 3 years ago

Hi there, I know, this might sound stupid, but I am trying to finish a transaction with this small demo code:

public static FiskalyHttpResponse FinishTransaction() { var payload = "{ \"schema\": { \"standard_v1\": { \"receipt\": { \"receipt_type\": \"RECEIPT\", \"amounts_per_vat_rate\": [ { \"vat_rate\": \"NORMAL\", \"amount\": \"21.42\" } ], \"amounts_per_payment_type\": [{ \"payment_type\": \"NON_CASH\", \"amount\": \"21.42\" } ] } } }, \"state\": \"FINISHED\", \"client_id\": \"" + CLIENT_ID + "\" }";

        var bodyBytes = Encoding.UTF8.GetBytes(payload);

        var response = client.Request("PUT", "/tss/" + TSS_ID + "/tx/" + TX_ID + "?last_revision=1", bodyBytes, null, null);

        return response;
    }

I have problems with "?last_revision" and I am not sure, if my payload is correct.

Can anybody help me, or provide a small example, that works?

THANK YOU VERY, VERY MUCH!!!

Phileas

cars10w commented 3 years ago

Hi,

don't construct the whole path yourself. Query-parameters are passed with the 5th parameter. Additional HTTP headers with the 4th.

Try something like:

var httpHeaders = new Dictionary<string, string>()
{
    { "Content-Type", "application/json" }
};

var queryParameters = new Dictionary<string, object>
{
    ["last_revision"] = 1
};

var response = client.Request("PUT", $"/tss/{TSS_ID}/tx/{TX_ID}", bodyBytes, httpHeaders, queryParameters);

Best regards, Carsten

phileas1969 commented 3 years ago

Dear Carsten,

just perfect! Thank you very much!!!

Best regards Phileas