Пример #1
0
        /// <summary>
        /// 订单状态查询
        /// </summary>
        /// <param name="yylsh">医院流水号</param>
        /// <returns></returns>
        public XmlDocument StatusOrder(long yylsh)
        {
            XmlDocument doc = new XmlDocument();

            try
            {
                XmlElement root = doc.CreateElement(AppUtils.Tag_REXML_Root);
                doc.AppendChild(root);
                string msg   = "";
                string _ztmc = "";
                long   _ddzt = 0;
                double _czje = 0;

                PaymentDB pdb   = new PaymentDB();
                int       dbout = pdb.DB_StatusOrder(yylsh, out _ddzt, out _ztmc, out _czje, out msg);

                if (dbout == 0)
                {
                    doc = ReplyXmlDoc.GetExceptionXML(dbout, msg);
                }
                else
                {
                    doc = ErrorReturnXml(dbout, msg);
                }
            }
            catch (Exception ex)
            {
                doc = ReplyXmlDoc.GetExceptionXML(AppUtils.Default_Exception_Code, ex);
            }
            return(doc);
        }
Пример #2
0
        /// <summary>
        /// 插入银联记录
        /// </summary>
        /// <param name="info">银联信息</param>
        /// <returns></returns>
        public XmlDocument InsertCcb(YLReplyInfo info)
        {
            XmlDocument doc = new XmlDocument();

            try
            {
                string msg = "";

                PaymentDB pdb = new PaymentDB();
                int       ret = pdb.DB_InsertCcb(info, out msg);

                if (ret == 0)
                {
                    doc = ReplyXmlDoc.GetSuccessXML(ret, msg);
                }
                else
                {
                    doc = ErrorReturnXml(ret, msg);
                }
            }
            catch (Exception ex)
            {
                doc = ReplyXmlDoc.GetExceptionXML(AppUtils.Default_Exception_Code, ex);
            }

            return(doc);
        }
Пример #3
0
        /// <summary>
        /// 确认订单
        /// </summary>
        /// <param name="yylsh">银行流水号</param>
        /// <param name="yydm">银行代码</param>
        /// <param name="yhmc">银行名称</param>
        /// <param name="yhlsh">医院流水号</param>
        /// <param name="czje">充值金额</param>
        /// <param name="tkje">退款给金额</param>
        /// <param name="czsj">操作时间</param>
        /// <param name="zzlx">充值类型 01-银联充值</param>
        /// <returns></returns>
        public XmlDocument FinishOrder(long yylsh, string yhlsh, string sjczzt, DateTime czsj,
                                       string payType)
        {
            XmlDocument doc = new XmlDocument();

            try
            {
                string msg = "";

                PaymentDB pdb = new PaymentDB();
                int       ret = pdb.DB_FinishOrder(yylsh, yhlsh, sjczzt, czsj, payType, out msg);

                if (ret == 0)
                {
                    doc = ReplyXmlDoc.GetSuccessXML(ret, msg);
                }
                else
                {
                    doc = ErrorReturnXml(ret, msg);
                }
            }
            catch (Exception ex)
            {
                doc = ReplyXmlDoc.GetExceptionXML(AppUtils.Default_Exception_Code, ex);
            }
            return(doc);
        }
Пример #4
0
        public PaymentApproval(ref PaymentDB PaymentDB, List <payment_schedual> SchedualList)
        {
            PaymentDBold = PaymentDB;
            InitializeComponent();

            //Setting the Mode for this Window. Result of this variable will determine logic of the certain Behaviours.
            payment_schedualViewSource      = (CollectionViewSource)this.FindResource("payment_schedualViewSource");
            paymentpayment_detailViewSource = (CollectionViewSource)this.FindResource("paymentpayment_detailViewSource");

            payment_schedualViewSource.Source = PaymentDBold.payment_schedual.Local;
            payment_schedualViewSource.View.MoveCurrentTo(SchedualList.FirstOrDefault());

            foreach (payment_schedual payment_schedual in SchedualList)
            {
                payment_detail payment_detail = new payment_detail();
                payment_detail.value         = SchedualList.Sum(x => x.AccountPayableBalance);
                payment_detail.IsSelected    = true;
                payment_detail.id_currencyfx = SchedualList.FirstOrDefault().id_currencyfx;
                payment_detail.State         = EntityState.Added;
                PaymentDBold.payment_detail.Add(payment_detail);

                payment_detail.payment_schedual.Add(payment_schedual);
            }

            paymentpayment_detailViewSource.Source = PaymentDBold.payment_detail.Local;
            paymentpayment_detailViewSource.View.MoveCurrentToFirst();
        }
        //Return money if session end Unsuccessfully
        public int UnSuccessfullySession(int SessionId)
        {
            IList <Operation> operations = PaymentDB.GetAllSessionOperations(SessionId, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));

            foreach (Operation op in operations)
            {
                //If the payment was made via the card so refund it
                if (op.PaymentMethodId == LkpDetails["Card"])
                {
                    if (op.Captured == 1)
                    {
                        ApiRefundPayment(op.Id);
                    }
                    else
                    {
                        ApiVoidPayment(op.Id);
                    }
                }

                //If the payment was made via OMT we need to refund it

                //If the payment was made via Paypal we need to refund it
            }
            int response = PaymentDB.ReturnPayments(SessionId, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));

            return(response);
        }
