public async Task <IActionResult> Link(Guid id) { var order = await _context.Orders.Include(i => i.Creator).SingleOrDefaultAsync(o => o.ShareIdentifier == id); if (order == null) { return(NotFound()); } if (order.Status != OrderStatusCodes.Finalized && order.Status != OrderStatusCodes.Complete) { return(NotFound()); } var model = new OrderResultsModel(); model.OrderReviewModel.Order = order; model.OrderReviewModel.OrderDetails = order.GetOrderDetails(); if (order.PaymentType == PaymentTypeCodes.CreditCard && !order.Paid) { model.ShowCreditCardPayment = true; Dictionary <string, string> dictionary = SetDictionaryValues(order, order.Creator); ViewBag.Signature = _dataSigningService.Sign(dictionary); model.PaymentDictionary = dictionary; model.CyberSourceUrl = _appSettings.CyberSourceUrl; } return(View(model)); }
public async Task <ActionResult> Pay(string id) { //Changes here should be made to Download too var invoice = await _dbContext.Invoices .Include(i => i.Items) .Include(i => i.Team) .Include(i => i.Attachments) .Include(i => i.Coupon) .FirstOrDefaultAsync(i => i.LinkId == id); if (invoice == null) { // check expired link id var link = await _dbContext.InvoiceLinks .Include(l => l.Invoice) .ThenInclude(i => i.Team) .FirstOrDefaultAsync(l => l.LinkId == id); // still not found if (link == null) { return(PublicNotFound()); } // if the invoice has a new link id, // just forward them to the corrected invoice if (!string.IsNullOrWhiteSpace(link.Invoice.LinkId)) { Message = "Your link was expired/old. We've forwarded you to the new link. Please review the invoice for any changes before proceeding."; return(RedirectToAction("Pay", new { id = link.Invoice.LinkId })); } // otherwise, the invoice is probably back in draft var expiredModel = new ExpiredInvoiceViewModel() { Team = new PaymentInvoiceTeamViewModel(link.Invoice.Team) }; return(View("Expired", expiredModel)); } // the customer isn't allowed access to draft or cancelled invoices if (invoice.Status == Invoice.StatusCodes.Draft || invoice.Status == Invoice.StatusCodes.Cancelled) { return(PublicNotFound()); } invoice.UpdateCalculatedValues(); var model = CreateInvoicePaymentViewModel(invoice); if (invoice.Status == Invoice.StatusCodes.Sent) { // prepare dictionary var dictionary = invoice.GetPaymentDictionary(); dictionary.Add("access_key", _cyberSourceSettings.AccessKey); dictionary.Add("profile_id", _cyberSourceSettings.ProfileId); var fieldNames = string.Join(",", dictionary.Keys); dictionary.Add("signed_field_names", "signed_field_names," + fieldNames); ViewBag.Signature = _dataSigningService.Sign(dictionary); ViewBag.CyberSourceUrl = _cyberSourceSettings.BaseUrl; model.PaymentDictionary = dictionary; } return(View(model)); }