Esempio n. 1
0
        /// <summary>
        /// Adds new Order to database
        /// </summary>
        /// <param name="orderInfo">OrderInfo Object which has order information in it</param>
        /// <param name="userDetails">User Object which includes information about the customer who purchased the order</param>
        /// <returns></returns>
        private static int AddOrderToDB(OrderInfo orderInfo, UserInfo userDetails)
        {
            bool cardValid = ChargeCard.CheckCard(orderInfo); //Checks if Card Is Valid

            if (!cardValid)
            {
                return(0); //If Invalid Return;
            }

            //Insert Order Into Database
            DAL.ExecCommand($"INSERT INTO `order` (CustomerID, VendorID) VALUES ({userDetails.UserID}, {orderInfo.VendorID})");
            DataTable IdDT    = DAL.ExecCommand($"SELECT id FROM `order` WHERE `CustomerID` = {userDetails.UserID} ORDER BY id DESC LIMIT 1");
            int       OrderID = Convert.ToInt32(IdDT.Rows[0][0]);

            //Inserts Each Item Into Item Table
            foreach (ItemModel Item in orderInfo.Items)
            {
                string SQLQuery = ($"INSERT INTO `orderline` (OrderID, ItemID, Quantity) VALUES ({OrderID}, {Item.ItemID}, {Item.Quantity})");
                DAL.ExecCommand(SQLQuery);
            }

            if (DAL.ErrorCode != -1)
            {
                return(1); //If No errors occured return 1;
            }

            return(2);
        }
Esempio n. 2
0
        private void ProcessChargeEvents()
        {
            try
            {
                _connection.ConnectToPersistentSubscription(STREAM, STREAM_GROUP_CARDTXGROUP, async(_, x) =>
                {
                    Console.WriteLine("Received an event!");
                    var data = Encoding.ASCII.GetString(x.Event.Data);

                    ChargeCard chargeCard = JsonConvert.DeserializeObject <ChargeCard>(data);

                    Console.WriteLine($"event received : {JsonConvert.SerializeObject(chargeCard)}");

                    var binsert = await _cardRepository.InsertCharge(chargeCard);
                    if (!binsert)
                    {
                        Console.WriteLine("Insert Charge on card unsuccessful");
                        throw new Exception("Insert Charge on card unsuccessful");
                    }

                    Console.WriteLine($"Insert Charge on card successful: cardid={chargeCard.id}");
                }, subscriptionDropped: null, userCredentials: null, bufferSize: 10, autoAck: true);

                Console.WriteLine("waiting for events. press enter to exit");
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error in ProcessEvents: {e.Message}");
                throw e;
            }
        }
Esempio n. 3
0
        public async Task <string> Charge(Card card, string amount, string custId, string currency, string country, string authModel, string narration, Driver driver, string responseUrl = "")
        {
            string     resource   = this.resources[driver.Env].Charge;
            ChargeCard chargeCard = new ChargeCard(card, amount, custId, currency, authModel, narration, responseUrl, country, driver.MerchantKey, driver.ApiKey);
            var        response   = await new Request(resource).MakeRequest(data: chargeCard, method: Verbs.POST);

            return(response);
        }
Esempio n. 4
0
        private async void PayBtn_Clicked(object sender, EventArgs e)
        {
            var cardCharge = new ChargeCard(Helper.raveConfig);
            var Payload    = new CardParams(Helper.PbKey, "Anonymous", "Customer", "*****@*****.**", 2100)
            {
                CardNo = "5438898014560229", Cvv = "789", Expirymonth = "09", Expiryyear = "19", TxRef = "Tr672yR"
            };

            await Navigation.PushAsync(new AddPinPay());
        }
Esempio n. 5
0
 public async Task <bool> InsertCharge(ChargeCard charge)
 {
     try
     {
         _cardContext.Add(charge);
         return(await Save());
     }
     catch (Exception e)
     {
         _logger.LogError($"Error in Insert: {e.Message}");
         return(false);
     }
 }
