Пример #1
0
        public CreditCardCaptureResult Capture(CreditCardTransaction transaction)
        {
            if (transaction == null)
            {
                throw new ArgumentNullException("transaction");
            }

            var result = new CreditCardCaptureResult();

            var authNetCapRes = _authorizeNetService.Capture(transaction.Amount,
                                                             transaction.TransactionDetails.TransactionProcessorTransactionID,
                                                             transaction.AuthorizationCode);

            if (authNetCapRes.Success)
            {
                result.Success = true;
            }
            else
            {
                result.Success = false;

                result.Errors.AddRange(authNetCapRes.Errors);
            }

            return(result);
        }
Пример #2
0
        private AddPaymentTransactionResult SubmitReferenceTransaction(AddPaymentTransactionParameter parameter)
        {
            if (parameter.OriginalRequestNumber.IsBlank() || parameter.OriginalRequestToken.IsBlank())
            {
                return(this.CreateErrorServiceResult <AddPaymentTransactionResult>(SubCode.CreditCardFailed, "Original Request Number and Original Reference Number required"));
            }
            SubmitTransactionParameter transactionParameter = new SubmitTransactionParameter()
            {
                TransactionType       = parameter.TransactionType,
                ReferenceNumber       = parameter.ReferenceNumber,
                OriginalRequestNumber = parameter.OriginalRequestNumber,
                OriginalRequestToken  = parameter.OriginalRequestToken,
                Amount    = parameter.Amount,
                WebsiteId = parameter.WebsiteId
            };
            CreditCardTransaction creditCardTransaction = this.CreateCreditCardTransaction(transactionParameter);

            transactionParameter.CreditCardTransactionId = new Guid?(creditCardTransaction.Id);
            SubmitTransactionResult submitTransactionResult = this.GetPaymentGateway().SubmitTransaction(transactionParameter);

            if (!submitTransactionResult.Success)
            {
                this.UpdateCreditCardTransaction(creditCardTransaction, transactionParameter, submitTransactionResult);
                if (submitTransactionResult.IsConnectionError)
                {
                    return(this.ResendTransaction(transactionParameter));
                }
                return(this.CreateErrorServiceResult <AddPaymentTransactionResult>(SubCode.CreditCardFailed, string.Join(Environment.NewLine, (IEnumerable <string>)submitTransactionResult.ResponseMessages)));
            }
            return(new AddPaymentTransactionResult()
            {
                CreditCardTransaction = this.UpdateCreditCardTransaction(creditCardTransaction, transactionParameter, submitTransactionResult)
            });
        }
Пример #3
0
        private static void Main(string[] args)
        {
            #region CreditCard Transaction

            var creditCardTransactionProcessor =
                TransactionProcessorFactory.CreateTransactionProcessor(TransactionType.CreditCard);

            var creditCardTransaction = new CreditCardTransaction(
                1000, "Joe Satriani", "222", "1111222233334444");

            var creditCardTransactionInfo = creditCardTransactionProcessor.Authorize(creditCardTransaction);

            Console.WriteLine($"{creditCardTransactionInfo.Amount} | {creditCardTransactionInfo.CreateDate:g} | " +
                              $"{creditCardTransactionInfo.TransactionKey} | {creditCardTransactionInfo.TransactionStatusType}");

            #endregion

            #region Debit Transaction

            var debitTransactionProcessor =
                TransactionProcessorFactory.CreateTransactionProcessor(TransactionType.Debit);

            var debitTransaction = new DebitTransaction(1300, "Banco Itaú");

            var debitTransactionInfo = debitTransactionProcessor.Authorize(debitTransaction);

            Console.WriteLine($"{debitTransactionInfo.Amount} | {debitTransactionInfo.CreateDate:g} | " +
                              $"{debitTransactionInfo.TransactionKey} | {debitTransactionInfo.TransactionStatusType}");

            #endregion
        }
Пример #4
0
        private IEnumerable <CreditCardTransaction> Generate(IOrder order, ICreditCard[] cards)
        {
            if (cards.IsNullOrEmpty())
            {
                yield break;
            }
            var countCard = cards.Count();

            foreach (var card in cards)
            {
                var transaction = new CreditCardTransaction
                {
                    /*Divide o total da compra pelo número de cartões enviados*/
                    AmountInCents        = order.AmountInCents / countCard,
                    TransactionReference = order.TransactionReference,
                    InstallmentCount     = card.InstallmentCount
                };
                if (card.InstantBuyKey.HasValue && card.InstantBuyKey.Value != Guid.Empty)
                {
                    transaction.CreditCard = new CreditCard()
                    {
                        InstantBuyKey = card.InstantBuyKey.Value
                    };
                    yield return(transaction);

                    continue;
                }
                transaction.CreditCard = card.Copiar <ICreditCard, CreditCard>();
                Contract.Assert(card.CreditCardBrand.HasValue);
                GatewayApiClient.DataContracts.EnumTypes.CreditCardBrandEnum brand;
                Enum.TryParse(card.CreditCardBrand.GetValueOrDefault().ToString(), true, out brand);
                transaction.CreditCard.CreditCardBrand = brand;
                yield return(transaction);
            }
        }