Пример #6
0
        public PaymentEdit(Modes App_Mode, payment _payment, PaymentDB _PaymentDB)
        {
            InitializeComponent();

            //Setting the Mode for this Window. Result of this variable will determine logic of the certain Behaviours.
            Mode              = App_Mode;
            PaymentDB         = _PaymentDB;
            paymentViewSource = (CollectionViewSource)this.FindResource("paymentViewSource");
            paymentpayment_detailViewSource = (CollectionViewSource)this.FindResource("paymentpayment_detailViewSource");


            paymentViewSource.Source = PaymentDB.payments.Local;


            if (paymentViewSource != null)
            {
                if (paymentViewSource.View != null)
                {
                    paymentViewSource.View.Filter = i =>
                    {
                        int     id_payment = _payment.id_payment;
                        payment payment    = (payment)i;
                        if (payment.id_payment == id_payment)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    };
                }
            }
        }
Пример #7
0
        private void New_Sale_Payment()
        {
            ///Creating new SALES INVOICE for upcomming sale.
            ///TransDate = 0 because in Point of Sale we are assuming sale will always be done today.
            sales_invoice sales_invoice = SalesInvoiceDB.New(0, false);

            SalesInvoiceDB.sales_invoice.Add(sales_invoice);

            Dispatcher.BeginInvoke((Action)(() => {
                sales_invoiceViewSource = ((CollectionViewSource)(FindResource("sales_invoiceViewSource")));
                sales_invoiceViewSource.Source = SalesInvoiceDB.sales_invoice.Local;
                sales_invoiceViewSource.View.MoveCurrentTo(sales_invoice);
            }));

            PaymentDB = new PaymentDB();
            ///Creating new PAYMENT for upcomming sale.
            payment payment = PaymentDB.New(true);

            payment.id_currencyfx = sales_invoice.id_currencyfx;
            PaymentDB.payments.Add(payment);

            Dispatcher.BeginInvoke((Action)(() =>
            {
                paymentViewSource = ((CollectionViewSource)(FindResource("paymentViewSource")));
                paymentViewSource.Source = PaymentDB.payments.Local;
                paymentViewSource.View.MoveCurrentTo(payment);

                tabContact.Focus();
                sbxContact.Text = "";
            }));
        }
Пример #8
0
        /// <summary>
        /// 取消订单
        /// </summary>
        /// <param name="yylsh">医院流水号</param>
        /// <returns></returns>
        public XmlDocument CancelOrder(long yylsh)
        {
            XmlDocument doc = new XmlDocument();

            try
            {
                string msg = "";

                PaymentDB pdb = new PaymentDB();
                int       ret = pdb.DB_CancelOrder(yylsh, out msg);

                if (ret == 0)
                {
                    doc = ReplyXmlDoc.GetSuccessXML(ret, msg);
                }
                else
                {
                    doc = ErrorReturnXml(ret, msg);
                }
            }
            catch (Exception ex)
            {
                doc = ReplyXmlDoc.GetExceptionXML(AppUtils.Default_Exception_Code, ex);
            }

            return(doc);
        }
Пример #9
0
        public static AD CreateUser(AD User)
        {
            AD inserted = ADDB.CreateUser(User);

            PaymentDB.CreatePayment(inserted.UserId);
            SAPHRDB.CreateSAPHR(inserted.UserId, inserted.Username);
            return(inserted);
        }
