コード例 #1
0
        protected void saveEasyPayOrder(EasyPayData data, List<SHOPPING_CART> carts, string originalResponse, decimal charge)
        {
            if (carts != null && carts.Count > 0)
            {
                int addrId, bonId = 0;
                decimal bonusUsed = 0;
                if (Session["AddrForEasyPay"] != null)
                {
                    addrId = (int)Session["AddrForEasyPay"];
                }
                else
                {
                    BasePage.Log(null, "EasyPay save - null address.", "", "EasyPay.saveOrder");
                }

                CultureInfo ci = new CultureInfo("en-US");
                string cartID = data.OrderId;

                decimal total = ApplicationContext.Current.Carts.GetShoppingCartTotalAmount(cartID).Value;

                ORDERS order = new ORDERS();

                int addrID = 0;
                // Bonus has been used
                decimal rate = ApplicationContext.Current.Payments.GetLastConversionRate().CurrencyRate + Configuration.CurrencyDelta;
                decimal amount = data.Amount / rate;
                if (total != amount)
                {
                    if (Session["BonForEasyPay"] != null && Session["BonIdForEasyPay"] != null && !String.IsNullOrWhiteSpace(Session["BonIdForEasyPay"].ToString()))
                    {
                        bonusUsed = (decimal)Session["BonForEasyPay"];
                        bonId = (int)Session["BonIdForEasyPay"];
                    }
                    if (bonusUsed == total - amount)
                    {
                        setBonus(order, bonId, bonusUsed);
                    }
                    else
                    {
                        BasePage.Log(null, "EasyPay order save - bonus MANIPULATION. Original:" + (total - amount) + " new: " + bonusUsed +
                            " - txnID: " + data.TransactionId, "", "EasyPay order save");
                        return;
                    }
                }

                order.TotalAmount = total;
                order.AmountPaid = amount;
                order.Verified = false;
                order.Canceled = false;

                order.Completed = true;
                order.Status = 1;

                try
                {
                    order.CustomerID = carts.First().CustomerID;

                    order.PAYMENT = new PAYMENT() { Type = 3 };
                    originalResponse = originalResponse.Replace("&", "\n");
                    order.PAYMENT.EASYPAY_PAYMENT = new EASYPAY_PAYMENT()
                    {
                        Amount = data.Amount,
                        MerchantUsername = Configuration.EasyPayMerchantUser,
                        TransactionID = data.TransactionId,
                        ResponseCode = data.ErrorCode,
                        Rate = rate,
                        OriginalResponse = originalResponse,
                        TransactionStatus = data.ErrorCodeS,
                        Date = DateTime.Now,
                        Fee = charge
                    };

                    // TODO for now it is set to carrier without a fee
                    order.ShippingID = 3;

                    order.DateCreated = DateTime.Now;
                    ADDRESS addr = ApplicationContext.Current.Customers.GetAddressById(addrID);
                    // addresses
                    if (addr != null)
                    {
                        ADDRESSINFO shipping = new ADDRESSINFO(addr);
                        order.ADDRESSINFO = shipping;
                    }
                    //inserting and not saving as the saving will be done in the details insertion
                    ApplicationContext.Current.Orders.Insert(order, true, false);

                    // inserting the products of this order

                    ApplicationContext.Current.Orders.InsertDetailsFromCart(order, carts, false);

                    List<ORDER_DETAIL> details = ApplicationContext.Current.Orders.GetDetails(order.ID);

                    CUSTOMER customer = ApplicationContext.Current.Customers.GetById(carts[0].CustomerID);

                    Thread thread = new Thread(() => BasePage.sendOrderMailToAdmins(details, "EasyPay", "EasyPay Order", order.TotalAmount, customer.Name + " " + customer.Surname));
                    thread.Start();

                    Thread thread2 = new Thread(() => BasePage.sendOrderMailToCustomer(customer, details, "Porosia ne FZone.al"));
                    thread2.Start();

                    lblResult.Text = "<b>" + Resources.Lang.PayPalThankyouLabel + "</b> <br/><br/>" +
                    Resources.Lang.SaveTransactionID + "<b>" + data.TransactionId + "</b>";
                }
                catch (System.Threading.ThreadAbortException ex)
                {
                }
                catch (Exception e)
                {
                    //TODO log exception
                    BasePage.Log(e, e.Message, e.StackTrace, "easyPay.Save");
                    lblResult.Text = Resources.Lang.PaymentProblemLiteral + "</b> <br/><br/>" +
                    Resources.Lang.SaveTransactionID + "<b>" + data.TransactionId + "</b>"; ;
                }
            }
        }
