Esempio n. 1
0
        public override String CaptureOrder(Order o)
        {
            String result = AppLogic.ro_OK;

            o.CaptureTXCommand = "";
            o.CaptureTXResult  = "";

            String TransID = o.AuthorizationPNREF;

            if (TransID.Length == 0 || TransID == "0")
            {
                result = "Invalid or Empty Transaction ID";
            }
            else
            {
                try
                {
                    GatewayClient client = SecureNetController.GetGatewayClient();

                    TRANSACTION oT = SecureNetController.GetTransactionWithDefaults();

                    oT.CODE = SecureNetController.GetTypeCodeString(SecureNetTransactionTypeCode.PRIOR_AUTH_CAPTURE);

                    oT.AMOUNT = o.OrderBalance;
                    oT.METHOD = SecureNetMethod.CC.ToString();

                    oT.REF_TRANSID = TransID;
                    oT.ORDERID     = o.OrderNumber.ToString();

                    String cardnumber = DB.GetSqlS("select Last4 S from Orders  with (NOLOCK)  where OrderNumber=" + o.OrderNumber.ToString());
                    if (!String.IsNullOrEmpty(cardnumber))
                    {
                        oT.CARD            = new CARD();
                        oT.CARD.CARDNUMBER = cardnumber;
                        oT.CARD.EXPDATE    = o.CardExpirationMonth.PadLeft(2, '0') + o.CardExpirationYear.ToString().Substring(2, 2); //MMYY
                    }

                    oT.INVOICENUM  = o.OrderNumber.ToString();
                    oT.INVOICEDESC = AppLogic.AppConfig("StoreName");

                    GATEWAYRESPONSE oTr = client.ProcessTransaction(oT);

                    if (oTr.TRANSACTIONRESPONSE.RESPONSE_CODE == "1") // 1=Approved, 2=Declined, 3=Error
                    {
                        result = AppLogic.ro_OK;
                    }
                    else
                    {
                        result = "Error: [" + oTr.TRANSACTIONRESPONSE.RESPONSE_CODE + "] " + oTr.TRANSACTIONRESPONSE.RESPONSE_REASON_TEXT;
                    }
                    o.CaptureTXCommand = this.GetXMLSerializedObject(oT);
                    o.CaptureTXResult  = this.GetXMLSerializedObject(oTr);
                }
                catch
                {
                    result = "NO RESPONSE FROM GATEWAY!";
                }
            }
            return(result);
        }
Esempio n. 2
0
        public IHttpActionResult PutTRANSACTION(int id, TRANSACTION tRANSACTION)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tRANSACTION.TRANSACTION_ID)
            {
                return(BadRequest());
            }

            db.Entry(tRANSACTION).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TRANSACTIONExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public ActionResult DeleteConfirmed(decimal id)
        {
            TRANSACTION tRANSACTION = db.TRANSACTIONS.Find(id);

            db.TRANSACTIONS.Remove(tRANSACTION);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 4
0
        public static TRANSACTION GetTransactionWithDefaults()
        {
            TRANSACTION oT = new TRANSACTION();

            oT.MERCHANT_KEY = GetMerchantKey();
            oT.TEST         = AppLogic.AppConfigBool("SecureNetV4.UseTestMode").ToString().ToUpper();
            return(oT);
        }
Esempio n. 5
0
        public bool AddTaskByViewModel(CreateTaskViewModel model)
        {
            var user = new USER();

            if (model.FK_ID_USER == 0)
            {
                user.EMAIL     = model.ShortEditUserViewModel.Email;
                user.FIRSTNAME = model.ShortEditUserViewModel.Firstname;
                user.LASTNAME  = model.ShortEditUserViewModel.Lastname;
                user.USERNAME  = model.ShortEditUserViewModel.Username;
                user.PASSWORD  = EncryptionUtil.Encrypt(model.ShortEditUserViewModel.Password);
            }
            else
            {
                // On update les infos user
                user = UoW.USER_Repository.GetByID(model.FK_ID_USER);

                user.LASTNAME  = model.ShortEditUserViewModel.Lastname;
                user.FIRSTNAME = model.ShortEditUserViewModel.Firstname;
                user.EMAIL     = model.ShortEditUserViewModel.Email;
            }

            bool userEdited = new USER_Service().AddOrUpdateUser(user);

            // on créé la tache
            var task = new TASK();

            task.STATUS = (int)EnumManager.PARAM_TASK_STATUS.A_FAIRE;

            task.IS_PAID = false;

            task.CreateFromModel(model);

            //Mise à jour du montant de la transaction
            var transaction = UoW.TRANSACTION_Repository.GetByID(model.TransactionId);

            // si l'utilisateur est nouveau on en crée une
            if (transaction == null)
            {
                transaction = new TRANSACTION
                {
                    DATE_TRANSACTION      = DateTime.Now,
                    FK_ID_USER            = user.PK_ID_USER,
                    PAYPAL_TRANSACTION_ID = DateTime.Now.Ticks
                };
            }

            transaction.PRICE += task.PRICE ?? 0;
            new TRANSACTION_Service().AddOrUpdateTransaction(transaction);

            task.FK_ID_TRANSACTION = model.TransactionId != 0 ? model.TransactionId : transaction.PK_ID_TRANSACTION;
            task.FK_ID_USER        = model.FK_ID_USER != 0 ? model.FK_ID_USER : user.PK_ID_USER;

            return(AddOrUpdateTask(task));
        }
 public ActionResult Edit([Bind(Include = "TRANSACTIONID,USERID,NAMEONCARD,CARDNUMBER,EXPIRYDATE,PRICE,DATEOFPURCHASE")] TRANSACTION tRANSACTION)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tRANSACTION).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.USERID = new SelectList(db.PAYMENTDETAILS, "USERID", "STREETNUMBER", tRANSACTION.USERID);
     return(View(tRANSACTION));
 }