Пример #10
0
        /// <summary>
        /// 交易明细
        /// </summary>
        /// <param name="brid">病人ID</param>
        /// <param name="brlx">病人类型 1:门诊  2:住院</param>
        /// <returns></returns>
        public XmlDocument QueryDetail(string brid, string brlx)
        {
            XmlDocument doc = new XmlDocument();

            try
            {
                ArrayList _list     = new ArrayList();
                string    error_msg = "";

                PaymentDB pdb   = new PaymentDB();
                int       rtint = pdb.DB_QueryDetail(brid, brlx, out _list, out error_msg);

                if (rtint == 0)
                {
                    XmlElement root = doc.CreateElement(AppUtils.Tag_REXML_Root);
                    doc.AppendChild(root);

                    XmlElement eleResult = doc.CreateElement(AppUtils.Tag_REXML_Result);
                    eleResult.InnerText = Convert.ToString(rtint);
                    root.AppendChild(eleResult);

                    XmlElement eleMsg = doc.CreateElement(AppUtils.Tag_REXML_Message);
                    root.AppendChild(eleMsg);

                    foreach (PaymentDetail pdt in _list)
                    {
                        XmlElement eleValue = doc.CreateElement(AppUtils.Tag_REXML_Value);
                        eleMsg.AppendChild(eleValue);

                        XmlElement eleOpdate = doc.CreateElement(AppUtils.Tag_Payment_OPDATE);
                        eleValue.AppendChild(eleOpdate);
                        //以下实现数据操作逻辑
                        eleOpdate.InnerText = pdt.rq.ToString("yyyy-MM-dd");

                        XmlElement eleJe = doc.CreateElement(AppUtils.Tag_Payment_CZJE);
                        eleValue.AppendChild(eleJe);
                        //以下实现数据操作逻辑
                        eleJe.InnerText = pdt.je.ToString("0.00");

                        XmlElement eleItem = doc.CreateElement(AppUtils.Tag_REXML_ITEM);
                        eleValue.AppendChild(eleItem);
                        //以下实现数据操作逻辑
                        eleItem.InnerText = pdt.item;
                    }
                    //eleResult.InnerText = "1";
                }
                else
                {
                    doc = ErrorReturnXml(rtint, error_msg);
                }
            }
            catch (Exception ex)
            {
                doc = ReplyXmlDoc.GetExceptionXML(AppUtils.Default_Exception_Code, ex);
            }

            return(doc);
        }
        public int MTransferPayment(string json)
        {
            Session session = new Session(json);

            if (session.AutoCapture)
            {
                session.CaptureOn = DateTime.Now;
            }
            int Response = 0;

            if (TempData["TutorModel"] != null)
            {
                UserCache userCache = JsonConvert.DeserializeObject <UserCache>(TempData["TutorModel"].ToString());
                string    Learner   = String.Concat(userCache.FirstName, userCache.LastName);
                Operation Op        = new Operation {
                    UID             = userCache.UserId,
                    RelationId      = session.Id,
                    RelationEntity  = "Event",
                    Amount          = session.Amount,
                    Currency        = session.Currency,
                    CaptureOn       = getCaptureDate(LkpDetails["MoneyTransfer"], session.DateStamp, session.CancelationDate),
                    Captured        = 0,
                    RespDate        = DateTime.Now,
                    Auto            = 0,
                    Description     = session.Title,
                    OprTypeId       = LkpDetails["Payment"],
                    PaymentMethodId = LkpDetails["MoneyTransfer"],
                    SerialId        = Serials["PT"],
                    ObjEntityId     = 1,
                    RespAttch       = session.Photo,
                    CancelationDate = session.CancelationDate,
                    TutorId         = session.TutorId,
                    TutorName       = session.TutorName,
                    billingInfo     = new BillingInfo()
                };
                Response = PaymentDB.SubmitOperation(Op, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));
                if (Response != 0)
                {
                    Op.LinkedOprId = Response;
                    SendNotification(DateTime.Now, Learner, "OMT Pymt", session.Amount, Op.Captured);
                    //Operation 2 : Add tutor Revenue

                    decimal revenue = Convert.ToDecimal(Perc["TutorPercentage"]);
                    AddTutorRevenue(Op, session.TutorId, session.TutorName, revenue);
                    //Operation 3 : Subtract OMT Fees

                    decimal fee = Convert.ToDecimal(Perc["OmtFees"]);
                    decimal Per = Convert.ToDecimal(Perc["OmtPercentage"]);
                    SubtractFees(Op, "OMT Fees", fee, Per, Serials["FT"]);
                    TempData.Keep("TutorModel");
                    return(Response);
                }
                return(0);
            }
            return(Response);
        }
        public int ApiRefundPayment(long OprId = 0)
        {
            int Response = -1;

            if (TempData["TutorModel"] != null)
            {
                Operation op = PaymentDB.GetOprDetails(OprId, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));
                if (op.Captured == 0 || op.Auto == 1 || op.PaymentMethodId != LkpDetails["Card"] || DateTime.Compare(DateTime.Now, op.CancelationDate) > 0)
                {
                    return(0);
                }

                UserCache userCache = JsonConvert.DeserializeObject <UserCache>(TempData["TutorModel"].ToString());
                string    Learner   = String.Concat(userCache.FirstName, userCache.LastName);

                object jsonParameters = new
                {
                    reference = "REFUND-" + op.RelationId
                };
                Console.WriteLine(op.ApiReference);
                var     requestUrl     = "https://api.sandbox.checkout.com/payments/" + op.ApiReference + "/refunds";
                string  responseString = ApiRequest(jsonParameters, requestUrl);
                dynamic jObj           = (JObject)JsonConvert.DeserializeObject(responseString);
                if (jObj != null)
                {
                    op.RespDate    = DateTime.Now;
                    op.RespDetails = responseString.Replace("\"", string.Empty);
                    op.RespId      = jObj.id;
                    op.Auto        = 0;
                    op.Captured    = 1;
                    op.OprTypeId   = LkpDetails["Refund"];
                    op.SerialId    = Serials["RF"];
                    op.LinkedOprId = OprId;
                    op.UID         = userCache.UserId;
                    op.ObjEntityId = 1;//Nabih get user Entity id
                    Response       = PaymentDB.CancelOperation(OprId, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));
                    Response       = PaymentDB.SubmitOperation(op, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));
                    if (Response != 0)
                    {
                        op.LinkedOprId = Response;
                        SendNotification(DateTime.Now, Learner, "Refund Pymt", op.Amount, op.Captured);

                        //Operation 2 : Substract tutor Revenue

                        decimal revenue = 1 - Convert.ToDecimal(Perc["TutorPercentage"]);
                        SubtractTutorFees(op, op.TutorId, op.TutorName, revenue);
                        //Operation 3 : Cancel Checkout Fees
                        decimal fee = Convert.ToDecimal(Perc["CheckoutFees"]);
                        decimal Per = Convert.ToDecimal(Perc["CheckoutPercentage"]);
                        CancelFees(op, "Refund Checkout Fees", fee, Per, Serials["FC"]);
                    }
                }
            }
            return(Response);
        }
