public void Should_get_parameter_string()
        {
            // Arrange
            var doc = new XmlDocument();

            doc.AppendChild(doc.CreateElement("Info"));

            var response = new PaymentResponse
            {
                Operation      = "Operation",
                OrderNumber    = 34634634,
                MerOrderNumber = 321,
                PRCode         = 23,
                SRCode         = 1,
                ResultText     = "ResultText",
                UserParam1     = "ResultText",
                AddInfo        = doc.DocumentElement,
                Digest         = "Digest",
                Digest1        = "Digest1"
            };

            var          testee   = new PaymentResponseTransformer();
            const string expected = "Operation|34634634|321|23|1|ResultText|ResultText|<Info />";

            // Assert
            var result = testee.GetParameterString(response);

            // Assert
            result.Should().BeEquivalentTo(expected);
        }
Ejemplo n.º 2
0
        public void Should_process_GPWP_response_from_response_no_mock_with_certificate()
        {
            // Arrange
            const string merchantNumber             = "62346346";
            const string privateCertificateFile     = "certs/server.pfx";
            const string privateCertificatePassword = "******";
            const string publicCertificateFile      = "certs/server_pub.pem";
            const string publicCertificatePassword  = null;
            var          privateCert = new X509Certificate2(privateCertificateFile, privateCertificatePassword,
                                                            Encoding.DefaultKeyStorageFlags);
            var publicCert = new X509Certificate2(publicCertificateFile, publicCertificatePassword,
                                                  Encoding.DefaultKeyStorageFlags);

            var response = new PaymentResponse
            {
                Operation      = "Operation",
                OrderNumber    = 12332,
                MerOrderNumber = 0,
                PRCode         = 0,
                SRCode         = 0,
                ResultText     = "ResultText",
                UserParam1     = "UserParam1",
                AddInfo        = null
            };

            var encodingServiceMock = this.GetLoggerMock <EncodingService>();
            var encodingService     = new EncodingService(encodingServiceMock.Object);
            var prt = new PaymentResponseTransformer();

            var parameterString = prt.GetParameterString(response);

            response.Digest  = encodingService.SignData(parameterString, privateCert);
            response.Digest1 = encodingService.SignData($"{parameterString}|{merchantNumber}", privateCert);

            var clientServiceLoggerMock = this.GetLoggerMock <ClientService>();
            var testee = new ClientService(encodingService,
                                           new PaymentRequestTransformer(), new PaymentResponseTransformer(), clientServiceLoggerMock.Object);

            // Act
            // Assert
            testee.ProcessGPWebPayResponse(response, merchantNumber, publicCert);
        }