Esempio n. 7
0
        public IHttpActionResult GetTRANSACTION(int id)
        {
            TRANSACTION tRANSACTION = db.TRANSACTIONs.Find(id);

            if (tRANSACTION == null)
            {
                return(NotFound());
            }

            return(Ok(tRANSACTION));
        }
Esempio n. 8
0
        public IHttpActionResult PostTRANSACTION(TRANSACTION tRANSACTION)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.TRANSACTIONs.Add(tRANSACTION);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = tRANSACTION.TRANSACTION_ID }, tRANSACTION));
        }
        public ActionResult Create([Bind(Include = "TRANSACTIONID,USERID,PRICE,DATEOFPURCHASE")] TRANSACTION tRANSACTION)
        {
            //checks if its valid for security reasons
            if (ModelState.IsValid)
            {
                db.TRANSACTIONS.Add(tRANSACTION);  // adds the transaction
                db.SaveChanges();                  // saves changes
                return(RedirectToAction("Index")); // goers back to table page
            }

            ViewBag.USERID = new SelectList(db.PAYMENTDETAILS, "USERID", "USERID", tRANSACTION.USERID); // passes the user id
            return(View(tRANSACTION));                                                                  // returns the transaction created
        }
Esempio n. 10
0
        public IHttpActionResult DeleteTRANSACTION(int id)
        {
            TRANSACTION tRANSACTION = db.TRANSACTIONs.Find(id);

            if (tRANSACTION == null)
            {
                return(NotFound());
            }

            db.TRANSACTIONs.Remove(tRANSACTION);
            db.SaveChanges();

            return(Ok(tRANSACTION));
        }
        //takes the user to the delete view with the specific element to be deleted and asks the user if he wants to delete
        // GET: Transactions/Delete/5
        public ActionResult Delete(decimal id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TRANSACTION tRANSACTION = db.TRANSACTIONS.Find(id);

            if (tRANSACTION == null)
            {
                return(HttpNotFound());
            }
            return(View(tRANSACTION));
        }
        // GET: Transactions/Details/5
        /// <summary>
        /// sents the transaction id to check if the transaction exists
        /// </summary>
        /// <param name="id"></param> Transaction
        /// <returns></returns>
        public ActionResult Details(decimal id)
        {
            //searches for the id and if the id and the whole table to display
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TRANSACTION tRANSACTION = db.TRANSACTIONS.Find(id);

            if (tRANSACTION == null)
            {
                return(HttpNotFound());
            }
            return(View(tRANSACTION));
        }
 public bool AddOrUpdateTransaction(TRANSACTION transaction)
 {
     if (transaction.PK_ID_TRANSACTION != 0)
     {
         UoW.TRANSACTION_Repository.Update(transaction);
         UoW.Save();
         return(true);
     }
     else
     {
         UoW.TRANSACTION_Repository.Insert(transaction);
         UoW.Save();
         return(true);
     }
 }
        // checks if the id and the element exists in the database
        // GET: Transactions/Edit/5
        public ActionResult Edit(decimal id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TRANSACTION tRANSACTION = db.TRANSACTIONS.Find(id);

            if (tRANSACTION == null)
            {
                return(HttpNotFound());
            }
            ViewBag.USERID = new SelectList(db.PAYMENTDETAILS, "USERID", "STREETNUMBER", tRANSACTION.USERID);
            return(View(tRANSACTION));
        }
        // GET: Transactions/Create
        /// <summary>
        ///  checks the last transaction id created and adds up to auto generate ids when the create button is pressed
        /// </summary>
        /// <returns></returns> Transaction ID
        public ActionResult Create()
        {
            //gets the id from the user
            ViewBag.USERID = new SelectList(db.USERACCOUNTs, "USERID", "USERID");
            TRANSACTION newTransaction = new TRANSACTION();
            // creates a new transaction so it can generate a unique id for each transaction
            var lastTransaction = db.TRANSACTIONS.OrderByDescending(x => x.TRANSACTIONID).FirstOrDefault();

            // if there are no transactions the first one gets assigned and then it gets incremented
            if (lastTransaction == null)
            {
                newTransaction.TRANSACTIONID = 8001;
            }
            else if (lastTransaction.TRANSACTIONID != 0)
            {
                newTransaction.TRANSACTIONID = lastTransaction.TRANSACTIONID + 1;
            }
            //converts to int
            Convert.ToInt32(newTransaction.TRANSACTIONID);

            return(View(newTransaction)); // returns the new transaction
        }