Пример #13
0
        /// <summary>
        /// 生成订单
        /// </summary>
        /// <param name="bkhm">卡号</param>
        /// <param name="brid">病人ID</param>
        /// <param name="czje">充值金额</param>
        /// <param name="tkje">退款金额</param>
        /// <param name="brlx">病人类型 1-门诊  2-住院</param>
        /// <param name="payType">支付类型 alipay-支付宝 unionpay-银联</param>
        /// <returns></returns>
        public XmlDocument CreateOrder(string brid, string bkhm, double czje, double tkje, string brlx,
                                       string payType)
        {
            XmlDocument doc = new XmlDocument();

            if (WebConfigParameter.StopCharge)
            {
                doc = ReplyXmlDoc.GetFailureXML(20, "医院内部维护中,暂停该功能");
                return(doc);
            }

            try
            {
                string error_msg = "";
                long   yylsh     = -1;

                PaymentDB pdb = new PaymentDB();
                int       ret = pdb.DB_CreateOrder(brid, bkhm, czje, tkje, brlx, payType,
                                                   out yylsh, out error_msg);

                if (ret == 0)
                {
                    //正常返回
                    doc = new XmlDocument();
                    XmlElement root = doc.CreateElement(AppUtils.Tag_REXML_Root);
                    doc.AppendChild(root);

                    XmlElement eleResult = doc.CreateElement(AppUtils.Tag_REXML_Result);
                    eleResult.InnerText = AppUtils.Value_Return_Success;
                    root.AppendChild(eleResult);

                    XmlElement eleMsg = doc.CreateElement(AppUtils.Tag_REXML_Message);
                    root.AppendChild(eleMsg);

                    XmlElement eleValue = doc.CreateElement(AppUtils.Tag_REXML_Value);
                    eleMsg.AppendChild(eleValue);

                    XmlElement eleYylsh = doc.CreateElement(AppUtils.Tag_Payment_YYLSH);
                    eleValue.AppendChild(eleYylsh);

                    eleYylsh.InnerText = StringHelper.YylshHasPrefix(yylsh);
                }
                else
                {
                    doc = ErrorReturnXml(ret, error_msg);
                }
            }
            catch (Exception ex)
            {
                doc = ReplyXmlDoc.GetExceptionXML(AppUtils.Default_Exception_Code, ex);
            }
            return(doc);
        }
