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); }
public void PaymentReceived(PaymentResult paymentResult, PaymentInfo paymentInfo) { Status = Status.PaymentReceived; registerCreditCardTransation(paymentResult); saveUserCreditCard(paymentInfo, paymentResult); }
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; }
public OrderPlaced(int orderId, PaymentInfo paymentInfo) { OrderId = orderId; PaymentInfo = paymentInfo; }