Пример #5
0
        private CreditCardTransaction UpdateCreditCardTransaction(CreditCardTransaction creditCardTransaction, SubmitTransactionParameter submitTransactionParameter, SubmitTransactionResult submitTransactionResult)
        {
            creditCardTransaction.Result    = submitTransactionResult.Success ? "0" : "1";
            creditCardTransaction.AuthCode  = submitTransactionResult.ResponseNumber;
            creditCardTransaction.RequestId = submitTransactionResult.ResponseNumber;
            creditCardTransaction.PNRef     = submitTransactionResult.ResponseToken ?? string.Empty;
            creditCardTransaction.Status    = !submitTransactionResult.Success ? "Error" : (submitTransactionParameter.TransactionType == TransactionType.Authorization ? "Open" : "Submitted");
            //Save CC last 4 digit and CardType
            string ccNumber = (submitTransactionParameter.CreditCard.CardNumber.Length > 3) ? submitTransactionParameter.CreditCard.CardNumber.Substring(submitTransactionParameter.CreditCard.CardNumber.Length - 4, 4) : submitTransactionParameter.CreditCard.CardNumber;

            creditCardTransaction.CreditCardNumber = ccNumber;
            creditCardTransaction.CardType         = this.GetCardType(submitTransactionParameter.CreditCard.CardType);
            //End
            this.UnitOfWork.GetRepository <CreditCardTransaction>().Insert(creditCardTransaction);
            if (!submitTransactionResult.Success)
            {
                creditCardTransaction.RespText = string.Join(Environment.NewLine, (IEnumerable <string>)submitTransactionResult.ResponseMessages);
                return(creditCardTransaction);
            }
            if (submitTransactionParameter.TransactionType == TransactionType.Capture || submitTransactionParameter.TransactionType == TransactionType.Void)
            {
                CreditCardTransaction creditCardTransaction1 = this.UnitOfWork.GetRepository <CreditCardTransaction>().GetTable().FirstOrDefault <CreditCardTransaction>((Expression <Func <CreditCardTransaction, bool> >)(c => c.RequestId.Equals(submitTransactionParameter.OriginalRequestNumber)));
                if (creditCardTransaction1 != null)
                {
                    creditCardTransaction1.Status = submitTransactionParameter.TransactionType == TransactionType.Capture ? "Captured" : "Voided";
                }
            }
            return(creditCardTransaction);
        }
    public void SaleClick()
    {
        float cost = 0;

        float.TryParse(costField.text, out cost);
        int costInCents = Mathf.RoundToInt(cost * 100);

        CreditCard creditCard = new CreditCard()
        {
            HolderName       = cardNameField.text,
            CreditCardBrand  = brandField.text,
            CreditCardNumber = cardNumberField.text.Replace("-", ""),
        };

        int.TryParse(securityCodeField.text, out creditCard.SecurityCode);
        int.TryParse(expMonthField.text, out creditCard.ExpMonth);
        int.TryParse(expYearField.text, out creditCard.ExpYear);

        CreditCardTransaction transaction = new CreditCardTransaction()
        {
            AmountInCents = costInCents,
            CreditCard    = creditCard
        };

        if (OnSaleClick != null)
        {
            OnSaleClick(transaction);
        }
    }
Пример #7
0
        public static CreateSaleRequest GenerateSaleRequest()
        {
            CreditCard card = GenerateCreditCard();
            // Cria a transação.
            var transaction = new CreditCardTransaction()
            {
                AmountInCents    = 10000,
                CreditCard       = card,
                InstallmentCount = 1
            };

            // Cria requisição.
            var createSaleRequest = new CreateSaleRequest()
            {
                // Adiciona a transação na requisição.
                CreditCardTransactionCollection = new Collection <CreditCardTransaction>(
                    new CreditCardTransaction[] { transaction }
                    ),
                Order = new Order()
                {
                    OrderReference = "NumeroDoPedido"
                }
            };

            return(createSaleRequest);
        }
        private IEnumerable <CreditCardTransaction> ParseData(string[] data)
        {
            var parsedData = new List <CreditCardTransaction>(data.Length);

            for (int i = 0; i < data.Length; i++)
            {
                try
                {
                    var columns     = data[i].Split("\t");
                    var transaction = new CreditCardTransaction
                    {
                        TransactionId = columns[0],
                        Owner         = columns[1],
                        AccountNumber = columns[2],
                        CardNumber    = columns[3],
                        Currency      = columns[4],
                        Amount        = int.Parse(columns[5]) / 100,
                        MerchantName  = columns[6],
                        Date          = DateTime.ParseExact(columns[7], "yyyyMMdd", CultureInfo.InvariantCulture)
                    };

                    parsedData.Add(transaction);
                }
                catch
                {
                }
            }

            return(parsedData);
        }
