Exemplo n.º 1
0
        public ActionResult Checkout(CheckoutViewModel creditCardValues)
        {
            var yearExpiration = Convert.ToInt16(creditCardValues.ExpirationYear);
            var monthExpiration = Convert.ToByte(creditCardValues.ExpirationMonth);

            var order = new Order(_randomOrderId, 4700.00m, DateTime.Now, "Goku e GokuSSJ");
            var paymentMethod = new PaymentMethod(CreditCard.MasterCard, PurchaseType.Credit);
            var options = new CreateTransactionOptions(AuthorizationType.AuthorizeSkippingAuthentication, true);
            var creditCardData = new CreditCardData(creditCardValues.CreditCardNumber,
                new CreditCardExpiration(yearExpiration, monthExpiration), SecurityCodeIndicator.Sent,
                creditCardValues.SecurityCode);
            var createTransactionRequest = new CreateTransactionRequest(order, paymentMethod, options, creditCardData,
                _configuration);

            try
            {
                var response = _cieloService.CreateTransaction(createTransactionRequest);
                Session["tid"] = response.Tid;
                return Redirect("CheckStatus");
            }
            catch (ResponseException ex)
            {
                ViewBag.MessageError = ex.Message;
                return View(creditCardValues);
            }
        }
Exemplo n.º 2
0
        public CreateTransactionResponse CreateTransaction(CreateTransactionRequest request)
        {
            var responseContent = string.Empty;

            try
            {
                responseContent = Execute(request);
                CreateExceptionIfError(responseContent);
                return new CreateTransactionResponse(responseContent);
            }
            catch (Exception ex)
            {
                throw new ResponseException(responseContent, ex);
            }
        }
        public void ToXml_CieloBuyPage_GivenACreateTransactionRequest_ShouldGenerateAXmlAsExpected()
        {
            var order = new Order("624726783", 10.00m, new DateTime(2013, 02, 18, 16, 45, 12), "[origem:172.16.34.66]");
            var paymentMethod = new PaymentMethod(CreditCard.Visa, PurchaseType.Credit);
            var createTransactionOptions =
                new CreateTransactionOptions(AuthorizationType.AuthorizeSkippingAuthentication, false);
            var fakeConfiguration = new FakeConfiguration();

            var createTransactionRequest = new CreateTransactionRequest(order, paymentMethod, createTransactionOptions,
                configuration: fakeConfiguration)
            {
                UniqueKey = Guid.Parse("b646a02f-9983-4df8-91b9-75b48345715a")
            };

            createTransactionRequest
                .ToXml(false)
                .RemoveNewLinesAndSpaces()
                .Should()
                .Be(ExpectedXmlCieloBuyPage.RemoveNewLinesAndSpaces());
        }
Exemplo n.º 4
0
        public ActionResult Checkout()
        {
            var order = new Order(_randomOrderId, 4700.00m, DateTime.Now, "Goku e GokuSSJ");

            //Crédito - A vista
            var paymentMethod = new PaymentMethod(CreditCard.MasterCard, PurchaseType.Credit);
            var options = new CreateTransactionOptions(AuthorizationType.AuthorizeSkippingAuthentication, true);

            //Crédito - Parcelado Loja
            //var paymentMethod = new PaymentMethod(CreditCard.MasterCard, PurchaseType.StoreInstallmentPayment, 5);
            //var options = new CreateTransactionOptions(AuthorizationType.AuthorizeSkippingAuthentication, capture: true);

            //Débito
            //var paymentMethod = new PaymentMethod(CreditCard.MasterCard, PurchaseType.Debit);
            //var options = new CreateTransactionOptions(AuthorizationType.AuthorizeAuthenticatedOrNot, capture: true);
            var createTransactionRequest = new CreateTransactionRequest(order, paymentMethod, options,
                configuration: _configuration);
            var response = _cieloService.CreateTransaction(createTransactionRequest);

            Session["tid"] = response.Tid;
            return Redirect(response.AuthenticationUrl);
        }
            ToXmlWithoutSensitiveData_GivenACreateTransactionRequest_ShouldGenerateAXmlWithoutSensitiveDataAkaCreditCardNumberAndDateAndSecurityCode
            ()
        {
            var order = new Order("624726783", 10.00m, new DateTime(2013, 02, 18, 16, 45, 12), "[origem:172.16.34.66]");
            var paymentMethod = new PaymentMethod(CreditCard.Visa, PurchaseType.Credit);
            var createTransactionOptions =
                new CreateTransactionOptions(AuthorizationType.AuthorizeSkippingAuthentication, false);
            var creditCardData = new CreditCardData("4551870000000183", new CreditCardExpiration(2015, 08),
                SecurityCodeIndicator.Sent, "973");
            var fakeConfiguration = new FakeConfiguration();

            var createTransactionRequest = new CreateTransactionRequest(order, paymentMethod, createTransactionOptions,
                creditCardData, fakeConfiguration)
            {
                UniqueKey = Guid.Parse("b646a02f-9983-4df8-91b9-75b48345715a")
            };

            createTransactionRequest
                .ToXmlWithoutSensitiveData(false)
                .RemoveNewLinesAndSpaces()
                .Should()
                .Be(ExpectedXmlLojaBuyPageWithoutSensitiveData.RemoveNewLinesAndSpaces());
        }