示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lblmsg.Text = "";
            try
            {
                if (RequestUnpack())
                {
                    if (transactionState.Equals("OK"))
                    {
                        ///////////////////////////////////////////////////////////////////////////////////
                        //   *** IMPORTANT  ****   ATTENTION
                        // Here you should check refrenceNumber in your DataBase tp prevent double spending
                        ///////////////////////////////////////////////////////////////////////////////////
                        ClEpayOrder cl = new ClEpayOrder();
                        cl.RefId = refrenceNumber;
                        DataSet ds = EpayOrderClass.GetList(cl);
                        if (ds.Tables[0].Rows.Count > 1)
                        {
                            //com.samanepay.acquirer.reverseTransaction1CompletedEventHandler;
                            try { ReverseTransaction(); }
                            catch { }
                            TerraficPlanBLL.Utility.ShowMsg(Page, TerraficPlanBLL.ProPertyData.MsgType.warning, "با این کد قبلا خرید شده  است .مبلغ حداکثر تا 48 ساعت دیگر عودت میگردد");
                            return;
                        }
                        ds.Dispose();
                        //////////////////////////////////////////////////////////////////////////////////



                        string RegMojaz = PublicFunction.RegWSmojaz(0, EpayOrderID);
                        if (RegMojaz != "")
                        {
                            TerraficPlanBLL.Utility.ShowMsg(Page, TerraficPlanBLL.ProPertyData.MsgType.warning, RegMojaz + " کاربر گرامی پول پرداختی شما تا چند دقیقه دیگر بازگشت خواهد خورد ");
                            return;
                        }


                        //For Ignore SSL Error
                        ServicePointManager.ServerCertificateValidationCallback =
                            delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return(true); };

                        var srv    = new ServiceReference1.PaymentIFBindingSoapClient();
                        var result = srv.verifyTransaction1(refrenceNumber, MerchantId);
                        ////////////////////////Save Result To DB///////////////////////////
                        ////////////string SQL = "update Tbl_EpayOrder set VerifyResult=" + result.ToString() + " where ResCode=" + reservationNumber.ToString() + " and RefId=" + refrenceNumber.ToString() + "";
                        ////////////SqlCommand cmd = new SqlCommand(SQL,new SqlConnection(CSharp.PublicFunction.cnstr()) );
                        ////////////cmd.CommandType = System.Data.CommandType.Text;
                        ClEpayOrder ClResultVerify = new ClEpayOrder();
                        //ClResultVerify.RefId = refrenceNumber;
                        //ClResultVerify.ResCode = reservationNumber;
                        ClResultVerify.VerifyResult = result.ToString();
                        ClResultVerify.EpayOrderID  = Convert.ToInt32(EpayOrderID);
                        EpayOrderClass.Update(ClResultVerify);
                        /////////////////////////////////////////////////////////////////////
                        if (result > 0)
                        {
                            ClEpayOrder cl2 = new ClEpayOrder();
                            cl2.ResCode = reservationNumber;
                            DataSet ds2 = EpayOrderClass.GetList(cl2);
                            DataRow dr2 = ds2.Tables[0].Rows[0];
                            if (Convert.ToInt32(dr2["Prcie"].ToString()) != result)    //check price
                            {
                                isError = true;
                                try { ReverseTransaction(); }
                                catch { TerraficPlanBLL.Utility.ShowMsg(Page, TerraficPlanBLL.ProPertyData.MsgType.warning, "عملیات خرید لغو شد"); }
                                TerraficPlanBLL.Utility.ShowMsg(Page, TerraficPlanBLL.ProPertyData.MsgType.warning, "مبلغ بازگشتی معتبر نیست وعملیات خرید لغو و مبلغ عودت شد");
                            }
                            else
                            {
                                isError    = false;
                                succeedMsg = "بانک صحت رسيد ديجيتالي شما را تصديق نمود. فرايند خريد تکميل گشت";
                                TerraficPlanBLL.Utility.ShowMsg(Page, TerraficPlanBLL.ProPertyData.MsgType.General_Success, succeedMsg);
                                ///Save To DB Transaction Complete
                                ClEpayOrder cll = new ClEpayOrder();
                                cll.EpayOrderID = Convert.ToInt32(EpayOrderID);
                                // cll.ResCode = reservationNumber;
                                cll.Comment = "OKK";
                                EpayOrderClass.Update(cll);
                            }
                        }
                        else
                        {
                            TransactionChecking((int)result);
                        }
                    }
                    else
                    {
                        isError  = true;
                        errorMsg = "متاسفانه بانک خريد شما را تاييد نکرده است";


                        if (transactionState.Equals("Canceled By User") || transactionState.Equals(string.Empty))
                        {
                            // Transaction was canceled by user
                            isError  = true;
                            errorMsg = "تراكنش توسط خريدار كنسل شد";
                        }
                        else if (transactionState.Equals("Invalid Amount"))
                        {
                            isError = true;

                            // Amount of revers teransaction is more than teransaction
                        }
                        else if (transactionState.Equals("Invalid Transaction"))
                        {
                            // Can not find teransaction
                        }
                        else if (transactionState.Equals("Invalid Card Number"))
                        {
                            // Card number is wrong
                        }
                        else if (transactionState.Equals("No Such Issuer"))
                        {
                            // Issuer can not find
                        }
                        else if (transactionState.Equals("Expired Card Pick Up"))
                        {
                            // The card is expired
                        }
                        else if (transactionState.Equals("Allowable PIN Tries Exceeded Pick Up"))
                        {
                            // For third time user enter a wrong PIN so card become invalid
                        }
                        else if (transactionState.Equals("Incorrect PIN"))
                        {
                            // Pin card is wrong
                        }
                        else if (transactionState.Equals("Exceeds Withdrawal Amount Limit"))
                        {
                            // Exceeds withdrawal from amount limit
                        }
                        else if (transactionState.Equals("Transaction Cannot Be Completed"))
                        {
                            // PIN and PAD are currect but Transaction Cannot Be Completed
                        }
                        else if (transactionState.Equals("Response Received Too Late"))
                        {
                            // Timeout occur
                        }
                        else if (transactionState.Equals("Suspected Fraud Pick Up"))
                        {
                            // User did not insert cvv2 & expiredate or they are wrong.
                        }
                        else if (transactionState.Equals("No Sufficient Funds"))
                        {
                            // there are not suficient funds in the account
                        }
                        else if (transactionState.Equals("Issuer Down Slm"))
                        {
                            // The bank server is down
                        }
                        else if (transactionState.Equals("TME Error"))
                        {
                            // unknown error occur
                        }

                        TerraficPlanBLL.Utility.ShowMsg(Page, TerraficPlanBLL.ProPertyData.MsgType.warning, errorMsg);
                    }
                }
            }

            catch (Exception ex)
            {
                string s = "عملیات با خطا مواجه شد" + Environment.NewLine + "کد :" + EpayOrderID.ToString() + " را برای رهگیری خطا یادداشت نمایید ";
                TerraficPlanBLL.Utility.ShowMsg(Page, TerraficPlanBLL.ProPertyData.MsgType.warning, s);
                lblmsg.Text = s + Environment.NewLine + ex.ToString();
            }
        }
示例#2
0
        private Double ReverseTransaction()
        {
            var r = new ServiceReference1.PaymentIFBindingSoapClient().reverseTransaction(refrenceNumber.ToString(), MerchantId.ToString(), MerchantId.ToString(), PassWord);

            return(r);// TerraficPlanBLL.Utility.ShowMsg(Page, TerraficPlanBLL.ProPertyData.MsgType.warning, "کاربر گرامی خرید لغو شد ");
        }