Ejemplo n.º 1
0
        public static void FailureNew(string telCo, string msisdn, string price, string link, string content_id, string detail, int type, string ErrorDetail)
        {
            TransactionLogInfo _log = new TransactionLogInfo();

            //Luu vao bang transaction log truong hop giao dich that bai
            _log.Wap_Transaction_Link     = link;
            _log.Wap_Transaction_Mobile   = msisdn;
            _log.Wap_Transaction_Operator = telCo;
            _log.Wap_Transaction_Portal   = telCo;
            _log.Wap_TransactionDetail    = detail;
            _log.Wap_Transaction_Amount   = ConvertUtility.ToDouble(price);
            _log.Wap_TransactionName      = content_id;
            _log.Wap_TransactionOn        = DateTime.Now;
            _log.Wap_TransactionType      = type;
            _log.ErrorCode   = 1;//That bai
            _log.ErrorDetail = ErrorDetail;
            _log.Is3g        = ConvertUtility.ToInt32(HttpContext.Current.Session["is3g"]);
            TransactionController.Insert_TransactionLog_New(_log);
        }
Ejemplo n.º 2
0
    protected void SendConfrimMessage()
    {
        AspxCommerce.ServiceItem.BookAnAppointmentInfo appointmentInfo = new AspxCommerce.ServiceItem.BookAnAppointmentInfo();
        if (Session["OrderID"] != null)
        {
            int    storeID    = GetStoreID;
            int    portalID   = GetPortalID;
            string userName   = GetUsername;
            int    customerID = GetCustomerID;
            var    orderdata  = new OrderDetailsCollection();
            if (HttpContext.Current.Session["OrderCollection"] != null)
            {
                orderdata = (OrderDetailsCollection)HttpContext.Current.Session["OrderCollection"];
            }
            string invoice = orderdata.ObjOrderDetails.InvoiceNumber;
            lblInvoice.Text = invoice;

            var    random  = new Random();
            string transID = (random.Next(99999, 111111)).ToString();
            lblTransaction.Text = transID.Trim();

            if (Session["PaymentMethodName"] != null)
            {
                if (HttpContext.Current.Session["PaymentMethodName"].ToString() == "paypal")
                {
                    var pw = new PayPalWCFService();
                    int j  = orderdata.ObjOrderDetails.PaymentGatewayTypeID;
                    List <PayPalSettingInfo> setting = pw.GetAllPayPalSetting(j, storeID, portalID);
                    _authToken = setting[0].AuthToken;

                    _txToken = Request.QueryString.Get("tx");
                    _query   = string.Format("cmd=_notify-synch&tx={0}&at={1}", _txToken, _authToken);
                    const string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
                    const string strLive    = "https://www.paypal.com/cgi-bin/webscr";
                    string       test       = string.Empty;

                    if (Session["IsTestPayPal"] != null)
                    {
                        test = bool.Parse(Session["IsTestPayPal"].ToString()) ? strSandbox : strLive;
                    }
                    var req = (HttpWebRequest)WebRequest.Create(test);

                    req.Method        = "POST";
                    req.ContentType   = "application/x-www-form-urlencoded";
                    req.ContentLength = _query.Length;

                    var stOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
                    stOut.Write(_query);
                    stOut.Close();

                    var stIn = new StreamReader(req.GetResponse().GetResponseStream());
                    _strResponse = stIn.ReadToEnd();
                    stIn.Close();

                    if (_strResponse.StartsWith("SUCCESS"))
                    {
                        string sessionCode = HttpContext.Current.Session.SessionID;
                        try
                        {
                            PayPalHandler pdtt = ParseAfterIPN(_strResponse, storeID, portalID, userName, customerID, sessionCode, TemplateName, _addressPath);
                        }
                        catch (Exception)
                        {
                            lblerror.Text = GetSageMessage("Payment", "PaymentParsingIPNError");
                        }

                        String[] stringArray = _strResponse.Split('\n');
                        int      i;
                        string   status = string.Empty;
                        for (i = 1; i < stringArray.Length - 1; i++)
                        {
                            String[] stringArray1 = stringArray[i].Split('=');

                            String sKey   = stringArray1[0];
                            String sValue = HttpUtility.UrlDecode(stringArray1[1]);

                            switch (sKey)
                            {
                            case "txn_id":
                                _transID = Convert.ToString(sValue);
                                break;

                            case "payment_status":
                                status = Convert.ToString(sValue);
                                break;
                            }
                        }
                        lblTransaction.Text = _transID.Trim();
                        //lblInvoice.Text = _invoice;
                        lblPaymentMethod.Text = "Paypal";
                        if (status.ToLower().Trim() == "completed")
                        {
                            lblerror.Text = GetSageMessage("Payment", "PaymentProcessed");
                        }
                        else if (status.ToLower().Trim() == "pending")
                        {
                            lblerror.Text = GetSageMessage("Payment", "PaymentPending");
                        }
                    }
                    else
                    {
                        lblerror.Text = GetSageMessage("Payment", "PaymentError");
                    }
                }
                else if (HttpContext.Current.Session["PaymentMethodName"].ToString().ToLower() == "cashondelivery")
                {
                    const int responseCode = 1;                    const string responsereasontext = "Transaction occured successfully";
                    const int responsereasonCode = 1;

                    string purchaseorderNo = (random.Next(0, 1000)).ToString();
                    string sessionCode     = HttpContext.Current.Session.SessionID;
                    string result          = Parse(transID, invoice, purchaseorderNo, responseCode, responsereasonCode, responsereasontext, storeID, portalID, userName, customerID, sessionCode);
                    lblerror.Text = result;
                    lblerror.Text = GetSageMessage("Payment", "PaymentProcessed");
                    var tinfo = new TransactionLogInfo();
                    var tlog  = new TransactionLog();
                }
            }
            else
            {
                Response.Redirect(_sageRedirectPath, false);
            }
            if (HttpContext.Current.Session["AppointmentCollection"] != null)
            {
                appointmentInfo = (AspxCommerce.ServiceItem.BookAnAppointmentInfo)HttpContext.Current.Session["AppointmentCollection"];
            }

            lblServiceName.Text         = appointmentInfo.ServiceCategoryName.Trim();
            lblServiceProduct.Text      = appointmentInfo.ServiceProductName;
            lblServiceDuration.Text     = appointmentInfo.ServiceDuration;
            lblStoreLocation.Text       = appointmentInfo.StoreLocationName;
            lblServiceProviderName.Text = appointmentInfo.EmployeeName;
            lblProductPrice.Text        = appointmentInfo.ServiceProductPrice.Trim();

            lblPaymentMethod.Text = appointmentInfo.PaymentMethodName;
            lblDate.Text          = appointmentInfo.PreferredDate.ToString("MM/dd/yyyy");
            lblTime.Text          = appointmentInfo.PreferredTimeInterval.Trim();
        }
    }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string selectedCurrency = string.Empty;
        string MainCurrency     = string.Empty;

        try
        {
            StoreSettingConfig ssc = new StoreSettingConfig();
            MainCurrency = ssc.GetStoreSettingsByKey(StoreSetting.MainCurrency, GetStoreID, GetPortalID, GetCurrentCultureName);
            if (Session["SelectedCurrency"] != null)
            {
                if (Session["SelectedCurrency"].ToString() != "")
                {
                    selectedCurrency = Session["SelectedCurrency"].ToString();
                }
            }
            else
            {
                selectedCurrency = MainCurrency;
            }

            string       islive     = Request.Form["custom"];
            string       test       = string.Empty;
            const string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
            const string strLive    = "https://www.paypal.com/cgi-bin/webscr";
            test = bool.Parse(islive.Split('#')[6]) ? strSandbox : strLive;

            var req = (HttpWebRequest)WebRequest.Create(test);
            req.Method      = "POST";
            req.ContentType = "application/x-www-form-urlencoded";
            byte[] param      = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
            string strRequest = Encoding.ASCII.GetString(param);
            strRequest       += "&cmd=_notify-validate";
            req.ContentLength = strRequest.Length;
            var streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
            streamOut.Write(strRequest);
            streamOut.Close();
            var    streamIn    = new StreamReader(req.GetResponse().GetResponseStream());
            string strResponse = streamIn.ReadToEnd();
            streamIn.Close();
            if (strResponse == "VERIFIED")
            {
                string payerEmail     = Request.Form["payer_email"];
                string paymentStatus  = Request.Form["payment_status"];
                string receiverEmail  = Request.Form["receiver_email"];
                string amount         = Request.Form["mc_gross"];
                string invoice        = Request.Form["invoice"];
                string addressName    = Request.Form["address_name"];
                string addressStreet  = Request.Form["address_street"];
                string addressCity    = Request.Form["address_city"];
                string addressZip     = Request.Form["address_zip"];
                string addressCountry = Request.Form["address_country"];
                string transID        = Request.Form["txn_id"];
                string custom         = Request.Form["custom"];

                string[] ids         = custom.Split('#');
                int      orderID     = int.Parse(ids[0]);
                int      storeID     = int.Parse(ids[1]);
                int      portalID    = int.Parse(ids[2]);
                string   userName    = ids[3];
                int      customerID  = int.Parse(ids[4]);
                string   sessionCode = ids[5];
                string   pgid        = ids[7];

                var tinfo = new TransactionLogInfo();
                var tlog  = new TransactionLog();

                tinfo.TransactionID      = transID;
                tinfo.AuthCode           = "";
                tinfo.TotalAmount        = decimal.Parse(amount);
                tinfo.ResponseCode       = "1";
                tinfo.ResponseReasonText = "";
                tinfo.OrderID            = orderID;
                tinfo.StoreID            = storeID;
                tinfo.PortalID           = portalID;
                tinfo.AddedBy            = userName;
                tinfo.CustomerID         = customerID;
                tinfo.SessionCode        = sessionCode;
                tinfo.PaymentGatewayID   = int.Parse(pgid);
                tinfo.PaymentStatus      = paymentStatus;
                tinfo.PayerEmail         = payerEmail;
                tinfo.CreditCard         = "";
                tinfo.RecieverEmail      = receiverEmail;
                tinfo.CurrencyCode       = selectedCurrency;
                tlog.SaveTransactionLog(tinfo);


                if (paymentStatus.Equals("Completed"))
                {
                    var paypalobj = new PayPalHandler();
                    paypalobj.ParseIPN(orderID, transID, paymentStatus, storeID, portalID, userName, customerID, sessionCode);
                }
            }
            else if (strResponse == "INVALID")
            {
            }
            else
            {
            }
        }
        catch (Exception ex)
        {
            ProcessException(ex);
        }
    }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Form["transaction_id"] != null)
        {
            string   receiverEmail  = Request.Form["pay_to_email"];
            string   amount         = Request.Form["amount"];
            string   transID        = Request.Form["transaction_id"];
            string   custom         = Request.Form["field1"];
            string   itemFields     = Request.Form["field2"];
            string   responsereason = Request.Form["failed_reason_code"];
            string[] ids            = custom.Split('#');
            int      orderID        = int.Parse(ids[0].ToString());
            int      storeID        = int.Parse(ids[1].ToString());
            int      portalID       = int.Parse(ids[2].ToString());
            string   userName       = ids[3].ToString();
            int      customerID     = int.Parse(ids[4].ToString());
            string   sessionCode    = ids[5].ToString();
            string   pgid           = ids[7].ToString();
            selectedCurrency = ids[8].ToString();

            string itemids    = itemFields.Split('#')[0];
            string couponCode = itemFields.Split('#')[1];


            MoneybookersWCFService         pw = new MoneybookersWCFService();
            List <MoneybookersSettingInfo> sf;
            sf = pw.GetAllMoneybookersSetting(int.Parse(pgid), storeID, portalID);
            string secretCode      = sf[0].MoneybookersSecretWord.Trim();
            string merchantAccount = sf[0].MoneybookersMerchantAccount.Trim();
            string concatFields    = Request.Form["merchant_id"]
                                     + Request.Form["transaction_id"]
                                     + StringToMD5(secretCode)
                                     + Request.Form["mb_amount"]
                                     + Request.Form["mb_currency"]
                                     + Request.Form["status"];


            string MBEmail = merchantAccount;///MerchantEmail


            string payerEmail = Request.Form["pay_from_email"];

            if (Request.Form["status"] == "2")
            {
                status = "Processed";
            }
            if (Request.Form["status"] == "1")
            {
                status = "Scheduled";
            }
            if (Request.Form["status"] == "0")
            {
                status = "Pending";
            }
            if (Request.Form["status"] == "-1")
            {
                status = "Cancelled";
            }
            if (Request.Form["status"] == "-2")
            {
                status = "Declined";
            }
            if (Request.Form["status"] == "-3")
            {
                status = "Chargeback";
            }

            TransactionLogInfo tinfo = new TransactionLogInfo();
            TransactionLog     Tlog  = new TransactionLog();

            tinfo.TransactionID      = transID;
            tinfo.AuthCode           = Request.Form["status"];
            tinfo.TotalAmount        = decimal.Parse(amount);
            tinfo.ResponseCode       = Request.Form["status"];
            responsereason           = status;
            tinfo.ResponseReasonText = responsereason;
            tinfo.OrderID            = orderID;
            tinfo.StoreID            = storeID;
            tinfo.PortalID           = portalID;
            tinfo.AddedBy            = userName;
            tinfo.CustomerID         = customerID;
            tinfo.SessionCode        = sessionCode;
            tinfo.PaymentGatewayID   = int.Parse(pgid);
            tinfo.PaymentStatus      = status;
            tinfo.PayerEmail         = payerEmail;
            tinfo.CreditCard         = "";
            tinfo.RecieverEmail      = receiverEmail;
            tinfo.CurrencyCode       = selectedCurrency;
            Tlog.SaveTransactionLog(tinfo);

            if (Request.Form["md5sig"] == StringToMD5(concatFields) && Request.Form["status"] == "2" && Request.Form["pay_to_email"] == MBEmail)
            {
                MoneybookersHandler.ParseIPN(orderID, transID, status, storeID, portalID, userName, customerID, sessionCode);
                MoneybookersHandler.UpdateItemQuantity(itemids, couponCode, storeID, portalID, userName);
                CartManageSQLProvider cms           = new CartManageSQLProvider();
                AspxCommonInfo        aspxCommonObj = new AspxCommonInfo();
                aspxCommonObj.CustomerID  = customerID;
                aspxCommonObj.SessionCode = sessionCode;
                aspxCommonObj.StoreID     = storeID;
                aspxCommonObj.PortalID    = portalID;
                aspxCommonObj.CultureName = null;
                aspxCommonObj.UserName    = null;
                cms.ClearCartAfterPayment(aspxCommonObj);
            }
            else
            {
            }
        }
    }
