Пример #1
0
        public ReturnState ChargeCreditCard(CustomerObject co, Promotion promo, int payTypeFk, decimal budget)
        {
            var sw = new ServiceClientWrapper();
            var gr = sw.CreateProfile(co);
            if (gr != null && gr.isGood && !gr.isError)
            {
                var refNum = gr.CustomerRefNum;
                gr = sw.AuthorizeAndCapture(refNum, double.Parse(budget.ToString()));
                if (gr != null && gr.isApproved && !gr.isError && gr.ResponseCode == "00")
                {
                    var tr = new TransactionRepository(_dbcontext);
                    var amount = decimal.Parse(gr.amountRedeemedNoDecimal);
                    var cp =
                        _dbcontext.CreditCardProfiles.Add(new CreditCardProfile
                                                              {
                                                                  CustomerRefNum = refNum,
                                                                  CustomerFK = promo.ProductGroup.CustomerFK
                                                              });
                    var tran = _dbcontext.Transactions.Add(new Transaction
                                                               {
                                                                   CreatedDate = DateTime.Now,
                                                                   Amount = amount,
                                                                   CreditCardProfileFK = cp.CreditCardProfilePK,
                                                                   AuthCode = gr.AuthCode,
                                                                   TxRefNum = gr.TxRefNum
                                                               });
                    tran.SemplestTransactions.Add(new SemplestTransaction
                                                      {
                                                          CreatedDate = DateTime.Now,
                                                          Amount = amount,
                                                          TransactionTypeFK = tr.GetTransactionTypeCode("MediaSpend")
                                                      });
                    promo.RemainingBudgetInCycle += amount;
                    promo.StartBudgetInCycle += amount;
                    promo.CreditCardProfileFK = cp.CreditCardProfilePK;
                    _dbcontext.PromotionBudgets.Add(new PromotionBudget
                                                        {
                                                            TransactionsFK = tran.TransactionsPK,
                                                            PromotionFK = promo.PromotionPK,
                                                            BudgetCarryOverAmount = 0,
                                                            BudgetToAddAmount = amount,
                                                            BudgetToAddDate = DateTime.Now,
                                                            CreatedDate = DateTime.Now,
                                                            IsValid = true,
                                                            IsAppliedToPromotion = true
                                                        });
                    return new ReturnState(false, false, string.Empty, null);
                }
                return gr == null
                           ? new ReturnState(true, false, "Server Exception", null)
                           : new ReturnState(true, true, gr.Message, null);
            }

            return gr == null
                       ? new ReturnState(true, false, "Server Exception", null)
                       : new ReturnState(true, true, "Card Declined", null);
        }
Пример #2
0
        public ActionResult AddNewCard(FormCollection fc)
        {
            try
            {
                Credential c = ((Credential)(Session[Semplest.SharedResources.SEMplestConstants.SESSION_USERID]));

                

                #region handle form data here....
                //handle form data
                if (fc["ExpirationDate"].ToString().Split(',')[0] == "-Select Month-" )
                { 
                    //no exp month has been selected
                }
                if (fc["ExpirationDate"].ToString().Split(',')[1] == "-Select Year-")
                { 
                    //no exp year has been selected
                }
                if (fc["CardNumber"].ToString() == "")
                {
                    //no card number entered
                }
                if (fc["FirstName"].ToString() == "")
                {
                    //no FirstName  entered
                }
                if (fc["LastName"].ToString() == "")
                {
                    //no LastName entered
                }
                if (fc["Address"].ToString() == "")
                {
                    //no Address entered
                }
                if (fc["City"].ToString() == "")
                {
                    //no City entered
                }
                if (fc["zip"].ToString() == "")
                {
                    //no zip entered
                }
                if (fc["phone"].ToString() == "")
                {
                    //no zip entered
                }
                if (fc["email"].ToString() == "")
                {
                    //no zip entered
                }

                #endregion

                //make api call 
                CustomerObject co = new CustomerObject() {  ExpireDateMMYY = fc["ExpirationDate"].ToString().Split(',')[0].ToString() + fc["ExpirationDate"].ToString().Split(',')[1],
                                                            creditCardNumber = fc["CardNumber"],
                                                            FirstName = fc["FirstName"].ToString(),
                                                            LastName = fc["FirstName"].ToString(),
                                                            Address1 = fc["Address"].ToString(),
                                                            City = fc["City"].ToString(),
                                                            ZipCode = fc["zip"].ToString(),
                                                            Phone = fc["phone"].ToString(),
                                                            Email = fc["email"].ToString(),
                                                             StateAbbr=fc["state"].ToString()};

                ServiceClientWrapper scw=new ServiceClientWrapper();
                GatewayReturnObject myret = scw.CreateProfile(co);
                if (myret.Message != "Profile Request Processed") throw new Exception();
                if (myret.isGood != true) throw new Exception();


                string customerreferencenumber = myret.CustomerRefNum.ToString();
                var dbContext = new SemplestModel.Semplest();
                var custid = ((Credential)(Session[Semplest.SharedResources.SEMplestConstants.SESSION_USERID])).User.Customer.CustomerPK;
                var trans = dbContext.CreditCardProfiles.Add(new CreditCardProfile() { CustomerFK = custid, CustomerRefNum = customerreferencenumber });
                
                //to do: add nickname for dropdown so that we can avoid calling the cc api everytime we are on the billinglaunch page
                //save nickname to creditcardprofiles
                

                //return to billinglaunch,
                //update the card drop down, select the last one added





                /////////////////////////////////////////////////////
                //info: to charge card call AuthorizeAndCapture below
                //double amountToCharge=2.0;
                //GatewayReturnObject myret3 = scw.AuthorizeAndCapture(myret.CustomerRefNum, amountToCharge);

               



            }
            catch (Exception ex)
            {

            }

            return View();


        }