Esempio n. 6
0
 public ActionResult Edit(ChargeCard model)
 {
     try
     {
         _chargeSrv.Save(model);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         return(View("Edit", model));
         //throw ex;
         //return View();
     }
 }
Esempio n. 7
0
        private ProcessorResponse CheckCreditCard(ChargeCard chargeCard)
        {
            var creditCardProcessingInfo = new CreditCardProcessorProcessingInfo
            {
                CreditCardNo = chargeCard.Number,
                SecurityCode = chargeCard.CVV,
                ExpiryMonth  = chargeCard.ExpirationDate.Month,
                ExpiryYear   = chargeCard.ExpirationDate.Year,
                CardType     = chargeCard.TypeId.ToString(),
                Price        = "1",
                Currency     = "USD"
            };

            return(_paymentProcessor.AuthorizeOnly(creditCardProcessingInfo));
        }
Esempio n. 8
0
 public void Save(ChargeCard model)
 {
     if (!model.CardNO.StartsWith("CZ"))
     {
         model.CardNO = "CZ" + model.CardNO;
     }
     if (model.ID == 0)
     {
         ValidCardNo(model.CardNO);
         _chargeCardRep.Add(model);
     }
     else
     {
         _chargeCardRep.Update(model);
     }
     _uow.Commit();
 }
Esempio n. 9
0
        public async Task <bool> Handle(ChargeCreditCard request, CancellationToken token)
        {
            try
            {
                _logger.LogInformation($"Handle ChargeCreditCard: {JsonConvert.SerializeObject(request)}");

                var chargeCard = new ChargeCard
                {
                    charge_amount = request.amount,
                    charge_date   = DateTime.Now,
                    guid_card     = request.guid_card
                };

                // persist to repository
                //if(!await _cardRepository.InsertCharge(chargeCard))
                //{
                //    _logger.LogError("Error saving charge card information");
                //    throw new Exception("Error saving charge card information");
                //}

                // record event in eventstore
                if (await _eventStoreCard.Connect())
                {
                    var writeResult = await _eventStoreCard.WriteChargeCardToStream(chargeCard);

                    if (writeResult)
                    {
                        _logger.LogInformation("Event written to stream");
                    }
                }
                else
                {
                    _logger.LogInformation("Problem in connecting to event store");
                }
                _eventStoreCard.Close();

                return(true);
            }
            catch (Exception e)
            {
                _logger.LogError($"Error occured in Handle: {e.Message}");
            }
            throw new NotImplementedException();
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            var raveConfig = new RaveConfig(PbKey, ScKey, false);
            var cardCharge = new ChargeCard(Helper.raveConfig);
            var cardParams = new CardParams();

            var Payload = new CardParams(PbKey, "Anonymous", "Customer", "*****@*****.**", 2100)
            {
                CardNo = "5438898014560229", Cvv = "789", Expirymonth = "09", Expiryyear = "19", TxRef = tranxRef
            };
            var cha = cardCharge.Charge(cardParams).Result;


            if (cha.Message == "AUTH_SUGGESTION" && cha.Data.SuggestedAuth == "PIN")
            {
                cardParams.Pin           = "3310";
                cardParams.Otp           = "12345";
                cardParams.SuggestedAuth = "PIN";
                cha = cardCharge.Charge(Payload).Result;
            }
        }
