Ejemplo n.º 1
0
        protected PaymentState GetPaymentState(TransactionStatus transactionStatus, int refundAmount)
        {
            PaymentState paymentState = PaymentState.Initialized;

            if (transactionStatus == TransactionStatus.PAYMENT_NEW)
            {
                paymentState = PaymentState.Authorized;
            }
            else if (transactionStatus == TransactionStatus.PAYMENT_CAPTURED && refundAmount == 0)
            {
                paymentState = PaymentState.Captured;
            }
            else if (transactionStatus == TransactionStatus.PAYMENT_DELETED)
            {
                paymentState = PaymentState.Cancelled;
            }
            else if (transactionStatus == TransactionStatus.PAYMENT_CAPTURED && refundAmount != 0)
            {
                paymentState = PaymentState.Refunded;
            }
            else if (transactionStatus == TransactionStatus.PAYMENT_EUROLINE_WAIT_CAPTURE || transactionStatus == TransactionStatus.PAYMENT_EUROLINE_WAIT_CREDIT)
            {
                paymentState = PaymentState.PendingExternalSystem;
            }
            return(paymentState);
        }
Ejemplo n.º 2
0
        public PaymentState PaymentProcess(PaymentDto payment, PaymentState paymentState)
        {
            if (payment.Amount <= 20)
            {
                paymentState.State = _cheapPaymentGateway.PaymentProcessCheap(payment).ToString();
            }
            else if (payment.Amount > 20 && payment.Amount <= 500)
            {
                paymentState.State = _expensivePaymentGateway.PaymentProcessExpensive(payment).ToString();
                if (paymentState.State == PaymentStateEnum.Failed.ToString())
                {
                    paymentState.State = _cheapPaymentGateway.PaymentProcessCheap(payment).ToString();
                }
            }
            else
            {
                int count = 0;
                while (count < 3)
                {
                    count++;
                    paymentState.State = _expensivePaymentGateway.PaymentProcessExpensive(payment).ToString();
                    if (paymentState.State == PaymentStateEnum.Processed.ToString())
                    {
                        break;
                    }
                }
            }

            PaymentStateUpdate(paymentState);
            return(paymentState);
        }
            public async Task <Unit> Handle(CreatePaymentCommand request, CancellationToken cancellationToken)
            {
                var paymentId = new Guid();
                var entity    = new Payment
                {
                    Id = paymentId,
                    CreditCardNumber = (CreditCardNumber)request.CreditCardNumber,
                    CardHolder       = request.CardHolder,
                    SecurityCode     = (SecurityCode)request.SecurityCode,
                    Amount           = (Amount)request.Amount,
                    ExpirationDate   = request.ExpirationDate,
                    Created          = _dateTime.Now
                };

                var entityState = new PaymentState
                {
                    Id        = new Guid(),
                    PaymentId = paymentId.ToString(),
                    Created   = _dateTime.Now,
                    Status    = PaymentStatus.Pending
                };

                _context.Payments.Add(entity);
                _context.PaymentStates.Add(entityState);

                await _context.SaveChangesAsync(cancellationToken);

                return(Unit.Value);
            }
        public void MapTransactionResult_NormalTransaction_MapsAndMaskData()
        {
            var mapper     = new TransactionResultMapper();
            var tansaction = new Models.Transaction
            {
                Amount              = 1.0m,
                CardHolderName      = string.Empty,
                CardNumber          = "0000-1111-2222-3333",
                CurrencyISO4217Code = "EUR",
                CVVNumber           = 123,
                ExperyDate          = new DateTime(1, 1, 1)
            };
            var paymentState = new PaymentState
            {
                Code = (PaymentStateCode)1,
                Id   = string.Empty
            };

            var result = mapper.Map(paymentState, tansaction);

            Assert.AreEqual(result.Code, PaymentStatusCode.Success);
            Assert.AreEqual(result.BankId, string.Empty);
            Assert.IsNull(result.PaymentId);
            Assert.IsNotNull(result.TransactionDetails);
        }
