private async Task <bool> ProcessPayment(CheckoutViewModel viewModel, User user, decimal transactionAmount, List <Team> teams) { bool success = true; var connectionInfo = new ConnectionInformation { AppKey = AppSettings.Payment.ClientId, AppSecret = AppSettings.Payment.ClientSecret, Url = AppSettings.Payment.BaseUrl }; var paymentInfo = new PaymentInformation { FirstName = viewModel.CcInfo.FirstName, LastName = viewModel.CcInfo.LastName, Address1 = viewModel.CcInfo.Address, City = viewModel.CcInfo.City, State = viewModel.CcInfo.State, PostalCode = viewModel.CcInfo.PostalCode, Country = viewModel.CcInfo.CountryCode, PhoneNumber = user.PhoneNumber, EmailAddress = user.Email, CreditCardNumber = viewModel.CcInfo.CardNumber, ExpirationDate = new DateTime(viewModel.CcInfo.Year, viewModel.CcInfo.Month, 1), Csc = viewModel.CcInfo.Cvv, TransactionAmount = transactionAmount, }; ITransactionResponse response = await PaymentService.ProcessPaymentAsync(connectionInfo, paymentInfo); if (response != null && response.IsSuccess) { foreach (Team team in teams) { team.PaymentTransactionId = response.TransactionId; } var transaction = new TransactionHistory() { ManagerId = Convert.ToInt32(User.FindFirstValue(ClaimTypes.NameIdentifier)), Amount = transactionAmount, PaymentStatus = response.PaymentStatus, TransactionDate = response.TransactionDate, TransactionId = response.TransactionId }; await TeamRepository.SaveAsync(); TransactionHistoryRepository.InsertOrUpdate(transaction); await TransactionHistoryRepository.SaveAsync(); } else { success = false; // need to log full response that came back } return(success); }
public ReversalResponse(Uri payment, ITransactionResponse reversal) { Payment = payment; Reversal = reversal; }
/// <summary> /// Instantiates a new response about a cancelled payment. /// </summary> /// <param name="payment">The <seealso cref="Uri"/> of the payment.</param> /// <param name="cancellation">Details about the transaction.</param> public CancellationResponse(Uri payment, ITransactionResponse cancellation) { Payment = payment; Cancellation = cancellation; }