示例#1
0
        public void Test1Auth()
        {
            authorization authorization = new authorization();

            authorization.id          = "1";
            authorization.orderId     = "1";
            authorization.amount      = 10100;
            authorization.orderSource = orderSourceType.ecommerce;
            contact contact = new contact();

            contact.name                = "John & Mary Smith";
            contact.addressLine1        = "1 Main St.";
            contact.city                = "Burlington";
            contact.state               = "MA";
            contact.zip                 = "01803-3747";
            contact.country             = countryTypeEnum.US;
            authorization.billToAddress = contact;
            cardType card = new cardType();

            card.type              = methodOfPaymentTypeEnum.VI;
            card.number            = "4457010000000009";
            card.expDate           = "0121";
            card.cardValidationNum = "349";
            authorization.card     = card;

            authorizationResponse response = cnp.Authorize(authorization);

            Assert.AreEqual("000", response.response);
            Assert.AreEqual("Approved", response.message);
            Assert.AreEqual("11111 ", response.authCode);
            Assert.AreEqual("01", response.fraudResult.avsResult);
            Assert.AreEqual("M", response.fraudResult.cardValidationResult);

            capture capture = new capture();

            capture.id       = response.id;
            capture.cnpTxnId = response.cnpTxnId;
            captureResponse captureResponse = cnp.Capture(capture);

            Assert.AreEqual("000", captureResponse.response);
            Assert.AreEqual("Approved", captureResponse.message);

            credit credit = new credit();

            credit.id       = captureResponse.id;
            credit.cnpTxnId = captureResponse.cnpTxnId;
            creditResponse creditResponse = cnp.Credit(credit);

            Assert.AreEqual("000", creditResponse.response);
            Assert.AreEqual("Approved", creditResponse.message);

            voidTxn newvoid = new voidTxn();

            newvoid.id       = creditResponse.id;
            newvoid.cnpTxnId = creditResponse.cnpTxnId;
            voidResponse voidResponse = cnp.DoVoid(newvoid);

            Assert.AreEqual("000", voidResponse.response);
            Assert.AreEqual("Approved", voidResponse.message);
        }
        public void Test32()
        {
            authorization auth = new authorization();

            auth.id          = "1";
            auth.orderId     = "32";
            auth.amount      = 10010;
            auth.orderSource = orderSourceType.ecommerce;
            contact billToAddress = new contact();

            billToAddress.name         = "John Smith";
            billToAddress.addressLine1 = "1 Main St.";
            billToAddress.city         = "Burlington";
            billToAddress.state        = "MA";
            billToAddress.zip          = "01803-3747";
            billToAddress.country      = countryTypeEnum.US;
            auth.billToAddress         = billToAddress;
            cardType card = new cardType();

            card.number            = "4457010000000009";
            card.expDate           = "0112";
            card.cardValidationNum = "349";
            card.type = methodOfPaymentTypeEnum.VI;
            auth.card = card;

            authorizationResponse authorizeResponse = cnp.Authorize(auth);

//            Assert.AreEqual("111", authorizeResponse.response);
//            Assert.AreEqual("Authorization amount has already been depleted", authorizeResponse.message);
            Assert.AreEqual("11111 ", authorizeResponse.authCode);
            Assert.AreEqual("01", authorizeResponse.fraudResult.avsResult);
            Assert.AreEqual("M", authorizeResponse.fraudResult.cardValidationResult);

            capture capture = new capture();

            capture.id       = authorizeResponse.id;
            capture.cnpTxnId = authorizeResponse.cnpTxnId;
            capture.amount   = 5005;
            captureResponse captureResponse = cnp.Capture(capture);

            Assert.AreEqual("000", captureResponse.response);
            Assert.AreEqual("Approved", captureResponse.message);

            authReversal reversal = new authReversal();

            reversal.id       = authorizeResponse.id;
            reversal.cnpTxnId = 320000000000000000;
            authReversalResponse reversalResponse = cnp.AuthReversal(reversal);

            Assert.AreEqual("000", reversalResponse.response);
            Assert.AreEqual("Approved", reversalResponse.message);
        }
示例#3
0
        public void SimpleCapture()
        {
            var capture = new capture
            {
                id          = "1",
                cnpTxnId    = 123456000,
                amount      = 106,
                payPalNotes = "Notes",
                pin         = "1234"
            };

            var response = _cnp.Capture(capture);

            Assert.AreEqual("Approved", response.message);
        }
示例#4
0
        public void TestHttpEvents()
        {
            var requestCount    = 0;
            var responseCount   = 0;
            var httpActionCount = 0;

            _cnp.HttpAction += (sender, args) =>
            {
                var eventArgs = (Communications.HttpActionEventArgs)args;
                httpActionCount++;
                if (eventArgs.RequestType == Communications.RequestType.Request)
                {
                    requestCount++;
                }
                else if (eventArgs.RequestType == Communications.RequestType.Response)
                {
                    responseCount++;
                }
            };

            var capture = new capture
            {
                cnpTxnId = 123456000,
                amount   = 106,
                id       = "1"
            };

            _cnp.Capture(capture);
            Assert.AreEqual(httpActionCount, 2);
            Assert.AreEqual(requestCount, 1);
            Assert.AreEqual(responseCount, 1);
        }
        public void TestSimpleCapture()
        {
            capture capture = new capture();

            capture.cnpTxnId    = 3;
            capture.amount      = 2;
            capture.payPalNotes = "note";
            capture.reportGroup = "Planets";
            capture.pin         = "1234";

            var mock = new Mock <Communications>();

            mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*<amount>2</amount>\r\n<payPalNotes>note</payPalNotes>\r\n<pin>1234</pin>.*", RegexOptions.Singleline), It.IsAny <Dictionary <String, String> >()))
            .Returns("<cnpOnlineResponse version='8.14' response='0' message='Valid Format' xmlns='http://www.vantivcnp.com/schema'><captureResponse><cnpTxnId>123</cnpTxnId></captureResponse></cnpOnlineResponse>");

            Communications mockedCommunication = mock.Object;

            cnp.SetCommunication(mockedCommunication);
            cnp.Capture(capture);
        }
示例#6
0
        public void TestCapture()
        {
            capture caputure = new capture();

            caputure.cnpTxnId    = 123456000;
            caputure.amount      = 106;
            caputure.payPalNotes = "Notes";


            var mock = new Mock <Communications>();

            mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?<cnpOnlineRequest.*?<capture.*?<cnpTxnId>123456000</cnpTxnId>.*?</capture>.*?", RegexOptions.Singleline), It.IsAny <Dictionary <String, String> >()))
            .Returns("<cnpOnlineResponse version='8.10' response='0' message='Valid Format' xmlns='http://www.vantivcnp.com/schema'><captureResponse><cnpTxnId>123</cnpTxnId></captureResponse></cnpOnlineResponse>");

            Communications mockedCommunication = mock.Object;

            cnp.SetCommunication(mockedCommunication);
            captureResponse captureresponse = cnp.Capture(caputure);

            Assert.AreEqual(123, captureresponse.cnpTxnId);
        }