public void ParsePostBackXmlResponse_InvalidXml()
        {
            var logFileName = Path.GetTempPath() + "skarptests.log";
            var logger      = new FileAltaPayLogger(logFileName);

            logger.LogLevel = AltaPayLogLevel.Error;

            string xmlResponse = @"<?xml version=""1.0""?><APIResponse version=""20130430""><NotValid>Not even a little bit</NotValid></APIResponse>";

            var merchantApi = new MerchantApi("url", "username", "password", logger);

            merchantApi.ParsePostBackXmlResponse(xmlResponse);
        }
        public void ParsePostBackXmlResponse_ChargebackEvent()
        {
            var logFileName = Path.GetTempPath() + "skarptests.log";
            var logger      = new FileAltaPayLogger(logFileName);

            logger.LogLevel = AltaPayLogLevel.Error;

            string xmlResponse = File.ReadAllText("Unit/txt/ChargebackEvent.xml");

            var       merchantApi = new MerchantApi("url", "username", "password", logger);
            ApiResult actual      = merchantApi.ParsePostBackXmlResponse(xmlResponse);

            Assert.AreEqual(Result.ChargebackEvent, actual.Result);
        }
        public void ParsePostBackXmlResponse_ErrorResponseWithoutTransactions()
        {
            var logFileName = Path.GetTempPath() + "skarptests.log";
            var logger      = new FileAltaPayLogger(logFileName);

            logger.LogLevel = AltaPayLogLevel.Error;

            string xmlResponse = @"<?xml version=""1.0""?> <APIResponse version=""20141202""><Header><Date>2015-04-24T13:03:21+02:00</Date><Path>/</Path><ErrorCode>0</ErrorCode><ErrorMessage></ErrorMessage></Header><Body><Result>Error</Result></Body></APIResponse>";

            var       merchantApi = new MerchantApi("url", "username", "password", logger);
            ApiResult actual      = merchantApi.ParsePostBackXmlResponse(xmlResponse);

            Assert.AreEqual(Result.Error, actual.Result);
        }
        public void ParsePostBackXmlResponse_ReadPaymentId()
        {
            var logFileName = Path.GetTempPath() + "skarptests.log";
            var logger      = new FileAltaPayLogger(logFileName);

            logger.LogLevel = AltaPayLogLevel.Error;

            var merchantApi = new MerchantApi("url", "username", "password", logger);

            string xmlResponse = File.ReadAllText(_baseProjectPath + Path.DirectorySeparatorChar
                                                  + "Unit" + Path.DirectorySeparatorChar + "txt" + Path.DirectorySeparatorChar
                                                  + "ReasonCode.xml");
            ApiResult     actual = merchantApi.ParsePostBackXmlResponse(xmlResponse);
            PaymentResult result = actual as PaymentResult;

            Assert.AreEqual("17794956-9bb6-4854-9712-bce5931e6e3a", result.Payment.PaymentId);
        }
        public void ParsePostBackXmlResponse_ReadCardHolderMessageMustBeShown()
        {
            var logFileName = Path.GetTempPath() + "skarptests.log";
            var logger      = new FileAltaPayLogger(logFileName);

            logger.LogLevel = AltaPayLogLevel.Error;

            var merchantApi = new MerchantApi("url", "username", "password", logger);

            string xmlResponse = File.ReadAllText(_baseProjectPath + Path.DirectorySeparatorChar
                                                  + "Unit" + Path.DirectorySeparatorChar + "txt" + Path.DirectorySeparatorChar
                                                  + "CardHolderMessageMustBeShownFalse.xml");

            ApiResult actual = merchantApi.ParsePostBackXmlResponse(xmlResponse);

            Assert.AreEqual(false, actual.ResultMessageMustBeShown);
            xmlResponse = File.ReadAllText(_baseProjectPath + Path.DirectorySeparatorChar
                                           + "Unit" + Path.DirectorySeparatorChar + "txt" + Path.DirectorySeparatorChar
                                           + "CardHolderMessageMustBeShownTrue.xml");
            actual = merchantApi.ParsePostBackXmlResponse(xmlResponse);
            Assert.AreEqual(true, actual.ResultMessageMustBeShown);
        }