public void TestTerminalApiRequestEmptyResponse() { try { //encrypt the request using encryption credentials var paymentRequest = MockPosApiRequest.CreatePosPaymentRequest(); //create a mock client var client = CreateMockTestClientPosLocalApiRequest(""); var posPaymentLocalApi = new PosPaymentLocalApi(client); var saleToPoiResponse = posPaymentLocalApi.TerminalApiLocal(paymentRequest, _encryptionCredentialDetails); Assert.IsNull(saleToPoiResponse); } catch (Exception) { Assert.Fail(); } }
public void TestNotificationDecryption() { try { var encryptedNotification = @"{""SaleToPOIRequest"":{""SecurityTrailer"":{""AdyenCryptoVersion"":1,""Nonce"":""Be6rAx+vRju2aCHwPh6lrg=="",""KeyIdentifier"":""ncrkey"",""Hmac"":""LG8A9Re1M8xLMr7rDUk0NwsnvAOX+VLjHv9sPHWTl34="",""KeyVersion"":1},""NexoBlob"":""x2DY8J2M9ZCyjOZ8Gt7JdLBA\/6bT\/KXvvAbJf9kzguqO8dWp1I1pPLQpLstpdIiAVqSwG3PR0PrP\/lF82UmhmCnUJGCuEXilqvBNF1tF\/yEgnFOklNc1myR2IPW\/+2oZOWKFXlTo\/gX89EbODXOOGUqaJfSdpDhlqjyMz7mGczobTPvPGqCVx2BDHU8VTxI9nicwQv+QV48GqVZzxnP8ZOdQOQ5cac+bcS0Y3l7SmWpIoQsoicnjahTY9ICosLJmN4DvDHsN4Kh2DAetFO5b9I9Lqgm\/dvnXUVhb9tPbM7Pn+ratjYpaNbonbO5M+Tm8rDEIyKoUUuFXPWISymrCXtCDVKEb2B5S5pilUmokrXVa9Ldtsv3BKG7rbrglYEuql4WVs6kzr6ybgAKh1Q0LsAXEve3pydt72ay4U3FOJSBxJ3gNqmnG8mVW2HCXQVo1RgVaZmP5TBWYuksCKXYypnMulu1PlRI++oeW\/J2qjQU="",""MessageHeader"":{""ProtocolVersion"":""3.0"",""SaleID"":""null"",""MessageClass"":""Event"",""MessageCategory"":""Event"",""POIID"":""P400Plus-275102806"",""MessageType"":""Notification"",""DeviceID"":""5""}}}"; var expectedDecryption = @"{ ""SaleToPOIRequest"": { ""EventNotification"": { ""EventDetails"": ""reference_id=9876"", ""TimeStamp"": ""2020-11-13T09:02:35.697Z"", ""EventToNotify"": ""SaleWakeUp"" }, ""MessageHeader"": { ""ProtocolVersion"": ""3.0"", ""SaleID"": ""null"", ""MessageClass"": ""Event"", ""MessageCategory"": ""Event"", ""POIID"": ""P400Plus-275102806"", ""MessageType"": ""Notification"", ""DeviceID"": ""5"" } } }"; //create a mock client var client = CreateMockTestClientPosLocalApiRequest("Mocks/terminalapi/pospayment-encrypted-success.json"); var posPaymentLocalApi = new PosPaymentLocalApi(client); var decryptedNotification = posPaymentLocalApi.DecryptNotification(encryptedNotification, _encryptionCredentialDetails); Assert.AreEqual(decryptedNotification, expectedDecryption); } catch (Exception) { Assert.Fail(); } }
public void TestTerminalApiRequestRemoteCertificationException() { try { //encrypt the request using encryption credentials var paymentRequest = MockPosApiRequest.CreatePosPaymentRequest(); //create a mock client var client = CreateMockTestClientPosLocalApiRequest("Mocks/terminalapi/pospayment-encrypted-success.json"); var posPaymentLocalApi = new PosPaymentLocalApi(client); var configEndpoint = posPaymentLocalApi.Client.Config.Endpoint; var saleToPoiResponse = posPaymentLocalApi.TerminalApiLocal(paymentRequest, _encryptionCredentialDetails, null); } catch (Exception ex) { Assert.AreEqual(ex.Message, "RemoteCertificateValidationCallback is a required property for TerminalApiLocal and cannot be null"); } }
public void TestTerminalApiRequestEmptyResponse() { try { //encrypt the request using encryption credentials var paymentRequest = MockPosApiRequest.CreatePosPaymentRequest(); //create a mock client var client = CreateMockTestClientPosLocalApiRequest(""); var posPaymentLocalApi = new PosPaymentLocalApi(client); var configEndpoint = posPaymentLocalApi.Client.Config.Endpoint; var saleToPoiResponse = posPaymentLocalApi.TerminalApiLocal(paymentRequest, _encryptionCredentialDetails, (sender, certificate, chain, errors) => { return(true); }); Assert.IsNull(saleToPoiResponse); } catch (Exception) { Assert.Fail(); } }
public void TestTerminalApiRequest() { try { //encrypt the request using encryption credentials var paymentRequest = MockPosApiRequest.CreatePosPaymentRequest(); //create a mock client var client = CreateMockTestClientPosLocalApiRequest("Mocks/terminalapi/pospayment-encrypted-success.json"); var posPaymentLocalApi = new PosPaymentLocalApi(client); var configEndpoint = posPaymentLocalApi.Client.Config.Endpoint; var saleToPoiResponse = posPaymentLocalApi.TerminalApiLocal(paymentRequest, _encryptionCredentialDetails); Assert.AreEqual(configEndpoint, @"https://_terminal_:8443/nexo/"); Assert.IsNotNull(saleToPoiResponse); } catch (Exception) { Assert.Fail(); } }