示例#1
0
        public void SimpleTransactionReversal()
        {
            var reversal = new transactionReversal
            {
                id          = "1",
                reportGroup = "Planets",
                cnpTxnId    = 12345678000L,
                amount      = 106,
            };

            var response = _cnp.TransactionReversal(reversal);

            Assert.AreEqual("Approved", response.message);
        }
        public void TestTransactionReversal()
        {
            var transactionReversal = new transactionReversal();

            transactionReversal.cnpTxnId = 12345678000;
            transactionReversal.amount   = 106;

            batchRequest.addTransactionReversal(transactionReversal);

            Assert.AreEqual(1, batchRequest.getNumTransactionReversal());
            Assert.AreEqual(transactionReversal.amount, batchRequest.getSumOfTransactionReversal());

            mockCnpFile.Verify(cnpFile => cnpFile.createRandomFile(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), mockCnpTime.Object));
            mockCnpFile.Verify(cnpFile => cnpFile.AppendLineToFile(mockFilePath, transactionReversal.Serialize()));
        }
示例#3
0
        public void TestTransactionReversalWithRecycling()
        {
            var reversal = new transactionReversal
            {
                id          = "1",
                reportGroup = "Planets",
                cnpTxnId    = 12345678000L,
                amount      = 106,
            };

            var response = _cnp.TransactionReversal(reversal);

            Assert.AreEqual("sandbox", response.location);
            Assert.AreEqual("Approved", response.message);
            Assert.AreEqual(12345678000L, response.recyclingResponse.creditCnpTxnId);
        }
示例#4
0
        public void TestTransactionReversalAsync()
        {
            var reversal = new transactionReversal
            {
                id          = "1",
                reportGroup = "Planets",
                cnpTxnId    = 12345678000L,
                amount      = 106,
                customerId  = "<'&\">"
            };

            CancellationToken cancellationToken = new CancellationToken(false);
            var response = _cnp.TransactionReversalAsync(reversal, cancellationToken);

            Assert.AreEqual("000", response.Result.response);
        }
示例#5
0
        public void TestTransactionReversalHandleSpecialCharacters()
        {
            var reversal = new transactionReversal()
            {
                id          = "1",
                reportGroup = "Planets",
                cnpTxnId    = 12345678000L,
                amount      = 106,
                customerId  = "<'&\">"
            };


            var response = _cnp.TransactionReversal(reversal);

            Assert.AreEqual("Approved", response.message);
        }
        public void TestSurchargeAmount_Optional()
        {
            transactionReversal reversal = new transactionReversal();

            reversal.cnpTxnId    = 3;
            reversal.amount      = 2;
            reversal.reportGroup = "Planets";

            var mock = new Mock <Communications>();

            mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*<amount>2</amount>\r\n.*", RegexOptions.Singleline)))
            .Returns("<cnpOnlineResponse version='12.16' response='0' message='Valid Format' xmlns='http://www.vantivcnp.com/schema'><transactionReversalResponse><cnpTxnId>123</cnpTxnId></transactionReversalResponse></cnpOnlineResponse>");

            Communications mockedCommunication = mock.Object;

            cnp.SetCommunication(mockedCommunication);
            cnp.TransactionReversal(reversal);
        }
        public void TestTransactionReversalWithLocation()
        {
            transactionReversal reversal = new transactionReversal();

            reversal.cnpTxnId        = 3;
            reversal.amount          = 2;
            reversal.surchargeAmount = 1;
            reversal.reportGroup     = "Planets";

            var mock = new Mock <Communications>();

            mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*<amount>2</amount>\r\n<surchargeAmount>1</surchargeAmount>\r\n.*", RegexOptions.Singleline)))
            .Returns("<cnpOnlineResponse version='12.16' response='0' message='Valid Format' xmlns='http://www.vantivcnp.com/schema'><transactionReversalResponse><cnpTxnId>123</cnpTxnId><location>sandbox</location></transactionReversalResponse></cnpOnlineResponse>");

            Communications mockedCommunication = mock.Object;

            cnp.SetCommunication(mockedCommunication);
            var response = cnp.TransactionReversal(reversal);

            Assert.NotNull(response);
            Assert.AreEqual("sandbox", response.location);
        }