Esempio n. 16
0
        public CreateTaskViewModel InitCreateTaskViewModel(int userId)
        {
            var listFormatTypes = UoW.FORMAT_TYPE_Repository.Get(null, q => q.OrderBy(s => s.PK_ID_FORMAT_TYPE), "").ToList();

            var listFormat             = new FORMAT_Service().GetAll();
            var user                   = UoW.USER_Repository.GetByID(userId);
            var shortEditUserViewModel = new ShortEditUserViewModel(user);

            var         userTasks = GetListOfTaskByUserId(userId, false).Where(x => x.IS_PAID == false);
            TRANSACTION transaction;

            if (userTasks.Any())
            {
                transaction = userTasks.First().TRANSACTION;
            }
            else
            {
                transaction = new TRANSACTION
                {
                    DATE_TRANSACTION      = DateTime.Now,
                    FK_ID_USER            = userId,
                    PAYPAL_TRANSACTION_ID = DateTime.Now.Ticks,
                    PRICE = 0
                };
                UoW.TRANSACTION_Repository.Insert(transaction);
                UoW.Save();
            }

            return(new CreateTaskViewModel
            {
                FK_ID_USER = userId,
                ListAvailableFormatTypes = listFormatTypes,
                ListAvailableFormats = listFormat,
                ShortEditUserViewModel = shortEditUserViewModel,
                TransactionId = transaction.PK_ID_TRANSACTION
            });
        }
