Esempio n. 1
0
        public void SettleBatch()
        {
            BatchSummary response = BatchService.CloseBatch();

            Assert.IsNotNull(response);
            Assert.AreEqual("SUCCESS", response.Status);
        }
Esempio n. 2
0
        public void Test_000_batch_close()
        {
            BatchSummary summary = BatchService.CloseBatch(BatchCloseType.Forced);

            Assert.IsNotNull(summary);
            Assert.IsTrue(summary.IsBalanced);
        }
Esempio n. 3
0
        public void CloseBatch_Verify_MissingBatchId()
        {
            var transaction = creditCard.Verify()
                              .WithCurrency(CURRENCY)
                              .Execute();

            Assert.IsNotNull(transaction);
            Assert.AreEqual(SUCCESS, transaction?.ResponseCode);
            Assert.AreEqual(VERIFIED, transaction?.ResponseMessage);

            var exceptionCaught = false;

            try {
                BatchService.CloseBatch(transaction.BatchSummary.BatchReference);
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("MANDATORY_DATA_MISSING", ex.ResponseCode);
                Assert.AreEqual("40223", ex.ResponseMessage);
                Assert.AreEqual($"Status Code: BadRequest - Request expects the batch_id",
                                ex.Message);
            }
            finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
Esempio n. 4
0
        public void CloseBatch_WithClosedBatchReference()
        {
            var transaction = creditCard.Charge(1.25m)
                              .WithCurrency(CURRENCY)
                              .Execute();

            AssertTransactionResponse(transaction, TransactionStatus.Captured);

            //TODO - remove when api fix polling issue
            Thread.Sleep(1000);

            var batchSummary = BatchService.CloseBatch(transaction.BatchSummary.BatchReference);

            AssertBatchCloseResponse(batchSummary, 1.25m);

            //TODO - remove when api fix polling issue
            Thread.Sleep(1000);

            var exceptionCaught = false;

            try {
                BatchService.CloseBatch(batchSummary.BatchReference);
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("INVALID_BATCH_ACTION", ex.ResponseCode);
                Assert.AreEqual("40014", ex.ResponseMessage);
                Assert.AreEqual("Status Code: BadRequest - 5,No current batch", ex.Message);
            }
            finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
Esempio n. 5
0
        public void CloseBatch_ActionNotAuthorized()
        {
            ServicesContainer.ConfigureService(new GpApiConfig {
                AppId   = APP_ID,
                AppKey  = APP_KEY,
                Channel = Channel.CardPresent
            });

            var transaction = creditTrackData
                              .Charge(AMOUNT)
                              .WithCurrency(CURRENCY)
                              .Execute();

            AssertTransactionResponse(transaction, TransactionStatus.Captured);

            waitForGpApiReplication();

            var exceptionCaught = false;

            try {
                BatchService.CloseBatch(transaction.BatchSummary.BatchReference);
            } catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("ACTION_NOT_AUTHORIZED", ex.ResponseCode);
                Assert.AreEqual("40212", ex.ResponseMessage);
                Assert.AreEqual("Status Code: Forbidden - Permission not enabled to execute action", ex.Message);
            } finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
Esempio n. 6
0
        public void CloseBatch_WithCardNumberDetails_DeclinedTransaction()
        {
            var card = new CreditCardData {
                Number      = "4263970000005262",
                ExpMonth    = expMonth,
                ExpYear     = expYear,
                Cvn         = "852",
                CardPresent = true
            };

            var chargeTransaction = card.Charge(AMOUNT)
                                    .WithCurrency(CURRENCY)
                                    .Execute();

            Assert.IsNotNull(chargeTransaction);
            Assert.AreEqual(DECLINED, chargeTransaction?.ResponseCode);
            Assert.AreEqual(GetMapping(TransactionStatus.Declined), chargeTransaction?.ResponseMessage);

            //TODO - remove when api fix polling issue
            waitForGpApiReplication();

            var batchSummary = BatchService.CloseBatch(chargeTransaction.BatchSummary.BatchReference);

            Assert.IsNotNull(batchSummary);
            Assert.AreEqual(CLOSED, batchSummary?.Status);
            Assert.AreEqual(0, batchSummary?.TransactionCount);
            Assert.AreEqual(0, batchSummary?.TotalAmount);
        }
Esempio n. 7
0
        public void CloseBatch_Auth_CreditCardData()
        {
            var transaction = creditTrackData.Authorize(AMOUNT)
                              .WithCurrency(CURRENCY)
                              .Execute();

            AssertTransactionResponse(transaction, TransactionStatus.Preauthorized);

            //TODO - remove when api fix polling issue
            waitForGpApiReplication();

            var exceptionCaught = false;

            try {
                BatchService.CloseBatch(transaction.BatchSummary.BatchReference);
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("MANDATORY_DATA_MISSING", ex.ResponseCode);
                Assert.AreEqual("40223", ex.ResponseMessage);
                Assert.AreEqual("Status Code: BadRequest - Request expects the batch_id", ex.Message);
            } finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
Esempio n. 8
0
        public void Test_033_Settlement()
        {
            BatchSummary response = BatchService.CloseBatch();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
        }
Esempio n. 9
0
        public void CloseBatch_WithCardNumberDetails_DeclinedTransaction()
        {
            var card = new CreditCardData {
                Number   = "4263970000005262",
                ExpMonth = 05,
                ExpYear  = 2025,
                Cvn      = "852",
            };

            var chargeTransaction = card.Charge(1.99m)
                                    .WithCurrency(CURRENCY)
                                    .Execute();

            Assert.IsNotNull(chargeTransaction);
            Assert.AreEqual("DECLINED", chargeTransaction?.ResponseCode);
            Assert.AreEqual(GetMapping(TransactionStatus.Declined), chargeTransaction?.ResponseMessage);

            //TODO - remove when api fix polling issue
            Thread.Sleep(1000);

            var exceptionCaught = false;

            try {
                BatchService.CloseBatch(chargeTransaction.BatchSummary.BatchReference);
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("INVALID_BATCH_ACTION", ex.ResponseCode);
                Assert.AreEqual("40017", ex.ResponseMessage);
                Assert.AreEqual("Status Code: BadRequest - 9,No transaction associated with batch", ex.Message);
            }
            finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
 public void recurring_999_CloseBatch()
 {
     try {
         var response = BatchService.CloseBatch();
         Assert.IsNotNull(response);
         //Console.WriteLine(string.Format("Batch ID: {0}", response.Id));
         //Console.WriteLine(string.Format("Sequence Number: {0}", response.SequenceNumber));
     }
     catch (GatewayException exc) {
         if (exc.ResponseMessage != "Transaction was rejected because it requires a batch to be open.")
         {
             Assert.Fail(exc.Message);
         }
     }
 }
Esempio n. 11
0
        public void CloseBatch()
        {
            var chargeTransaction = creditTrackData.Charge(AMOUNT)
                                    .WithCurrency(CURRENCY)
                                    .Execute();

            AssertTransactionResponse(chargeTransaction, TransactionStatus.Captured);

            //TODO - remove when api fix polling issue
            waitForGpApiReplication();

            var batchSummary = BatchService.CloseBatch(chargeTransaction.BatchSummary.BatchReference);

            AssertBatchCloseResponse(batchSummary, AMOUNT);
        }
Esempio n. 12
0
        public void CloseBatch()
        {
            var chargeTransaction = creditCard.Charge(1.99m)
                                    .WithCurrency(CURRENCY)
                                    .Execute();

            AssertTransactionResponse(chargeTransaction, TransactionStatus.Captured);

            //TODO - remove when api fix polling issue
            Thread.Sleep(1000);

            var batchSummary = BatchService.CloseBatch(chargeTransaction.BatchSummary.BatchReference);

            AssertBatchCloseResponse(batchSummary, 1.99m);
        }
Esempio n. 13
0
        public void Test_000_Settlement()
        {
            Logger.AppendText("Authorization End Date/Time: {0}", DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss"));
            Logger.AppendText("First HRN: {0}", _firstTransactionId);
            Logger.AppendText("Last HRN: {0}", _lastTransactionId);

            Logger.AppendText("\r\nTest_000_Settlement");
            Logger.AppendText("Settlement Time: {0}", DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss"));

            BatchSummary response = BatchService.CloseBatch();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);

            //_logger.AppendText("Batch Number: {0}", response.BatchId);
        }
Esempio n. 14
0
        public void Test_240_batchClose_EndOfShift()
        {
            configName = "default";

            CreditSale(100);
            CreditSale(100);
            CreditSale(10);
            DebitSale(10);
            DebitSale(10);
            DebitSale(1);

            BatchSummary response = BatchService.CloseBatch(BatchCloseType.EndOfShift);

            Assert.IsNotNull(response);
            Assert.IsTrue(response.IsBalanced);
        }
Esempio n. 15
0
        //TODO - add idempotency key as header
        public void CloseBatch_WithIdempotency()
        {
            var idempotency = Guid.NewGuid().ToString();

            var transaction = creditCard.Charge(1.99m)
                              .WithCurrency(CURRENCY)
                              .Execute();

            AssertTransactionResponse(transaction, TransactionStatus.Captured);

            var batchSummary = BatchService.CloseBatch(transaction.BatchSummary.BatchReference);

            //.setIdempotency - ToDo

            Assert.IsNotNull(batchSummary);
            Assert.AreEqual(CLOSED, batchSummary?.Status);

            BatchService.CloseBatch(transaction.BatchSummary.BatchReference);
        }
Esempio n. 16
0
        public void Ecom_001_CloseBatch()
        {
            ServicesContainer.ConfigureService(new PorticoConfig {
                SecretApiKey = "skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A"
            });

            try {
                var response = BatchService.CloseBatch();
                Assert.IsNotNull(response);
                Debug.WriteLine(string.Format("Batch ID: {0}", response.Id));
                Debug.WriteLine(string.Format("Sequence Number: {0}", response.SequenceNumber));
            }
            catch (GatewayException exc) {
                if (exc.ResponseMessage != "Transaction was rejected because it requires a batch to be open.")
                {
                    Assert.Fail(exc.Message);
                }
            }
        }
Esempio n. 17
0
        public void CloseBatch_WithInvalidBatchReference()
        {
            var batchReference = Guid.NewGuid().ToString().Replace("-", "");

            var exceptionCaught = false;

            try {
                BatchService.CloseBatch(batchReference);
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("RESOURCE_NOT_FOUND", ex.ResponseCode);
                Assert.AreEqual("40118", ex.ResponseMessage);
                Assert.AreEqual($"Status Code: NotFound - Batch {batchReference} not found at this location.",
                                ex.Message);
            } finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
Esempio n. 18
0
        public void Retail_000_CloseBatch()
        {
            ServicesContainer.ConfigureService(new PorticoConfig {
                SecretApiKey = "skapi_cert_MaePAQBr-1QAqjfckFC8FTbRTT120bVQUlfVOjgCBw"
            });

            try {
                var response = BatchService.CloseBatch();
                Assert.IsNotNull(response);
                Debug.WriteLine(string.Format("Batch ID: {0}", response.Id));
                Debug.WriteLine(string.Format("Sequence Number: {0}", response.SequenceNumber));
            }
            catch (GatewayException exc) {
                if (exc.ResponseMessage != "Transaction was rejected because it requires a batch to be open.")
                {
                    Assert.Fail(exc.Message);
                }
            }
        }
Esempio n. 19
0
        public void CloseBatch_MultipleChargeCreditTrackData()
        {
            var firstTransaction = creditCard.Charge(1.25m)
                                   .WithCurrency(CURRENCY)
                                   .Execute();

            AssertTransactionResponse(firstTransaction, TransactionStatus.Captured);

            var secondTransaction = creditCard.Charge(2.03m)
                                    .WithCurrency(CURRENCY)
                                    .Execute();

            AssertTransactionResponse(secondTransaction, TransactionStatus.Captured);

            //TODO - remove when api fix polling issue
            Thread.Sleep(1000);

            var batchSummary = BatchService.CloseBatch(secondTransaction.BatchSummary.BatchReference);

            AssertBatchCloseResponse(batchSummary, 3.28m);
        }
Esempio n. 20
0
        public void CloseBatch_CardNotPresentChannel()
        {
            ServicesContainer.ConfigureService(new GpApiConfig {
                AppId   = "P3LRVjtGRGxWQQJDE345mSkEh2KfdAyg",
                AppKey  = "ockJr6pv6KFoGiZA",
                Channel = Channel.CardNotPresent,
            });

            var creditCardData = new CreditCardData {
                Number   = "5425230000004415",
                ExpMonth = 05,
                ExpYear  = 2025,
                Cvn      = "852",
            };

            var transaction = creditCardData.Charge(1.25m)
                              .WithCurrency(CURRENCY)
                              .Execute();

            AssertTransactionResponse(transaction, TransactionStatus.Captured);

            //TODO - remove when api fix polling issue
            Thread.Sleep(1000);

            var exceptionCaught = false;

            try {
                BatchService.CloseBatch(transaction.BatchSummary.BatchReference);
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("UNAUTHORIZED_DOWNSTREAM", ex.ResponseCode);
                Assert.AreEqual("50002", ex.ResponseMessage);
                Assert.AreEqual($"Status Code: BadGateway - -2,Authentication error—Verify and correct credentials",
                                ex.Message);
            }
            finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
Esempio n. 21
0
        public void CloseBatch_ContactlessTransaction()
        {
            var debitCard = new DebitTrackData {
                Value       = ";4024720012345671=18125025432198712345?",
                EntryMethod = EntryMethod.Proximity,
                PinBlock    = "AFEC374574FC90623D010000116001EE"
            };

            var transaction = debitCard.Charge(1.99m)
                              .WithCurrency(CURRENCY)
                              .WithTagData(TAG_DATA)
                              .Execute();

            AssertTransactionResponse(transaction, TransactionStatus.Captured);

            //TODO - remove when api fix polling issue
            Thread.Sleep(1000);

            var batchSummary = BatchService.CloseBatch(transaction.BatchSummary.BatchReference);

            AssertBatchCloseResponse(batchSummary, 1.99m);
        }
Esempio n. 22
0
        public void CloseBatch_CardNotPresentChannel()
        {
            ServicesContainer.ConfigureService(new GpApiConfig {
                AppId   = APP_ID_FOR_BATCH,
                AppKey  = APP_KEY_FOR_BATCH,
                Channel = Channel.CardNotPresent,
            });

            var creditCardData = new CreditCardData {
                Number   = "5425230000004415",
                ExpMonth = expMonth,
                ExpYear  = expYear,
                Cvn      = "852",
            };

            var transaction = creditCardData.Charge(AMOUNT)
                              .WithCurrency(CURRENCY)
                              .Execute();

            AssertTransactionResponse(transaction, TransactionStatus.Captured);

            //TODO - remove when api fix polling issue
            waitForGpApiReplication();

            var exceptionCaught = false;

            try {
                BatchService.CloseBatch(transaction.BatchSummary.BatchReference);
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("UNAUTHORIZED_DOWNSTREAM", ex.ResponseCode);
                Assert.AreEqual("50002", ex.ResponseMessage);
                Assert.AreEqual($"Status Code: BadGateway - -2,Authentication error—Verify and correct credentials",
                                ex.Message);
            } finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
Esempio n. 23
0
        public void CloseBatch_DebitTrackData()
        {
            var debitCard = new DebitTrackData {
                Value =
                    "%B4012002000060016^VI TEST CREDIT^251210118039000000000396?;4012002000060016=25121011803939600000?",
                PinBlock    = "32539F50C245A6A93D123412324000AA",
                EntryMethod = EntryMethod.Swipe,
            };

            var transaction = debitCard.Charge(1.99m)
                              .WithCurrency(CURRENCY)
                              .Execute();

            AssertTransactionResponse(transaction, TransactionStatus.Captured);

            //TODO - remove when api fix polling issue
            Thread.Sleep(1000);

            var batchSummary = BatchService.CloseBatch(transaction.BatchSummary.BatchReference);

            AssertBatchCloseResponse(batchSummary, 1.99m);
        }
Esempio n. 24
0
        public void CloseBatch_Reverse_DebitTrackData()
        {
            var debitCard = new DebitTrackData {
                Value =
                    "%B4012002000060016^VI TEST CREDIT^251210118039000000000396?;4012002000060016=25121011803939600000?",
                PinBlock    = "32539F50C245A6A93D123412324000AA",
                EntryMethod = EntryMethod.Swipe,
            };

            var transaction = debitCard.Authorize(1.99m)
                              .WithCurrency(CURRENCY)
                              .Execute();

            AssertTransactionResponse(transaction, TransactionStatus.Preauthorized);

            var reverseTransaction = transaction.Reverse()
                                     .WithCurrency(CURRENCY)
                                     .Execute();

            AssertTransactionResponse(reverseTransaction, TransactionStatus.Reversed);

            //TODO - remove when api fix polling issue
            Thread.Sleep(1000);

            var exceptionCaught = false;

            try {
                BatchService.CloseBatch(transaction.BatchSummary.BatchReference);
            }
            catch (GatewayException ex) {
                exceptionCaught = true;
                Assert.AreEqual("MANDATORY_DATA_MISSING", ex.ResponseCode);
                Assert.AreEqual("40223", ex.ResponseMessage);
                Assert.AreEqual("Status Code: BadRequest - Request expects the batch_id", ex.Message);
            }
            finally {
                Assert.IsTrue(exceptionCaught);
            }
        }
Esempio n. 25
0
        public void CloseBatch_WithCardNumberDetails()
        {
            var card = new CreditCardData {
                Number   = "4263970000005262",
                ExpMonth = 05,
                ExpYear  = 2025,
                Cvn      = "123",
            };

            var chargeTransaction = card.Charge(1.99m)
                                    .WithCurrency(CURRENCY)
                                    .Execute();

            AssertTransactionResponse(chargeTransaction, TransactionStatus.Captured);

            //TODO - remove when api fix polling issue
            Thread.Sleep(1000);

            var batchSummary = BatchService.CloseBatch(chargeTransaction.BatchSummary.BatchReference);

            AssertBatchCloseResponse(batchSummary, 1.99m);
        }
Esempio n. 26
0
        public void CloseBatch_WithCardNumberDetails()
        {
            var card = new CreditCardData {
                Number      = "4263970000005262",
                ExpMonth    = expMonth,
                ExpYear     = expYear,
                Cvn         = "123",
                CardPresent = true
            };

            var chargeTransaction = card.Charge(AMOUNT)
                                    .WithCurrency(CURRENCY)
                                    .Execute();

            AssertTransactionResponse(chargeTransaction, TransactionStatus.Captured);

            //TODO - remove when api fix polling issue
            waitForGpApiReplication();

            var batchSummary = BatchService.CloseBatch(chargeTransaction.BatchSummary.BatchReference);

            AssertBatchCloseResponse(batchSummary, AMOUNT);
        }
Esempio n. 27
0
        public void CloseBatch_ReverseTransaction()
        {
            var chargeTransaction = creditTrackData.Charge(AMOUNT)
                                    .WithCurrency(CURRENCY)
                                    .Execute();

            AssertTransactionResponse(chargeTransaction, TransactionStatus.Captured);

            var response = chargeTransaction.Reverse()
                           .Execute();

            AssertTransactionResponse(response, TransactionStatus.Reversed);

            //TODO - remove when api fix polling issue
            waitForGpApiReplication();

            var batchSummary = BatchService.CloseBatch(chargeTransaction.BatchSummary.BatchReference);

            Assert.IsNotNull(batchSummary);
            Assert.AreEqual(CLOSED, batchSummary?.Status);
            Assert.AreEqual(0, batchSummary?.TransactionCount);
            Assert.AreEqual(0, batchSummary?.TotalAmount);
        }