예제 #1
0
        public void TestCreditCardTokenTransactionValidationError()
        {
            var request = GetBasicRequest();

            request.Amount = null;

            var errors = new Collection <string>();

            if (!request.TryValidate(errors))
            {
                foreach (var error in errors)
                {
                    Debug.WriteLine(error);
                }
            }

            CreditCardTransactionResponse result = null;

            try
            {
                result = request.PostAsync().Result;
            }
            catch (AggregateException e)
            {
                // what happened here...
                Debug.WriteLine(e.Message);
                Debug.WriteLine(e);
            }
            Assert.IsFalse(result.Success);
            Assert.AreEqual(1, result.MessageCode);
            Assert.AreEqual(result.Message, "Validation Error");
            Assert.IsTrue(result.Errors != null);
            Assert.IsTrue(result.Errors.Count == 1);
            Assert.AreEqual("amount: required", result.Errors.Single());
        }
예제 #2
0
        public void TestCreditCardTokenTransactionInvalidUsernameAndPassword()
        {
            var factory = new RequestFactory(106, "wrong password", "PelonEppSdkTests", baseUri);
            var request = factory.GetCreditCardTransactionRequest();

            request.OrderNumber     = Guid.NewGuid().ToString("N").Substring(0, 25);
            request.CreditCardToken = "2fb92b4fb43a453288b388fcce6659d3";     //  "93610b81fd4749f69b81d7f12286bf61"; //"3aa58fecce92433fbcc17ea9a3e6d923"; // "ae7b55027a6a439ea29a1e2b718e0f8a";// "6fefd54fa8854710a8331797bfd14e3a";
            request.Amount          = (decimal?)1.00;
            request.Type            = TransactionType.PURCHASE.ToString();

            var errors = new Collection <string>();

            if (!request.TryValidate(errors))
            {
                foreach (var error in errors)
                {
                    Debug.WriteLine(error);
                }
            }

            CreditCardTransactionResponse result = null;

            try
            {
                result = request.PostAsync().Result;

                Assert.Fail();
            }
            catch (Exception e)
            {
                Assert.AreEqual("One or more errors occurred.", e.Message);
                Assert.AreEqual("Invalid username or password", e.InnerException.Message);
                Debug.WriteLine("test successful");
                return;
            }

            Assert.Fail();
        }
예제 #3
0
        public void TestCreditCardTokenTransactionMaxOrderNumberLength()
        {
            var request = GetBasicRequest();

            request.OrderNumber = Guid.NewGuid().ToString("N").Substring(0, 30);
            var errors = new Collection <string>();

            if (request.TryValidate(errors))
            {
                foreach (var error in errors)
                {
                    Debug.WriteLine(error);
                }
            }

            CreditCardTransactionResponse result = null;

            try
            {
                result = request.PostAsync().Result;
            }
            catch (Exception e)
            {
                // what happened here...
                Debug.WriteLine(e.Message);
                Debug.WriteLine(e);
                //Debug.WriteLineIf((esult.Errors != null && result.Errors.Count >= 1), string.Join("; ", result.Errors ?? new List<string>()));
                Assert.Fail();
            }
            Debug.WriteLine(result.Message);
            Debug.WriteLineIf((result.Errors != null && result.Errors.Count >= 1), string.Join("; ", result.Errors ?? new List <string>()));
            // this transaction fails because the card token is not related to a card that actually accepts transactions.
            Assert.IsFalse(result.Success);
            Assert.AreEqual(741, result.MessageCode);
            Assert.AreEqual(result.Message, "The transaction was declined by your financial institution. Please contact your financial institution for further information.");
            Assert.IsTrue(result.Errors == null);
        }
        public void TestCreditCardTokenTransactionAndReturn()
        {
            var cardtoken = GetCreditCardToken(clientid, clientkey, applicationName);

            Assert.IsNotNull(cardtoken, "Failed to create credit card token");

            // make a transaction
            var transactionRequest = GetBasicCreditCardTokenTransactionRequest(clientid, clientkey, applicationName);

            transactionRequest.CreditCardToken = cardtoken; // using just-created token
            transactionRequest.Amount          = 10;
            transactionRequest.Type            = TransactionType.PURCHASE.ToString();

            //transactionRequest.OrderNumber = null;

            var errors = new Collection <string>();

            if (!transactionRequest.TryValidate(errors))
            {
                foreach (var error in errors)
                {
                    Debug.WriteLine(error);
                }
            }

            CreditCardTransactionResponse transactionResult = null;

            try
            {
                transactionResult = transactionRequest.PostAsync().Result;
            }
            catch (Exception e)
            {
                // what happened here...
                Debug.WriteLine(e.Message);
                Debug.WriteLine(e);
                Assert.Fail();
            }
            Debug.WriteLine(transactionResult.Message);
            Debug.WriteLineIf((transactionResult.Errors != null && transactionResult.Errors.Count >= 1), string.Join("; ", transactionResult.Errors ?? new List <string>()));
            Assert.IsTrue(transactionResult.Success);
            Assert.AreEqual(0, transactionResult.MessageCode);
            Assert.IsTrue(transactionResult.Errors == null);

            // make a return
            var returnRequest = GetBasicCreditCardTokenTransactionRequest(clientid, clientkey, applicationName);

            returnRequest.TransactionRefCode = transactionResult.TransactionRefCode;
            returnRequest.CreditCardToken    = cardtoken; // using just-created token
            returnRequest.Amount             = 10;
            returnRequest.Type = TransactionType.RETURN.ToString();

            errors = new Collection <string>();
            if (!returnRequest.TryValidate(errors))
            {
                foreach (var error in errors)
                {
                    Debug.WriteLine(error);
                }
            }

            CreditCardTransactionResponse returnResult = null;

            try
            {
                returnResult = returnRequest.PostAsync().Result;
            }
            catch (Exception e)
            {
                // what happened here...
                Debug.WriteLine(e.Message);
                Debug.WriteLine(e);
                Assert.Fail();
            }
            Debug.WriteLine(returnResult.Message);
            Debug.WriteLineIf((returnResult.Errors != null && returnResult.Errors.Count >= 1), string.Join("; ", returnResult.Errors ?? new List <string>()));
            Assert.IsTrue(returnResult.Success);
            Assert.AreEqual(0, returnResult.MessageCode);
            Assert.IsTrue(returnResult.Errors == null);

            // clean up the token
            var successfulDelete = DeleteCreditCardToken(cardtoken, clientid, clientkey, applicationName);

            Assert.IsTrue(successfulDelete, "Failed to delete credit card token");
        }