Пример #14
0
 // method to read the column values in the database (through the referenced reader) and assign it to the correct properties of the referenced Extension object
 // allows for easier editing of column names if needed, used only for methods with select statments regarding Extension
 private static void readAnExtension(ref Extension extent, ref SqlDataReader reader)
 {
     extent.ExtensionID       = reader["extentionID"].ToString();
     extent.NewReturnLocation = reader["newReturnLocation"].ToString();
     extent.NewReturnTime     = Convert.ToDateTime(reader["newReturnTime"]);
     extent.NewEndDate        = Convert.ToDateTime(reader["newEndDate"]);
     extent.Unit               = Convert.ToString(reader["unit"]);
     extent.Status             = Convert.ToString(reader["status"]);
     extent.ExtensionRentalFee = Convert.ToDecimal(reader["extensionRentalFee"]);
     extent.Payment            = PaymentDB.getPaymentbyID(reader["paymentID"].ToString());
     extent.Rental             = RentalDB.getRentalbyID(reader["rentalID"].ToString());
 }
        //Cancel Chekout Fees when refund money
        private void CancelFees(Operation Op, string Method, decimal Fees, decimal percentage, int serial)
        {
            Op.UID       = 40108; //Nabih chkout id
            Op.Amount    = Op.Amount * (decimal)percentage + (decimal)Fees;
            Op.Auto      = 1;
            Op.Captured  = 0;
            Op.OprTypeId = LkpDetails["Refund"];
            Op.Canceled  = 1;

            int Response = PaymentDB.SubmitOperation(Op, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));

            SendNotification(DateTime.Now, Method, "Refund CHKT Fees", Op.Amount, Op.Captured);
        }
        //Chekout Fees or OMT Fees
        private void SubtractFees(Operation Op, string Method, decimal Fees, decimal percentage, int serial)
        {
            Op.UID    = serial == 8 ? 40108 : 40109; //Nabih chkout id
            Op.Amount = Op.Amount * (decimal)percentage + (decimal)Fees;
            Op.Auto   = 1;
            //Op.Captured = 0;
            Op.OprTypeId   = LkpDetails["Fees"];
            Op.SerialId    = serial;
            Op.LinkedOprId = Op.Id;
            Console.WriteLine(Op);
            int Response = PaymentDB.SubmitOperation(Op, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));

            SendNotification(DateTime.Now, Method, "CHKT Fees", Op.Amount, Op.Captured);
        }
        //Decrease tutor Balance when cash operation done
        private void SubtractTutorFees(Operation Op, long TutorId, string TutorName, decimal percentage)
        {
            Op.UID    = TutorId;
            Op.Amount = Op.Amount * (decimal)percentage;
            Op.Auto   = 1;
            //Op.Captured = 0;
            Op.OprTypeId   = LkpDetails["Fees"];
            Op.SerialId    = Serials["FI"];
            Op.LinkedOprId = Op.Id;

            int Response = PaymentDB.SubmitOperation(Op, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));

            SendNotification(DateTime.Now, TutorName, "INTO Fees", Op.Amount, Op.Captured);
        }
 public IActionResult Invoice(int OprId)
 {
     if (TempData["TutorModel"] != null)
     {
         UserCache    userCache    = JsonConvert.DeserializeObject <UserCache>(TempData["TutorModel"].ToString());
         PaymentModel paymentModel = new PaymentModel
         {
             User      = userCache.Extract(),
             operation = PaymentDB.GetOprDetails(OprId, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION))
         };
         TempData.Keep("TutorModel");
         return(PartialView(paymentModel));
     }
     return(PartialView(new PaymentModel()));
 }
 //Get Sessions as json array for Js Tabulator Library
 public IActionResult GetAllJsonOpr()
 {
     if (TempData["TutorModel"] != null)
     {
         UserCache    userCache    = JsonConvert.DeserializeObject <UserCache>(TempData["TutorModel"].ToString());
         PaymentModel paymentModel = new PaymentModel
         {
             User = userCache.Extract()
         };
         paymentModel.Operations = PaymentDB.GetAllOperations(GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));
         TempData.Keep("TutorModel");
         return(Json(paymentModel.Operations));
     }
     return(null);
 }