Esempio n. 17
0
        public String ProcessCard(int OrderNumber, int CustomerID, Decimal OrderTotal, bool useLiveTransactions, TransactionModeEnum TransactionMode, Address UseBillingAddress, String CardExtraCode, Address UseShippingAddress, String CAVV, String ECI, String XID, out String AVSResult, out String AuthorizationResult, out String AuthorizationCode, out String AuthorizationTransID, out String TransactionCommandOut, out String TransactionResponse, Boolean IsVaultTransaction, Customer ThisCustomer)
        {
            if (IsVaultTransaction && ThisCustomer == null)
            {
                throw new ArgumentException("Customer Object required for vault transactions.");
            }

            String result = AppLogic.ro_OK;

            AuthorizationCode     = String.Empty;
            AuthorizationResult   = String.Empty;
            AuthorizationTransID  = String.Empty;
            AVSResult             = String.Empty;
            TransactionCommandOut = String.Empty;
            TransactionResponse   = String.Empty;

            GatewayClient client = SecureNetController.GetGatewayClient();

            TRANSACTION oT = SecureNetController.GetTransactionWithDefaults();

            if (IsVaultTransaction)
            {
                //vault info
                oT.CUSTOMERID = ThisCustomer.CustomerID.ToString();
                oT.PAYMENTID  = AppLogic.GetSelectedSecureNetVault(ThisCustomer);
            }
            else
            {
                //Credit Card Info
                oT.CARD            = new CARD();
                oT.CARD.CARDCODE   = CardExtraCode;
                oT.CARD.CARDNUMBER = UseBillingAddress.CardNumber;
                oT.CARD.EXPDATE    = UseBillingAddress.CardExpirationMonth.PadLeft(2, '0') + UseBillingAddress.CardExpirationYear.ToString().Substring(2, 2); //MMYY
            }


            //Billing Address Info
            oT.CUSTOMER_BILL           = new CUSTOMER_BILL();
            oT.CUSTOMER_BILL.ADDRESS   = UseBillingAddress.Address1;
            oT.CUSTOMER_BILL.CITY      = UseBillingAddress.City;
            oT.CUSTOMER_BILL.ZIP       = UseBillingAddress.Zip;
            oT.CUSTOMER_BILL.STATE     = UseBillingAddress.State;
            oT.CUSTOMER_BILL.COMPANY   = UseBillingAddress.Company;
            oT.CUSTOMER_BILL.COUNTRY   = UseBillingAddress.Country;
            oT.CUSTOMER_BILL.EMAIL     = UseBillingAddress.EMail;
            oT.CUSTOMER_BILL.FIRSTNAME = UseBillingAddress.FirstName;
            oT.CUSTOMER_BILL.LASTNAME  = UseBillingAddress.LastName;
            oT.CUSTOMER_BILL.PHONE     = UseBillingAddress.Phone;

            //Shipping Address Info
            if (UseShippingAddress != null)
            {
                oT.CUSTOMER_SHIP           = new CUSTOMER_SHIP();
                oT.CUSTOMER_SHIP.ADDRESS   = UseShippingAddress.Address1;
                oT.CUSTOMER_SHIP.CITY      = UseShippingAddress.City;
                oT.CUSTOMER_SHIP.ZIP       = UseShippingAddress.Zip;
                oT.CUSTOMER_SHIP.STATE     = UseShippingAddress.State;
                oT.CUSTOMER_SHIP.COMPANY   = UseShippingAddress.Company;
                oT.CUSTOMER_SHIP.COUNTRY   = UseShippingAddress.Country;
                oT.CUSTOMER_SHIP.FIRSTNAME = UseShippingAddress.FirstName;
                oT.CUSTOMER_SHIP.LASTNAME  = UseShippingAddress.LastName;
            }

            //todo - look into adding cartitems

            //Transaction Information
            oT.AMOUNT      = OrderTotal;
            oT.CODE        = CommonLogic.IIF(AppLogic.TransactionModeIsAuthOnly(), SecureNetController.GetTypeCodeString(SecureNetTransactionTypeCode.AUTH_ONLY), SecureNetController.GetTypeCodeString(SecureNetTransactionTypeCode.AUTH_CAPTURE));
            oT.METHOD      = SecureNetMethod.CC.ToString();
            oT.ORDERID     = OrderNumber.ToString();
            oT.CUSTOMERIP  = CommonLogic.CustomerIpAddress();
            oT.INVOICENUM  = OrderNumber.ToString();
            oT.INVOICEDESC = AppLogic.AppConfig("StoreName");

            //pasing unused integers as zeros as defined in the securenet docs
            oT.TOTAL_INSTALLMENTCOUNT  = 0;
            oT.OVERRIDE_FROM           = 0;
            oT.INSTALLMENT_SEQUENCENUM = 0;
            oT.RETAIL_LANENUM          = 0;
            oT.CASHBACK_AMOUNT         = 0;

            if (IsVaultTransaction)
            {
                oT.TRANSACTION_SERVICE = 1;
            }
            else
            {
                oT.TRANSACTION_SERVICE = 0;
            }

            //MPI for 3D Secure
            oT.MPI = new MPI();

            if (!String.IsNullOrEmpty(ECI))
            {
                oT.MPI.AUTHINDICATOR = ECI;
            }

            if (!String.IsNullOrEmpty(CAVV))
            {
                oT.MPI.AUTHVALUE = CAVV;
            }

            GATEWAYRESPONSE oG = client.ProcessTransaction(oT);

            if (oG.TRANSACTIONRESPONSE.RESPONSE_CODE == "1")
            {
                AuthorizationTransID = oG.TRANSACTIONRESPONSE.TRANSACTIONID.ToString();
                AuthorizationCode    = "Response Code: " + oG.TRANSACTIONRESPONSE.RESPONSE_CODE + ", Reason Code: " + oG.TRANSACTIONRESPONSE.RESPONSE_REASON_CODE;

                if (!String.IsNullOrEmpty(oG.TRANSACTIONRESPONSE.AVS_RESULT_CODE))
                {
                    AVSResult = oG.TRANSACTIONRESPONSE.AVS_RESULT_CODE;
                }

                if (!String.IsNullOrEmpty(oG.TRANSACTIONRESPONSE.CARD_CODE_RESPONSE_CODE))
                {
                    if (AVSResult.Length > 0)
                    {
                        AVSResult += ", ";
                    }
                    AVSResult += "ExtraCode: " + oG.TRANSACTIONRESPONSE.CARD_CODE_RESPONSE_CODE;
                }

                //if (!String.IsNullOrEmpty(oTr.CAVV_Response_Code))
                if (!String.IsNullOrEmpty(oG.TRANSACTIONRESPONSE.CAVV_RESPONSE_CODE))
                {
                    if (AVSResult.Length > 0)
                    {
                        AVSResult += ", ";
                    }
                    AVSResult += "CAVV: " + oG.TRANSACTIONRESPONSE.CAVV_RESPONSE_CODE;
                }

                AuthorizationResult = oG.TRANSACTIONRESPONSE.RESPONSE_REASON_TEXT + ", Approval Code: " + oG.TRANSACTIONRESPONSE.AUTHCODE;
                result = AppLogic.ro_OK;
            }
            else
            {
                AuthorizationResult = "Error: [" + oG.TRANSACTIONRESPONSE.RESPONSE_CODE + "] " + oG.TRANSACTIONRESPONSE.RESPONSE_REASON_TEXT;
                result = oG.TRANSACTIONRESPONSE.RESPONSE_REASON_TEXT;
            }

            TransactionCommandOut = this.GetXMLSerializedObject(oT);
            TransactionResponse   = this.GetXMLSerializedObject(oG);

            if (!IsVaultTransaction && AppLogic.SecureNetVaultIsEnabled() && result == AppLogic.ro_OK)
            {
                if (ThisCustomer == null)
                {
                    ThisCustomer = new Customer(CustomerID);
                }
                if (ThisCustomer.SecureNetVaultMasterShouldWeStoreCreditCardInfo)
                {
                    try
                    {
                        SecureNetVault vault = new SecureNetVault(ThisCustomer);
                        vault.AddCreditCardToCustomerVault(UseBillingAddress.CardName, UseBillingAddress.CardNumber, CardExtraCode, UseBillingAddress.CardType, UseBillingAddress.CardExpirationMonth, UseBillingAddress.CardExpirationYear);
                    }
                    catch { }
                }
            }

            if (IsVaultTransaction && result == AppLogic.ro_OK)
            {
                AppLogic.ClearSelectedSecureNetVaultInSession(ThisCustomer);
            }

            return(result);
        }
