//public byte[] GeneratePDF(string orderID) //{ // MemoryStream memoryStream = new MemoryStream(); // Document document = new XDocument(PageSize.A5, 0, 0, 0, 0); // PdfWriter writer = PdfWriter.GetInstance(document, memoryStream); // document.Open(); // Order order = db.Orders.Find(orderID); // var userName = User.Identity.GetUserName(); // /* Find the details of the customer placing the order*/ // var customer = db.Customers.Where(x => x.Email == userName).FirstOrDefault(); // Order_Item order_Item = db.Order_Items.Find(orderID); // //var reservation = _iReservationService.Get(Convert.ToInt64(ReservationID)); // //var user = _iUserService.Get(reservation.UserID); // iTextSharp.text.Font font_heading_3 = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 12, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.RED); // iTextSharp.text.Font font_body = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 9, iTextSharp.text.BaseColor.BLUE); // // Create the heading paragraph with the headig font // PdfPTable table1 = new PdfPTable(1); // PdfPTable table2 = new PdfPTable(5); // PdfPTable table3 = new PdfPTable(1); // iTextSharp.text.pdf.draw.VerticalPositionMark seperator = new iTextSharp.text.pdf.draw.LineSeparator(); // seperator.Offset = -6f; // // Remove table cell // table1.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER; // table3.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER; // table1.WidthPercentage = 80; // table1.SetWidths(new float[] { 100 }); // table2.WidthPercentage = 80; // table3.SetWidths(new float[] { 100 }); // table3.WidthPercentage = 80; // PdfPCell cell = new PdfPCell(new Phrase("")); // cell.Colspan = 3; // table1.AddCell("\n"); // table1.AddCell(cell); // table1.AddCell("\n\n"); // table1.AddCell( // "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" + // "Alliance Properties SA \n" + // "Email :[email protected]" + "\n" + // "\n" + "\n"); // table1.AddCell("------------Customer Details--------------!"); // table1.AddCell("First Name : \t" + customer.FirstName); // table1.AddCell("Last Name : \t" + customer.LastName); // table1.AddCell("Phone Number : \t" + customer.phone); // table1.AddCell("Address : \t" + customer.Address); // table1.AddCell("\n------------Order details--------------!\n"); // table1.AddCell("Order # : \t" + orderID); // table1.AddCell("Price : \t" + order_Item.price); // table1.AddCell("Qauntity : \t" + order_Item.quantity); // table1.AddCell("Items : \t" + order_Item.Item.Name); // //table1.AddCell("Building name : \t" + roomBooking.BuildingId); // //table1.AddCell("Building Address : \t" + roomBooking.BuildingAddress); // table1.AddCell("\n"); // table3.AddCell("------------Looking forward to hear from you soon--------------!"); // //////Intergrate information into 1 document // //var qrCode = iTextSharp.text.Image.GetInstance(roomBooking.QrCodeImage); // //qrCode.ScaleToFit(200, 200); // table1.AddCell(cell); // document.Add(table1); // //document.Add(qrCode); // document.Add(table3); // document.Close(); // byte[] bytes = memoryStream.ToArray(); // memoryStream.Close(); // return bytes; //} public ActionResult OnceOff(string id) { var order = order_Service.GetOrder(id); var onceOffRequest = new PayFastRequest(this.payFastSettings.PassPhrase); var payment = new Payment(); payment.AmountPaid = order_Service.GetOrderTotal(order.Order_ID); payment.PaymentFor = order.Order_ID; payment.PaymentMethod = "Pay Fast Payment"; payment.Email = User.Identity.GetUserName(); payment.Order_ID = order.Order_ID; payment.Date = DateTime.Now; payment_Service.AddPayment(payment); order_Service.MarkOrderAsPaid(id); //SendMail(id); //var order= // Merchant Details onceOffRequest.merchant_id = this.payFastSettings.MerchantId; onceOffRequest.merchant_key = this.payFastSettings.MerchantKey; onceOffRequest.return_url = this.payFastSettings.ReturnUrl; onceOffRequest.cancel_url = this.payFastSettings.CancelUrl; onceOffRequest.notify_url = this.payFastSettings.NotifyUrl; // Buyer Details onceOffRequest.email_address = "*****@*****.**"; //double amount = Convert.ToDouble(db.Items.Select(x => x.CostPrice).FirstOrDefault()); //var products = db.Items.Select(x => x.Name).ToList(); // Transaction Details onceOffRequest.m_payment_id = ""; onceOffRequest.amount = order_Service.GetOrderTotal(order.Order_ID); onceOffRequest.item_name = "Once off option"; onceOffRequest.item_description = "Some details about the once off payment"; // Transaction Options onceOffRequest.email_confirmation = true; onceOffRequest.confirmation_address = "*****@*****.**"; var redirectUrl = $"{this.payFastSettings.ProcessUrl}{onceOffRequest.ToString()}"; return(Redirect(redirectUrl)); }