Example #1
0
 public static Request ProcessCheckRequest(Request request)
 {
     Request request2 = new Request();
     try
     {
         PayRequest request3;
         if (request.RequestParameters.RequestId == 0L)
         {
             if (string.IsNullOrEmpty(request.Sender.PaymentSystem))
             {
                 return request2.SetStatus(StatusCode.НеНайденТэгPaymentSystem);
             }
             if (string.IsNullOrEmpty(request.Sender.Organization))
             {
                 return request2.SetStatus(StatusCode.НеНайденТэгOrganization);
             }
             if (string.IsNullOrEmpty(request.Sender.Operator) && string.IsNullOrEmpty(request.Sender.Terminal))
             {
                 return request2.SetStatus(StatusCode.НеНайденыТэгиOperatorИTerminal);
             }
             request3 = new PayRequest {
                 AccountNumber = request.RequestParameters.AccountNumber,
                 Period = new System.DateTime(request.RequestParameters.PayPeriodYear, request.RequestParameters.PayPeriodMonth, 1),
                 PaymentSystem = request.Sender.PaymentSystem,
                 Organization = request.Sender.Organization,
                 Office = request.Sender.Office,
                 Terminal = request.Sender.Terminal,
                 Operator = request.Sender.Operator,
                 ServiceCode = request.Sender.ServiceCode
             };
             request3.SaveChanges();
             request3.ProcessRequest_Service(true);
         }
         else
         {
             request3 = ObjectWithId.FindById<PayRequest>(request.RequestParameters.RequestId);
             if (request3.IsConfirmed)
             {
                 return request2.SetStatus(StatusCode.ЗапросУжеПроведен);
             }
             request3.Period = new System.DateTime(request.RequestParameters.PayPeriodYear, request.RequestParameters.PayPeriodMonth, 1);
             request3.PaidSumm = request.RequestParameters.PaidSumm;
             request3.SaveChanges();
             foreach (PayRequestServicePayAmount amount in request3.GetRequestServicePayAmounts())
             {
                 amount.Delete();
             }
             foreach (AIS.SN.Model.DomainObjects.PaymentService.Service service in request.Services)
             {
                 new PayRequestServicePayAmount { RequestId = request3.Id, Code = service.Code, CounterIndication = service.NewCounter, Paid = service.Paid }.SaveChanges();
             }
             request3.ProcessRequest_Service(false);
         }
         request3 = ObjectWithId.FindById<PayRequest>(request3.Id);
         request2 = new Request {
             ResponseParameters = { RequestId = request3.Id, OwnerName = request3.OwnerName, ApartmentType = request3.ApartmentType, ApartmentTotalSquare = request3.ApartmentTotalSquare, ResidentsCount = System.Convert.ToByte(request3.ResidentsCount), ResidentVacationsCount = System.Convert.ToByte(request3.ResidentVacationsCount), Benefits = new System.Collections.Generic.List<AIS.SN.Model.DomainObjects.PaymentService.Benefit>() }
         };
         foreach (PayRequestBenefit benefit in request3.GetRequestBenefits())
         {
             AIS.SN.Model.DomainObjects.PaymentService.Benefit benefit2 = new AIS.SN.Model.DomainObjects.PaymentService.Benefit {
                 Name = benefit.BenefitName,
                 Persons = benefit.PersonsCount
             };
             request2.ResponseParameters.Benefits.Add(benefit2);
         }
         request2.ResponseParameters.CurrentChargeSumm = request3.CurrentChargeSumm;
         request2.ResponseParameters.CurrentBenefitSumm = request3.CurrentBenefitSumm;
         request2.ResponseParameters.CurrentRecalcSumm = request3.CurrentRecalcSumm;
         request2.ResponseParameters.TotalDebt = request3.TotalDebt;
         request2.ResponseParameters.TotalPenalty = request3.TotalPenalty;
         request2.ResponseParameters.Comments = request3.Comments;
         request2.ResponseParameters.AdditionalInfo = request3.AdditionalInfo;
         foreach (PayRequestService service2 in request3.GetRequestServices())
         {
             AIS.SN.Model.DomainObjects.PaymentService.Service service3 = new AIS.SN.Model.DomainObjects.PaymentService.Service {
                 Code = service2.Code,
                 Name = service2.Name,
                 Counter = service2.CounterIndication,
                 NewCounter = service2.NewCounterIndication,
                 Rate = service2.Rate,
                 Charge = service2.ChargeSumm,
                 Benefit = service2.BenefitSumm,
                 Recalc = service2.RecalcSumm,
                 CounterCharge = service2.DiffChargeSumm - service2.DiffBenefitSumm,
                 FirstCounter = service2.FirstCounterIndication,
                 Saldo = service2.Saldo,
                 RateCounter = service2.RateCounter,
                 Debt = service2.Debt,
                 Paid = service2.Paid,
                 DebtPenalty = service2.DebtPenalty,
                 Penalty = service2.Penalty,
                 IsClosed = System.Convert.ToBoolean(service2.IsClosed),
                 IsFixed = System.Convert.ToBoolean(service2.IsFixed),
                 IsCounter = System.Convert.ToBoolean(service2.IsCounter),
                 Edk = service2.Edk
             };
             request2.Services.Add(service3);
         }
         request2.SetStatus(StatusCode.ЗапросВыполненУспешно);
     }
     catch (System.Exception exception)
     {
         request2 = new Request().SetStatus(StatusCode.НепредвиденнаяОшибка, exception);
     }
     return request2;
 }