Пример #9
0
        private AddPaymentTransactionResult ResendTransaction(SubmitTransactionParameter submitTransactionParameter)
        {
            SubmitTransactionParameter transactionParameter = new SubmitTransactionParameter()
            {
                TransactionType       = submitTransactionParameter.TransactionType,
                ReferenceNumber       = submitTransactionParameter.ReferenceNumber,
                OriginalRequestNumber = submitTransactionParameter.OriginalRequestNumber,
                OriginalRequestToken  = submitTransactionParameter.OriginalRequestToken,
                Amount              = submitTransactionParameter.Amount,
                WebsiteId           = submitTransactionParameter.WebsiteId,
                IsResentTransaction = true
            };
            CreditCardTransaction   creditCardTransaction   = this.CreateCreditCardTransaction(transactionParameter);
            SubmitTransactionResult submitTransactionResult = this.GetPaymentGateway().SubmitTransaction(transactionParameter);

            this.UpdateCreditCardTransaction(creditCardTransaction, transactionParameter, submitTransactionResult);
            if (!submitTransactionResult.Success)
            {
                return(this.CreateErrorServiceResult <AddPaymentTransactionResult>(SubCode.CreditCardFailed, string.Join(Environment.NewLine, (IEnumerable <string>)submitTransactionResult.ResponseMessages)));
            }
            return(new AddPaymentTransactionResult()
            {
                CreditCardTransaction = this.UpdateCreditCardTransaction(creditCardTransaction, submitTransactionParameter, submitTransactionResult)
            });
        }
        public void ParseNotification_AllFields_Test()
        {
            NotificationParser notificationParser = new NotificationParser();

            var statusNotification = notificationParser.ParseNotification(fullNotification);

            Assert.AreEqual(8500, statusNotification.AmountInCents);
            Assert.AreEqual(8500, statusNotification.AmountPaidInCents);
            Assert.IsNotNull(statusNotification.OnlineDebitTransaction);
            Assert.IsNotNull(statusNotification.CreditCardTransaction);
            Assert.IsNotNull(statusNotification.BoletoTransaction);
            Assert.AreEqual(Guid.Parse("B1B1092C-8681-40C2-A734-500F22683D9B"), statusNotification.MerchantKey);
            Assert.AreEqual(Guid.Parse("1025FCB5-41D8-43B5-82FE-398F61E83879"), statusNotification.OrderKey);
            Assert.AreEqual("9623472", statusNotification.OrderReference);
            Assert.AreEqual(OrderStatusEnum.Paid, statusNotification.OrderStatus);

            // BoletoTransaction
            Assert.AreEqual(1000, statusNotification.BoletoTransaction.AmountInCents);
            Assert.AreEqual(1000, statusNotification.BoletoTransaction.AmountPaidInCents);
            Assert.AreEqual(ParseDateTime("2015-09-21T15:42:04.573"), statusNotification.BoletoTransaction.BoletoExpirationDate);
            Assert.AreEqual("0123456789", statusNotification.BoletoTransaction.NossoNumero);
            Assert.AreEqual(ParseDateTime("2015-09-22T07:06:00.537"), statusNotification.BoletoTransaction.StatusChangedDate);
            Assert.AreEqual(Guid.Parse("F7C4B737-E8B5-4BAA-BB47-6ED2A1A1EE09"), statusNotification.BoletoTransaction.TransactionKey);
            Assert.AreEqual("6741137", statusNotification.BoletoTransaction.TransactionReference);
            Assert.AreEqual(BoletoTransactionStatusEnum.Generated, statusNotification.BoletoTransaction.PreviousBoletoTransactionStatus);
            Assert.AreEqual(BoletoTransactionStatusEnum.Paid, statusNotification.BoletoTransaction.BoletoTransactionStatus);

            // CreditCardTransaction
            CreditCardTransaction creditCardTransaction = statusNotification.CreditCardTransaction;

            Assert.AreEqual("Simulator", creditCardTransaction.Acquirer);
            Assert.AreEqual(500, creditCardTransaction.AmountInCents);
            Assert.AreEqual("123456", creditCardTransaction.AuthorizationCode);
            Assert.AreEqual(500, creditCardTransaction.AuthorizedAmountInCents);
            Assert.AreEqual(500, creditCardTransaction.CapturedAmountInCents);
            Assert.AreEqual("Mastercard", creditCardTransaction.CreditCardBrand);
            Assert.AreEqual("String Content", creditCardTransaction.CustomStatus);
            Assert.AreEqual(100, creditCardTransaction.RefundedAmountInCents);
            Assert.AreEqual(this.ParseDateTime("2015-09-22T15:51:41.217"), creditCardTransaction.StatusChangedDate);
            Assert.AreEqual("9876543210", creditCardTransaction.TransactionIdentifier);
            Assert.AreEqual(Guid.Parse("4111D523-9A83-4BE3-94D2-160F1BC9C4BD"), creditCardTransaction.TransactionKey);
            Assert.AreEqual("91735820", creditCardTransaction.TransactionReference);
            Assert.AreEqual("63417982", creditCardTransaction.UniqueSequentialNumber);
            Assert.AreEqual(100, creditCardTransaction.VoidedAmountInCents);
            Assert.AreEqual(CreditCardTransactionStatusEnum.AuthorizedPendingCapture, creditCardTransaction.PreviousCreditCardTransactionStatus);
            Assert.AreEqual(CreditCardTransactionStatusEnum.Captured, creditCardTransaction.CreditCardTransactionStatus);

            // OnlineDebitTransaction
            Assert.AreEqual(7000, statusNotification.OnlineDebitTransaction.AmountInCents);
            Assert.AreEqual(7000, statusNotification.OnlineDebitTransaction.AmountPaidInCents);
            Assert.AreEqual("BancoDoBrasil", statusNotification.OnlineDebitTransaction.BankName);
            Assert.AreEqual("22092015", statusNotification.OnlineDebitTransaction.BankPaymentDate);
            Assert.AreEqual(ParseDateTime("2015-09-22T13:15:46.333"), statusNotification.OnlineDebitTransaction.StatusChangedDate);
            Assert.AreEqual(Guid.Parse("751AE9F0-AF0B-4DE5-A483-2EFF2DE0FDF6"), statusNotification.OnlineDebitTransaction.TransactionKey);
            Assert.AreEqual("00000000000012345", statusNotification.OnlineDebitTransaction.TransactionKeyToBank);
            Assert.AreEqual("656885531", statusNotification.OnlineDebitTransaction.TransactionReference);
            Assert.AreEqual(OnlineDebitTransactionStatusEnum.OpenedPendingPayment, statusNotification.OnlineDebitTransaction.PreviousOnlineDebitTransactionStatus);
            Assert.AreEqual(OnlineDebitTransactionStatusEnum.Paid, statusNotification.OnlineDebitTransaction.OnlineDebitTransactionStatus);
        }
Пример #11
0
        /// <summary>
        /// Cria uma transação de cartão de crédito
        /// </summary>
        /// <param name="creditCardTransaction">Dados da transação de cartão de crédito</param>
        /// <param name="orderReference">Identificação do pedido na loja</param>
        /// <returns></returns>
        public HttpResponse <CreateSaleResponse> Create(CreditCardTransaction creditCardTransaction, string orderReference)
        {
            Collection <CreditCardTransaction> creditCardTransactionCollection = new Collection <CreditCardTransaction>();

            creditCardTransactionCollection.Add(creditCardTransaction);

            return(this.Create(creditCardTransactionCollection, orderReference));
        }
Пример #12
0
        /// <summary>
        /// Cria uma transação de cartão de crédito
        /// </summary>
        /// <param name="creditCardTransaction">Dados da transação de cartão de crédito</param>
        /// <returns></returns>
        public HttpResponse <CreateSaleResponse> Create(CreditCardTransaction creditCardTransaction)
        {
            Collection <CreditCardTransaction> creditCardTransactionCollection = new Collection <CreditCardTransaction>();

            creditCardTransactionCollection.Add(creditCardTransaction);

            return(this.Create(creditCardTransactionCollection));
        }
Пример #13
0
        private Task <string> SendSale(CreditCardTransaction creditCardTransaction, User user)
        {
            var acquirerConfig = new AcquirerConfiguration(configuration).FindAcquirerConfig(user);
            var data           = (CreditCardTransactionCielo)creditCardTransaction;
            var response       = APIService.GetApi(acquirerConfig.urlApi, data, acquirerConfig.headers);

            return(response);
        }
Пример #14
0
 public void Process(CreditCardTransaction t)
 {
     if (!Validate(t))
     {
         throw new ArgumentException("Could not validate transaction");
     }
     // processing code;;;
 }
Пример #15
0
        public string CartaoDeCredito(Pedido pedido)
        {
            string retorno = string.Empty;

            try
            {
                // Cria a transação.
                var transaction = new CreditCardTransaction()
                {
                    AmountInCents = 10000,
                    CreditCard    = new CreditCard()
                    {
                        //CreditCardBrand = CreditCardBrandEnum.Visa,
                        CreditCardBrand  = ((CreditCardBrandEnum)(pedido.Cliente.CartaoDeCredito.Bandeira)),
                        CreditCardNumber = pedido.Cliente.CartaoDeCredito.Numero,
                        ExpMonth         = int.Parse(pedido.Cliente.CartaoDeCredito.Validade.Split('/')[0]),
                        ExpYear          = int.Parse(pedido.Cliente.CartaoDeCredito.Validade.Split('/')[1]),
                        HolderName       = pedido.Cliente.CartaoDeCredito.Nome,
                        SecurityCode     = pedido.Cliente.CartaoDeCredito.CodigoSeguranca
                    },
                    InstallmentCount = 1
                };

                // Cria requisição.
                var createSaleRequest = new CreateSaleRequest()
                {
                    // Adiciona a transação na requisição.
                    CreditCardTransactionCollection = new Collection <CreditCardTransaction>(new CreditCardTransaction[] { transaction }),
                    Order = new Order()
                    {
                        OrderReference = pedido.Id.ToString()
                    }
                };

                // Coloque a sua MerchantKey aqui.
                Guid merchantKey = pedido.TokenLoja;

                // Cria o client que enviará a transação.
                var serviceClient = new GatewayServiceClient(merchantKey, new Uri("https://transaction.stone.com.br"));

                // Autoriza a transação e recebe a resposta do gateway.
                var httpResponse = serviceClient.Sale.Create(createSaleRequest);

                Console.WriteLine("Código retorno: {0}", httpResponse.HttpStatusCode);
                Console.WriteLine("Chave do pedido: {0}", httpResponse.Response.OrderResult.OrderKey);
                if (httpResponse.Response.CreditCardTransactionResultCollection != null)
                {
                    //retorno = httpResponse.Response.CreditCardTransactionResultCollection.FirstOrDefault().CreditCardTransactionStatus.ToString();
                    retorno = CreditCardTransactionStatusEnum.AuthorizedPendingCapture.ToString();
                }
            }
            catch (Exception ex)
            {
                retorno = CreditCardTransactionStatusEnum.WithError.ToString();
            }

            return(retorno);
        }