コード例 #2
0
        public static EasyPayData Parse(string postData)
        {
            EasyPayData data = new EasyPayData();
            string[] response = postData.Split('|');
            CultureInfo ci = new CultureInfo("en-US");

            if (response.Length > 0)
            {
                data.ErrorCode = Int32.Parse(response[0]);
                data.TransactionId = response[1];
                data.OrderId = response[2];
                data.Amount = Decimal.Parse(response[3], ci);
                switch (data.ErrorCode)
                {
                    case 400:
                        data.ErrorCodeS = "Success";
                        break;
                    case 401:
                        data.ErrorCodeS = "Invalid user name or reference number";
                        break;
                    case 402:
                        data.ErrorCodeS = "Under process";
                        break;
                    case 403:
                        data.ErrorCodeS = "Declined";
                        break;
                    case 404:
                        data.ErrorCodeS = "Killed";
                        break;
                    case 405:
                        data.ErrorCodeS = "Pending";
                        break;
                    case 406:
                        data.ErrorCodeS = "Empty value";
                        break;
                    case 407:
                        data.ErrorCodeS = "Incorrect mobile no";
                        break;
                    case 408:
                        data.ErrorCodeS = "Invalid IP";
                        break;
                    case 471:
                        data.ErrorCodeS = "Invalid amount";
                        break;
                    case 411:
                        data.ErrorCodeS = "Transaction exist";
                        break;
                    case 500:
                        data.ErrorCodeS = "Timeout";
                        break;
                    case 305:
                        data.ErrorCodeS = "User not registered";
                        break;
                    case 304:
                        data.ErrorCodeS = "Registration pending";
                        break;
                    case 302:
                        data.ErrorCodeS = "Registered User";
                        break;
                }
            }
            return data;
        }
コード例 #3
0
        public static EasyPayData Parse(string postData)
        {
            EasyPayData data = new EasyPayData();

            string[]    response = postData.Split('|');
            CultureInfo ci       = new CultureInfo("en-US");

            if (response.Length > 0)
            {
                data.ErrorCode     = Int32.Parse(response[0]);
                data.TransactionId = response[1];
                data.OrderId       = response[2];
                data.Amount        = Decimal.Parse(response[3], ci);
                switch (data.ErrorCode)
                {
                case 400:
                    data.ErrorCodeS = "Success";
                    break;

                case 401:
                    data.ErrorCodeS = "Invalid user name or reference number";
                    break;

                case 402:
                    data.ErrorCodeS = "Under process";
                    break;

                case 403:
                    data.ErrorCodeS = "Declined";
                    break;

                case 404:
                    data.ErrorCodeS = "Killed";
                    break;

                case 405:
                    data.ErrorCodeS = "Pending";
                    break;

                case 406:
                    data.ErrorCodeS = "Empty value";
                    break;

                case 407:
                    data.ErrorCodeS = "Incorrect mobile no";
                    break;

                case 408:
                    data.ErrorCodeS = "Invalid IP";
                    break;

                case 471:
                    data.ErrorCodeS = "Invalid amount";
                    break;

                case 411:
                    data.ErrorCodeS = "Transaction exist";
                    break;

                case 500:
                    data.ErrorCodeS = "Timeout";
                    break;

                case 305:
                    data.ErrorCodeS = "User not registered";
                    break;

                case 304:
                    data.ErrorCodeS = "Registration pending";
                    break;

                case 302:
                    data.ErrorCodeS = "Registered User";
                    break;
                }
            }
            return(data);
        }
