Exemple #1
0
 public PlaceOrder(int userId, int eventId, int quantity, PaymentInfo paymentInfo)
 {
     this.UserId = userId;
     this.EventId = eventId;
     this.Quantity = quantity;
     this.PaymentInfo = paymentInfo;
 }
        private CreditCardTransaction createCreditCardTransation(PaymentInfo paymentInfo)
        {
            var creditCard = paymentInfo.InstantBuyKey != null
                ? new CreditCard { InstantBuyKey = paymentInfo.InstantBuyKey.Value }
                : new CreditCard
                {
                    CreditCardNumber = paymentInfo.CreditCardNumber,
                    CreditCardBrand = (CreditCardBrandEnum)paymentInfo.CreditCardBrand,
                    ExpMonth = paymentInfo.ExpMonth,
                    ExpYear = paymentInfo.ExpYear,
                    SecurityCode = paymentInfo.SecurityCode,
                    HolderName = paymentInfo.HolderName
                };

            return new CreditCardTransaction()
            {
                AmountInCents = paymentInfo.Amount,
                CreditCard = creditCard
            };
        }
        public PaymentResult CreateTransaction(PaymentInfo paymentInfo)
        {
            HttpResponse<CreateSaleResponse> httpResponse = null;
            try
            {
                var transaction = createCreditCardTransation(paymentInfo);
                Logger.Info("GatewayServiceClient Request: {0}", transaction.Serialize());
                httpResponse = _serviceClient.Sale.Create(transaction);
                Logger.Info("GatewayServiceClient Response: {0}", httpResponse.Serialize());
            }
            catch (Exception ex)
            {
                Logger.Error("GatewayServiceClient Error: {0}", ex);
            }

            var createSaleResponse = httpResponse.Response;
            if (httpResponse.HttpStatusCode != HttpStatusCode.Created)
                throw new InvalidOperationException("Unable to process payment.", treatErrorReport(createSaleResponse.ErrorReport));

            var creditCardTransaction = createSaleResponse.CreditCardTransactionResultCollection.FirstOrDefault();
            return new PaymentResult(creditCardTransaction.TransactionReference, creditCardTransaction.CreditCard.InstantBuyKey);
        }
Exemple #4
0
 public void PaymentReceived(PaymentResult paymentResult, PaymentInfo paymentInfo)
 {
     Status = Status.PaymentReceived;
     registerCreditCardTransation(paymentResult);
     saveUserCreditCard(paymentInfo, paymentResult);
 }
Exemple #5
0
        private void saveUserCreditCard(PaymentInfo paymentInfo, PaymentResult paymentResult)
        {
            if (!paymentInfo.ShouldSaveCreditCard() || !paymentResult.InstantBuyKey.HasValue)
                return;

            var creditCard = new CreditCard(this.Customer, paymentResult.InstantBuyKey.Value,
                paymentInfo.CreditCardBrand, paymentInfo.CreditCardNumber.GetLast(4), paymentInfo.ExpMonth, paymentInfo.ExpYear);
            this.Customer.AddCreditCard(creditCard);
        }
 public ProcessPayment(int orderId, PaymentInfo paymentInfo)
 {
     OrderId = orderId;
     PaymentInfo = paymentInfo;
 }
Exemple #7
0
 public void PaymentReceived(PaymentResult paymentResult, PaymentInfo paymentInfo)
 {
     Status = Status.PaymentReceived;
     registerCreditCardTransation(paymentResult);
     saveUserCreditCard(paymentInfo, paymentResult);
 }
Exemple #8
0
 public OrderPlaced(int orderId, PaymentInfo paymentInfo)
 {
     OrderId = orderId;
     PaymentInfo = paymentInfo;
 }