From 9eef735e031ac2ab6b22bc7d2142d554c673ac35 Mon Sep 17 00:00:00 2001 From: Garr Godfrey Date: Wed, 28 Jul 2021 18:15:57 -0700 Subject: [PATCH 1/2] must have device type set before creating BMP --- .../PAX/Responses/SignatureResponse.cs | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/GlobalPayments.Api/Terminals/PAX/Responses/SignatureResponse.cs b/src/GlobalPayments.Api/Terminals/PAX/Responses/SignatureResponse.cs index bbce1e9d..e911533d 100644 --- a/src/GlobalPayments.Api/Terminals/PAX/Responses/SignatureResponse.cs +++ b/src/GlobalPayments.Api/Terminals/PAX/Responses/SignatureResponse.cs @@ -8,29 +8,46 @@ public class SignatureResponse : PaxTerminalResponse, ISignatureResponse { private DeviceType _deviceType; public int TotalLength { get; set; } - public int ResponseLegth { get; set; } + public int ResponseLength { get; set; } + public string UnparsedSignature { get; set; } + + public SignatureResponse(byte[] response, DeviceType deviceType = DeviceType.PAX_S300) : base(response, PAX_MSG_ID.A09_RSP_GET_SIGNATURE, PAX_MSG_ID.A21_RSP_DO_SIGNATURE) { _deviceType = deviceType; + ProcessImage(); // must be called AFTER setting device type } protected override void ParseResponse(BinaryReader br) { base.ParseResponse(br); - - if (DeviceResponseCode == "000000" && Command == PAX_MSG_ID.A09_RSP_GET_SIGNATURE) { + if (DeviceResponseCode == "000000" && Command == PAX_MSG_ID.A09_RSP_GET_SIGNATURE) + { TotalLength = int.Parse(br.ReadToCode(ControlCodes.FS)); - ResponseLegth = int.Parse(br.ReadToCode(ControlCodes.FS)); + ResponseLength = int.Parse(br.ReadToCode(ControlCodes.FS)); - var signatureData = br.ReadToCode(ControlCodes.ETX); + UnparsedSignature = br.ReadToCode(ControlCodes.ETX); + } + + } + /// + /// call this to convert string data to a BMP image and store it + /// + private void ProcessImage() + { + if (UnparsedSignature != null) + { int imageWidth = 150; - switch (_deviceType) { + switch (_deviceType) + { case DeviceType.PAX_PX5: - case DeviceType.PAX_PX7: { + case DeviceType.PAX_PX7: + { imageWidth = 350; - } break; + } + break; } - SignatureData = TerminalUtilities.BuildSignatureImage(signatureData, imageWidth); + SignatureData = TerminalUtilities.BuildSignatureImage(UnparsedSignature, imageWidth); } } } From c7127293184abd6870509bde6165b39a8951a9c2 Mon Sep 17 00:00:00 2001 From: Garr Godfrey Date: Wed, 28 Jul 2021 18:32:41 -0700 Subject: [PATCH 2/2] fix for PromptForSignature to use device type --- src/GlobalPayments.Api/Terminals/PAX/PaxInterface.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 src/GlobalPayments.Api/Terminals/PAX/PaxInterface.cs diff --git a/src/GlobalPayments.Api/Terminals/PAX/PaxInterface.cs b/src/GlobalPayments.Api/Terminals/PAX/PaxInterface.cs old mode 100644 new mode 100755 index 29b52734..e052dab3 --- a/src/GlobalPayments.Api/Terminals/PAX/PaxInterface.cs +++ b/src/GlobalPayments.Api/Terminals/PAX/PaxInterface.cs @@ -54,7 +54,7 @@ public override ISignatureResponse PromptForSignature(string transactionId = nul ControlCodes.FS, 300 )); - var signatureResponse = new SignatureResponse(response); + var signatureResponse = new SignatureResponse(response, _controller.DeviceType.Value); if (signatureResponse.DeviceResponseCode == "000000") return GetSignatureFile(); return signatureResponse;