Пример #16
0
        public async Task <IActionResult> Pay()
        {
            StringBuilder console = new StringBuilder();

            // Cria a transação.
            var transaction = new CreditCardTransaction()
            {
                AmountInCents = 10000,
                CreditCard    = new CreditCard()
                {
                    CreditCardBrand  = CreditCardBrandEnum.Visa,
                    CreditCardNumber = "4111111111111111",
                    ExpMonth         = 10,
                    ExpYear          = 22,
                    HolderName       = "LUKE SKYWALKER",
                    SecurityCode     = "123"
                },
                InstallmentCount = 1
            };

            // Cria requisição.
            var createSaleRequest = new CreateSaleRequest()
            {
                // Adiciona a transação na requisição.
                CreditCardTransactionCollection = new Collection <CreditCardTransaction>(new CreditCardTransaction[] { transaction }),
                Order = new Order()
                {
                    OrderReference = "NumeroDoPedido"
                }
            };

            // Coloque a sua MerchantKey aqui.
            Guid merchantKey = Guid.Parse("0d96500c-fe5e-4454-bd3a-d2a6b83e81a3");

            // Cria o client que enviará a transação.


            var serviceClient = new GatewayServiceClient(merchantKey, new Uri("https://sandbox.mundipaggone.com"));

            // Autoriza a transação e recebe a resposta do gateway.
            var httpResponse = await serviceClient.CreateSale(createSaleRequest);

            console.AppendLine(string.Format("Código retorno: {0}", httpResponse.HttpStatusCode));
            console.AppendLine(string.Format("Chave do pedido: {0}", httpResponse.Response.OrderResult.OrderKey));

            if (httpResponse.Response.CreditCardTransactionResultCollection != null)
            {
                console.AppendLine(string.Format("Status transação: {0}", httpResponse.Response.CreditCardTransactionResultCollection.FirstOrDefault().CreditCardTransactionStatus));
            }

            ViewBag.Result = console.ToString();

            return(View());
        }
Пример #17
0
    public bool Validate(CreditCardTransaction t)
    {
        foreach (ICreditCardTransactionValidator validator in Validators)
        {
            if (!validator.Validate(t))
            {
                return(false);
            }
        }

        return(true);
    }
        public IReportItem Parse(string[] elements)
        {
            if (elements.Length < 27)
            {
                throw new InvalidDataException("The expected parameter count is 27");
            }

            CreditCardTransaction creditCardTransaction = new CreditCardTransaction();

            creditCardTransaction.Order                = new Order();
            creditCardTransaction.Order.OrderKey       = Guid.Parse(elements[Constants.IDX_CCT_ORDER_ORDER_KEY]);
            creditCardTransaction.Order.OrderReference = elements[Constants.IDX_CCT_ORDER_ORDER_REFERENCE];
            creditCardTransaction.Order.MerchantKey    = Guid.Parse(elements[Constants.IDX_CCT_ORDER_MERCHANT_KEY]);
            creditCardTransaction.Order.MerchantName   = elements[Constants.IDX_CCT_ORDER_MERCHANT_NAME];

            creditCardTransaction.TransactionKey           = Guid.Parse(elements[Constants.IDX_CCT_TRANSACTION_KEY]);
            creditCardTransaction.TransactionKeyToAcquirer = elements[Constants.IDX_CCT_TRANSACTION_KEY_TO_ACQUIRER];
            creditCardTransaction.TransactionReference     = elements[Constants.IDX_CCT_TRANSACTION_REFERENCE];
            creditCardTransaction.CreditCardBrand          = elements[Constants.IDX_CCT_CREDIT_CARD_BRAND];
            creditCardTransaction.CreditCardNumber         = elements[Constants.IDX_CCT_CREDIT_CARD_NUMBER];
            creditCardTransaction.InstallmentCount         = string.IsNullOrWhiteSpace(elements[Constants.IDX_CCT_INSTALLMENT_COUNT]) == false?int.Parse(elements[Constants.IDX_CCT_INSTALLMENT_COUNT]) : 0;

            creditCardTransaction.AcquirerName  = elements[Constants.IDX_CCT_ACQUIRER_NAME];
            creditCardTransaction.Status        = elements[Constants.IDX_CCT_STATUS];
            creditCardTransaction.AmountInCents = string.IsNullOrWhiteSpace(elements[Constants.IDX_CCT_AMOUNT_IN_CENTS]) == false?int.Parse(elements[Constants.IDX_CCT_AMOUNT_IN_CENTS]) : 0;

            creditCardTransaction.IataAmountInCents = string.IsNullOrWhiteSpace(elements[Constants.IDX_CCT_IATA_AMOUNT_IN_CENTS]) == false?int.Parse(elements[Constants.IDX_CCT_IATA_AMOUNT_IN_CENTS]) : 0;

            creditCardTransaction.AuthorizationCode       = elements[Constants.IDX_CCT_AUTHORIZATION_CODE];
            creditCardTransaction.TransactionIdentifier   = elements[Constants.IDX_CCT_TRANSACTION_IDENTIFIER];
            creditCardTransaction.UniqueSequentialNumber  = elements[Constants.IDX_CCT_UNIQUE_SEQUENTIAL_NUMBER];
            creditCardTransaction.AuthorizedAmountInCents = string.IsNullOrWhiteSpace(elements[Constants.IDX_CCT_AUTHORIZED_AMOUNT_IN_CENTS]) == false?long.Parse(elements[Constants.IDX_CCT_AUTHORIZED_AMOUNT_IN_CENTS]) : 0;

            creditCardTransaction.CapturedAmountInCents = string.IsNullOrWhiteSpace(elements[Constants.IDX_CCT_CAPTURED_AMOUNT_IN_CENTS]) == false?long.Parse(elements[Constants.IDX_CCT_CAPTURED_AMOUNT_IN_CENTS]) : 0;

            creditCardTransaction.VoidedAmountInCents = string.IsNullOrWhiteSpace(elements[Constants.IDX_CCT_VOIDED_AMOUNT_IN_CENTS]) == false?long.Parse(elements[Constants.IDX_CCT_VOIDED_AMOUNT_IN_CENTS]) : 0;

            creditCardTransaction.RefundedAmountInCents = string.IsNullOrWhiteSpace(elements[Constants.IDX_CCT_REFUNDED_AMOUNT_IN_CENTS]) == false?long.Parse(elements[Constants.IDX_CCT_REFUNDED_AMOUNT_IN_CENTS]) : 0;

            creditCardTransaction.AcquirerAuthorizationReturnCode = elements[Constants.IDX_CCT_ACQUIRER_AUTHORIZATION_RETURN_CODE];
            creditCardTransaction.AuthorizedDate = string.IsNullOrWhiteSpace(elements[Constants.IDX_CCT_AUTHORIZED_DATE]) == false?DateTime.ParseExact(elements[Constants.IDX_CCT_AUTHORIZED_DATE], Constants.CCT_DATE_TIME_FORMAT, null) : (DateTime?)null;

            creditCardTransaction.CapturedDate = string.IsNullOrWhiteSpace(elements[Constants.IDX_CCT_CAPTURED_DATE]) == false?DateTime.ParseExact(elements[Constants.IDX_CCT_CAPTURED_DATE], Constants.CCT_DATE_TIME_FORMAT, null) : (DateTime?)null;

            creditCardTransaction.VoidedDate = string.IsNullOrWhiteSpace(elements[Constants.IDX_CCT_VOIDED_DATE]) == false?DateTime.ParseExact(elements[Constants.IDX_CCT_VOIDED_DATE], Constants.CCT_DATE_TIME_FORMAT, null) : (DateTime?)null;

            creditCardTransaction.LastProbeDate = string.IsNullOrWhiteSpace(elements[Constants.IDX_CCT_LAST_PROBE_DATE]) == false?DateTime.ParseExact(elements[Constants.IDX_CCT_LAST_PROBE_DATE], Constants.CCT_DATE_TIME_FORMAT, null) : (DateTime?)null;

            return(creditCardTransaction);
        }