Ejemplo n.º 5
0
        public void ProcessPayment(PaymentDetail paymentDetail)
        {
            var PremiumAmountString = _configuration["PremiumAmount"];
            int PremiumAmount;

            int.TryParse(PremiumAmountString, out PremiumAmount);
            if (paymentDetail.Amount > PremiumAmount)
            {
                var premiumRetriesString = _configuration["PremiumRetries"];
                int premiumRetries;
                int.TryParse(premiumRetriesString, out premiumRetries);

                var waitTimeString = _configuration["WaitTime"];
                int waitTime;
                int.TryParse(waitTimeString, out waitTime);

                for (int i = 0; i < premiumRetries; i++)
                {
                    PaymentState paymentState = _paymentDbContext.PaymentStates.FirstOrDefault(p => p.PaymentDetailId == paymentDetail.Id);
                    if (paymentState.Status == _configuration["Success"])
                    {
                        break;
                    }
                    ExpensivePaymentGateway expensivePaymentGateway = new ExpensivePaymentGateway(_paymentDbContext, _configuration);
                    expensivePaymentGateway.ProcessPayment(paymentDetail);
                    System.Threading.Thread.Sleep(waitTime * 1000);
                }
            }
        }
Ejemplo n.º 6
0
        public void TestProcessPayment_CheckMethodCalls(decimal amount, string creditCardNumber, string creditCardHolder, string expiryDate,
                                                        string securityCode, string guid, string status)
        {
            var mockProcessGateway = new Mock <IProcessGateway>();

            PaymentModel model = new PaymentModel()
            {
                Amount           = amount,
                CardHolder       = creditCardHolder,
                CreditCardNumber = creditCardNumber,
                ExpirationDate   = DateTime.Parse(expiryDate),
                SecurityCode     = securityCode
            };

            PaymentState paymentState = new PaymentState()
            {
                Amount            = amount,
                CreditCardNo      = creditCardNumber,
                StateOfTransation = status,
                TransactionId     = Guid.Parse(guid)
            };

            mockProcessGateway.Setup(x => x.ProceessAmount(model)).Returns(paymentState);

            var sut = new PaymentController(mockProcessGateway.Object);

            sut.ProcessPayment(model);

            mockProcessGateway.Verify(x => x.ProceessAmount(model), Times.Once);
        }
Ejemplo n.º 7
0
        public void TestProcessPayment_WithNoStatus(decimal amount, string creditCardNumber, string creditCardHolder, string expiryDate,
                                                    string securityCode, string guid, string status, int statuscode, string outputString)
        {
            var mockProcessGateway = new Mock <IProcessGateway>();

            PaymentModel model = new PaymentModel()
            {
                Amount           = amount,
                CardHolder       = creditCardHolder,
                CreditCardNumber = creditCardNumber,
                ExpirationDate   = DateTime.Parse(expiryDate),
                SecurityCode     = securityCode
            };

            PaymentState paymentState = new PaymentState()
            {
                Amount            = amount,
                CreditCardNo      = creditCardNumber,
                StateOfTransation = status,
                TransactionId     = Guid.Parse(guid)
            };

            mockProcessGateway.Setup(x => x.ProceessAmount(model)).Returns(paymentState);

            var sut = new PaymentController(mockProcessGateway.Object);

            var result = sut.ProcessPayment(model);

            var okResult    = result as ObjectResult;
            var errorString = okResult.Value as ObjectResult;

            Assert.NotNull(okResult);
            Assert.Equal(statuscode, okResult.StatusCode);
            Assert.Equal(outputString, errorString.Value);
        }
        /// <summary>
        /// To save payment details.
        /// </summary>
        /// <param name="paymentModel">Payment Model</param>
        /// <param name="paymentStatus">Payment Status</param>
        /// <returns>
        /// It returns the payment status for the requested process.
        /// or
        /// It returns customized error if any exception occur.
        /// </returns>
        private async Task <StringMessage> SavePaymentDetails(PaymentModel paymentModel, string paymentStatus)
        {
            try
            {
                ProcessPaymentDetail payment = new ProcessPaymentDetail();
                payment.CardHolder       = paymentModel.CardHolder;
                payment.CreditCardNumber = paymentModel.CreditCardNumber;
                payment.ExpirationDate   = paymentModel.ExpirationDate;
                payment.SecurityCode     = paymentModel.SecurityCode;
                payment.Amount           = paymentModel.Amount;
                await _context.ProcessPaymentDetail.AddAsync(payment);

                await _context.SaveChangesAsync();

                PaymentState paymentstate = new PaymentState();
                paymentstate.PaymentID          = payment.PaymentID;
                paymentstate.PaymentStateStatus = paymentStatus;
                await _context.PaymentState.AddAsync(paymentstate);

                await _context.SaveChangesAsync();

                return(new StringMessage("Payment is processed.", paymentStatus));
            }
            catch (Exception e)
            {
                return(new StringMessage(e.Message, "Failed"));
            }
        }
        protected PaymentState GetPaymentState(Charge charge)
        {
            PaymentState paymentState = PaymentState.Initialized;

            if (charge == null)
            {
                return(paymentState);
            }

            if (charge.Paid)
            {
                paymentState = PaymentState.Authorized;

                if (charge.Captured != null && charge.Captured.Value)
                {
                    paymentState = PaymentState.Captured;

                    if (charge.Refunded)
                    {
                        paymentState = PaymentState.Refunded;
                    }
                }
                else
                {
                    if (charge.Refunded)
                    {
                        paymentState = PaymentState.Cancelled;
                    }
                }
            }

            return(paymentState);
        }