コード例 #4
0
        public static EasyPayData ParseUnverified(string postData)
        {
            String sKey, sValue;
            EasyPayData data = new EasyPayData();
            String[] StringArray = postData.Split('&');
            CultureInfo ci = new CultureInfo("en-US");
            // use split to split array we already have using "=" as delimiter
            int i;
            for (i = 0; i < StringArray.Length - 1; i++)
            {
                String[] StringArray1 = StringArray[i].Split('=');

                sKey = StringArray1[0];
                sValue = StringArray1[1];

                // set string vars to hold variable names using a switch
                switch (sKey)
                {
                    case "errorcode":
                        data.ErrorCode = Int32.Parse(sValue);
                        switch (data.ErrorCode)
                        {
                            case 400:
                                data.ErrorCodeS = "Success";
                                break;
                            case 401:
                                data.ErrorCodeS = "Invalid user name or reference number";
                                break;
                            case 402:
                                data.ErrorCodeS = "Under process";
                                break;
                            case 403:
                                data.ErrorCodeS = "Declined";
                                break;
                            case 404:
                                data.ErrorCodeS = "Killed";
                                break;
                            case 405:
                                data.ErrorCodeS = "Pending";
                                break;
                            case 406:
                                data.ErrorCodeS = "Empty value";
                                break;
                            case 407:
                                data.ErrorCodeS = "Incorrect mobile no";
                                break;
                            case 408:
                                data.ErrorCodeS = "Invalid IP";
                                break;
                            case 471:
                                data.ErrorCodeS = "Invalid amount";
                                break;
                            case 411:
                                data.ErrorCodeS = "Transaction exist";
                                break;
                            case 500:
                                data.ErrorCodeS = "Timeout";
                                break;
                            case 305:
                                data.ErrorCodeS = "User not registered";
                                break;
                            case 304:
                                data.ErrorCodeS = "Registration pending";
                                break;
                            case 302:
                                data.ErrorCodeS = "Registered User";
                                break;
                        }
                        break;
                    case "transactionid":
                        data.TransactionId = sValue;
                        break;
                    case "Orderid":
                        data.OrderId = sValue;
                        break;
                    case "Amount":
                        data.Amount = Decimal.Parse(sValue, ci);
                        break;
                    case "ServiceCharge":
                        data.ServiceCharge = Decimal.Parse(sValue, ci);
                        break;
                    case "message":
                        data.Message = sValue;
                        break;
                }
            }
            return data;
        }
コード例 #5
0
        public static EasyPayData ParseUnverified(string postData)
        {
            String      sKey, sValue;
            EasyPayData data = new EasyPayData();

            String[]    StringArray = postData.Split('&');
            CultureInfo ci          = new CultureInfo("en-US");
            // use split to split array we already have using "=" as delimiter
            int i;

            for (i = 0; i < StringArray.Length - 1; i++)
            {
                String[] StringArray1 = StringArray[i].Split('=');

                sKey   = StringArray1[0];
                sValue = StringArray1[1];

                // set string vars to hold variable names using a switch
                switch (sKey)
                {
                case "errorcode":
                    data.ErrorCode = Int32.Parse(sValue);
                    switch (data.ErrorCode)
                    {
                    case 400:
                        data.ErrorCodeS = "Success";
                        break;

                    case 401:
                        data.ErrorCodeS = "Invalid user name or reference number";
                        break;

                    case 402:
                        data.ErrorCodeS = "Under process";
                        break;

                    case 403:
                        data.ErrorCodeS = "Declined";
                        break;

                    case 404:
                        data.ErrorCodeS = "Killed";
                        break;

                    case 405:
                        data.ErrorCodeS = "Pending";
                        break;

                    case 406:
                        data.ErrorCodeS = "Empty value";
                        break;

                    case 407:
                        data.ErrorCodeS = "Incorrect mobile no";
                        break;

                    case 408:
                        data.ErrorCodeS = "Invalid IP";
                        break;

                    case 471:
                        data.ErrorCodeS = "Invalid amount";
                        break;

                    case 411:
                        data.ErrorCodeS = "Transaction exist";
                        break;

                    case 500:
                        data.ErrorCodeS = "Timeout";
                        break;

                    case 305:
                        data.ErrorCodeS = "User not registered";
                        break;

                    case 304:
                        data.ErrorCodeS = "Registration pending";
                        break;

                    case 302:
                        data.ErrorCodeS = "Registered User";
                        break;
                    }
                    break;

                case "transactionid":
                    data.TransactionId = sValue;
                    break;

                case "Orderid":
                    data.OrderId = sValue;
                    break;

                case "Amount":
                    data.Amount = Decimal.Parse(sValue, ci);
                    break;

                case "ServiceCharge":
                    data.ServiceCharge = Decimal.Parse(sValue, ci);
                    break;

                case "message":
                    data.Message = sValue;
                    break;
                }
            }
            return(data);
        }