Пример #19
0
        private DataContracts.LocalDb.Transaction StonePayment(PaymentRequest pPaymentRequest, Acquirer pAcquirer)
        {
            //Create transaction.
            var transaction = new CreditCardTransaction()
            {
                AmountInCents = 10000,
                CreditCard    = new CreditCard()
                {
                    CreditCardBrand  = CreditCardBrandEnum.Mastercard,
                    CreditCardNumber = pPaymentRequest.CreditCardNumber,
                    ExpMonth         = Convert.ToInt32(pPaymentRequest.ExpMonth),
                    ExpYear          = Convert.ToInt32(pPaymentRequest.ExpYear),
                    HolderName       = pPaymentRequest.HolderName,
                    SecurityCode     = pPaymentRequest.SecurityCode
                },
                InstallmentCount = 1,
                Options          = new CreditCardTransactionOptions {
                    PaymentMethodCode = 1
                }
            };

            //Create request.
            var createSaleRequest = new CreateSaleRequest()
            {
                // Adiciona a transação na requisição.
                CreditCardTransactionCollection = new Collection <CreditCardTransaction>(new CreditCardTransaction[] { transaction }),
                Order = new StonePaymentGateway.DataContracts.Order()
                {
                    OrderReference = "Simulador"
                }
            };

            Guid merchantKey   = Guid.Parse(pAcquirer.MerchanteKey);
            var  serviceClient = new GatewayServiceClient(merchantKey, new Uri("https://transaction.stone.com.br"));
            var  httpResponse  = serviceClient.Sale.Create(createSaleRequest);
            var  result        = httpResponse.Response.CreditCardTransactionResultCollection.FirstOrDefault();
            var  transactionDb = new DataContracts.LocalDb.Transaction();

            transactionDb.Authorization     = result.AuthorizationCode;
            transactionDb.AuthAmountInCents = result.AuthorizedAmountInCents.ToString();
            transactionDb.CardExpiration    = pPaymentRequest.ExpYear + pPaymentRequest.ExpMonth;
            transactionDb.CardNumber        = pPaymentRequest.CreditCardNumber;
            transactionDb.Date             = (DateTime)result.CapturedDate;
            transactionDb.MerchanteKey     = pAcquirer.MerchanteKey;
            transactionDb.Message          = result.AcquirerMessage;
            transactionDb.CardName         = pPaymentRequest.HolderName;
            transactionDb.CardSecurityCode = pPaymentRequest.SecurityCode;

            return(transactionDb);
        }
Пример #20
0
        public CreditCardAuthorizationResult Authorize(CreditCardPayment payment, String description, Project.MVC.Entity.Models.Address billingAddress)
        {
            if (billingAddress == null)
            {
                throw new ArgumentNullException("billingAddress");
            }

            if (payment == null)
            {
                throw new ArgumentNullException("payment");
            }

            var result = new CreditCardAuthorizationResult();

            AuthorizeNetAuthorizationResult authResult = _authorizeNetService
                                                         .Authorize(payment.CreditCardNumber, payment.Expiration.ToString("MM/yy"), payment.CVV, payment.Amount, description, billingAddress);

            if (authResult.Success)
            {
                result.Success = true;

                CreditCardTransaction transaction = new CreditCardTransaction()
                {
                    Amount            = authResult.Amount,
                    AuthorizationCode = authResult.AuthorizationCode,
                    CardLastFour      = payment.CreditCardNumber.Substring(payment.CreditCardNumber.Length - 4),
                    PaymentMethod     = PaymentMethod.CreditCard,
                    TransactionDate   = DateTime.Now,
                    TransactionType   = TransactionType.Authorization
                };

                TransactionDetails transactionDetails = new TransactionDetails()
                {
                    TransactionProcessor = TransactionProcessor.AuthorizeNet,
                    TransactionProcessorTransactionID = authResult.MerchantTransactionID
                };

                transaction.TransactionDetails = transactionDetails;

                result.Transaction = transaction;

                return(result);
            }

            result.Success = false;

            result.Errors.AddRange(authResult.Errors);

            return(result);
        }