Пример #3
0
        public GatewayReturnObject CreateProfile(CustomerObject customerObject)
        {
            string returnData;
            GatewayReturnObject ReturnGatewayReturnObject = new GatewayReturnObject();
            try
            {
                var jsonHash = new Dictionary<string, string>();


                string jsonAdds = JsonConvert.SerializeObject(customerObject, Formatting.None);
                jsonHash.Add("customerObject", jsonAdds);

                string jsonstr = JsonConvert.SerializeObject(jsonHash, Formatting.None);
                try
                {

                    returnData = runMethod("http://VMDEVJAVA1:9898/semplest",
                                           "semplest.service.chaseorbitalgateway.ChaseOrbitalGatewayService",
                                           "CreateProfile", jsonstr, "0");
                }
                catch (Exception ex)
                {
                    string errmsg = ex.Message;
                    throw;
                }


                var dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(returnData);
                List<string> lis = dict.Values.ToList();



                var objval =
                    JsonConvert.DeserializeObject<Dictionary<string, string>>((dict.Values.ToList()[0].ToString()));

                ReturnGatewayReturnObject.isGood = Convert.ToBoolean(objval["isGood"]);
                ReturnGatewayReturnObject.isError = Convert.ToBoolean(objval["isError"]);
                ReturnGatewayReturnObject.isApproved = Convert.ToBoolean(objval["isApproved"]);
                ReturnGatewayReturnObject.isDeclined = Convert.ToBoolean(objval["isDeclined"]);
                ReturnGatewayReturnObject.Status = objval["Status"];
                ReturnGatewayReturnObject.Message = objval["Message"];
                ReturnGatewayReturnObject.CustomerRefNum = objval["CustomerRefNum"];


            }
            catch
            {
                if (ReturnGatewayReturnObject == null)
                    throw;
                else
                    throw new Exception();
            }
            return ReturnGatewayReturnObject;
        }
Пример #4
0
 public GatewayReturnObject CreateProfile(CustomerObject customerObject)
 {
     try
     {
         var jsonHash = new Dictionary<string, string>();
         var jsonAdds = JsonConvert.SerializeObject(customerObject, Formatting.None);
         jsonHash.Add("customerObject", jsonAdds);
         var jsonstr = JsonConvert.SerializeObject(jsonHash, Formatting.None);
         var dict = RunMethod(_baseURLTest, Chaseorbitalservice, "CreateProfile", jsonstr);
         var objval = JsonConvert.DeserializeObject<Dictionary<string, string>>((dict.Values.ToList()[0]));
         return new GatewayReturnObject
                    {
                        isGood = Convert.ToBoolean(objval["isGood"]),
                        isError = Convert.ToBoolean(objval["isError"]),
                        isApproved = Convert.ToBoolean(objval["isApproved"]),
                        isDeclined = Convert.ToBoolean(objval["isDeclined"]),
                        Status = objval["Status"],
                        Message = objval["Message"],
                        CustomerRefNum = objval["CustomerRefNum"]
                    };
     }
     catch (Exception ex)
     {
         Helpers.ExceptionHelper.LogException(ex);
     }
     return null;
 }