Ejemplo n.º 10
0
        public async Task <bool> Update(PaymentState entity)
        {
            var catalogue = await _context.PaymentState.FindAsync(entity);

            this._context.Entry(catalogue).CurrentValues.SetValues(entity);
            return(true);
        }
Ejemplo n.º 11
0
        public async Task <ActionResult <bool> > ProcessPayment(CardDetail cardDetail)
        {
            try
            {
                if (cardDetail == null)
                {
                    throw new Exception();
                }

                var paymentStatus = new PaymentState();
                paymentStatus.StateEnum = PaymentStateEnum.Pending;
                _context.PaymentState.Add(paymentStatus);
                await _context.SaveChangesAsync();

                var isProcessed = await _paymentGatewayRepo.ProcessTransaction(cardDetail, paymentStatus);

                if (isProcessed)
                {
                    return(Ok("Payment is processed"));
                }

                return(BadRequest(new
                {
                    message = "The request is invalid"
                }));
            }
            catch (Exception e)
            {
                return(StatusCode(500, new
                {
                    error = e.Message,
                    message = "Lost connection to payment platform, Please try back later"
                }));
            }
        }
Ejemplo n.º 12
0
        public override string ProcessRequest(Order order, HttpRequest request, IDictionary <string, string> settings)
        {
            string response = "";

            try {
                order.MustNotBeNull("order");
                request.MustNotBeNull("request");
                settings.MustNotBeNull("settings");

                // If in test mode, write out the form data to a text file
                if (settings.ContainsKey("mode") && settings["mode"] == "test")
                {
                    LogRequest <Stripe>(request, logPostData: true);
                }

                //Stripe supports webhooks
                StripeEvent  stripeEvent = GetStripeEvent(request);
                StripeCharge charge      = Mapper <StripeCharge> .MapFromJson(stripeEvent.Data.Object.ToString());

                if (stripeEvent.Type.StartsWith("charge."))
                {
                    PaymentState paymentState = GetPaymentState(charge);
                    if (order.TransactionInformation.PaymentState != paymentState)
                    {
                        order.TransactionInformation.TransactionId = charge.Id;
                        order.TransactionInformation.PaymentState  = paymentState;
                        order.Save();
                    }
                }
            } catch (Exception exp) {
                LoggingService.Instance.Error <Stripe>("Stripe(" + order.CartNumber + ") - ProcessRequest", exp);
            }

            return(response);
        }
Ejemplo n.º 13
0
        //Function to store Payment and Payment State entities
        public async Task <bool> SavePaymentProcessAndState(paymentProcessViewModel model, string response)
        {
            var savePaymentProcess = new PRProcessPayment
            {
                creditCardNumber = model.creditCardNumber,
                cardHolder       = model.cardHolder,
                expirationDate   = model.expirationDate,
                securityCode     = model.securityCode,
                amount           = model.amount
            };

            var savePaymentState = new PaymentState
            {
                paymentState     = response,
                processPaymentID = savePaymentProcess.processPaymentID
            };

            await _unitOfWork.PaymentProcess.AddAsync(savePaymentProcess);

            await _unitOfWork.PaymentState.AddAsync(savePaymentState);

            await _unitOfWork.CompleteAsync();

            return(true);
        }
Ejemplo n.º 14
0
 public Result SaveProcessState(PaymentState paymentState, string CardNo)
 {
     try
     {
         var payment = _Db.PaymentStates.Where(x => x.ProcessPayment.CreditCardNumber == CardNo && x.PaymentStates == paymentState.PaymentStates).SingleOrDefault();
         if (payment == null)
         {
             _Db.PaymentStates.Add(paymentState);
             _Db.SaveChanges();
         }
         else
         {
             payment.NumberOfAttempt = payment.NumberOfAttempt + 1;
             payment.PaymentStates   = paymentState.PaymentStates;
             _Db.SaveChanges();
         }
         return(new Result()
         {
             Data = paymentState,
             Message = "CheapPaymentProcess",
             Status = Enums.ResultStatus.OK
         });
     }
     catch (Exception ex)
     {
         return(new Result()
         {
             Data = null,
             Message = "Exception",
             Status = Enums.ResultStatus.Warning
         });
     }
 }
        public PaymentState ProcessPayment()
        {


            PaymentState paymentState = new PaymentState();

            int num = _random.Next(1,3);//This is only for Simulation of Payment Status

            switch (num)
            {
                case 1:
                    paymentState.PaymentProcessStatus = Standard.PaymentProcessStatus.PaymentStatus.Pending;
                    break;
                case 2:
                    paymentState.PaymentProcessStatus = Standard.PaymentProcessStatus.PaymentStatus.Processed;
                    break;
                default:
                    paymentState.PaymentProcessStatus = Standard.PaymentProcessStatus.PaymentStatus.Failed;
                    break;
            }


            return paymentState;



        }