Esempio n. 18
0
        public override String RefundOrder(int OriginalOrderNumber, int NewOrderNumber, decimal RefundAmount, String RefundReason, Address UseBillingAddress)
        {
            String result = String.Empty;

            DB.ExecuteSQL("update orders set RefundTXCommand=NULL, RefundTXResult=NULL where OrderNumber=" + OriginalOrderNumber.ToString());
            String  TransID             = String.Empty;
            Decimal OrderTotal          = System.Decimal.Zero;
            string  Last4               = string.Empty;
            string  CardExpirationMonth = string.Empty;
            string  CardExpirationYear  = string.Empty;

            using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
            {
                dbconn.Open();
                using (IDataReader rs = DB.GetRS("select * from Orders  with (NOLOCK)  where OrderNumber=" + OriginalOrderNumber.ToString(), dbconn))
                {
                    if (rs.Read())
                    {
                        TransID             = DB.RSField(rs, "AuthorizationPNREF");
                        OrderTotal          = DB.RSFieldDecimal(rs, "OrderTotal");
                        Last4               = DB.RSField(rs, "Last4");
                        CardExpirationMonth = DB.RSField(rs, "CardExpirationMonth");
                        CardExpirationYear  = DB.RSField(rs, "CardExpirationYear");
                    }
                }
            }

            if (TransID.Length == 0 || TransID == "0")
            {
                result = "Invalid or Empty Transaction ID";
            }
            else
            {
                try
                {
                    GatewayClient client = SecureNetController.GetGatewayClient();
                    TRANSACTION   oT     = SecureNetController.GetTransactionWithDefaults();

                    // AUTH_CAPTURE, AUTH_ONLY, CREDIT, VOID, PRIOR_AUTH_CAPTURE
                    oT.CODE = SecureNetController.GetTypeCodeString(SecureNetTransactionTypeCode.CREDIT);

                    //If partial refund set value ( like 1.95). If FULL Refund leave it empty. The transactionID will take care of the amount
                    if (OrderTotal == RefundAmount || RefundAmount == 0.0M)
                    {
                        oT.AMOUNT = OrderTotal;
                    }
                    else
                    {
                        oT.AMOUNT = RefundAmount;
                    }

                    if (!String.IsNullOrEmpty(Last4))
                    {
                        oT.CARD            = new CARD();
                        oT.CARD.CARDNUMBER = Last4;
                        oT.CARD.EXPDATE    = CardExpirationMonth.PadLeft(2, '0') + CardExpirationYear.ToString().Substring(2, 2); //MMYY
                    }

                    if (!String.IsNullOrEmpty(RefundReason))
                    {
                        oT.NOTE = RefundReason;
                    }

                    oT.METHOD = SecureNetMethod.CC.ToString();

                    oT.REF_TRANSID = TransID;
                    oT.ORDERID     = OriginalOrderNumber.ToString() + "REFUND" + DateTime.Today.ToShortDateString().Replace("/", "");

                    GATEWAYRESPONSE oTr = client.ProcessTransaction(oT);

                    if (oTr.TRANSACTIONRESPONSE.RESPONSE_CODE == "1") // 1=Approved, 2=Declined, 3=Error
                    {
                        result = AppLogic.ro_OK;
                    }
                    else
                    {
                        result = "Error: [" + oTr.TRANSACTIONRESPONSE.RESPONSE_CODE + "] " + oTr.TRANSACTIONRESPONSE.RESPONSE_REASON_TEXT;
                    }

                    DB.ExecuteSQL("update orders set RefundTXCommand=" + DB.SQuote(this.GetXMLSerializedObject(oT))
                                  + ", RefundTXResult=" + DB.SQuote(this.GetXMLSerializedObject(oTr)) + " where OrderNumber=" + OriginalOrderNumber.ToString());
                }
                catch
                {
                    result = "NO RESPONSE FROM GATEWAY!";
                }
            }
            return(result);
        }