Пример #20
0
        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                PaymentDB.CancelAllChanges();

                Grid parentGrid = (Grid)this.Parent;
                parentGrid.Children.Clear();
                parentGrid.Visibility = System.Windows.Visibility.Hidden;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public int CashPayment(string json)
        {
            Session session = new Session(json);

            if (session.AutoCapture)
            {
                session.CaptureOn = DateTime.Now;
            }
            int Response = 0;

            if (TempData["TutorModel"] != null)
            {
                UserCache userCache = JsonConvert.DeserializeObject <UserCache>(TempData["TutorModel"].ToString());
                Operation Op        = new Operation {
                    UID             = userCache.UserId,
                    RelationId      = session.Id,
                    RelationEntity  = "Event",
                    Amount          = session.Amount,
                    Currency        = session.Currency,
                    CaptureOn       = getCaptureDate(LkpDetails["Cash"], session.DateStamp, session.CancelationDate),
                    Captured        = 0,
                    RespDate        = DateTime.Now,
                    Auto            = 0,
                    Description     = session.Title,
                    OprTypeId       = LkpDetails["Payment"],
                    PaymentMethodId = LkpDetails["Cash"],
                    SerialId        = Serials["PC"],
                    ObjEntityId     = 1,
                    CancelationDate = session.CancelationDate,
                    TutorId         = session.TutorId,
                    TutorName       = session.TutorName,
                    billingInfo     = new BillingInfo()
                };
                Response = PaymentDB.SubmitOperation(Op, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));
                if (Response != 0)
                {
                    Op.LinkedOprId = Response;
                    SendNotification(DateTime.Now, userCache.FirstName, "Cash Pymt", session.Amount, Op.Captured);
                    //Operation 2 : Subtract tutor Fees
                    decimal fee = 1 - Convert.ToDecimal(Perc["TutorPercentage"]);
                    SubtractTutorFees(Op, session.TutorId, session.TutorName, fee);
                    TempData.Keep("TutorModel");
                    return(Response);
                }
                return(0);
            }
            return(Response);
        }
        //Open Opr Details : Show Opr details and Refund if possible
        public IActionResult OprDetails(int OprId)
        {
            if (TempData["TutorModel"] != null)
            {
                UserCache    userCache    = JsonConvert.DeserializeObject <UserCache>(TempData["TutorModel"].ToString());
                PaymentModel paymentModel = new PaymentModel
                {
                    User      = userCache.Extract(),
                    operation = PaymentDB.GetOprDetails(OprId, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION))
                };
                if (paymentModel.operation == null)
                {
                    return(PartialView(new PaymentModel()));
                }
                Console.WriteLine(paymentModel.operation.Auto);
                Console.WriteLine(paymentModel.operation.PaymentMethodId);
                Console.WriteLine(DateTime.Compare(DateTime.Now, paymentModel.operation.CancelationDate) < 0);
                Console.WriteLine(paymentModel.operation.Captured);
                //if payment is not returned before   &&   not auto payment   &&   made by card    && before cancelation Date   -> THEN CAN BE REFUND
                if (paymentModel.operation.Canceled == 0 && paymentModel.operation.Auto == 0 && paymentModel.operation.PaymentMethodId == LkpDetails["Card"] && DateTime.Compare(DateTime.Now, paymentModel.operation.CancelationDate) < 0)
                {
                    //refund if opr is captured
                    if (paymentModel.operation.Captured == 1)
                    {
                        paymentModel.operation.Action    = "RefundPayment";
                        paymentModel.operation.CanRefund = true;
                    }
                    //Void if opr is not captured yet
                    else
                    {
                        paymentModel.operation.Action  = "VoidPayment";
                        paymentModel.operation.CanVoid = true;
                    }
                }
                else if (paymentModel.operation.Canceled == 1)
                {
                    paymentModel.operation.Action = "Canceled";
                }
                else
                {
                    paymentModel.operation.Action = "NoAction";
                }

                TempData.Keep("TutorModel");
                return(PartialView(paymentModel));
            }
            return(PartialView(new PaymentModel()));
        }