Esempio n. 11
0
        public void avschargetest()
        {
            var raveConfig = new RaveConfig(PbKey, ScKey, false);
            var cardCharge = new ChargeCard(raveConfig);
            var card       = new Card("5377283645077450", "09", "21", "789");

            var payload = new CardParams(PbKey, ScKey, "Anonymous", "Tester", "*****@*****.**", 200, "USD", card, "07205", "Hillside", "470 Mundet PI", "NJ", "US");

            var res = cardCharge.Charge(payload).Result;

            try
            {
                Assert.IsNotNull(res.Data);
                Console.WriteLine(res.Data);
                Assert.AreEqual("success", res.Status);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Esempio n. 12
0
        public async Task <bool> WriteChargeCardToStream(ChargeCard card)
        {
            try
            {
                Guid chargeEventStoreGuid = Guid.NewGuid();

                byte[] cardBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(card));

                var eventData = new EventData(chargeEventStoreGuid, "chargeCreditCard", true,
                                              cardBytes, cardBytes);

                var writeResult = await this.connection.AppendToStreamAsync("cardtx",
                                                                            ExpectedVersion.Any, eventData);

                return(true);
            }
            catch (Exception e)
            {
                _logger.LogError($"Error in WriteChargeCardToStream: {e.Message}");
                throw e;
            }
        }
Esempio n. 13
0
 public ProcessorResponse ApplyRefundtoNewCard(decimal amountToRefund, Name customerName, ChargeCard card, AddressEditModel address, string ipAddress, string cardProcessingUniqueId, string email)// Should use Address DO in place of Model
 {
     return
         (_paymentProcessor.RefundRequestOnOtherCreditCard(
              GetCreditCardProcesingInfo(amountToRefund > 0 ? (-1 * amountToRefund) : amountToRefund, customerName,
                                         card, address, ipAddress, cardProcessingUniqueId, email)));
 }
Esempio n. 14
0
 public ChargeCardPaymentEditModel()
 {
     ChargeCard        = new ChargeCard();
     ChargeCardPayment = new ChargeCardPayment();
 }
Esempio n. 15
0
 /// <summary>
 /// Execute new charge with card data
 /// </summary>
 /// <param name="charge">Charge Card Object</param>
 /// <returns>Confirmation of the charge</returns>
 public dynamic Execute(ChargeCard charge)
 {
     return(ApiRequest("charge/", charge, Method.POST, typeof(ChargeCardResponse)));
 }
Esempio n. 16
0
 public EligibilityEditModel()
 {
     Request    = new EligibilityRequestEditModel();
     CardDetail = new ChargeCard();
 }
Esempio n. 17
0
 //Yasir: This is really a factory method. june 10 2011
 private CreditCardProcessorProcessingInfo GetCreditCardProcesingInfo(decimal amount, Name customerName, ChargeCard card, AddressEditModel address, string ipAddress, string cardProcessingUniqueId, string email)// Should use Address DO in place of Model
 {
     return(new CreditCardProcessorProcessingInfo
     {
         CreditCardNo = card.Number,
         SecurityCode = card.CVV,
         ExpiryMonth = card.ExpirationDate.Month,
         ExpiryYear = card.ExpirationDate.Year,
         CardType = card.TypeId.ToString(),
         Price = amount.ToString(),
         FirstName = customerName.FirstName,
         LastName = !string.IsNullOrEmpty(customerName.LastName) ? customerName.LastName : customerName.FirstName,
         BillingAddress = address.StreetAddressLine1,
         BillingCity = address.City,
         BillingState = _stateRepository.GetState(address.StateId).Code,
         BillingPostalCode = address.ZipCode,
         BillingCountry = _countryRepository.GetCountryCode(address.CountryId),
         Email = string.IsNullOrEmpty(email)?_settings.SupportEmail.ToString():email,
         IpAddress = ipAddress,
         Currency = "USD",
         OrderId = cardProcessingUniqueId
     });
 }
Esempio n. 18
0
 public ProcessorResponse ChargefromCard(decimal amountToCharge, Name customerName, ChargeCard card, AddressEditModel address, string ipAddress, string cardProcessingUniqueId, string email)// Should use Address DO in place of Model
 {
     return(_paymentProcessor.ChargeCreditCard(GetCreditCardProcesingInfo(amountToCharge, customerName, card, address, ipAddress, cardProcessingUniqueId, email)));
 }