Esempio n. 19
0
        public override String VoidOrder(int OrderNumber)
        {
            String result = String.Empty;

            DB.ExecuteSQL("update orders set VoidTXCommand=NULL, VoidTXResult=NULL where OrderNumber=" + OrderNumber.ToString());
            String  TransID             = String.Empty;
            decimal OrderTotal          = 0.0M;
            string  Last4               = string.Empty;
            string  CardExpirationMonth = string.Empty;
            string  CardExpirationYear  = string.Empty;

            using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
            {
                dbconn.Open();
                using (IDataReader rs = DB.GetRS("select * from orders   with (NOLOCK)  where OrderNumber=" + OrderNumber.ToString(), dbconn))
                {
                    if (rs.Read())
                    {
                        // If you are voiding a transaction that has been reauthorized,
                        // use the ID from the original authorization, and not the reauthorization.
                        TransID             = DB.RSField(rs, "AuthorizationPNREF");
                        OrderTotal          = DB.RSFieldDecimal(rs, "OrderTotal");
                        Last4               = DB.RSField(rs, "Last4");
                        CardExpirationMonth = DB.RSField(rs, "CardExpirationMonth");
                        CardExpirationYear  = DB.RSField(rs, "CardExpirationYear");
                    }
                }
            }

            if (TransID.Length == 0 || TransID == "0")
            {
                result = "Invalid or Empty Transaction ID";
            }
            else
            {
                try
                {
                    GatewayClient client = SecureNetController.GetGatewayClient();
                    TRANSACTION   oT     = SecureNetController.GetTransactionWithDefaults();

                    // AUTH_CAPTURE, AUTH_ONLY, CREDIT, VOID, PRIOR_AUTH_CAPTURE

                    oT.CODE   = SecureNetController.GetTypeCodeString(SecureNetTransactionTypeCode.VOID);
                    oT.METHOD = SecureNetMethod.CC.ToString();

                    oT.REF_TRANSID = TransID;
                    oT.ORDERID     = OrderNumber.ToString();
                    oT.AMOUNT      = OrderTotal;

                    if (!String.IsNullOrEmpty(Last4))
                    {
                        oT.CARD            = new CARD();
                        oT.CARD.CARDNUMBER = Last4;
                        oT.CARD.EXPDATE    = CardExpirationMonth.PadLeft(2, '0') + CardExpirationYear.ToString().Substring(2, 2); //MMYY
                    }

                    GATEWAYRESPONSE oTr = client.ProcessTransaction(oT);


                    if (oTr.TRANSACTIONRESPONSE.RESPONSE_CODE == "1") // 1=Approved, 2=Declined, 3=Error
                    {
                        result = AppLogic.ro_OK;
                    }
                    else
                    {
                        result = "Error: [" + oTr.TRANSACTIONRESPONSE.RESPONSE_CODE + "] " + oTr.TRANSACTIONRESPONSE.RESPONSE_REASON_TEXT;
                    }

                    DB.ExecuteSQL("update orders set VoidTXCommand=" + DB.SQuote(this.GetXMLSerializedObject(oT))
                                  + ", VoidTXResult=" + DB.SQuote(this.GetXMLSerializedObject(oTr)) + " where OrderNumber=" + OrderNumber.ToString());
                }
                catch
                {
                    result = "NO RESPONSE FROM GATEWAY!";
                }
            }
            return(result);
        }
Esempio n. 20
0
    public void SetTransactionError(){
	transaction = TRANSACTION.RESPONSE_SUCCESS;
    }
Esempio n. 21
0
    public bool SetTransaction(){
	if( IsTransactionNone() ){
	    SetTimeStamp();
	    http.SendRequest( apiURL, SerializeCommonData() );
	    transaction = TRANSACTION.WAIT_FOR_RESPONSE;
	    return true;
	}else{
	    return false;
	}
    }
Esempio n. 22
0
    ////////////////////////////////////////////////////////////////////
    //TRANSACTION control
    ////////////////////////////////////////////////////////////////////
    public void AdmitTransaction(){
	transaction = TRANSACTION.NONE;
    }