Пример #21
0
        public IActionResult Post([FromBody] CreditCardTransaction creditCardTransaction)
        {
            var           radixMerchantKey = Request.Headers[MERCHANT_KEY];
            var           user             = userRepository.FindByMerchantKey(radixMerchantKey);
            Task <string> response         = Task.FromResult(string.Empty);

            if (user == null)
            {
                Messages.Add(new NotificationMessage(SalesResource.MerchantKeyInvalid, NotificationType.Error));
            }

            if (!Messages.HasErrors())
            {
                if (user != null && user.AntiFraudSystem)
                {
                    if (creditCardTransaction.AntiFraud == null)
                    {
                        Messages.Add(new NotificationMessage(SalesResource.AndiFraudNull, NotificationType.Error));
                    }
                    else
                    {
                        var antiFraudSystem = new AntiFraudAPIService();
                        if (!antiFraudSystem.IsApproved(creditCardTransaction.AntiFraud))
                        {
                            Messages.Add(new NotificationMessage(SalesResource.TransactionDenied, NotificationType.Error));
                        }
                    }
                }
            }

            if (!Messages.HasErrors())
            {
                response = SendSale(creditCardTransaction, user);
                SaveTransactionHistory(radixMerchantKey, response.Result);
                return(Ok(new
                {
                    success = true,
                    data = response
                }));
            }

            return(BadRequest(new
            {
                success = true,
                data = Messages
            }));
        }
Пример #22
0
        public static void test()
        {
            var transaction = new CreditCardTransaction()
            {
                AmountInCents = 10000,
                CreditCard    = new CreditCard()
                {
                    CreditCardBrand  = CreditCardBrandEnum.Visa,
                    CreditCardNumber = "4111111111111111",
                    ExpMonth         = 10,
                    ExpYear          = 22,
                    HolderName       = "LUKE SKYWALKER",
                    SecurityCode     = "123"
                },
                InstallmentCount = 1
            };

            // Cria requisição.
            var createSaleRequest = new CreateSaleRequest()
            {
                // Adiciona a transação na requisição.
                CreditCardTransactionCollection = new CreditCardTransactionCollection(new CreditCardTransaction[] { transaction }),
                Order = new Order()
                {
                    OrderReference = "NumeroDoPedido"
                }
            };

            // Coloque a sua MerchantKey.
            Guid merchantKey = Guid.Parse("F2A1F485-CFD4-49F5-8862-0EBC438AE923");

            // Cria o client que enviará a transação.
            var serviceClient = new MockGatewayServiceClient(merchantKey);

            // Autoriza a transação e recebe a resposta do gateway.
            var httpResponse = serviceClient.Sale.Create(createSaleRequest);

            Console.WriteLine("Código retorno: {0}", httpResponse.HttpStatusCode);
            Console.WriteLine("Chave do pedido: {0}", httpResponse.Response.OrderResult.OrderKey);
            if (httpResponse.Response.CreditCardTransactionResultCollection != null)
            {
                Console.WriteLine("Status transação: {0}", httpResponse.Response.CreditCardTransactionResultCollection.FirstOrDefault().CreditCardTransactionStatus);
            }
        }
Пример #23
0
        public override HttpResponse <CreateSaleResponse> Create(CreateTransactionForm form)
        {
            // Converts string into one of CreditCardBrandEnum options
            CreditCardBrandEnum card = (CreditCardBrandEnum)Enum.Parse(typeof(CreditCardBrandEnum), form.CreditCardBrand);

            // Creates Transaction
            CreditCardTransaction transaction = new CreditCardTransaction()
            {
                AmountInCents = form.AmountInCents,
                CreditCard    = new CreditCard()
                {
                    CreditCardBrand  = card,
                    CreditCardNumber = form.CreditCardNumber,
                    ExpMonth         = form.ExpMonth,
                    ExpYear          = form.ExpYear,
                    HolderName       = form.HolderName,
                    SecurityCode     = form.SecurityCode.ToString()
                },
                InstallmentCount = form.InstallmentCount
            };

            // Cria requisição.
            CreateSaleRequest createSaleRequest = new CreateSaleRequest()
            {
                // Adiciona a transação na requisição.
                CreditCardTransactionCollection = new Collection <CreditCardTransaction>
                                                  (
                    new CreditCardTransaction[] { transaction }
                                                  ),
                Order = new Order()
                {
                    OrderReference = "NumeroDoPedido"
                }
            };

            // Autoriza a transação e recebe a resposta do gateway.
            HttpResponse <CreateSaleResponse> httpResponse = serviceClient.Sale.Create(createSaleRequest);

            return(httpResponse);
        }
Пример #24
0
        public CreateSaleRequest MapSaleRequest(Partner partner)
        {
            var buyer             = new Buyer();
            var transaction       = new CreditCardTransaction();
            var createSaleRequest = new CreateSaleRequest();

            buyer.Email = partner.Email;
            buyer.Name  = partner.Name;

            ExpiryDateStruct expiryDate = new ExpiryDateStruct();

            expiryDate.Month = partner.CreditCard.ExpiryDate.Substring(0, 2);  // MONTH_LENTH = 2
            expiryDate.Year  = partner.CreditCard.ExpiryDate.Substring(2 + 3); // MONTH_LENTH+1 + space + /

            var computedBrand = CreditCardUtility.GetBrandByNumber(partner.CreditCard.Number);

            // Cria a transação
            transaction.AmountInCents = partner.Plan;
            transaction.CreditCard    = new GatewayApiClient.DataContracts.CreditCard();
            transaction.CreditCard.CreditCardBrand  = computedBrand;
            transaction.CreditCard.CreditCardNumber = partner.CreditCard.Number;
            transaction.CreditCard.ExpMonth         = Convert.ToInt16(expiryDate.Month);
            transaction.CreditCard.ExpYear          = Convert.ToInt16(expiryDate.Year);
            transaction.CreditCard.HolderName       = partner.Name;
            transaction.CreditCard.SecurityCode     = partner.CreditCard.Cvv;
            transaction.InstallmentCount            = 1;
            transaction.Recurrency = new Recurrency()
            {
                DateToStartBilling = DateTime.Now,
                Frequency          = FrequencyEnum.Monthly,
                Interval           = 1,
                Recurrences        = 0
            };

            // Adiciona a transação na requisição.
            createSaleRequest.CreditCardTransactionCollection = new Collection <CreditCardTransaction>(new CreditCardTransaction[] { transaction });
            createSaleRequest.Order = new Order();

            return(createSaleRequest);
        }
