Exemple #1
0
        public void ShouldReturnSuccesstatusWhenSendVoidTransaction()
        {
            //Arrange
            //É necessário fazer uma autorização e uma captura antes do cancelamento
            #region Autorização
            AuthorizationRequest authRequest = new AuthorizationRequest()
            {
                Customer = customerData, Payment = paymentData, MerchantOrderId = "12345"
            };
            CieloTransaction      authorizationTransaction = new CieloTransaction(TransactionType.Authorization, credentials, ApiEnvironment.Sandbox);
            AuthorizationResponse authResponse             = (AuthorizationResponse)authorizationTransaction.Execute(authRequest);
            #endregion

            #region Captura
            PaymentRequest captureRequest = new PaymentRequest()
            {
                PaymentId = authResponse.Payment.PaymentId
            };
            BaseResponse captureResponse = new CieloTransaction(TransactionType.Capture, credentials, ApiEnvironment.Sandbox).Execute(captureRequest);
            #endregion
            //Act
            PaymentRequest voidRequest = new PaymentRequest()
            {
                PaymentId = authResponse.Payment.PaymentId
            };
            CieloTransaction voidTransaction         = new CieloTransaction(TransactionType.Void, credentials, ApiEnvironment.Sandbox);
            BaseResponse     voidTransactionResponse = voidTransaction.Execute(voidRequest);
            //Assert
            Assert.AreEqual(10, voidTransactionResponse.Status);
            Assert.AreEqual(0, voidTransactionResponse.ReturnCode);
        }
        public void ShouldReturnErrorWhenSendAuthorizationTransactionWithNullRequest()
        {
            //Arrange
            AuthorizationRequest authorizationRequestData = null;
            CieloTransaction     authorizationTransaction = new CieloTransaction(TransactionType.Authorization, credentials);
            //Act
            AuthorizationResponse authorizationResponse = (AuthorizationResponse)authorizationTransaction.Execute(authorizationRequestData);

            //Assert
            Assert.AreEqual("Ocorreu um erro na chamada da transação de autorização. Verifique o log de erro para mais detalhes", authorizationResponse.ReturnMessage);
        }
Exemple #3
0
        public void ShouldReturnNotFoundStatusWhenSendCaptureTransactionWithNotValidPaymentId()
        {
            //Arrange
            PaymentRequest captureRequest = new PaymentRequest()
            {
                PaymentId = Guid.NewGuid().ToString(), Amount = 50000
            };
            //Act
            CieloTransaction captureTransaction = new CieloTransaction(TransactionType.Capture, credentials, ApiEnvironment.Sandbox);
            BaseResponse     captureResponse    = captureTransaction.Execute(captureRequest);

            //Assert
            Assert.AreEqual(404, captureResponse.ReturnCode);
        }
        public void ShouldReturnAuthorizedStatusWhenSendAuthorizationTransactionWithCreditCard()
        {
            //Arrange
            AuthorizationRequest authorizationRequestData = new AuthorizationRequest()
            {
                MerchantOrderId = "12345",
                Customer        = customerData,
                Payment         = paymentData
            };

            CieloTransaction authorizationTransaction = new CieloTransaction(TransactionType.Authorization, credentials, ApiEnvironment.Sandbox);
            //Act
            AuthorizationResponse authorizationResponse = (AuthorizationResponse)authorizationTransaction.Execute(authorizationRequestData);

            //Assert
            Assert.AreEqual(1, authorizationResponse.Status);
            Assert.AreEqual(4, authorizationResponse.ReturnCode);
        }
        public void ShouldReturnProblemStatusWhenSendAuthorizationTransactionWithCreditCard()
        {
            //Arrange
            paymentData.CreditCard = creditCardCreator.WithCardNumber("0000000000000008").Result;
            AuthorizationRequest authorizationRequestData = new AuthorizationRequest()
            {
                MerchantOrderId = "12345",
                Customer        = customerData,
                Payment         = paymentData
            };
            CieloTransaction authorizationTransaction = new CieloTransaction(TransactionType.Authorization, credentials, ApiEnvironment.Sandbox);
            //Act
            AuthorizationResponse authorizationResponse = (AuthorizationResponse)authorizationTransaction.Execute(authorizationRequestData);

            //Assert
            Assert.AreEqual(3, authorizationResponse.Status);
            Assert.AreEqual(70, authorizationResponse.ReturnCode);
        }
        public void ShouldReturnErrorWhenSendAuthorizationTransactionWithAmountEqualToZero()
        {
            //Arrange
            PaymentClass paymentWithAmountZero = paymentCreator.WithAmount(0).Result;

            paymentWithAmountZero.CreditCard = creditCardData;
            AuthorizationRequest authorizationRequestData = new AuthorizationRequest()
            {
                MerchantOrderId = "12345",
                Customer        = customerData,
                Payment         = paymentWithAmountZero
            };

            CieloTransaction authorizationTransaction = new CieloTransaction(TransactionType.Authorization, credentials, ApiEnvironment.Sandbox);
            //Act
            AuthorizationResponse authorizationResponse = (AuthorizationResponse)authorizationTransaction.Execute(authorizationRequestData);

            //Assert
            Assert.AreEqual("Ocorreu um erro de validação na chamada da transação de autorização. Verifique o log de informação para mais detalhes", authorizationResponse.ReturnMessage);
        }
        public void ShouldReturnAuthorizedStatusWhenSendSearchPaymentTransactionWithCreditCard()
        {
            //Arrange
            paymentData.CreditCard = creditCardData;
            AuthorizationRequest authorizationRequestData = new AuthorizationRequest()
            {
                MerchantOrderId = "12345",
                Customer        = customerData,
                Payment         = paymentData
            };
            CieloTransaction      authorizationTransaction = new CieloTransaction(TransactionType.Authorization, credentials, ApiEnvironment.Sandbox);
            AuthorizationResponse authorizationResponse    = (AuthorizationResponse)authorizationTransaction.Execute(authorizationRequestData);
            CieloTransaction      searchPaymentTransaction = new CieloTransaction(TransactionType.SearchPayment, credentials, ApiEnvironment.Sandbox);
            //Act
            BaseResponse searchPaymentResponse = searchPaymentTransaction.Execute(new PaymentRequest()
            {
                PaymentId = authorizationResponse.Payment.PaymentId
            });

            //Assert
            Assert.AreEqual(1, searchPaymentResponse.Status);
        }