Ejemplo n.º 5
0
    protected void SendConfrimMessage(string redirectPat)
    {
        try
        {
            if (Session["OrderID"] != null)
            {
                const int responseCode = 1;                const string responsereasontext = "Transaction occured successfully";
                const int responsereasonCode = 1;
                string    paymentmethod      = string.Empty;
                var       orderdata2         = new OrderDetailsCollection();
                if (HttpContext.Current.Session["OrderCollection"] != null)
                {
                    orderdata2 = (OrderDetailsCollection)HttpContext.Current.Session["OrderCollection"];
                }
                string invoice         = orderdata2.ObjOrderDetails.InvoiceNumber;
                var    random          = new Random();
                string purchaseorderNo = (random.Next(0, 1000)).ToString();
                string timeStamp       = ((int)(DateTime.UtcNow - new DateTime(2011, 1, 1)).TotalSeconds).ToString();
                string transID         = (random.Next(99999, 111111)).ToString();
                lblTransaction.Text   = transID;
                lblInvoice.Text       = invoice;
                lblPaymentMethod.Text = "Cash On Delivery";
                lblPaymentStatus.Text = "Successfull";
                lblDateTime.Text      = DateTime.Now.ToString("dddd, dd MMMM yyyy ");
                lblOrderNo.Text       = "#" + Session["OrderID"].ToString();
                AspxCommonInfo aspxCommonObj = new AspxCommonInfo();
                aspxCommonObj.StoreID     = GetStoreID;
                aspxCommonObj.PortalID    = GetPortalID;
                aspxCommonObj.UserName    = GetUsername;
                aspxCommonObj.CustomerID  = GetCustomerID;
                aspxCommonObj.SessionCode = HttpContext.Current.Session.SessionID;
                aspxCommonObj.CultureName = GetCurrentCultureName;
                int    orderID = orderdata2.ObjOrderDetails.OrderID;
                string result  = CashOnDelivery.Parse(transID, invoice, purchaseorderNo, responseCode, responsereasonCode, responsereasontext, aspxCommonObj);
                AspxGiftCardController.IssueGiftCard(orderdata2.LstOrderItemsInfo, orderID, true, aspxCommonObj);
                if (orderdata2.GiftCardDetail != null && CheckOutSessions.Get <List <GiftCardUsage> >("UsedGiftCard").Count > 0)
                {
                    AspxGiftCardController.UpdateGiftCardUsage(orderdata2.GiftCardDetail, orderdata2.ObjCommonInfo.StoreID,
                                                               orderdata2.ObjCommonInfo.PortalID, orderdata2.ObjOrderDetails.OrderID, orderdata2.ObjCommonInfo.AddedBy,
                                                               orderdata2.ObjCommonInfo.CultureName);
                }

                lblerror.Text = result;
                lblerror.Text = GetSageMessage("Payment", "PaymentProcessed");
                var tinfo = new TransactionLogInfo();
                var tlog  = new TransactionLog();

                tinfo.TransactionID      = transID;
                tinfo.AuthCode           = "";
                tinfo.TotalAmount        = orderdata2.ObjOrderDetails.GrandTotal * currencyRate;
                tinfo.ResponseCode       = responseCode.ToString();
                tinfo.ResponseReasonText = responsereasontext;
                tinfo.OrderID            = orderdata2.ObjOrderDetails.OrderID;
                tinfo.StoreID            = orderdata2.ObjCommonInfo.StoreID;
                tinfo.PortalID           = orderdata2.ObjCommonInfo.PortalID;
                tinfo.AddedBy            = orderdata2.ObjCommonInfo.AddedBy;
                tinfo.CustomerID         = orderdata2.ObjOrderDetails.CustomerID;
                tinfo.SessionCode        = orderdata2.ObjOrderDetails.SessionCode;
                tinfo.PaymentGatewayID   = orderdata2.ObjOrderDetails.PaymentGatewayTypeID;
                tinfo.PaymentStatus      = "Processed";
                tinfo.CreditCard         = "";
                tinfo.CurrencyCode       = SelectedCurrency;
                tlog.SaveTransactionLog(tinfo);
                CheckOutHelper cHelper = new CheckOutHelper();
                cHelper.ClearSessions();

                if (Session["OrderCollection"] != null)
                {
                    var orderdata = (OrderDetailsCollection)Session["OrderCollection"];
                    try
                    {
                        orderdata.ObjOrderDetails.OrderStatus = "Processed";
                        EmailTemplate.SendEmailForOrder(GetPortalID, orderdata, _addressPath, TemplateName, transID);
                    }
                    catch (Exception ex)
                    {
                        lblerror.Text = "";
                        lblerror.Text = GetSageMessage("Payment", "EmailSendOrderProblem");
                        ProcessException(ex);
                    }
                    Session.Remove("OrderCollection");
                }
            }
            else
            {
                Response.Redirect(_sageRedirectPath, false);
            }
        }
        catch (Exception ex)
        {
            ProcessException(ex);
        }
    }
