protected void submitPayment_Click(object sender, EventArgs e) { IPaymentSystem paymentSystem = INFT3050PaymentFactory.Create(); PaymentRequest payment = new PaymentRequest(); payment.CardName = "Arthur Anderson"; payment.CardNumber = "4444333322221111"; payment.CVC = 123; payment.Expiry = new DateTime(2020, 11, 1); payment.Amount = 200; payment.Description = "test"; var task = paymentSystem.MakePayment(payment); if (task.IsCompleted) { Label1.Text = task.Result.ToString();; } //Response.Redirect("/Application Layer/MainSite/OrderConfirmation.aspx"); }
//The super janky payment function. Not sure if this how it's supposed to work but it seems to? public static int MakePayment(string name, string cardnum, int cvc, DateTime expiry) { IPaymentSystem paymentSystem = INFT3050PaymentFactory.Create(); PaymentRequest payment = new PaymentRequest(); payment.CardName = name; payment.CardNumber = cardnum; payment.CVC = cvc; payment.Expiry = expiry; payment.Amount = total; payment.Description = "Lotsa Watches"; var task = paymentSystem.MakePayment(payment); System.Threading.Thread.Sleep(5000); if (task.IsCompleted) { var result = Convert.ToInt32(task.Result.TransactionResult); switch (result) { case 0: return(0); case 1: return(1); case 2: return(2); case 3: return(3); case 4: return(4); default: return(4); } } else { return(4); } }
/// <summary> /// Determines whether transaction can be made on the specified card. /// </summary> /// <param name="card"></param> /// <returns></returns> public TransactionResult processPurchase(string[] card) { IPaymentSystem paymentSystem = INFT3050PaymentFactory.Create(); // Initialise card details PaymentRequest pr = new PaymentRequest { Amount = Convert.ToDecimal(Cart.Amount + Shipping.Cost), CardName = card[0], CardNumber = card[1], CVC = Convert.ToInt32(card[2]), Expiry = Convert.ToDateTime("01-" + card[3]), Description = "BCD Group - JerseySure" }; // Attempt to process order Task <PaymentResult> result = paymentSystem.MakePayment(pr); return(result.Result.TransactionResult); }
public TransactionResult processPayment(string[] card) { IPaymentSystem paymentSystem = INFT3050PaymentFactory.Create(); // Initialise card details PaymentRequest paymentRequest = new PaymentRequest(); paymentRequest.Amount = Convert.ToDecimal(ShoppingCart.Amount + PostageOption.postageCost); paymentRequest.CardName = card[0]; paymentRequest.CardNumber = card[1]; paymentRequest.CVC = Convert.ToInt32(card[2]); paymentRequest.Expiry = Convert.ToDateTime("01-" + card[3]); paymentRequest.Description = "JerseyZone"; // Attempt to process order Task <PaymentResult> result = paymentSystem.MakePayment(paymentRequest); return(result.Result.TransactionResult); }
protected void btnPayment_Click(object sender, EventArgs e) { IPaymentSystem paymentSystem = INFT3050PaymentFactory.Create(); PaymentRequest payment = new PaymentRequest(); payment.CardName = txtCardName.Text; payment.CardNumber = txtCardNumber.Text; payment.CVC = Convert.ToInt32(txtCVC.Text); payment.Expiry = DateTime.Parse(txtExpiryDate.Text); payment.Amount = 200; payment.Description = "test"; var task = paymentSystem.MakePayment(payment); if (task.IsCompleted) { //showTransactionResult(task.Result); } cart.Clear(); Response.Redirect("Confirmation.aspx"); }
protected void BtnConfirmation_Click(object sender, EventArgs e) { //page will only run payment if page is valid if (Page.IsValid) { //create new payment from payment code IPaymentSystem paymentSystem = INFT3050PaymentFactory.Create(); PaymentRequest payment = new PaymentRequest(); //take user data from input page payment.CardName = txtbxCardName.Text; payment.CardNumber = txtbxCardNumber.Text; payment.CVC = Convert.ToInt32(txtbxCVC.Text); payment.Expiry = new DateTime(Convert.ToInt32(txtbxYear.Text), Convert.ToInt32(txtbxMonth.Text), Convert.ToInt32(txtbxDay.Text)); //new DateTime(2020, 11, 1); payment.Amount = 200; payment.Description = "test"; //compare input user data for validation var task = paymentSystem.MakePayment(payment); //return result of data validation string result = Convert.ToString(task.Result.TransactionResult); //display result lblPaymentStatus.Text = result; //if result is approve move user to confirmation page if (result == "Approved") { //display loading bar to simulate processing task.Wait(); lblPaymentStatus.Text = result; task.Wait(); Response.Redirect("Confirmation.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { // SSL CODE. COMMENT OUT IF SSL DOESN'T WORK // SECURE PATH FOUND IN WEB.CONFIG FILE // SECURE PATH WILL DEPEND ON WHAT VS GIVES YOU WHEN ENABLING SSL = TRUE // Redirect for SSL if not already secured string securePath = (System.Configuration.ConfigurationManager.AppSettings["SecurePath"] + "UL/userPaymentPage.aspx"); System.Diagnostics.Debug.WriteLine(securePath); System.Diagnostics.Debug.WriteLine(HttpContext.Current.Request.Url.AbsoluteUri); if (securePath != HttpContext.Current.Request.Url.AbsoluteUri) { Response.Redirect(securePath); } else { System.Diagnostics.Debug.WriteLine("Already secured"); } // other btnPayment.Click += new EventHandler(this.paymentFunc); btnOkay.Click += new EventHandler(this.okayFunc); paymentSystem = INFT3050PaymentFactory.Create(); }
/// <summary> /// take Invoice/customer information /// set a paymentRequest corresponding to the subit button used /// Wait until end of payment /// Display result /// </summary> /// <param name="realPayment"></param> private void Payment(bool realPayment) { try { //Invoice recuperation (List of 1 element) int customerID = Convert.ToInt32(this.Session["CustID"]); int invoiceID = Convert.ToInt32(this.Session["InvoiceID"]); decimal TotalAmount = blInvoice.FindInvoiceByID(customerID, invoiceID)[0].GetTotal(); //Payment //Created the Payment system IPaymentSystem paymentSystem = INFT3050PaymentFactory.Create(); //Making a payment PaymentRequest payment = new PaymentRequest(); if (realPayment == false) { //Value to make the payment approved payment.CardName = "Arthur Anderson"; payment.CardNumber = "4444333322221111"; payment.CVC = 123; payment.Expiry = new DateTime(2020, 11, 1); payment.Amount = 200; } else { payment.CardName = TextName.Text; payment.CardNumber = TextCardNumber.Text; payment.CVC = Convert.ToInt16(TextCSC.Text); payment.Expiry = new DateTime(Convert.ToInt16(YearExpiration.SelectedValue), Convert.ToInt16(MonthExpiration.SelectedValue), 1); payment.Amount = TotalAmount; } payment.Description = "OrderID : " + invoiceID + " for customer : " + customerID; var task = paymentSystem.MakePayment(payment); while (!task.IsCompleted) { } //Let time to executing transaction //Display result if (task.Result.TransactionResult.ToString() == "Approved") { lblResult.CssClass = "text-success"; lblResult.Text = "Your paiment is approved !"; var urlF = FriendlyUrl.Href("/UL/Customer/checkout", 1); Response.Redirect(ConfigurationManager.AppSettings["SecurePath"] + urlF); } else if (task.Status.ToString() == "RanToCompletion") { lblResult.CssClass = "text-danger"; lblResult.Text = "Issue during the paiment : " + task.Result.TransactionResult.ToString(); lblWait.Visible = false; } else { lblResult.Text = "Issue during the paiment procedure, please try later"; lblWait.Visible = false; } } catch (Exception ex) { ex.GetBaseException(); Debug.Write(ex.ToString()); } }
public void StartPayment() { IPaymentSystem paymentSystem = INFT3050PaymentFactory.Create(); ActivePayment = paymentSystem.MakePayment(Request); }