public static void HandleChargeAmountNotification(GCheckout.AutoGen.ChargeAmountNotification chargenotification)
 {
     string googleOrderID = chargenotification.googleordernumber;
     Cart order = new Cart().GetByPayment(googleOrderID);
     if (order.getTotal() == chargenotification.totalchargeamount.Value) {
         order.UpdatePayment("Complete");
         order.SendConfirmation();
         EDI edi = new EDI();
         edi.CreatePurchaseOrder(order.ID);
     }
 }
Exemplo n.º 2
0
 public string Read()
 {
     EDI edi = new EDI();
     edi.Read();
     return "done";
 }
Exemplo n.º 3
0
 //
 // GET: /Index/
 public string Index(int id = 0)
 {
     EDI edi = new EDI();
     edi.CreatePurchaseOrder(id);
     return "done";
 }
 public void CreatePO(int id = 0)
 {
     EDI edi = new EDI();
     edi.CreatePurchaseOrder(id);
 }
        public ActionResult Authorize()
        {
            Customer customer = new Customer();
            Settings settings = ViewBag.settings;
            // Retrieve Customer from Sessions/Cookie
            customer.GetFromStorage();
            if (!customer.LoggedIn()) {
                return RedirectToAction("Index", "Authenticate", new { referrer = "https://" + Request.Url.Host + "/Cart/Checkout" });
            }

            if (customer.Cart.payment_id > 0) {
                UDF.ExpireCart(customer.ID);
                return RedirectToAction("Index", "Cart");
            }
            customer.BindAddresses();

            decimal amount = customer.Cart.getTotal();
            string cardnum = Request.Form["cardnumber"];
            string month = Request.Form["expiremonth"];
            string year = Request.Form["expireyear"];
            string cvv = Request.Form["cvv"];
            string first = Request.Form["first"];
            string last = Request.Form["last"];

            //step 1 - create the request
            IGatewayRequest request = new AuthorizationRequest(cardnum, month + year, amount, "Transaction");

            //These are optional calls to the API
            request.AddCardCode(cvv);

            //Customer info - this is used for Fraud Detection
            request.AddCustomer(customer.ID.ToString(), first, last, customer.Cart.Billing.street1 + ((customer.Cart.Billing.street2 != "") ? " " + customer.Cart.Billing.street2 : ""), customer.Cart.Billing.State1.abbr, customer.Cart.Billing.postal_code);

            //order number
            //request.AddInvoice("invoiceNumber");

            //Custom values that will be returned with the response
            //request.AddMerchantValue("merchantValue", "value");

            //Shipping Address
            request.AddShipping(customer.ID.ToString(), customer.Cart.Shipping.first, customer.Cart.Shipping.last, customer.Cart.Shipping.street1 + ((customer.Cart.Shipping.street2 != "") ? " " + customer.Cart.Shipping.street2 : ""), customer.Cart.Shipping.State1.abbr, customer.Cart.Shipping.postal_code);

            //step 2 - create the gateway, sending in your credentials and setting the Mode to Test (boolean flag)
            //which is true by default
            //this login and key are the shared dev account - you should get your own if you
            //want to do more testing
            bool testmode = false;
            if (settings.Get("AuthorizeNetTestMode").Trim() == "true") {
                testmode = true;
            }

            Gateway gate = new Gateway(settings.Get("AuthorizeNetLoginKey"), settings.Get("AuthorizeNetTransactionKey"), testmode);

            //step 3 - make some money
            IGatewayResponse response = gate.Send(request);
            if (response.Approved) {
                customer.Cart.AddPayment("credit card",response.AuthorizationCode,"Complete");
                customer.Cart.SendConfirmation();
                int cartid = customer.Cart.ID;

                Cart new_cart = new Cart().Save();
                new_cart.UpdateCart(customer.ID);
                DateTime cookexp = Request.Cookies["hdcart"].Expires;
                HttpCookie cook = new HttpCookie("hdcart", new_cart.ID.ToString());
                cook.Expires = cookexp;
                Response.Cookies.Add(cook);

                customer.Cart = new_cart;
                customer.Cart.BindAddresses();

                EDI edi = new EDI();
                edi.CreatePurchaseOrder(cartid);

                return RedirectToAction("Complete", new { id = cartid });
            } else {
                return RedirectToAction("Index", new { message = response.Message });
            }
        }
        public ActionResult CompletePayPalCheckout(string token = "", string payerID = "")
        {
            Customer customer = ViewBag.customer;
            customer.GetFromStorage();
            if (!customer.LoggedIn()) {
                return RedirectToAction("Index", "Authenticate", new { referrer = "https://" + Request.Url.Host + "/Cart/Checkout" });
            }
            decimal total = customer.Cart.getTotal();
            Paypal p = new Paypal();
            string confirmationKey = p.ECDoExpressCheckout(token, payerID, total.ToString(), customer.Cart);
            if (confirmationKey == "Success") {
                customer.Cart.AddPayment("PayPal", token, "Complete");
                customer.Cart.SendConfirmation();
                int cartid = customer.Cart.ID;

                Cart new_cart = new Cart().Save();
                new_cart.UpdateCart(customer.ID);
                DateTime cookexp = Request.Cookies["hdcart"].Expires;
                HttpCookie cook = new HttpCookie("hdcart", new_cart.ID.ToString());
                cook.Expires = cookexp;
                Response.Cookies.Add(cook);

                customer.Cart = new_cart;
                customer.Cart.BindAddresses();

                EDI edi = new EDI();
                edi.CreatePurchaseOrder(cartid);
                return RedirectToAction("Complete", new { id = cartid });
            } else {
                return RedirectToAction("Index", new { message = "Your PayPal Transaction Could not be processed. Try Again." });
            }
        }