Пример #23
0
    // method to read the column values in the database (through the referenced reader) and assign it to the correct properties of the referenced Rental object
    // allows for easier editing of column names if needed, used only for methods with select statments regarding Rental
    private static void readARental(ref Rental rent, ref SqlDataReader reader)
    {
        rent.RentalID           = Convert.ToString(reader["rentalID"]);
        rent.PickUpLocation     = Convert.ToString(reader["pickUpLocation"]);
        rent.PickUpTime         = (TimeSpan)reader["pickUpTime"];
        rent.RentalFee          = Convert.ToDecimal(reader["rentalFee"]);
        rent.Unit               = reader["unit"].ToString();
        rent.Deposit            = Convert.ToDecimal(reader["deposit"]);
        rent.DateCreated        = Convert.ToDateTime(reader["dateCreated"]);
        rent.StartDate          = Convert.ToDateTime(reader["startDate"]);
        rent.EndDate            = Convert.ToDateTime(reader["endDate"]);
        rent.Status             = Convert.ToString(reader["status"]);
        rent.PaymentReleaseCode = Convert.ToString(reader["paymentReleaseCode"]);

        if (reader["depositRetrievalCode"] != DBNull.Value)
        {
            rent.DepositRetrievalCode = Convert.ToString(reader["depositRetrievalCode"]);
        }
        else
        {
            rent.DepositRetrievalCode = null;
        }

        if (reader["returnLocation"] != DBNull.Value)
        {
            rent.ReturnLocation = reader["returnLocation"].ToString();
        }
        else
        {
            rent.ReturnLocation = "";
        }

        if (reader["returnTime"] != DBNull.Value)
        {
            rent.ReturnTime = (TimeSpan)reader["returnTime"];
        }
        else
        {
            rent.ReturnTime = new TimeSpan(0, 0, 0);
        }

        rent.Rentee = MemberDB.getMemberbyID(reader["renteeID"].ToString());

        rent.Item = ItemDB.getItembyID(reader["itemID"].ToString());

        rent.Payment = PaymentDB.getPaymentbyID(reader["paymentID"].ToString());
    }
        public int ApiVoidPayment(long OprId = 0)
        {
            int Response = -1;

            if (TempData["TutorModel"] != null)
            {
                Operation op = PaymentDB.GetOprDetails(OprId, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));

                if (op.Captured == 0 || op.Auto == 1 || op.PaymentMethodId != LkpDetails["Card"])
                {
                    return(0);
                }

                UserCache userCache = JsonConvert.DeserializeObject <UserCache>(TempData["TutorModel"].ToString());
                string    Learner   = String.Concat(userCache.FirstName, userCache.LastName);

                object jsonParameters = new
                {
                    reference = "VOID-" + op.RelationId
                };
                Console.WriteLine(op.ApiReference);
                var     requestUrl     = "https://api.sandbox.checkout.com/payments/" + op.ApiReference + "/captures";
                string  responseString = ApiRequest(jsonParameters, requestUrl);
                dynamic jObj           = (JObject)JsonConvert.DeserializeObject(responseString);
                if (jObj != null)
                {
                    op.RespDate    = (DateTime)jObj.processed_on;
                    op.RespDetails = responseString.Replace("\"", string.Empty);
                    op.RespId      = jObj.id;
                    op.Auto        = 0;
                    op.Captured    = 1;
                    op.OprTypeId   = LkpDetails["Void"];
                    op.SerialId    = Serials["PB"];
                    op.LinkedOprId = OprId;
                    op.UID         = userCache.UserId;
                    op.ObjEntityId = 1;//Nabih get user Entity id

                    Response = PaymentDB.CancelOperation(OprId, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));
                    Response = PaymentDB.SubmitOperation(op, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));
                    if (Response != 0)
                    {
                        SendNotification(DateTime.Now, Learner, "Void Pymt", op.Amount, op.Captured);
                    }
                }
            }
            return(Response);
        }
 public IActionResult Index()
 {
     if (TempData["TutorModel"] != null)
     {
         UserCache    userCache    = JsonConvert.DeserializeObject <UserCache>(TempData["TutorModel"].ToString());
         PaymentModel paymentModel = new PaymentModel
         {
             User = userCache.Extract(),
         };
         paymentModel.hasHasBlInfo = PaymentDB.HasBillingInfo(paymentModel.User.UserId, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));
         paymentModel.PaidSessions = PaymentDB.GetPaidSessions(paymentModel.User.UserId, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));
         Console.WriteLine("Date         Name            Operation     Amount     Captured?");
         TempData.Keep("TutorModel");
         return(View(paymentModel));
     }
     return(View(new PaymentModel()));
 }
 public IActionResult PayNow1(int SessionId)
 {
     if (TempData["TutorModel"] != null)
     {
         UserCache    userCache    = JsonConvert.DeserializeObject <UserCache>(TempData["TutorModel"].ToString());
         PaymentModel paymentModel = new PaymentModel
         {
             User = userCache.Extract()
         };
         paymentModel.session     = PaymentDB.GetSessionDetails(SessionId, paymentModel.User.UserId, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));
         paymentModel.wallet      = PaymentDB.GetWallet(paymentModel.User.UserId, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));
         paymentModel.billingInfo = PaymentDB.GetBillingInfo(userCache.UserId, GetConfiguration().GetConnectionString(DEFAULT_CONNECTION));
         TempData.Keep("TutorModel");
         return(PartialView(paymentModel));
     }
     return(PartialView(new PaymentModel()));
 }