Esempio n. 23
0
        // GET: Trade
        public ActionResult Index(CUSTOMER customerModel, string withdraw, string deposit, string transfer, string amount, string iban)
        {
            TRANSACTION transactionModel = new TRANSACTION();

            using (PSSCEntities dbModel = new PSSCEntities())
            {
                if (!string.IsNullOrEmpty(withdraw))//// make a withdrawal
                {
                    if (Int32.Parse(customerModel.FIRSTNAME) < Int32.Parse(amount))
                    {
                        ViewBag.Message = "Not enough funds to perform this action!";
                        return(View());
                        //return RedirectToAction("Show", "History", customerModel);
                    }
                    else
                    {
                        customerModel.FIRSTNAME    = (Int32.Parse(customerModel.FIRSTNAME) - Int32.Parse(amount)).ToString();
                        transactionModel.FIRSTNAME = amount;
                        Random rnd = new Random();
                        transactionModel.ID       = "4567";
                        transactionModel.USERIBAN = iban;
                        transactionModel.USERNAME = customerModel.USERNAME + "1";
                        transactionModel.LASTNAME = customerModel.LASTNAME;
                        transactionModel.PASSWORD = "******";
                        transactionModel.CUSTOMER = customerModel;
                        customerModel.TRANSACTIONS.Add(transactionModel);
                        dbModel.SaveChanges();
                        //dbModel.TRANSACTIONS.Add(transactionModel);
                        dbModel.SaveChanges();
                        Receive rcv = new Receive("Your account was deducted with the amount of " + amount + "dollars");
                        return(RedirectToAction("Show", "History", customerModel));
                        //return View();
                    }
                }
                if (!string.IsNullOrEmpty(deposit))
                {
                    customerModel.FIRSTNAME    = (Int32.Parse(customerModel.FIRSTNAME) + Int32.Parse(amount)).ToString();
                    transactionModel.FIRSTNAME = amount;
                    Random rnd = new Random();
                    transactionModel.ID       = rnd.Next(9999).ToString();
                    transactionModel.USERIBAN = iban;
                    transactionModel.USERNAME = customerModel.USERNAME + "1";
                    transactionModel.LASTNAME = customerModel.LASTNAME;
                    transactionModel.PASSWORD = "******";
                    transactionModel.CUSTOMER = customerModel;
                    customerModel.TRANSACTIONS.Add(transactionModel);
                    dbModel.SaveChanges();
                    //dbModel.TRANSACTIONS.Add(transactionModel);
                    dbModel.SaveChanges();
                    return(RedirectToAction("Show", "History", customerModel));
                    //return View();
                }
                if (!string.IsNullOrEmpty(transfer))
                {
                    foreach (CUSTOMER cst in dbModel.CUSTOMERS)
                    {
                        if (cst.IBAN.CompareTo(iban) == 0)
                        {
                            if (Int32.Parse(customerModel.FIRSTNAME) < Int32.Parse(amount))
                            {
                                ViewBag.Message = "Not enough funds to perform this action!";
                                return(View());
                                //return RedirectToAction("Show", "History", customerModel);
                            }
                            else
                            {
                                customerModel.FIRSTNAME    = (Int32.Parse(customerModel.FIRSTNAME) - Int32.Parse(amount)).ToString();
                                cst.FIRSTNAME              = (Int32.Parse(customerModel.FIRSTNAME) + Int32.Parse(amount)).ToString();
                                transactionModel.FIRSTNAME = amount;
                                Random rnd = new Random();
                                transactionModel.ID       = rnd.Next(9999).ToString();
                                transactionModel.USERIBAN = iban;
                                transactionModel.USERNAME = customerModel.USERNAME + "1";
                                transactionModel.LASTNAME = customerModel.LASTNAME;
                                transactionModel.PASSWORD = "******";
                                transactionModel.CUSTOMER = customerModel;
                                customerModel.TRANSACTIONS.Add(transactionModel);
                                dbModel.SaveChanges();
                                //dbModel.TRANSACTIONS.Add(transactionModel);
                                dbModel.SaveChanges();
                                Receive rcv = new Receive("Transfer successful. Your account was deducted with the amount of " + amount + "dollars");
                                return(RedirectToAction("Show", "History", customerModel));
                                //return View();
                            }
                        }
                    }
                    ViewBag.Message = "This iban doesn't exist in our database!";

                    return(View());
                }
            }
            return(View());
        }
