Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ artifacts/
**/bin/
**/obj/
**/.vs/
**/*.lscache
9 changes: 7 additions & 2 deletions HOWTO_01_Payment_csharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ static async Task Main(string[] args)
{
Logger.LogInfo("fiskaltrust POS System API initialized successfully.");

Console.WriteLine("Please enter cbTerminalID to use (press ENTER for default 'term1'):");
string cbTerminalIDInput = Console.ReadLine() ?? string.Empty;
string cbTerminalID = string.IsNullOrWhiteSpace(cbTerminalIDInput) ? "term1" : cbTerminalIDInput.Trim();
Logger.LogInfo($"Using cbTerminalID: {cbTerminalID}");

/////////////////////////////////////////////////////////////////////////////////////////////////
// execute a simple payment
Console.WriteLine("\n--- Simple Payment Example ---\n");
Expand Down Expand Up @@ -60,15 +65,15 @@ static async Task Main(string[] args)
// execute the payment
// - with with defined amount
// - allow the target device to select the payment protocol (= use_auto; see payment config in target device / InStore App)
// - the terminal ID is not defined here (null) so the request will be processed by all available terminals for the cashbox
// - the terminal ID is defined here ("term1") so the request will be processed by the specified terminal (if the terminal is configured also with a terminal ID)
// IMPORTANT: In a real setup you might want to define a specific terminal ID here to target a specific payment terminal device; especially when multiple payment terminals are registered for the same cashbox!
Comment on lines +68 to 69
// - we provide the operation ID to be able to retry in case of failure
var payItemRequest = new PayItemRequest
{
Description = "Card",
Amount = amount,
};
ExecutedResult<PayResponse> payResult = await ftPosAPI.Pay.PaymentAsync(payItemRequest, fiskaltrust.Payment.DTO.PaymentProtocol.use_auto, null, operationId);
ExecutedResult<PayResponse> payResult = await ftPosAPI.Pay.PaymentAsync(payItemRequest, fiskaltrust.Payment.DTO.PaymentProtocol.use_auto, cbTerminalID, operationId);

/////////////////////////////////////////////////////////////////////////////////////////////////
// Check Result
Expand Down
10 changes: 8 additions & 2 deletions HOWTO_08_pay_sign_issue_csharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ static async Task Main(string[] args)
{
Logger.LogInfo("fiskaltrust POS System API initialized successfully.");

Console.WriteLine("Please enter cbTerminalID to use (press ENTER for default 'term1'):");
string cbTerminalIDInput = Console.ReadLine() ?? string.Empty;
string cbTerminalID = string.IsNullOrWhiteSpace(cbTerminalIDInput) ? "term1" : cbTerminalIDInput.Trim();
Logger.LogInfo($"Using cbTerminalID: {cbTerminalID}");

///////////////////////////////////////////////////////////////////////////////////////////////////////
/// Create the "dummy" charge items
List<ChargeItem> chargeItems = new List<ChargeItem>()
Expand Down Expand Up @@ -63,7 +68,7 @@ static async Task Main(string[] args)
(PayResponse? pResp, string errorMsg) = await payRunner.Execute<PayResponse>(async () =>
{

return await ftPosAPI.Pay.PaymentAsync(payRequest, PaymentProtocol.use_auto, null, payRunner.OperationID);
return await ftPosAPI.Pay.PaymentAsync(payRequest, PaymentProtocol.use_auto, cbTerminalID, payRunner.OperationID);
});

if (pResp == null)
Expand All @@ -89,6 +94,7 @@ static async Task Main(string[] args)
.SetCountry("AT") // Austria
.SetReceiptCase(ReceiptCase.PointOfSaleReceipt0x0001);
ReceiptRequest receiptRequest = new ReceiptRequest(receiptReference, receiptCaseBuilder, chargeItems, pResp.ftPayItems);
receiptRequest.cbTerminalID = cbTerminalID;
receiptRequest.ftReceiptCaseData = new FtReceiptCaseData
{
cbReceiptLines = new string[]
Expand Down Expand Up @@ -154,7 +160,7 @@ static async Task Main(string[] args)
if (isDelivered)
{
Logger.LogInfo("Receipt has been delivered successfully.");
Logger.LogDebug($"Delivery details - {deliveryDateils.state}: {deliveryDateils.message}");
Logger.LogDebug($"Delivery details - {deliveryDateils?.Message}");
}
else
{
Expand Down
21 changes: 17 additions & 4 deletions libPosSystemAPI/DTO/IssueDeliveredResponse.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
namespace fiskaltrust.DevKit.POSSystemAPI.lib.DTO
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace fiskaltrust.DevKit.POSSystemAPI.lib.DTO
{
/// <summary>
/// Provides some details about how the delivery was executed for debug purpose.
/// </summary>
public class IssueDeliveredResponse
{
public string state { get; set; } = string.Empty;
public string message { get; set; } = string.Empty;
}
/// <summary>
/// A message describing how the delivery was executed.
/// </summary>
/// <example>""Receipt was printed at 01/30/2026 00:03:57. DeliveryMethod: customeraccepted"</example>
[JsonPropertyName("message")]
public string Message { get; set; } = string.Empty;

/// <summary>
/// Additional arbitrary properties that will be serialized as top-level JSON fields
/// alongside the known properties.
/// </summary>
[JsonExtensionData]
public Dictionary<string, object?>? AdditionalProperties { get; set; } }
}
7 changes: 5 additions & 2 deletions libPosSystemAPI/DTO/PaymentRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ public class PaymentRequest : IJsonContentConverter
[JsonIgnore(Condition = JsonIgnoreCondition.Never)] // required so even if it has default value it must be included
public required PayItemRequest cbPayItem { get; set; }

public string? cbTerminalId { get; set; }
/// <summary>
/// Allows to identify a specific target device/terminal or group that should process the request.
/// </summary>
public string? cbTerminalID { get; set; }

public JsonContent ToJsonContent()
{
if (string.IsNullOrEmpty(cbTerminalId)) cbTerminalId = null;
if (string.IsNullOrEmpty(cbTerminalID)) cbTerminalID = null;
return JsonContent.Create(this, options: JsonConfiguration.DefaultOptions);
}
}
Expand Down
11 changes: 4 additions & 7 deletions libPosSystemAPI/DTO/ReceiptRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,14 @@ public JsonContent ToJsonContent()
return JsonContent.Create(this, options: JsonConfiguration.DefaultOptions);
}

/*
[JsonProperty("cbTerminalID", DefaultValueHandling = DefaultValueHandling.Ignore)]
/// <summary>
/// Allows to identify a specific target device/terminal or group that should process the request.
/// </summary>
[JsonPropertyName("cbTerminalID")]
[System.Text.Json.Serialization.JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string? cbTerminalID { get; set; }






/*
[JsonProperty("ftCashBoxID", DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonPropertyName("ftCashBoxID")]
[System.Text.Json.Serialization.JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
Expand Down
7 changes: 5 additions & 2 deletions libPosSystemAPI/DTO/RefundCancelRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ internal class RefundCancelRequest : IJsonContentConverter
[JsonIgnore(Condition = JsonIgnoreCondition.Never)] // required so even if it has default value it must be included
public required PayItem cbPayItem { get; set; }

public string? cbTerminalId { get; set; }
/// <summary>
/// Allows to identify a specific target device/terminal or group that should process the request.
/// </summary>
public string? cbTerminalID { get; set; }

public JsonContent ToJsonContent()
{
if (string.IsNullOrEmpty(cbTerminalId)) cbTerminalId = null;
if (string.IsNullOrEmpty(cbTerminalID)) cbTerminalID = null;
return JsonContent.Create(this, options: JsonConfiguration.DefaultOptions);
}
}
Expand Down
4 changes: 2 additions & 2 deletions libPosSystemAPI/PosAPIClient/PosAPIPay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class PosAPIPay
/// See https://docs.fiskaltrust.cloud/apis/pos-system-api about the meaning of the operation / operationID
/// </param>
/// <returns></returns>
public async Task<ExecutedResult<PayResponse>> PaymentAsync(PayItemRequest cbPayItem, PaymentProtocol protocol = PaymentProtocol.use_auto, string? terminalID = null, Guid? operationId = null)
public async Task<ExecutedResult<PayResponse>> PaymentAsync(PayItemRequest cbPayItem, PaymentProtocol protocol = PaymentProtocol.use_auto, string? terminalID = "term1", Guid? operationId = null)
{
// https://docs.fiskaltrust.cloud/apis/pos-system-api#tag/SynchronAPI/paths/~1pay/post

Expand All @@ -32,7 +32,7 @@ public async Task<ExecutedResult<PayResponse>> PaymentAsync(PayItemRequest cbPay
Action = PayAction.payment,
Protocol = protocol,
cbPayItem = cbPayItem,
cbTerminalId = terminalID,
cbTerminalID = terminalID,
};
Comment on lines 26 to 36
var rBuilder = new APIRequestBuilder<PaymentRequest, PayResponse>()
.SetMethod(HttpMethod.Post)
Expand Down
2 changes: 1 addition & 1 deletion libPosSystemAPI/ftPosAPIRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal override APIRequestBuilder<PaymentRequest, PayResponse> Build()
Action = PayAction.payment,
Protocol = this._protocol,
cbPayItem = this._payItem,
cbTerminalId = this._terminalID,
cbTerminalID = this._terminalID,
};
var rBuilder = new APIRequestBuilder<PaymentRequest, PayResponse>()
.SetMethod(HttpMethod.Post)
Expand Down
Loading