Ejemplo n.º 16
0
        /// <summary>
        /// 根据交易号(订单号)更新订单状态
        /// </summary>
        public bool SheZhiZhiFuByOrderCode(string OrderCode, PaymentState state)
        {
            if (string.IsNullOrEmpty(OrderCode))
            {
                return(false);
            }
            bool result = dal.SheZhiZhiFuByOrderCode(OrderCode, state) > 0 ? true : false;

            if (result)
            {
                var zhifu = GetModelByOrderCode(OrderCode);
                if (zhifu == null)
                {
                    return(false);
                }
                var member = new Eyousoft_yhq.BLL.Member().GetModel(zhifu.OperatorID);
                if (member == null)
                {
                    return(false);
                }
                member.YuE = member.YuE + zhifu.OptMoney;
                return(new Eyousoft_yhq.BLL.Member().UpdateYuE(member));
            }
            else
            {
                return(result);
            }
        }
Ejemplo n.º 17
0
        public override void Start()
        {
            // init
            this.output          = new TPCCWorkloadOutput();
            output.txFinalStatus = TxFinalStatus.UNKNOWN;

            // the first step
            // determine c_id
            this.C_ID = input.C_ID;
            if (C_ID == 0)  // by c_last
            {
                var k   = CustomerPayload.GetLastNameIndexKey(input.C_W_ID, input.C_D_ID, input.C_LAST);
                var ids = redisClient.GetAllItemsFromList(k);
                C_ID = Convert.ToUInt32(ids[ids.Count / 2]);    // TODO order by c_first?
            }

            this.currentState = PaymentState.ReadC;
            var cpk = new CustomerPkey
            {
                C_ID   = C_ID,
                C_D_ID = input.C_D_ID,
                C_W_ID = input.C_W_ID
            };

            this.cpkStr = cpk.ToString();
            this.AddReq(this.cpkStr);
        }