Example #2
0
 public static Request ProcessReverseRequest(Request request)
 {
     request = Serializer.FromXml<Request>(System.IO.File.ReadAllText(@"D:\Projects\AIS.SN\AIS.SN.PaymentService\App_Data\5-PayRequest.xml"));
     Request request2 = new Request();
     try
     {
         if (string.IsNullOrEmpty(request.Sender.PaymentSystem))
         {
             return request2.SetStatus(StatusCode.НеНайденТэгPaymentSystem);
         }
         if (string.IsNullOrEmpty(request.Sender.Organization))
         {
             return request2.SetStatus(StatusCode.НеНайденТэгOrganization);
         }
         if (string.IsNullOrEmpty(request.Sender.Operator) && string.IsNullOrEmpty(request.Sender.Terminal))
         {
             return request2.SetStatus(StatusCode.НеНайденыТэгиOperatorИTerminal);
         }
         string reverseTransactionId = request.RequestParameters.ReverseTransactionId;
         if (string.IsNullOrEmpty(reverseTransactionId))
         {
             return request2.SetStatus(StatusCode.НеНайденТэгReverseTransactionId);
         }
         string operationType = request.RequestParameters.OperationType;
         if (string.IsNullOrEmpty(operationType))
         {
             return request2.SetStatus(StatusCode.НеНайденТэгOperationType);
         }
         PayRequest request3 = ObjectWithId.FindById<PayRequest>(request2.RequestParameters.RequestId);
         if (request3.ReverseRequestId != 0L)
         {
             return ((ObjectWithId.FindById<PayRequest>(request3.ReverseRequestId).ExternalTransactionId == reverseTransactionId) ? request2.SetStatus(StatusCode.ЗапросВыполненУспешно) : request2.SetStatus(StatusCode.ЗапросУжеПроведен));
         }
         PayRequest request4 = new PayRequest {
             PaymentSystem = request.Sender.PaymentSystem,
             Organization = request.Sender.Organization,
             Office = request.Sender.Office,
             Terminal = request.Sender.Terminal,
             Operator = request.Sender.Operator,
             ServiceCode = request.Sender.ServiceCode,
             AccountNumber = request3.AccountNumber,
             Period = request3.Period,
             AccountId = request3.AccountId,
             PaidSumm = request3.PaidSumm,
             IsConfirmed = true,
             ConfirmedAt = Register.GetDatabaseTime()
         };
         foreach (FasetItem item in Register.GetFasetItemList(FasetsEnum.PaymentOperationType))
         {
             if (item.Name == operationType)
             {
                 request4.RequestTypeFasetId = item.Id;
             }
         }
         request4.ExternalTransactionId = reverseTransactionId;
         request4.ReverseRequestId = request3.Id;
         request4.SaveChanges();
         request3.ReverseRequestId = request4.Id;
         request3.SaveChanges();
         request2.SetStatus(StatusCode.ЗапросВыполненУспешно);
     }
     catch (System.Exception exception)
     {
         request2 = new Request().SetStatus(StatusCode.НепредвиденнаяОшибка, exception);
     }
     return request2;
 }
Example #3
0
 public static Request ProcessPaymentRequest(Request request)
 {
     Request request2 = new Request();
     try
     {
         string paymentTransactionId = request.RequestParameters.PaymentTransactionId;
         if (string.IsNullOrEmpty(paymentTransactionId))
         {
             return request2.SetStatus(StatusCode.НеНайденТэгPaymentTransactionId);
         }
         string operationType = request.RequestParameters.OperationType;
         if (string.IsNullOrEmpty(operationType))
         {
             return request2.SetStatus(StatusCode.НеНайденТэгOperationType);
         }
         PayRequest request3 = ObjectWithId.FindById<PayRequest>(request.RequestParameters.RequestId);
         if (request3.PaidSumm != request.RequestParameters.PaidSumm)
         {
             return request2.SetStatus(StatusCode.НевернаяСуммаОплаты);
         }
         if (request3.IsConfirmed)
         {
             return ((request3.ExternalTransactionId == paymentTransactionId) ? request2.SetStatus(StatusCode.ЗапросВыполненУспешно) : request2.SetStatus(StatusCode.ЗапросУжеПроведен));
         }
         request3.IsConfirmed = true;
         request3.ConfirmedAt = Register.GetDatabaseTime();
         foreach (FasetItem item in Register.GetFasetItemList(FasetsEnum.PaymentOperationType))
         {
             if (item.Name == operationType)
             {
                 request3.RequestTypeFasetId = item.Id;
             }
         }
         request3.ExternalTransactionId = paymentTransactionId;
         request3.SaveChanges();
         request2.SetStatus(StatusCode.ЗапросВыполненУспешно);
     }
     catch (System.Exception exception)
     {
         request2 = new Request().SetStatus(StatusCode.НепредвиденнаяОшибка, exception);
     }
     return request2;
 }