Esempio n. 24
0
        private void btnTambahTransaksi_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                TRANSACTION transaksi = new TRANSACTION()
                {
                    PATIENT_ID       = Convert.ToInt32(txtIdPasienTransaksi.Text),
                    TRANSACTION_DATE = Convert.ToDateTime(dtTanggalTransaksi.Text),
                };

                et.TRANSACTIONs.Add(transaksi);
                et.SaveChanges();

                PATIENT pasien = SearchByIdPasienTransaksi(Convert.ToInt32(txtIdPasienTransaksi.Text));
                pasien.STATUS = 1;

                et.Entry(pasien).State = System.Data.Entity.EntityState.Modified;
                et.SaveChanges();

                ROOM     ruangan = SearchByIdRoomTransaksi(Convert.ToInt32(cmbNamaRuanganTransaksi.SelectedValue));
                MEDICINE obat    = SearchByIdObatTransaksi(Convert.ToInt32(cmbNamaObatTransaksi.SelectedValue));
                DOCTOR   dokter  = SearchByIdDokterTransaksi(Convert.ToInt32(cmbNamaDokterTransaksi.SelectedValue));
                NURSE    perawat = SearchByIdPerawatTransaksi(Convert.ToInt32(cmbNamaPerawatTransaksi.SelectedValue));

                TRANSACTION_DETAIL detil_transaksi = new TRANSACTION_DETAIL()
                {
                    ARRIVAL_DATE   = Convert.ToDateTime(dtKedatanganTransaksi.Text),
                    LEAVING_DATE   = Convert.ToDateTime(dtKepergianTransaksi.Text),
                    ROOM_ID        = Convert.ToInt32(cmbNamaRuanganTransaksi.SelectedValue),
                    TRANSACTION_ID = Convert.ToInt32(transaksi.TRANSACTION_ID),
                    PRICE_ROOM     = Convert.ToDouble(ruangan.TYPE_ROOM.PRICE),
                    QTY_MEDICINE   = Convert.ToInt32(txtQtyObat.Text),
                    TOTAL_PRICE    = totalPrice()
                };

                et.TRANSACTION_DETAIL.Add(detil_transaksi);

                /*detil_transaksi.MEDICINEs.Add(new MEDICINE { MEDICINE_ID = SearchByIdObatTransaksi(Convert.ToInt32(cmbNamaObatTransaksi.SelectedValue)).MEDICINE_ID });
                 * detil_transaksi.DOCTORs.Add(new DOCTOR { DOCTOR_ID = SearchByIdDokterTransaksi(Convert.ToInt32(cmbNamaDokterTransaksi.SelectedValue)).DOCTOR_ID });
                 * detil_transaksi.NURSEs.Add(new NURSE { NURSE_ID = SearchByIdPerawatTransaksi(Convert.ToInt32(cmbNamaPerawatTransaksi.SelectedValue)).NURSE_ID });*/

                TRANSACTION_DETAIL detil_transaksi1 = new TRANSACTION_DETAIL {
                    TRANSACTION_DETAIL_ID = detil_transaksi.TRANSACTION_DETAIL_ID
                };
                et.TRANSACTION_DETAIL.Add(detil_transaksi1);
                et.TRANSACTION_DETAIL.Attach(detil_transaksi1);

                MEDICINE obat1 = new MEDICINE {
                    MEDICINE_ID = obat.MEDICINE_ID
                };
                et.MEDICINEs.Add(obat1);
                //et.MEDICINEs.Attach(obat1);

                DOCTOR dokter1 = new DOCTOR {
                    DOCTOR_ID = dokter.DOCTOR_ID
                };
                et.DOCTORs.Add(dokter1);
                //et.DOCTORs.Attach(dokter1);

                NURSE perawat1 = new NURSE {
                    NURSE_ID = perawat.NURSE_ID
                };
                et.NURSEs.Add(perawat1);
                //et.NURSEs.Attach(perawat1);

                detil_transaksi1.MEDICINEs.Add(obat1);
                detil_transaksi1.DOCTORs.Add(dokter1);
                detil_transaksi1.NURSEs.Add(perawat1);

                et.SaveChanges();

                MEDICINE mEDICINE = SearchByIdObatTransaksi(Convert.ToInt32(cmbNamaObatTransaksi.SelectedValue));
                mEDICINE.STOCK = obat.STOCK - detil_transaksi.QTY_MEDICINE;

                et.Entry(mEDICINE).State = System.Data.Entity.EntityState.Modified;
                et.SaveChanges();

                clearTextTransaksi();
                this.viewBlmTransaksiPasien(dgTransaksiPasien);
                MessageBox.Show("Transaksi Berhasil !", "Informasi", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
            }



            //TRANSACTION_DETAIL detil_transaksi1 = new TRANSACTION_DETAIL { TRANSACTION_DETAIL_ID = detil_transaksi.TRANSACTION_DETAIL_ID };
            //detil_transaksi1.MEDICINEs.Add(new MEDICINE { MEDICINE_ID = obat.MEDICINE_ID });

            //et.TRANSACTION_DETAIL.Add(detil_transaksi1);
            //et.SaveChanges();
        }