Ejemplo n.º 18
0
        public void ProcessPayment(PaymentDetail paymentDetail)
        {
            var amount = paymentDetail.Amount;
            var LowerExpensiveAmountString = _configuration["LowerExpensiveAmount"];
            int LowerExpensiveAmount;

            int.TryParse(LowerExpensiveAmountString, out LowerExpensiveAmount);

            var PremiumAmountString = _configuration["PremiumAmount"];
            int PremiumAmount;

            int.TryParse(PremiumAmountString, out PremiumAmount);

            if (amount >= LowerExpensiveAmount && amount <= PremiumAmount)
            {
                PaymentState paymentState = _paymentDbContext.PaymentStates.FirstOrDefault(p => p.PaymentDetailId == paymentDetail.Id);;
                if (IsAvailable)
                {
                    CheapPaymentGateway cheapPaymentGateway = new CheapPaymentGateway(_paymentDbContext, _configuration);
                    cheapPaymentGateway.ProcessPayment(paymentDetail);
                }
                else
                {
                    if (paymentState != null)
                    {
                        paymentState.Status    = _configuration["Success"];
                        paymentState.UpdatedAt = DateTime.Now;
                        _paymentDbContext.PaymentStates.Update(paymentState);
                        _paymentDbContext.SaveChanges();
                    }
                    else
                    {
                        paymentState.Status    = _configuration["Failure"];
                        paymentState.UpdatedAt = DateTime.Now;
                        _paymentDbContext.PaymentStates.Update(paymentState);
                        _paymentDbContext.SaveChanges();
                    }
                }
            }

            if (amount > PremiumAmount)
            {
                PaymentState paymentState = _paymentDbContext.PaymentStates.FirstOrDefault(p => p.PaymentDetailId == paymentDetail.Id);;
                if (paymentState != null)
                {
                    paymentState.Status    = _configuration["Success"];
                    paymentState.UpdatedAt = DateTime.Now;
                    _paymentDbContext.PaymentStates.Update(paymentState);
                    _paymentDbContext.SaveChanges();
                }
                else
                {
                    paymentState.Status    = _configuration["Failure"];
                    paymentState.UpdatedAt = DateTime.Now;
                    _paymentDbContext.PaymentStates.Update(paymentState);
                    _paymentDbContext.SaveChanges();
                }
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Get orders filterd by state.
        /// </summary>
        /// <param name="state"></param>
        /// <param name="payment"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public static List <Order> GetByState(OrderState state, PaymentState payment, User user = null)
        {
            var orders = GetAllOrders();

            return(user == null?
                   orders.Where(x => x.PayState == payment && x.State == state).ToList() :
                       orders.Where(x => x.PayState == payment && x.State == state && x.Customer.ID == user.ID).ToList());
        }
 public void Awake()
 {
     gettingChange = false;
     currMoney = INITIAL_MONEY;
     currChange = currPayment = excessChange = 0;
     currCapacity = 0;
     currState = PaymentState.NoPayment;
 }
Ejemplo n.º 21
0
 public void Awake()
 {
     gettingChange = false;
     currMoney     = INITIAL_MONEY;
     currChange    = currPayment = excessChange = 0;
     currCapacity  = 0;
     currState     = PaymentState.NoPayment;
 }
        public async Task <PaymentState> CreatePaymentRecord(PaymentState paymentState)
        {
            var objPymntState = await _db.Set <PaymentState>().AddAsync(paymentState);

            await _db.SaveChangesAsync();

            return(objPymntState.Entity);
        }
Ejemplo n.º 23
0
 /// <summary>
 /// 更新付款状态
 /// </summary>
 public int SheZhiZhiFus(string DingDanId, PaymentState state)
 {
     if (string.IsNullOrEmpty(DingDanId))
     {
         return(0);
     }
     return(dal.SheZhiZhiFus(DingDanId, state));
 }
        public void UpdatePaymentStatus(int paymentId, PaymentState state)
        {
            var payment = _context.Payments.Where(x => x.PaymentId == paymentId).Include(x => x.PaymentDetails).FirstOrDefault();

            payment.PaymentDetails.State = state;
            _context.Add(payment);
            _context.SaveChanges();
        }
Ejemplo n.º 25
0
 public TPCCPaymentStoredProcedure(string sessionId, PaymentInParameters inParams, RedisClient redisClient)
 {
     this.pid          = int.Parse(sessionId);
     this.sessionId    = sessionId;
     this.input        = inParams;
     this.currentState = PaymentState.ToStart;
     this.redisClient  = redisClient;
 }
Ejemplo n.º 26
0
        public override ApiInfo GetStatus(Order order, IDictionary <string, string> settings)
        {
            ApiInfo apiInfo = null;

            try
            {
                order.MustNotBeNull("order");
                settings.MustNotBeNull("settings");
                settings.MustContainKey("merchantId", "settings");
                settings.MustContainKey("token", "settings");

                Dictionary <string, string> inputFields = new Dictionary <string, string>();
                inputFields["merchantId"]    = settings["merchantId"];
                inputFields["token"]         = settings["token"];
                inputFields["transactionId"] = order.TransactionInformation.TransactionId;

                XDocument xmlResponse = QueryTransaction(order.TransactionInformation.TransactionId, settings);

                if (xmlResponse.XPathSelectElement("//PaymentInfo") != null)
                {
                    string transactionId = xmlResponse.XPathSelectElement("//PaymentInfo/TransactionId").Value;
                    bool   authorized    = bool.Parse(xmlResponse.XPathSelectElement("//PaymentInfo/Summary/Authorized").Value);
                    bool   cancelled     = bool.Parse(xmlResponse.XPathSelectElement("//PaymentInfo/Summary/Annulled").Value);
                    bool   captured      = decimal.Parse(xmlResponse.XPathSelectElement("//PaymentInfo/Summary/AmountCaptured").Value, CultureInfo.InvariantCulture) > 0;
                    bool   refunded      = decimal.Parse(xmlResponse.XPathSelectElement("//PaymentInfo/Summary/AmountCredited").Value, CultureInfo.InvariantCulture) > 0;

                    PaymentState paymentState = PaymentState.Initialized;
                    if (refunded)
                    {
                        paymentState = PaymentState.Refunded;
                    }
                    else if (captured)
                    {
                        paymentState = PaymentState.Captured;
                    }
                    else if (cancelled)
                    {
                        paymentState = PaymentState.Cancelled;
                    }
                    else if (authorized)
                    {
                        paymentState = PaymentState.Authorized;
                    }

                    apiInfo = new ApiInfo(transactionId, paymentState);
                }
                else
                {
                    LoggingService.Instance.Warn <Netaxept>("Netaxept(" + order.OrderNumber + ") - Error making API request - error message: " + xmlResponse.XPathSelectElement("//Error/Message").Value);
                }
            }
            catch (Exception exp)
            {
                LoggingService.Instance.Error <Netaxept>("Netaxept(" + order.OrderNumber + ") - Get status", exp);
            }

            return(apiInfo);
        }
Ejemplo n.º 27
0
        public override CallbackInfo ProcessCallback(Order order, HttpRequest request, IDictionary <string, string> settings)
        {
            CallbackInfo callbackInfo = null;

            try
            {
                order.MustNotBeNull("order");
                request.MustNotBeNull("request");
                settings.MustNotBeNull("settings");
                settings.MustContainKey("md5Key1", "settings");
                settings.MustContainKey("md5Key2", "settings");

                //Write data when testing
                if (settings.ContainsKey("test_mode") && settings["test_mode"] == "true")
                {
                    LogRequest <Payer>(request, logGetData: true);
                }

                //Check for payer IP addresses
                string remoteServerIpAddress = request.ServerVariables["REMOTE_ADDR"];

                if (remoteServerIpAddress == "217.151.207.84" || remoteServerIpAddress == "79.136.103.5" || remoteServerIpAddress == "79.136.103.9" || remoteServerIpAddress == "94.140.57.180" || remoteServerIpAddress == "94.140.57.181" || remoteServerIpAddress == "94.140.57.184" || remoteServerIpAddress == "192.168.100.1")
                {
                    string url             = request.Url.Scheme + "://" + request.Url.Host + request.ServerVariables["REQUEST_URI"];
                    string urlExceptMd5Sum = url.Substring(0, url.IndexOf("&md5sum", StringComparison.Ordinal));

                    string md5CheckValue = GenerateMD5Hash(settings["md5Key1"] + urlExceptMd5Sum + settings["md5Key2"]).ToUpperInvariant();

                    if (md5CheckValue == request.QueryString["md5sum"])
                    {
                        HttpContext.Current.Response.Output.Write("TRUE");

                        string       transaction  = request.QueryString["payread_payment_id"];
                        string       paymentType  = request.QueryString["payer_payment_type"];
                        string       callbackType = request.QueryString["payer_callback_type"];
                        PaymentState paymentState = callbackType == "auth" ? PaymentState.Authorized : PaymentState.Captured;

                        callbackInfo = new CallbackInfo(order.TotalPrice.Value.WithVat, transaction, paymentState, paymentType);
                    }
                    else
                    {
                        LoggingService.Instance.Warn <Payer>("Payer(" + order.CartNumber + ") - MD5Sum security check failed");
                    }
                }
                else
                {
                    LoggingService.Instance.Warn <Payer>("Payer(" + order.CartNumber + ") - IP security check failed - IP: " + remoteServerIpAddress);
                }

                HttpContext.Current.Response.Output.Write("FALSE");
            }
            catch (Exception exp)
            {
                LoggingService.Instance.Error <Payer>("QuickPay(" + order.CartNumber + ") - Process callback", exp);
            }

            return(callbackInfo);
        }
Ejemplo n.º 28
0
        public void TestProceessAmount_VerifyMethodCalls(decimal amount, string creditCardNumber, string creditCardHolder, string expiryDate,
                                                         string securityCode, string guid, string status)
        {
            //arrange
            PaymentModel model = new PaymentModel()
            {
                Amount           = amount,
                CardHolder       = creditCardHolder,
                CreditCardNumber = creditCardNumber,
                ExpirationDate   = DateTime.Parse(expiryDate),
                SecurityCode     = securityCode
            };

            CreditCardDetails creditCardDetails = new CreditCardDetails()
            {
                CardHolder       = creditCardHolder,
                CreditCardNumber = creditCardNumber,
                ExpirationDate   = DateTime.Parse(expiryDate),
                SecurityCode     = securityCode
            };

            PaymentState paymentState = new PaymentState()
            {
                Amount            = amount,
                CreditCardNo      = creditCardNumber,
                StateOfTransation = status,
                TransactionId     = Guid.Parse(guid)
            };

            mockMapper.Setup(x => x.Map <CreditCardDetails>(model)).Returns(creditCardDetails);

            mockDataDal.Setup(x => x.InsertCreditCardDetails(creditCardDetails));

            mockPaymentFactory.Setup(x => x.GetPaymentGateway(amount)).Returns(PaymentStatus.Processed);

            mockMapper.Setup(x => x.Map <PaymentState>(model)).Returns(paymentState);

            mockDataDal.Setup(x => x.InsertTransactionDetails(paymentState));

            //act

            sut = new ProcessGateway(mockPaymentFactory.Object, mockMapper.Object, mockDataDal.Object);

            sut.ProceessAmount(model);

            //Verify

            mockMapper.Verify(x => x.Map <CreditCardDetails>(model), Times.Once());

            mockDataDal.Verify(x => x.InsertCreditCardDetails(creditCardDetails), Times.Once());

            mockPaymentFactory.Verify(x => x.GetPaymentGateway(amount), Times.Once());

            mockMapper.Verify(x => x.Map <PaymentState>(model), Times.Once());

            mockDataDal.Verify(x => x.InsertTransactionDetails(paymentState), Times.Once());
        }
Ejemplo n.º 29
0
        private SecurityContext CreateContextForSpecialOrder(OrderState orderState, PaymentState paymentState)
        {
            var states = new Dictionary <string, Enum>();

            states.Add("State", orderState);
            states.Add("Payment", paymentState);

            return(SecurityContext.Create(typeof(SpecialOrder), "owner", "ownerGroup", "ownerTenant", states, new Enum[0]));
        }
 public void CreatePaymentState(PaymentState paymentState)
 {
     if (paymentState == null)
     {
         throw new ArgumentNullException(nameof(paymentState));
     }
     _context.PaymentStates.Add(paymentState);
     SaveChanges();
 }
Ejemplo n.º 31
0
        public override CallbackInfo ProcessCallback(Order order, HttpRequest request, IDictionary <string, string> settings)
        {
            CallbackInfo callbackInfo = null;

            try
            {
                order.MustNotBeNull("order");
                request.MustNotBeNull("request");
                settings.MustNotBeNull("settings");
                settings.MustContainKey("accountNumber", "settings");
                settings.MustContainKey("encryptionKey", "settings");

                long   accountNumber = long.Parse(settings["accountNumber"]);
                string orderRef      = order.Properties.First(p => p.Alias.Equals("orderRef")).Value;
                string md5Hash       = GenerateMD5Hash(accountNumber + orderRef + settings["encryptionKey"]);

                ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
                string xmlReturn = GetPayExServiceClient(settings).Complete(accountNumber, orderRef, md5Hash);

                //Write data when testing
                if (settings.ContainsKey("testing") && settings["testing"] == "1")
                {
                    using (StreamWriter writer = new StreamWriter(File.Create(HostingEnvironment.MapPath("~/payex-callback-data.txt"))))
                    {
                        writer.WriteLine("Xml return:");
                        writer.WriteLine(xmlReturn);
                        writer.Flush();
                    }
                }

                XDocument xmlDoc            = XDocument.Parse(xmlReturn, LoadOptions.PreserveWhitespace);
                string    transactionStatus = xmlDoc.XPathSelectElement("//transactionStatus").Value;
                string    errorCode         = xmlDoc.XPathSelectElement("//status/errorCode").Value;

                //0 = Sale | 3 = Authorize
                if (errorCode == "OK" && (transactionStatus == "0" || transactionStatus == "3") && !bool.Parse(xmlDoc.XPathSelectElement("//alreadyCompleted").Value))
                {
                    decimal      amount            = decimal.Parse(xmlDoc.XPathSelectElement("//amount").Value, CultureInfo.InvariantCulture);
                    string       transactionNumber = xmlDoc.XPathSelectElement("//transactionNumber").Value;
                    PaymentState paymentState      = transactionStatus.Equals("3") ? PaymentState.Authorized : PaymentState.Captured;
                    string       paymentMethod     = xmlDoc.XPathSelectElement("//paymentMethod").Value;
                    string       maskedNumber      = xmlDoc.XPathSelectElement("//maskedNumber").Value;

                    callbackInfo = new CallbackInfo(amount / 100M, transactionNumber, paymentState, paymentMethod, maskedNumber);
                }
                else
                {
                    LoggingService.Instance.Warn <PayEx>("PayEx(" + order.CartNumber + ") - Callback failed - error code: " + errorCode + " - Description: " + xmlDoc.XPathSelectElement("//status/description").Value);
                }
            }
            catch (Exception exp)
            {
                LoggingService.Instance.Error <PayEx>("PayEx(" + order.CartNumber + ") - Process callback", exp);
            }

            return(callbackInfo);
        }
 public void AddPayment()
 {
     currCapacity++;
     int randompayment = 0;
     for(int i = 0; i < 6; i++){
         randompayment += UnityEngine.Random.Range(1,50);
     }
     randompayment /= 6;
     float amount = JEEPNEY_FARE + randompayment;
     Debug.Log (amount + "pesos");
     transactions.Enqueue(amount);
     if(currState == PaymentState.GiveChange){}
     else currState = PaymentState.ReceivePayment;
 }
Ejemplo n.º 33
0
        /// <summary>
        /// 根据交易号(订单号)更新订单状态
        /// </summary>
        public bool SheZhiZhiFuByOrderCode(string OrderCode, PaymentState state)
        {
            if (string.IsNullOrEmpty(OrderCode)) return false;
            bool result = dal.SheZhiZhiFuByOrderCode(OrderCode, state) > 0 ? true : false;
            if (result)
            {
                var zhifu = GetModelByOrderCode(OrderCode);
                if (zhifu == null) return false;
                var member = new Eyousoft_yhq.BLL.Member().GetModel(zhifu.OperatorID);
                if (member == null) return false;
                member.YuE = member.YuE + zhifu.OptMoney;
                return new Eyousoft_yhq.BLL.Member().UpdateYuE(member);

            }
            else
            {
                return result;
            }
        }
Ejemplo n.º 34
0
        protected ApiInfo MakeApiRequest( string orderNumber, IDictionary<string, string> inputFields, string transactionId, PaymentState paymentState, string url )
        {
            ApiInfo apiInfo = null;

              try {
            inputFields.MustNotBeNull( "inputFields" );

            XDocument xmlResponse = XDocument.Parse( MakePostRequest( url, inputFields ), LoadOptions.PreserveWhitespace );

            if ( xmlResponse.XPathSelectElement( "//ProcessResponse" ) != null && xmlResponse.XPathSelectElement( "//ProcessResponse/ResponseCode" ).Value == "OK" ) {
              apiInfo = new ApiInfo( transactionId, paymentState );
            } else {
              LoggingService.Instance.Log( "Netaxept(" + orderNumber + ") - Error making API request - error message: " + xmlResponse.XPathSelectElement( "//Error/Message" ).Value );
            }
              } catch ( Exception exp ) {
            LoggingService.Instance.Log( exp, "Netaxept(" + orderNumber + ") - Make API request" );
              }

              return apiInfo;
        }
Ejemplo n.º 35
0
 /// <summary>
 /// 更新付款状态
 /// </summary>
 public int SheZhiZhiFus(string DingDanId, PaymentState state)
 {
     if (string.IsNullOrEmpty(DingDanId)) return 0;
     return dal.SheZhiZhiFus(DingDanId, state);
 }
    private void OnTriggerEnter(Collider other)
    {
        switch(currState){
            case PaymentState.ReceivePayment:
        //				Debug.Log("Receive Payment");
                currPayment = transactions.Dequeue();
                currMoney += currPayment;
                if(currPayment == JEEPNEY_FARE){
                    if(transactions.Count == 0){
                        currPayment = 0;
                        currState = PaymentState.NoPayment;
                    }
                }
                else{
                    currPayment -= JEEPNEY_FARE;
                    MoneyBoxes.gameObject.SetActive(true);
                    currState = PaymentState.GiveChange;
                }
                break;
            case PaymentState.GiveChange:
        //				Debug.Log ("Give Change");
                if(currChange < currPayment){
        //					Debug.Log("Kulang Po");
                }
                else{
                    if (currChange > currPayment){
        //						Debug.Log("Sobra ng " + (currChange - currPayment));
                        currMoney += (currChange - currPayment);
                        excessChange += (currChange - currPayment);
                    }
                    if(transactions.Count == 0){
                        currState = PaymentState.NoPayment;

                    }
                    else{
                        currState = PaymentState.ReceivePayment;
                    }
                    currChange = 0;
                    currPayment = 0;
                }
                break;
        }
    }
Ejemplo n.º 37
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int SheZhiZhiFus(string DingDanId, PaymentState state)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("UPDATE tmp_tbl_ChongZhi   SET  PayState = @PayState WHERE orderid=@orderid ");
     DbCommand cmd = this._db.GetSqlStringCommand(strSql.ToString());
     this._db.AddInParameter(cmd, "orderid", DbType.AnsiStringFixedLength, DingDanId);
     this._db.AddInParameter(cmd, "PayState", DbType.Byte, state);
     return DbHelper.ExecuteSql(cmd, this._db);
 }