Пример #25
0
        private void SubmitReversalTransaction(SubmitTransactionParameter submitTransactionParameter, SubmitTransactionResult submitTransactionResult)
        {
            SubmitTransactionParameter transactionParameter = new SubmitTransactionParameter()
            {
                TransactionType      = TransactionType.Reversal,
                CustomerNumber       = submitTransactionParameter.CustomerNumber,
                ReferenceNumber      = submitTransactionParameter.ReferenceNumber,
                CurrencyCode         = submitTransactionParameter.CurrencyCode,
                BillToAddress        = submitTransactionParameter.BillToAddress,
                ShipToAddress        = submitTransactionParameter.ShipToAddress,
                PaymentProfileId     = submitTransactionParameter.PaymentProfileId,
                CreditCard           = submitTransactionParameter.CreditCard,
                Amount               = submitTransactionParameter.Amount,
                WebsiteId            = submitTransactionParameter.WebsiteId,
                OriginalRequestToken = submitTransactionResult.ResponseToken
            };
            CreditCardTransaction creditCardTransaction = this.CreateCreditCardTransaction(transactionParameter);

            submitTransactionParameter.OriginalRequestToken = submitTransactionResult.ResponseToken;
            SubmitTransactionResult submitTransactionResult1 = this.GetPaymentGateway().SubmitTransaction(transactionParameter);

            this.UpdateCreditCardTransaction(creditCardTransaction, transactionParameter, submitTransactionResult1);
        }
        public void ParseNotification_CreditCard_Test()
        {
            NotificationParser notificationParser = new NotificationParser();

            StatusNotification statusNotification = null;

            statusNotification = notificationParser.ParseNotification(this.creditCardNotification);

            Assert.AreEqual(500, statusNotification.AmountInCents);
            Assert.AreEqual(500, statusNotification.AmountPaidInCents);
            Assert.IsNotNull(statusNotification.CreditCardTransaction);
            Assert.IsNull(statusNotification.OnlineDebitTransaction);
            Assert.AreEqual(Guid.Parse("B1B1092C-8681-40C2-A734-500F22683D9B"), statusNotification.MerchantKey);
            Assert.AreEqual(Guid.Parse("18471F05-9F6D-4497-9C24-D60D5BBB6BBE"), statusNotification.OrderKey);
            Assert.AreEqual("64a85875", statusNotification.OrderReference);
            Assert.AreEqual(OrderStatusEnum.Paid, statusNotification.OrderStatus);

            // CreditCardTransaction
            CreditCardTransaction creditCardTransaction = statusNotification.CreditCardTransaction;

            Assert.AreEqual("Simulator", creditCardTransaction.Acquirer);
            Assert.AreEqual(500, creditCardTransaction.AmountInCents);
            Assert.AreEqual("123456", creditCardTransaction.AuthorizationCode);
            Assert.AreEqual(500, creditCardTransaction.AuthorizedAmountInCents);
            Assert.AreEqual(500, creditCardTransaction.CapturedAmountInCents);
            Assert.AreEqual("Mastercard", creditCardTransaction.CreditCardBrand);
            Assert.IsTrue(string.IsNullOrEmpty(creditCardTransaction.CustomStatus));
            Assert.IsNull(creditCardTransaction.RefundedAmountInCents);
            Assert.AreEqual(this.ParseDateTime("2015-09-22T15:51:41.217"), creditCardTransaction.StatusChangedDate);
            Assert.AreEqual("9876543210", creditCardTransaction.TransactionIdentifier);
            Assert.AreEqual(Guid.Parse("4111D523-9A83-4BE3-94D2-160F1BC9C4BD"), creditCardTransaction.TransactionKey);
            Assert.AreEqual("91735820", creditCardTransaction.TransactionReference);
            Assert.AreEqual("63417982", creditCardTransaction.UniqueSequentialNumber);
            Assert.IsNull(creditCardTransaction.VoidedAmountInCents);
            Assert.AreEqual(CreditCardTransactionStatusEnum.AuthorizedPendingCapture, creditCardTransaction.PreviousCreditCardTransactionStatus);
            Assert.AreEqual(CreditCardTransactionStatusEnum.Captured, creditCardTransaction.CreditCardTransactionStatus);
        }
Пример #27
0
        public static async Task <CreateSaleResponse> EnviarTransacao(CartaoCredito cartaoCredito)
        {
            var model = new CreateSaleResponse();

            try
            {
                var transacao = new CreditCardTransaction()
                {
                    AmountInCents = Convert.ToInt64(cartaoCredito.ValorVenda.ToString("N2").Replace(",", "")),
                    CreditCard    = new CreditCard()
                    {
                        CreditCardBrand  = cartaoCredito.CreditCardBrand,
                        CreditCardNumber = cartaoCredito.Numero,
                        ExpMonth         = cartaoCredito.Validade.Substring(0, 2).DefaultInt(),
                        ExpYear          = cartaoCredito.Validade.Substring(5, 2).DefaultInt(),
                        HolderName       = cartaoCredito.Titular, //O nome do portador deve conter mais de um caracter
                        SecurityCode     = cartaoCredito.CVV
                    },
                    InstallmentCount = cartaoCredito.NumeroParcelas,
                    Options          = new CreditCardTransactionOptions()
                    {
                        //0 - PRODUÇÃO
                        //1 - HOMOLOGAÇÃO (TESTE)
                        PaymentMethodCode  = 1,
                        CurrencyIso        = CurrencyIsoEnum.BRL,
                        SoftDescriptorText = "Obraki"                            //Texto da fatura do cartão
                    },
                    CreditCardOperation = CreditCardOperationEnum.AuthAndCapture //Autorização e Captura Instantânea
                };

                var saleRequest = new CreateSaleRequest()
                {
                    CreditCardTransactionCollection = new Collection <CreditCardTransaction>(new CreditCardTransaction[] { transacao }),
                    Order = new Order()
                    {
                        //Um dos campos que não é obrigatório, mas que é de extrema importância é o OrderReference.
                        //Aconselhamos que sempre envie essa informação, pois assim, facilitara a sua gestão!
                        OrderReference = cartaoCredito.OrderReference.ToString()
                    }
                };

                var data = JsonConvert.SerializeObject(saleRequest);
                //HttpContent content = new StringContent(data, Encoding.UTF8, "application/json");
                //content.Headers.Add("Keep-Alive", "true");

                var request = (HttpWebRequest)WebRequest.Create(new Uri($"{Utils.STONE_BASE_URL}/Sale"));
                request.ContentType            = Utils.CONTENT_TYPE;
                request.Accept                 = Utils.CONTENT_TYPE;
                request.Method                 = "POST";
                request.Headers["MerchantKey"] = Utils.STONE_MERCHANT_KEY;

                using (var writer = new StreamWriter(await request.GetRequestStreamAsync()))
                {
                    writer.Write(data);
                    writer.Flush();
                    writer.Dispose();
                }

                using (var response = await request.GetResponseAsync())
                {
                    using (var stream = response.GetResponseStream())
                    {
                        var streamReader = new StreamReader(stream);
                        var result       = streamReader.ReadToEnd();

                        if (!string.IsNullOrEmpty(result))
                        {
                            model = JsonConvert.DeserializeObject <CreateSaleResponse>(result);
                        }
                        else
                        {
                            model.ErrorReport = new ErrorReport()
                            {
                                ErrorItemCollection = new Collection <ErrorItem>()
                                {
                                    new ErrorItem()
                                    {
                                        ErrorCode   = 999,
                                        Description = TransactionResult.Message("c999")
                                    }
                                }
                            };
                        }
                    }
                }

                return(model);
            }
            catch (WebException ex)
            {
                using (WebResponse response = ex.Response)
                {
                    HttpWebResponse httpResponse = (HttpWebResponse)response;

                    model.ErrorReport = new ErrorReport()
                    {
                        ErrorItemCollection = new Collection <ErrorItem>()
                        {
                            new ErrorItem()
                            {
                                ErrorCode   = ((int)httpResponse.StatusCode),
                                Description = TransactionResult.Message(((int)httpResponse.StatusCode).ToString())
                            }
                        }
                    };
                }

                return(model);

                //await Application.Current.MainPage.DisplayAlert("Informação", ex.Message, "OK");
            }
        }