Ejemplo n.º 6
0
    private void MobileSuccess(string redirectPath)
    {
        try
        {
            if (Session["mb_OrderDetail"] != null)
            {
                var    orderInfo         = (OrderInfo)Session["mb_OrderDetail"];
                var    giftCardUsage     = (List <GiftCardUsage>)Session["mb_GiftCardUsage"];
                var    coupons           = (List <CouponSession>)Session["mb_CouponSession"];
                var    couponCodeApplied = int.Parse(Session["mb_CouponCodeApplied"].ToString());
                var    billingAddress    = (UserAddressInfo)Session["mb_BillingAddress"];
                var    shippingAddress   = (UserAddressInfo)Session["mb_ShippingAddress"];
                var    itemsInfo         = (List <OrderItem>)Session["mb_ItemDetails"];
                int    storeId           = orderInfo.StoreId;
                int    portalId          = orderInfo.PortalId;
                string userName          = orderInfo.AddedBy;
                int    customerId        = orderInfo.CustomerId;

                const int responseCode = 1;                const string responsereasontext = "Transaction occured successfully";
                const int responsereasonCode = 1;

                string invoice         = orderInfo.InvoiceNumber;
                var    random          = new Random();
                string purchaseorderNo = (random.Next(0, 1000)).ToString();
                string timeStamp       = ((int)(DateTime.UtcNow - new DateTime(2011, 1, 1)).TotalSeconds).ToString();

                if (!string.IsNullOrEmpty(orderInfo.TransactionId) && orderInfo.TransactionId.Trim() != "0")
                {
                    lblTransaction.Text   = orderInfo.TransactionId;
                    lblInvoice.Text       = orderInfo.InvoiceNumber;
                    lblPaymentStatus.Text = "Successfull";
                    lblPaymentMethod.Text = orderInfo.PaymentMethodName;
                    lblDateTime.Text      = orderInfo.AddedOn.ToString("dddd, dd MMMM yyyy ");
                    lblOrderNo.Text       = "#" + orderInfo.OrderId;
                }
                else
                {
                    string transID = (random.Next(99999, 111111)).ToString();
                    lblTransaction.Text   = transID;
                    lblInvoice.Text       = invoice;
                    lblPaymentStatus.Text = "Successfull";
                    lblPaymentMethod.Text = orderInfo.PaymentMethodName;
                    lblDateTime.Text      = DateTime.Now.ToString("dddd, dd MMMM yyyy ");
                    lblOrderNo.Text       = "#" + orderInfo.OrderId;

                    string result = CashOnDelivery.ParseForMobile(transID, orderInfo, purchaseorderNo, responseCode,
                                                                  responsereasonCode,
                                                                  responsereasontext);

                    AspxCommonInfo aspxCommonObj = new AspxCommonInfo();
                    aspxCommonObj.StoreID     = storeId;
                    aspxCommonObj.PortalID    = portalId;
                    aspxCommonObj.UserName    = userName;
                    aspxCommonObj.CultureName = GetCurrentCultureName;
                    int orderID = orderInfo.OrderId;

                    CashOnDelivery.UpdateItemQuantityAndCoupon(orderInfo, itemsInfo, coupons, storeId, portalId,
                                                               userName);
                    AspxGiftCardController.IssueGiftCardForMobile(itemsInfo, orderID, false, aspxCommonObj);
                    if (giftCardUsage != null && giftCardUsage.Count > 0)
                    {
                        AspxGiftCardController.UpdateGiftCardUsage(giftCardUsage, storeId,
                                                                   portalId,
                                                                   orderInfo.OrderId,
                                                                   userName,
                                                                   orderInfo.CultureName);
                    }


                    lblerror.Text = result;
                    lblerror.Text = GetSageMessage("Payment", "PaymentProcessed");
                    var tinfo = new TransactionLogInfo();
                    var tlog  = new TransactionLog();


                    tinfo.TransactionID      = transID;
                    tinfo.AuthCode           = "";
                    tinfo.TotalAmount        = decimal.Parse(orderInfo.GrandTotal.ToString()) * currencyRate;
                    tinfo.ResponseCode       = responseCode.ToString();
                    tinfo.ResponseReasonText = responsereasontext;
                    tinfo.OrderID            = orderInfo.OrderId;
                    tinfo.StoreID            = orderInfo.StoreId;
                    tinfo.PortalID           = orderInfo.PortalId;
                    tinfo.AddedBy            = orderInfo.AddedBy;
                    tinfo.CustomerID         = orderInfo.CustomerId;
                    tinfo.SessionCode        = orderInfo.SessionCode;
                    tinfo.PaymentGatewayID   = orderInfo.PaymentGatewayTypeId;
                    tinfo.PaymentStatus      = "Processed";
                    tinfo.CreditCard         = "";
                    tinfo.CurrencyCode       = SelectedCurrency;
                    tlog.SaveTransactionLog(tinfo);

                    try
                    {
                        EmailTemplate.SendEmailForOrderMobile(orderInfo, billingAddress, shippingAddress, _addressPath,
                                                              TemplateName, transID);
                    }
                    catch
                    {
                        lblerror.Text = "";
                        lblerror.Text = GetSageMessage("Payment", "EmailSendOrderProblem");
                    }
                }
                Session.Clear();
            }
            else
            {
                Response.Redirect(redirectPath, false);
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    protected void SendConfrimMessage()
    {
        try
        {
            if (Session["OrderID"] != null)
            {
                string transID            = string.Empty; // transaction ID from Relay Response
                int    responseCode       = 1;            // response code, defaulted to Invalid
                string responsereasontext = string.Empty;
                responsereasontext = "Transaction occured Successfully";
                int    responsereasonCode         = 1;
                string purchaseorderNo            = string.Empty;
                string invoice                    = string.Empty;
                string paymentmethod              = string.Empty;
                OrderDetailsCollection orderdata2 = new OrderDetailsCollection();
                if (HttpContext.Current.Session["OrderCollection"] != null)
                {
                    orderdata2 = (OrderDetailsCollection)HttpContext.Current.Session["OrderCollection"];
                }
                invoice = orderdata2.ObjOrderDetails.InvoiceNumber.ToString();
                Random random = new Random();
                purchaseorderNo = (random.Next(0, 1000)).ToString();
                string timeStamp = ((int)(DateTime.UtcNow - new DateTime(2011, 1, 1)).TotalSeconds).ToString();
                transID               = (random.Next(99999, 111111)).ToString();
                lblTransaction.Text   = transID;
                lblInvoice.Text       = invoice;
                lblPaymentMethod.Text = "Cash On Delivery";
                lblDateTime.Text      = DateTime.Now.ToString("dddd, dd MMMM yyyy ");
                int    storeID     = int.Parse(GetStoreID.ToString());
                int    portalID    = int.Parse(GetPortalID.ToString());
                string userName    = GetUsername.ToString();
                int    customerID  = int.Parse(GetCustomerID.ToString());
                string sessionCode = HttpContext.Current.Session.SessionID.ToString();
                string result      = CashOnDelivery.Parse(transID, invoice, purchaseorderNo, responseCode, responsereasonCode, responsereasontext, storeID, portalID, userName, customerID, sessionCode);
                lblerror.Text = result.ToString();
                lblerror.Text = GetSageMessage("Payment", "PaymentProcessed");
                TransactionLogInfo tinfo = new TransactionLogInfo();
                TransactionLog     Tlog  = new TransactionLog();

                tinfo.TransactionID      = transID;
                tinfo.AuthCode           = "";
                tinfo.TotalAmount        = decimal.Parse(orderdata2.ObjOrderDetails.GrandTotal.ToString());
                tinfo.ResponseCode       = responseCode.ToString();
                tinfo.ResponseReasonText = responsereasontext;
                tinfo.OrderID            = orderdata2.ObjOrderDetails.OrderID;
                tinfo.StoreID            = orderdata2.ObjCommonInfo.StoreID;
                tinfo.PortalID           = orderdata2.ObjCommonInfo.PortalID;
                tinfo.AddedBy            = orderdata2.ObjCommonInfo.AddedBy;
                tinfo.CustomerID         = orderdata2.ObjOrderDetails.CustomerID;
                tinfo.SessionCode        = orderdata2.ObjOrderDetails.SessionCode;
                tinfo.PaymentGatewayID   = orderdata2.ObjOrderDetails.PaymentGatewayTypeID;
                tinfo.PaymentStatus      = "Processed";
                tinfo.CreditCard         = "";
                Tlog.SaveTransactionLog(tinfo);

                AspxCommerceWebService clSes = new AspxCommerceWebService();
                if (Session["IsFreeShipping"] != null)
                {
                    HttpContext.Current.Session.Remove("IsFreeShipping");
                }
                if (Session["DiscountAmount"] != null)
                {
                    HttpContext.Current.Session.Remove("DiscountAmount");
                }
                if (Session["CouponCode"] != null)
                {
                    HttpContext.Current.Session.Remove("CouponCode");
                }
                if (Session["CouponApplied"] != null)
                {
                    HttpContext.Current.Session.Remove("CouponApplied");
                }
                if (Session["DiscountAll"] != null)
                {
                    HttpContext.Current.Session.Remove("DiscountAll");
                }
                if (Session["TaxAll"] != null)
                {
                    HttpContext.Current.Session.Remove("TaxAll");
                }
                if (Session["ShippingCostAll"] != null)
                {
                    HttpContext.Current.Session.Remove("ShippingCostAll");
                }
                if (Session["GrandTotalAll"] != null)
                {
                    HttpContext.Current.Session.Remove("GrandTotalAll");
                }
                if (Session["Gateway"] != null)
                {
                    HttpContext.Current.Session.Remove("Gateway");
                }

                //invoice  transID

                if (Session["OrderCollection"] != null)
                {
                    OrderDetailsCollection orderdata = new OrderDetailsCollection();
                    orderdata = (OrderDetailsCollection)Session["OrderCollection"];
                    try
                    {
                        EmailTemplate.SendEmailForOrder(GetPortalID, orderdata, addressPath, TemplateName, transID);
                    }
                    catch
                    {
                        lblerror.Text = "";
                        lblerror.Text = GetSageMessage("Payment", "EmailSendOrderProblem");
                    }
                    clSes.ClearSessionVariable("OrderCollection");
                }
            }
            else
            {
                Response.Redirect(sageRedirectPath, false);
            }
        }
        catch (Exception ex)
        {
            ProcessException(ex);
        }
    }
    private static void HandleNewOrderNotification(GCheckout.AutoGen.NewOrderNotification inputNewOrderNotification)
    {
        try
        {
            if (inputNewOrderNotification.shoppingcart.merchantprivatedata != null && inputNewOrderNotification.shoppingcart.merchantprivatedata.Any != null && inputNewOrderNotification.shoppingcart.merchantprivatedata.Any.Length > 0)
            {
                //Retrieve data from MerchantPrivateData
                GCheckout.AutoGen.anyMultiple oneAnyMultiple  = inputNewOrderNotification.shoppingcart.merchantprivatedata;
                System.Xml.XmlNode[]          oneXmlNodeArray = oneAnyMultiple.Any;
                foreach (XmlNode xn in oneXmlNodeArray)
                {
                    if (xn.Name == "OrderID")
                    {
                        orderID = Int32.Parse(xn.InnerText.ToString());
                    }

                    if (xn.Name == "userName")
                    {
                        userName = xn.InnerText.ToString();
                    }

                    if (xn.Name == "amount")
                    {
                        totalAmount = decimal.Parse(xn.InnerText.ToString());
                    }

                    if (xn.Name == "selectedCurrency")
                    {
                        selectedCurrency = xn.InnerText.ToString();
                    }

                    if (xn.Name == "portalID")
                    {
                        portalID = int.Parse(xn.InnerText.ToString());
                    }
                    if (xn.Name == "customerID")
                    {
                        customerID = int.Parse(xn.InnerText.ToString());
                    }
                    if (xn.Name == "itemIds")
                    {
                        itemIds = xn.InnerText.ToString();
                    }
                    if (xn.Name == "storeID")
                    {
                        storeID = int.Parse(xn.InnerText.ToString());
                    }
                    if (xn.Name == "couponCode")
                    {
                        couponCode = xn.InnerText.ToString();
                    }
                    if (xn.Name == "sessionCode")
                    {
                        sessionCode = xn.InnerText.ToString();
                    }
                    if (xn.Name == "pgID")
                    {
                        pgID = int.Parse(xn.InnerText.ToString());
                    }
                    if (xn.Name == "MerchantID")
                    {
                        MerchantID = xn.InnerText.ToString();
                    }
                    if (xn.Name == "MerchantKey")
                    {
                        MerchantID = xn.InnerText.ToString();
                    }
                }
                paymentStatus = GCNotificationStatus.Succeeded.ToString();
                transID       = inputNewOrderNotification.googleordernumber;

                if (paymentStatus == "Succeeded")
                {
                    TransactionLogInfo     tinfo = new TransactionLogInfo();
                    TransactionLog         Tlog  = new TransactionLog();
                    OrderDetailsCollection odc   = new OrderDetailsCollection();

                    tinfo.ResponseReasonText = "Succeeded";
                    tinfo.OrderID            = orderID;
                    tinfo.StoreID            = storeID;
                    tinfo.PortalID           = portalID;
                    tinfo.AddedBy            = userName;
                    tinfo.CustomerID         = customerID;
                    tinfo.SessionCode        = sessionCode;
                    tinfo.PaymentGatewayID   = pgID;
                    tinfo.PaymentStatus      = paymentStatus;
                    tinfo.PayerEmail         = "";
                    tinfo.CreditCard         = "";
                    tinfo.TotalAmount        = totalAmount;
                    tinfo.TransactionID      = transID;
                    tinfo.RecieverEmail      = "";
                    tinfo.CurrencyCode       = selectedCurrency;
                    Tlog.SaveTransactionLog(tinfo);

                    GoogleCheckOutHandler.ParseIPN(orderID, transID, paymentStatus, storeID, portalID, userName, customerID, sessionCode);
                    GoogleCheckOutHandler.UpdateItemQuantity(itemIds, couponCode, storeID, portalID, userName);
                    CartManageSQLProvider cms           = new CartManageSQLProvider();
                    AspxCommonInfo        aspxCommonObj = new AspxCommonInfo();
                    aspxCommonObj.CustomerID  = customerID;
                    aspxCommonObj.SessionCode = sessionCode;
                    aspxCommonObj.StoreID     = storeID;
                    aspxCommonObj.PortalID    = portalID;
                    aspxCommonObj.CultureName = null;
                    aspxCommonObj.UserName    = null;
                    cms.ClearCartAfterPayment(aspxCommonObj);
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }

        // TODO: Process the MerchantPrivateData if provided

        foreach (GCheckout.AutoGen.Item oneItem in inputNewOrderNotification.shoppingcart.items)
        {
            // TODO: Get MerchantItemId from shopping cart item (oneItem.merchantitemid) and process it
        }

        // TODO: Add custom processing for this notification type
    }
Ejemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lang   = Request.QueryString["lang"];
            width  = Request.QueryString["w"];
            id     = ConvertUtility.ToInt32(Request.QueryString["id"]);
            price  = ConfigurationSettings.AppSettings.Get("tuviprice");
            cipher = Request.QueryString["link"];
            MobileUtils.GetDetailCharging(EAS.DecryptData(cipher, ConfigurationSettings.AppSettings.Get("vmskey")), ref msisdn, ref cpid, ref transaction_oldid, ref transaction_newid, ref content_id, ref content_price, ref debit_status);
            if (!IsPostBack)
            {
                if (lang == "1")
                {
                    lnkBack.Text = "Quay lại";
                }
                if (debit_status == "0")
                {
                    //luu giao dich
                    trans = new TransactionInfo();
                    trans.Wap_Transaction_Link     = "";
                    trans.Wap_Transaction_Mobile   = msisdn;
                    trans.Wap_Transaction_Operator = "Mobifone";
                    trans.Wap_Transaction_Portal   = "Mobifone";
                    trans.Wap_TransactionDetail    = "Tu vu: id:" + id.ToString() + " -- newtransactionid: " + transaction_newid + " -- old tranid: " + transaction_oldid;
                    trans.Wap_Transaction_Amount   = ConvertUtility.ToDouble(price);
                    trans.Wap_TransactionName      = content_id;
                    trans.Wap_TransactionOn        = DateTime.Now;
                    trans.Wap_TransactionType      = 18;//thu gian
                    TransactionController.Insert_Transaction(trans);
                    //end luu giao dich
                    //DateTime vTime = DateTime.Now;
                    DataTable dtDetail = null;

                    dtDetail = TuViController.Horoscope_GetItemByID(id);
                    if (lang == "1")
                    {
                        ltrTieude.Text = "TỬ VI";
                        if (dtDetail.Rows.Count > 0)
                        {
                            lblNoidung.Text = dtDetail.Rows[0]["MT5"].ToString();
                        }
                    }
                    else
                    {
                        ltrTieude.Text = "TU VI";
                        if (dtDetail.Rows.Count > 0)
                        {
                            lblNoidung.Text = dtDetail.Rows[0]["MT_KD5"].ToString();
                        }
                    };
                    divthongbao.Visible = false;
                }
                else
                {
                    TransactionLogInfo _log     = new TransactionLogInfo();
                    string             thongbao = "Thanh toán không thành công hoặc tài khoản không đủ tiền.";
                    ltrthongbao.Text = thongbao;
                    //Luu vao bang transaction log truong hop giao dich that bai
                    _log.Wap_Transaction_Link     = "";
                    _log.Wap_Transaction_Mobile   = msisdn;
                    _log.Wap_Transaction_Operator = "Mobifone";
                    _log.Wap_Transaction_Portal   = "Mobifone";
                    _log.Wap_TransactionDetail    = "Tu vi: id:" + id.ToString() + " -- newtransactionid: " + transaction_newid + " -- old tranid: " + transaction_oldid;
                    _log.Wap_Transaction_Amount   = ConvertUtility.ToDouble(price);
                    _log.Wap_TransactionName      = content_id;
                    _log.Wap_TransactionOn        = DateTime.Now;
                    _log.Wap_TransactionType      = 18;
                    _log.ErrorCode = 1;//That bai
                    TransactionController.Insert_TransactionLog(_log);
                };
            }
            ;
        }
Ejemplo n.º 10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string selectedCurrency = string.Empty;
        string MainCurrency     = string.Empty;

        try
        {
            StoreSettingConfig ssc = new StoreSettingConfig();
            MainCurrency = ssc.GetStoreSettingsByKey(StoreSetting.MainCurrency, GetStoreID, GetPortalID, GetCurrentCultureName);
            if (Session["SelectedCurrency"] != null && Session["SelectedCurrency"] != "")
            {
                selectedCurrency = Session["SelectedCurrency"].ToString();
            }
            else
            {
                selectedCurrency = MainCurrency;
            }

            string       islive     = Request.Form["custom"];
            string       test       = string.Empty;
            const string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
            const string strLive    = "https://www.paypal.com/cgi-bin/webscr";
            test = bool.Parse(islive.Split('#')[6]) ? strSandbox : strLive;

            var req = (HttpWebRequest)WebRequest.Create(test);
            //Set values for the request back
            req.Method      = "POST";
            req.ContentType = "application/x-www-form-urlencoded";
            byte[] param      = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
            string strRequest = Encoding.ASCII.GetString(param);
            strRequest       += "&cmd=_notify-validate";
            req.ContentLength = strRequest.Length;
            //for proxy
            //WebProxy proxy = new WebProxy(new Uri("http://url:port#"));
            //req.Proxy = proxy;
            //Send the request to PayPal and get the response
            var streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
            streamOut.Write(strRequest);
            streamOut.Close();
            var    streamIn    = new StreamReader(req.GetResponse().GetResponseStream());
            string strResponse = streamIn.ReadToEnd();
            streamIn.Close();
            //string appPath = Request.PhysicalApplicationPath;
            //string filePath = appPath + "IPN.txt";
            //StreamWriter w;
            //w = File.CreateText(filePath);
            //w.WriteLine("This is a test line.");
            //w.WriteLine(islive.Split('#')[6] + "," + islive.Split('#')[1]);
            //w.Flush();
            //w.Close();
            if (strResponse == "VERIFIED")
            {
                string payerEmail     = Request.Form["payer_email"];
                string paymentStatus  = Request.Form["payment_status"];
                string receiverEmail  = Request.Form["receiver_email"];
                string amount         = Request.Form["mc_gross"];
                string invoice        = Request.Form["invoice"];
                string addressName    = Request.Form["address_name"];
                string addressStreet  = Request.Form["address_street"];
                string addressCity    = Request.Form["address_city"];
                string addressZip     = Request.Form["address_zip"];
                string addressCountry = Request.Form["address_country"];
                string transID        = Request.Form["txn_id"];
                string custom         = Request.Form["custom"];

                string[] ids         = custom.Split('#');
                int      orderID     = int.Parse(ids[0]);
                int      storeID     = int.Parse(ids[1]);
                int      portalID    = int.Parse(ids[2]);
                string   userName    = ids[3];
                int      customerID  = int.Parse(ids[4]);
                string   sessionCode = ids[5];
                string   pgid        = ids[7];

                var tinfo = new TransactionLogInfo();
                var tlog  = new TransactionLog();

                tinfo.TransactionID      = transID;
                tinfo.AuthCode           = "";
                tinfo.TotalAmount        = decimal.Parse(amount);
                tinfo.ResponseCode       = "1";
                tinfo.ResponseReasonText = "";
                tinfo.OrderID            = orderID;
                tinfo.StoreID            = storeID;
                tinfo.PortalID           = portalID;
                tinfo.AddedBy            = userName;
                tinfo.CustomerID         = customerID;
                tinfo.SessionCode        = sessionCode;
                tinfo.PaymentGatewayID   = int.Parse(pgid);
                tinfo.PaymentStatus      = paymentStatus;
                tinfo.PayerEmail         = payerEmail;
                tinfo.CreditCard         = "";
                tinfo.RecieverEmail      = receiverEmail;
                tinfo.CurrencyCode       = selectedCurrency;
                tlog.SaveTransactionLog(tinfo);


                if (paymentStatus.Equals("Completed"))
                {
                    //string appPath = Request.PhysicalApplicationPath;
                    //string filePath = appPath + "IPN.txt";
                    //StreamWriter w;
                    //w = File.CreateText(filePath);
                    //w.WriteLine("This is a test line.");
                    //w.WriteLine(payerEmail + " " + paymentStatus + " " + amount);
                    //w.WriteLine("This 2nd.");
                    //w.Flush();
                    //w.Close();
                    var paypalobj = new PayPalHandler();
                    paypalobj.ParseIPN(orderID, transID, paymentStatus, storeID, portalID, userName, customerID, sessionCode);
                    // PayPalHandler.UpdateItemQuantity(itemReduce, coupon, storeID, portalID, userName);
                }
            }
            else if (strResponse == "INVALID")
            {
                //log for manual investigation
            }
            else
            {
                //log response/ipn data for manual investigation
            }
            // }
        }
        catch (Exception ex)
        {
            ProcessException(ex);
            //  throw new Exception("This Page is not accessible!");
        }
    }
Ejemplo n.º 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string islive     = Request.Form["custom"];
            string test       = string.Empty;
            string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
            string strLive    = "https://www.paypal.com/cgi-bin/webscr";
            if (bool.Parse(islive.Split('#')[6].ToString()))
            {
                test = strSandbox;
            }
            else
            {
                test = strLive;
            }

            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(test);
            //Set values for the request back
            req.Method      = "POST";
            req.ContentType = "application/x-www-form-urlencoded";
            byte[] param      = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
            string strRequest = Encoding.ASCII.GetString(param);
            strRequest       += "&cmd=_notify-validate";
            req.ContentLength = strRequest.Length;
            //for proxy
            //WebProxy proxy = new WebProxy(new Uri("http://*****:*****@"IPN\IPN.xml"; //
                //DataSet ds = new DataSet();
                //ds.ReadXml(st);
                //DataRow r = ds.Tables[0].NewRow();
                //r[0] = transID;
                //r[1] = payerEmail;
                //r[2] = amount;
                //r[3] = paymentStatus;
                //r[4] = receiverEmail;
                //r[5] = orderID;
                //r[6] = storeID;
                //r[7] = portalID;
                //r[8] = userName;
                //r[9] = customerID;
                //r[10] = sessionCode;
                //ds.Tables[0].Rows.Add(r);
                //ds.WriteXml(st);

                if (paymentStatus.Equals("Completed"))
                {
                    //string appPath = Request.PhysicalApplicationPath;
                    //string filePath = appPath + "IPN.txt";
                    //StreamWriter w;
                    //w = File.CreateText(filePath);
                    //w.WriteLine("This is a test line.");
                    //w.WriteLine(payerEmail + " " + paymentStatus + " " + amount);
                    //w.WriteLine("This 2nd.");
                    //w.Flush();
                    //w.Close();
                    PayPalHandler pdt = PayPalHandler.ParseIPN(orderID, transID, paymentStatus, storeID, portalID, userName, customerID, sessionCode);
                    // PayPalHandler.UpdateItemQuantity(itemReduce, coupon, storeID, portalID, userName);
                }
                // Session.Remove("IsTestPayPal");
            }
            else if (strResponse == "INVALID")
            {
                //log for manual investigation
            }
            else
            {
                //log response/ipn data for manual investigation
            }
            // }
        }
        catch (Exception ex)
        {
            ProcessException(ex);
            //  throw new Exception("This Page is not accessible!");
        }
    }
    protected void SendConfrimMessage(string redirectPat)
    {
        try
        {
            if (Session["OrderID"] != null)
            {
                const int    responseCode       = 1; // response code, defaulted to Invalid
                const string responsereasontext = "Transaction occured successfully";
                const int    responsereasonCode = 1;
                string       paymentmethod      = string.Empty;
                var          orderdata2         = new OrderDetailsCollection();
                if (HttpContext.Current.Session["OrderCollection"] != null)
                {
                    orderdata2 = (OrderDetailsCollection)HttpContext.Current.Session["OrderCollection"];
                }
                string invoice         = orderdata2.ObjOrderDetails.InvoiceNumber;
                var    random          = new Random();
                string purchaseorderNo = (random.Next(0, 1000)).ToString();
                string timeStamp       = ((int)(DateTime.UtcNow - new DateTime(2011, 1, 1)).TotalSeconds).ToString();
                string transID         = (random.Next(99999, 111111)).ToString();
                lblTransaction.Text   = transID;
                lblInvoice.Text       = invoice;
                lblPaymentMethod.Text = "Cash On Delivery";
                lblPaymentStatus.Text = "Successfull";
                lblDateTime.Text      = DateTime.Now.ToString("dddd, dd MMMM yyyy ");
                lblOrderNo.Text       = "#" + Session["OrderID"].ToString();
                AspxCommonInfo aspxCommonObj = new AspxCommonInfo();
                aspxCommonObj.StoreID     = GetStoreID;
                aspxCommonObj.PortalID    = GetPortalID;
                aspxCommonObj.UserName    = GetUsername;
                aspxCommonObj.CustomerID  = GetCustomerID;
                aspxCommonObj.SessionCode = HttpContext.Current.Session.SessionID;
                aspxCommonObj.CultureName = GetCurrentCultureName;
                string result = CashOnDelivery.Parse(transID, invoice, purchaseorderNo, responseCode, responsereasonCode, responsereasontext, aspxCommonObj);
                AspxGiftCardController.IssueGiftCard(orderdata2.LstOrderItemsInfo, false, aspxCommonObj);
                if (orderdata2.GiftCardDetail != null && HttpContext.Current.Session["UsedGiftCard"] != null)
                {
                    AspxGiftCardController.UpdateGiftCardUsage(orderdata2.GiftCardDetail, orderdata2.ObjCommonInfo.StoreID,
                                                               orderdata2.ObjCommonInfo.PortalID, orderdata2.ObjOrderDetails.OrderID, orderdata2.ObjCommonInfo.AddedBy,
                                                               orderdata2.ObjCommonInfo.CultureName);
                    HttpContext.Current.Session.Remove("UsedGiftCard");
                }

                lblerror.Text = result;
                lblerror.Text = GetSageMessage("Payment", "PaymentProcessed");
                var tinfo = new TransactionLogInfo();
                var tlog  = new TransactionLog();

                tinfo.TransactionID = transID;
                tinfo.AuthCode      = "";
                // tinfo.TotalAmount = decimal.Parse(orderdata2.ObjOrderDetails.GrandTotal.ToString());
                tinfo.TotalAmount        = decimal.Parse(Session["GrandTotalAll"].ToString()) * currencyRate;
                tinfo.ResponseCode       = responseCode.ToString();
                tinfo.ResponseReasonText = responsereasontext;
                tinfo.OrderID            = orderdata2.ObjOrderDetails.OrderID;
                tinfo.StoreID            = orderdata2.ObjCommonInfo.StoreID;
                tinfo.PortalID           = orderdata2.ObjCommonInfo.PortalID;
                tinfo.AddedBy            = orderdata2.ObjCommonInfo.AddedBy;
                tinfo.CustomerID         = orderdata2.ObjOrderDetails.CustomerID;
                tinfo.SessionCode        = orderdata2.ObjOrderDetails.SessionCode;
                tinfo.PaymentGatewayID   = orderdata2.ObjOrderDetails.PaymentGatewayTypeID;
                tinfo.PaymentStatus      = "Processed";
                tinfo.CreditCard         = "";
                tinfo.CurrencyCode       = SelectedCurrency;
                tlog.SaveTransactionLog(tinfo);

                var clSes = new AspxCommerceWebService();
                if (Session["IsFreeShipping"] != null)
                {
                    HttpContext.Current.Session.Remove("IsFreeShipping");
                }
                if (Session["DiscountAmount"] != null)
                {
                    HttpContext.Current.Session.Remove("DiscountAmount");
                }
                if (Session["CouponDiscountAmount"] != null)
                {
                    HttpContext.Current.Session.Remove("CouponDiscountAmount");
                }
                if (Session["IsCouponInPercent"] != null)
                {
                    HttpContext.Current.Session.Remove("IsCouponInPercent");
                }
                if (Session["CouponPercentValue"] != null)
                {
                    HttpContext.Current.Session.Remove("CouponPercentValue");
                }
                if (Session["CouponSessionPercentAmount"] != null)
                {
                    HttpContext.Current.Session.Remove("CouponSessionPercentAmount");
                }
                if (Session["CouponSessionAmount"] != null)
                {
                    HttpContext.Current.Session.Remove("CouponSessionAmount");
                }
                if (Session["CouponCode"] != null)
                {
                    HttpContext.Current.Session.Remove("CouponCode");
                }
                if (Session["CouponApplied"] != null)
                {
                    HttpContext.Current.Session.Remove("CouponApplied");
                }
                if (Session["DiscountAll"] != null)
                {
                    HttpContext.Current.Session.Remove("DiscountAll");
                }
                if (Session["TaxAll"] != null)
                {
                    HttpContext.Current.Session.Remove("TaxAll");
                }
                if (Session["ShippingCostAll"] != null)
                {
                    HttpContext.Current.Session.Remove("ShippingCostAll");
                }
                if (Session["GrandTotalAll"] != null)
                {
                    HttpContext.Current.Session.Remove("GrandTotalAll");
                }
                if (Session["Gateway"] != null)
                {
                    HttpContext.Current.Session.Remove("Gateway");
                }

                //invoice  transID

                if (Session["OrderCollection"] != null)
                {
                    var orderdata = (OrderDetailsCollection)Session["OrderCollection"];
                    try
                    {
                        orderdata.ObjOrderDetails.OrderStatus = "Processed";
                        EmailTemplate.SendEmailForOrder(GetPortalID, orderdata, _addressPath, TemplateName, transID);
                    }
                    catch (Exception ex)
                    {
                        lblerror.Text = "";
                        lblerror.Text = GetSageMessage("Payment", "EmailSendOrderProblem");
                        ProcessException(ex);
                    }
                    clSes.ClearSessionVariable("OrderCollection");
                }
            }
            else
            {
                Response.Redirect(_sageRedirectPath, false);
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Ejemplo n.º 13
0
        public string SendPaymentInfoAIM(OrderDetailsCollection OrderDetail, string TemplateName, string addressPath)
        {
            var objRequest = new WebClient();
            var objInf     = new System.Collections.Specialized.NameValueCollection(30);

            string strError;

            //OrderDetail.ObjOrderDetails.CustomerID = int.Parse(Crypto.GenerateCustomerID());
            OrderDetail.ObjOrderDetails.InvoiceNumber       = Crypto.GenerateInvoiceNumber();
            OrderDetail.ObjOrderDetails.PurchaseOrderNumber = Crypto.GeneratePurchaseOrderNumber();

            //merchant generated field
            objInf.Add("x_version", OrderDetail.ObjOrderDetails.Version);
            objInf.Add("x_delim_data", "True");
            objInf.Add("x_login", OrderDetail.ObjOrderDetails.APILogin);
            objInf.Add("x_tran_key", OrderDetail.ObjOrderDetails.TransactionKey);
            objInf.Add("x_relay_response", "False");
            objInf.Add("x_delim_char", ",");
            objInf.Add("x_encap_char", "|");
            objInf.Add("x_invoice_num", OrderDetail.ObjOrderDetails.InvoiceNumber);
            objInf.Add("x_cust_id", OrderDetail.ObjOrderDetails.CustomerID.ToString(CultureInfo.InvariantCulture));
            objInf.Add("x_po_num", OrderDetail.ObjOrderDetails.PurchaseOrderNumber);

            // Billing Address
            objInf.Add("x_first_name", OrderDetail.ObjBillingAddressInfo.FirstName);
            objInf.Add("x_last_name", OrderDetail.ObjBillingAddressInfo.LastName);
            objInf.Add("x_company", OrderDetail.ObjBillingAddressInfo.CompanyName);
            objInf.Add("x_email", OrderDetail.ObjBillingAddressInfo.EmailAddress);
            objInf.Add("x_address", OrderDetail.ObjBillingAddressInfo.Address);
            objInf.Add("x_city", OrderDetail.ObjBillingAddressInfo.City);
            objInf.Add("x_state", OrderDetail.ObjBillingAddressInfo.State);
            objInf.Add("x_zip", OrderDetail.ObjBillingAddressInfo.Zip);
            objInf.Add("x_country", OrderDetail.ObjBillingAddressInfo.Country);
            objInf.Add("x_phone", OrderDetail.ObjBillingAddressInfo.Phone);
            objInf.Add("x_fax", OrderDetail.ObjBillingAddressInfo.Fax);
            objInf.Add("x_email_customer", OrderDetail.ObjOrderDetails.IsEmailCustomer);

            if (OrderDetail.ObjOrderDetails.IsMultipleCheckOut == false)
            {
                //shipping address
                objInf.Add("x_ship_to_first_name", OrderDetail.ObjShippingAddressInfo.FirstName);
                objInf.Add("x_ship_to_last_name", OrderDetail.ObjShippingAddressInfo.LastName);
                objInf.Add("x_ship_to_company", OrderDetail.ObjShippingAddressInfo.CompanyName);
                objInf.Add("x_ship_to_address", OrderDetail.ObjShippingAddressInfo.Address);
                objInf.Add("x_ship_to_city", OrderDetail.ObjShippingAddressInfo.City);
                objInf.Add("x_ship_to_state", OrderDetail.ObjShippingAddressInfo.State);
                objInf.Add("x_ship_to_zip", OrderDetail.ObjShippingAddressInfo.Zip);
                objInf.Add("x_ship_to_country", OrderDetail.ObjShippingAddressInfo.Country);
            }
            // Card Details
            objInf.Add("x_card_num", OrderDetail.ObjPaymentInfo.CardNumber);
            objInf.Add("x_card_type", OrderDetail.ObjPaymentInfo.CardType);
            objInf.Add("x_exp_date", OrderDetail.ObjPaymentInfo.ExpireDate);

            var            ssc = new StoreSettingConfig();
            double         rate;
            string         mainCurrency    = ssc.GetStoreSettingsByKey(StoreSetting.MainCurrency, OrderDetail.ObjCommonInfo.StoreID, OrderDetail.ObjCommonInfo.PortalID, OrderDetail.ObjCommonInfo.CultureName);
            const string   gateWayCurrency = "USD";
            AspxCommonInfo aspxCommonObj   = new AspxCommonInfo();

            aspxCommonObj.CustomerID  = OrderDetail.ObjOrderDetails.CustomerID;
            aspxCommonObj.SessionCode = OrderDetail.ObjOrderDetails.SessionCode;
            aspxCommonObj.StoreID     = OrderDetail.ObjCommonInfo.StoreID;
            aspxCommonObj.PortalID    = OrderDetail.ObjCommonInfo.PortalID;

            if (gateWayCurrency.ToLower().Trim() == mainCurrency.ToLower().Trim())
            {
                rate = 1;
            }
            else
            {
                AspxCoreController acc = new AspxCoreController();
                rate = acc.GetCurrencyRateOnChange(aspxCommonObj, mainCurrency, gateWayCurrency.Trim(), "en-US");
            }
            //double amountTotal = double.Parse(HttpContext.Current.Session["GrandTotalAll"].ToString()) * rate;
            double  amountTotal = double.Parse(CheckOutSessions.Get <Double>("GrandTotalAll", 0).ToString()) * rate;
            decimal amount      = decimal.Parse(amountTotal.ToString(CultureInfo.InvariantCulture));

            //string amount = Regex.Replace(OrderDetail.ObjOrderDetails.GrandTotal.ToString("0.00"), @"[A-Z]", String.Empty);
            objInf.Add("x_amount", Math.Round(amount, 2).ToString(CultureInfo.InvariantCulture));
            objInf.Add("x_test_request", "False");
            if (OrderDetail.ObjPaymentInfo.PaymentMethodCode == "CC")
            {
                // Authorization code of the card (CCV)
                objInf.Add("x_card_code", OrderDetail.ObjPaymentInfo.CardCode.Trim());
                objInf.Add("x_method", OrderDetail.ObjPaymentInfo.PaymentMethodCode.Trim());
                objInf.Add("x_type", OrderDetail.ObjPaymentInfo.TransactionType.Trim());
                // string amount = Regex.Replace(OrderDetail.ObjOrderDetails.GrandTotal.ToString("0.00"), @"[A-Z]", String.Empty);
                // objInf.Add("x_amount", amount);
                objInf.Add("x_description", OrderDetail.ObjOrderDetails.Remarks.Trim());
            }
            else
            {
                //bank
                objInf.Add("x_bank_aba_code", OrderDetail.ObjPaymentInfo.RoutingNumber.Trim());
                objInf.Add("x_bank_acct_num", OrderDetail.ObjPaymentInfo.AccountNumber.Trim());
                objInf.Add("x_bank_acct_type", OrderDetail.ObjPaymentInfo.AccountType.Trim());
                objInf.Add("x_bank_name", OrderDetail.ObjPaymentInfo.BankName.Trim());
                objInf.Add("x_bank_acct_name", OrderDetail.ObjPaymentInfo.AccountHolderName.Trim());
                objInf.Add("x_echeck_type", OrderDetail.ObjPaymentInfo.ChequeType.Trim());
                objInf.Add("x_bank_check_number", OrderDetail.ObjPaymentInfo.ChequeNumber.Trim());
            }

            // Currency setting. Check the guide for other supported currencies
            objInf.Add("x_currency_code", OrderDetail.ObjOrderDetails.CurrencyCode.Trim());

            if (OrderDetail.ObjOrderDetails.IsTest.ToLower().Trim() == "true" || OrderDetail.ObjOrderDetails.IsTest.ToLower() == "1")
            {
                objRequest.BaseAddress = "https://test.authorize.net/gateway/transact.dll";
            }
            else
            {
                objRequest.BaseAddress = "https://secure.authorize.net/gateway/transact.dll";
            }

            try
            {
                // POST request

                byte[]   objRetBytes = objRequest.UploadValues(objRequest.BaseAddress, "POST", objInf);
                string[] objRetVals  = System.Text.Encoding.ASCII.GetString(objRetBytes).Split(",".ToCharArray());

                // Process Return Values
                OrderDetail.ObjOrderDetails.ResponseCode       = int.Parse(objRetVals[0].Trim(char.Parse("|")));
                OrderDetail.ObjOrderDetails.ResponseReasonCode = int.Parse(objRetVals[2].Trim(char.Parse("|")));

                if (objRetVals[0].Trim(char.Parse("|")) == "1")
                {
                    // Returned Authorisation Code
                    //response.AuthorizationCode = objRetVals[4].Trim(char.Parse("|"));
                    // Returned Transaction ID
                    OrderDetail.ObjOrderDetails.TransactionID = Convert.ToString(objRetVals[6].Trim(char.Parse("|")));
                    strError = "Transaction completed successfully.";

                    AspxCoreController acc = new AspxCoreController();
                    OrderDetail.ObjOrderDetails.OrderStatusID = 8;
                    OrderDetail.ObjOrderDetails.TransactionID = Convert.ToString(objRetVals[6].Trim(char.Parse("|")));
                    acc.AddOrderDetails(OrderDetail);
                    HttpContext.Current.Session["TransDetailsAIM"] = OrderDetail.ObjOrderDetails.InvoiceNumber + "#" + OrderDetail.ObjOrderDetails.TransactionID + "#" + "AIM Authorize.Net";
                    if (HttpContext.Current.Session["OrderCollection"] != null)
                    {
                        OrderDetailsCollection orderdata2 = new OrderDetailsCollection();
                        if (HttpContext.Current.Session["OrderCollection"] != null)
                        {
                            orderdata2 = (OrderDetailsCollection)HttpContext.Current.Session["OrderCollection"];
                        }

                        AspxOrderController.UpdateItemQuantity(orderdata2);
                        AspxGiftCardController.IssueGiftCard(orderdata2.LstOrderItemsInfo, orderdata2.ObjOrderDetails.OrderID, true, aspxCommonObj);
                        if (orderdata2.GiftCardDetail != null && HttpContext.Current.Session["UsedGiftCard"] != null)
                        {   //updating giftcard used in chekout
                            AspxGiftCardController.UpdateGiftCardUsage(orderdata2.GiftCardDetail, orderdata2.ObjCommonInfo.StoreID,
                                                                       orderdata2.ObjCommonInfo.PortalID, orderdata2.ObjOrderDetails.OrderID, orderdata2.ObjCommonInfo.AddedBy,
                                                                       orderdata2.ObjCommonInfo.CultureName);
                            HttpContext.Current.Session.Remove("UsedGiftCard");
                        }


                        var tinfo = new TransactionLogInfo();
                        var tlog  = new TransactionLog();

                        tinfo.TransactionID      = OrderDetail.ObjOrderDetails.TransactionID;
                        tinfo.AuthCode           = objRetVals[4].Trim(char.Parse("|"));//auth Code
                        tinfo.TotalAmount        = OrderDetail.ObjOrderDetails.GrandTotal;
                        tinfo.ResponseCode       = "1";
                        tinfo.ResponseReasonText = strError;
                        tinfo.OrderID            = orderdata2.ObjOrderDetails.OrderID;
                        tinfo.StoreID            = OrderDetail.ObjCommonInfo.StoreID;
                        tinfo.PortalID           = OrderDetail.ObjCommonInfo.PortalID;
                        tinfo.AddedBy            = OrderDetail.ObjCommonInfo.AddedBy;
                        tinfo.CustomerID         = OrderDetail.ObjOrderDetails.CustomerID;
                        tinfo.SessionCode        = OrderDetail.ObjOrderDetails.SessionCode;
                        tinfo.PaymentGatewayID   = OrderDetail.ObjOrderDetails.PaymentGatewayTypeID;
                        tinfo.PaymentStatus      = "Processed";
                        tinfo.PayerEmail         = OrderDetail.ObjBillingAddressInfo.EmailAddress;
                        tinfo.CreditCard         = OrderDetail.ObjPaymentInfo.CardNumber;
                        tinfo.CurrencyCode       = gateWayCurrency.Trim();
                        tlog.SaveTransactionLog(tinfo);
                    }

                    var cms = new AspxCommerce.Core.CartManageSQLProvider();
                    cms.ClearCartAfterPayment(aspxCommonObj);

                    // StoreSettingConfig ssc = new StoreSettingConfig();
                    string sendEmailFrom   = ssc.GetStoreSettingsByKey(StoreSetting.SendEcommerceEmailsFrom, OrderDetail.ObjCommonInfo.StoreID, OrderDetail.ObjCommonInfo.PortalID, OrderDetail.ObjCommonInfo.CultureName);
                    string sendOrderNotice = ssc.GetStoreSettingsByKey(StoreSetting.SendOrderNotification, OrderDetail.ObjCommonInfo.StoreID, OrderDetail.ObjCommonInfo.PortalID, OrderDetail.ObjCommonInfo.CultureName);



                    if (sendOrderNotice.ToLower() == "true")
                    {
                        try
                        {
                            EmailTemplate.SendEmailForOrder(OrderDetail.ObjCommonInfo.PortalID, OrderDetail, addressPath,
                                                            TemplateName, OrderDetail.ObjOrderDetails.TransactionID);
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                    acc.ClearSessionVariable("OrderCollection");
                    CheckOutHelper cHelper = new CheckOutHelper();
                    cHelper.ClearSessions();
                }
                else
                {
                    // Error!
                    strError = objRetVals[3].Trim(char.Parse("|")) + " (" +
                               objRetVals[2].Trim(char.Parse("|")) + ")";

                    if (objRetVals[2].Trim(char.Parse("|")) == "44")
                    {
                        // CCV transaction decline
                        strError += "Our Card Code Verification (CCV) returned " +
                                    "the following error: ";

                        switch (objRetVals[38].Trim(char.Parse("|")))
                        {
                        case "N":
                            strError += "Card Code does not match.";
                            break;

                        case "P":
                            strError += "Card Code was not processed.";
                            break;

                        case "S":
                            strError += "Card Code should be on card but was not indicated.";
                            break;

                        case "U":
                            strError += "Issuer was not certified for Card Code.";
                            break;
                        }
                    }

                    if (objRetVals[2].Trim(char.Parse("|")) == "45")
                    {
                        if (strError.Length > 1)
                        {
                            strError += "<br />n";
                        }

                        // AVS transaction decline
                        strError += "Our Address Verification System (AVS) " +
                                    "returned the following error: ";

                        switch (objRetVals[5].Trim(char.Parse("|")))
                        {
                        case "A":
                            strError += " the zip code entered does not match " +
                                        "the billing address.";
                            break;

                        case "B":
                            strError += " no information was provided for the AVS check.";
                            break;

                        case "E":
                            strError += " a general error occurred in the AVS system.";
                            break;

                        case "G":
                            strError += " the credit card was issued by a non-US bank.";
                            break;

                        case "N":
                            strError += " neither the entered street address nor zip " +
                                        "code matches the billing address.";
                            break;

                        case "P":
                            strError += " AVS is not applicable for this transaction.";
                            break;

                        case "R":
                            strError += " please retry the transaction; the AVS system " +
                                        "was unavailable or timed out.";
                            break;

                        case "S":
                            strError += " the AVS service is not supported by your " +
                                        "credit card issuer.";
                            break;

                        case "U":
                            strError += " address information is unavailable for the " +
                                        "credit card.";
                            break;

                        case "W":
                            strError += " the 9 digit zip code matches, but the " +
                                        "street address does not.";
                            break;

                        case "Z":
                            strError += " the zip code matches, but the address does not.";
                            break;
                        }
                    }
                    var tinfo = new TransactionLogInfo();
                    var tlog  = new TransactionLog();

                    tinfo.TransactionID      = "";
                    tinfo.AuthCode           = objRetVals[4].Trim(char.Parse("|"));//auth Code
                    tinfo.TotalAmount        = amount;
                    tinfo.ResponseCode       = objRetVals[2].Trim(char.Parse("|"));
                    tinfo.ResponseReasonText = strError;
                    tinfo.OrderID            = OrderDetail.ObjOrderDetails.OrderID;
                    tinfo.StoreID            = OrderDetail.ObjCommonInfo.StoreID;
                    tinfo.PortalID           = OrderDetail.ObjCommonInfo.PortalID;
                    tinfo.AddedBy            = OrderDetail.ObjCommonInfo.AddedBy;
                    tinfo.CustomerID         = OrderDetail.ObjOrderDetails.CustomerID;
                    tinfo.SessionCode        = OrderDetail.ObjOrderDetails.SessionCode;
                    tinfo.PaymentGatewayID   = OrderDetail.ObjOrderDetails.PaymentGatewayTypeID;
                    tinfo.PaymentStatus      = "Failed";
                    tinfo.PayerEmail         = OrderDetail.ObjBillingAddressInfo.EmailAddress;
                    tinfo.CreditCard         = OrderDetail.ObjPaymentInfo.CardNumber;
                    tinfo.CurrencyCode       = gateWayCurrency.Trim();
                    tlog.SaveTransactionLog(tinfo);
                }
            }
            catch (Exception ex)
            {
                strError = ex.Message;
            }
            OrderDetail.ObjOrderDetails.ResponseReasonText = strError;
            return(OrderDetail.ObjOrderDetails.ResponseReasonText);
        }