Пример #27
0
        public HttpResponseMessage CheckPaymentSmsCode(PaymentChackPaymentSmsCodeRequestModel model)
        {
            PaymentChackPaymentSmsCodeResponseModel responseModel = new PaymentChackPaymentSmsCodeResponseModel();
            HttpResponseMessage responseMessage = new HttpResponseMessage();

            if (!ModelState.IsValid)
            {
                responseModel.IsSuccess    = false;
                responseMessage.StatusCode = HttpStatusCode.BadRequest;
                responseModel.Message      = "There is not such action";
                responseMessage.Content    = new StringContent(JsonConvert.SerializeObject(responseModel));
                return(responseMessage);
            }
            responseModel              = PaymentDB.ChackPaymentSmsCode(model);
            responseMessage.Content    = new StringContent(JsonConvert.SerializeObject(responseModel));
            responseMessage.StatusCode = HttpStatusCode.Accepted;
            return(responseMessage);
        }
Пример #28
0
        public HttpResponseMessage Pay(PaymentPayRequestModel model)
        {
            PaymentPayResponseModel responseModel   = new PaymentPayResponseModel();
            HttpResponseMessage     responseMessage = new HttpResponseMessage();

            if (!ModelState.IsValid)
            {
                responseModel.IsSuccess    = false;
                responseModel.Message      = "False request for payment";
                responseMessage.StatusCode = HttpStatusCode.BadRequest;
                responseMessage.Content    = new StringContent(JsonConvert.SerializeObject(responseModel));
                return(responseMessage);
            }
            responseModel              = PaymentDB.Pay(model);
            responseMessage.Content    = new StringContent(JsonConvert.SerializeObject(responseModel));
            responseMessage.StatusCode = HttpStatusCode.Accepted;
            return(responseMessage);
        }
Пример #29
0
        public HttpResponseMessage GeneratePayment(PaymentGenerateRequestModel model)
        {
            HttpResponseMessage          httpResponse  = new HttpResponseMessage();
            PaymentGenerateResponseModel responsemodel = new PaymentGenerateResponseModel();

            if (!ModelState.IsValid)
            {
                responsemodel.IsSuccess = false;
                responsemodel.Message   = "False Request";

                httpResponse.Content    = new StringContent(JsonConvert.SerializeObject(responsemodel));
                httpResponse.StatusCode = HttpStatusCode.ExpectationFailed;
                return(httpResponse);
            }
            responsemodel           = PaymentDB.GeneratePayment(model);
            httpResponse.Content    = new StringContent(JsonConvert.SerializeObject(responsemodel));
            httpResponse.StatusCode = HttpStatusCode.Accepted;
            return(httpResponse);
        }
Пример #30
0
        /// <summary>
        /// 查询账户余额
        /// </summary>
        /// <param name="brid">病人ID</param>
        /// <param name="brlx">病人类型 1:门诊  2:住院</param>
        /// <returns></returns>
        public XmlDocument QueryBalance(string brid, string brlx)
        {
            XmlDocument doc = new XmlDocument();

            try
            {
                string error_msg = "";

                BalanceInfo info = new BalanceInfo();
                PaymentDB   pdb  = new PaymentDB();
                int         ret  = pdb.DB_QueryBalance(brid, brlx, out info, out error_msg);

                if (ret == 0)
                {
                    XmlElement root = doc.CreateElement(AppUtils.Tag_REXML_Root);
                    doc.AppendChild(root);

                    XmlElement eleResult = doc.CreateElement(AppUtils.Tag_REXML_Result);
                    eleResult.InnerText = AppUtils.Value_Return_Success;
                    root.AppendChild(eleResult);

                    XmlElement eleMsg = doc.CreateElement(AppUtils.Tag_REXML_Message);
                    root.AppendChild(eleMsg);

                    XmlElement eleValue = doc.CreateElement(AppUtils.Tag_REXML_Value);
                    eleMsg.AppendChild(eleValue);

                    XmlElement eleZhye = doc.CreateElement(AppUtils.Tag_Balance_Zhye);
                    eleValue.AppendChild(eleZhye);
                    eleZhye.InnerText = info.zhye.ToString();
                }
                else
                {
                    doc = ErrorReturnXml(ret, error_msg);
                }
            }
            catch (Exception ex)
            {
                doc = ReplyXmlDoc.GetExceptionXML(AppUtils.Default_Exception_Code, ex);
            }
            return(doc);
        }