Пример #28
0
    public bool Validate(CreditCardTransaction t)
    {
        var card; // lookup credit card

        return(t.BillingAddress == card.BillingAddress);
    }
Пример #29
0
    public bool Validate(CreditCardTransaction t)
    {
        var card; // lookup credit card

        return(t.TransactionAmount <= card.AvailableBalance);
    }
Пример #30
0
        private AddPaymentTransactionResult SubmitNewTransaction(AddPaymentTransactionParameter parameter)
        {
            Customer billTo1;
            Customer shipTo1;

            if (parameter.IsAdmin)
            {
                ICustomerRepository typedRepository = this.UnitOfWork.GetTypedRepository <ICustomerRepository>();
                if (!parameter.BillToId.HasValue)
                {
                    return(this.CreateErrorServiceResult <AddPaymentTransactionResult>(SubCode.NotFound, "BillToId is empty"));
                }
                Guid?nullable = parameter.ShipToId;
                if (!nullable.HasValue)
                {
                    return(this.CreateErrorServiceResult <AddPaymentTransactionResult>(SubCode.NotFound, "ShipToId is empty"));
                }
                ICustomerRepository customerRepository1 = typedRepository;
                nullable = parameter.BillToId;
                Guid id1 = nullable.Value;
                billTo1 = customerRepository1.Get(id1);
                ICustomerRepository customerRepository2 = typedRepository;
                nullable = parameter.ShipToId;
                Guid id2 = nullable.Value;
                shipTo1 = customerRepository2.Get(id2);
            }
            else
            {
                GetBillToResult billTo2 = this.GetBillTo(parameter.BillToId);
                if (billTo2.ResultCode != ResultCode.Success)
                {
                    return(this.CreateErrorServiceResult <AddPaymentTransactionResult>(billTo2.SubCode, billTo2.Message));
                }
                billTo1 = billTo2.BillTo;
                GetShipToResult shipTo2 = this.GetShipTo(parameter.BillToId, parameter.ShipToId);
                if (shipTo2.ResultCode != ResultCode.Success)
                {
                    return(this.CreateErrorServiceResult <AddPaymentTransactionResult>(shipTo2.SubCode, shipTo2.Message));
                }
                shipTo1 = shipTo2.ShipTo;
            }
            SubmitTransactionParameter transactionParameter = new SubmitTransactionParameter()
            {
                TransactionType  = parameter.TransactionType,
                CustomerNumber   = billTo1.CustomerNumber,
                ReferenceNumber  = parameter.ReferenceNumber,
                CurrencyCode     = parameter.CurrencyCode,
                BillToAddress    = CreateCreditCardAddress(billTo1, parameter.CreditCard),
                ShipToAddress    = CreateCreditCardAddress(shipTo1, (CreditCardDto)null),
                PaymentProfileId = parameter.PaymentProfileId,
                CreditCard       = parameter.CreditCard,
                Amount           = parameter.Amount,
                WebsiteId        = parameter.WebsiteId
            };

            if (!parameter.PaymentProfileId.IsBlank())
            {
                UserProfile userProfile = this.UnitOfWork.GetRepository <UserProfile>().Get(SiteContext.Current.UserProfileDto.Id);
                transactionParameter.CustomerProfileId = userProfile.GetProperty("StoredCustomerProfileId", string.Empty);
            }
            CreditCardTransaction creditCardTransaction = this.CreateCreditCardTransaction(transactionParameter);

            transactionParameter.CreditCardTransactionId = new Guid?(creditCardTransaction.Id);
            SubmitTransactionResult submitTransactionResult = (parameter.CreditCard.CardType == "PayPal" ? this.paymentGatewayFactory.GetPaymentGateway("PaypalExpress") : this.GetPaymentGateway()).SubmitTransaction(transactionParameter);

            if (submitTransactionResult.ResponseMessages.Count > 0)
            {
                LogHelper.For(this).Error(transactionParameter.CustomerNumber + submitTransactionResult.ResponseMessages.FirstOrDefault() + submitTransactionResult.Success, "CenposResponse");
            }
            if (!submitTransactionResult.Success)
            {
                this.UnitOfWork.RollbackTransaction();
                this.UnitOfWork.Clear(true);
                this.UnitOfWork.BeginTransaction();
                this.ResetContext();
                this.UpdateCreditCardTransaction(creditCardTransaction, transactionParameter, submitTransactionResult);
                if (submitTransactionResult.IsConnectionError)
                {
                    this.SubmitReversalTransaction(transactionParameter, submitTransactionResult);
                }
                return(this.CreateErrorServiceResult <AddPaymentTransactionResult>(SubCode.CreditCardFailed, string.Join(Environment.NewLine, (IEnumerable <string>)submitTransactionResult.ResponseMessages)));
            }
            return(new AddPaymentTransactionResult()
            {
                CreditCardTransaction = this.UpdateCreditCardTransaction(creditCardTransaction, transactionParameter, submitTransactionResult)
            });
        }