Exemplo n.º 1
0
        public bool UpdatePaymentStatus(UpdatePaymentStatusRequest request)
        {
            var conn           = GetConnection(ConnectionNames.CSPSqlDatabase);
            var commandWrapper = GetStoredProcCommand("dbo.UpdatePaymentStatus", conn);

            AddInParameter(commandWrapper, "@CreationId", DbType.Int16, request.Creation.CreationId);

            AddInParameter(commandWrapper, "@ERROR", DbType.String, 1000);
            AddInParameter(commandWrapper, "@ERROR_CODE", DbType.String, 4);

            try
            {
                conn.Open();
                int results = commandWrapper.ExecuteNonQuery();

                var isProcedureSucced = Convert.ToBoolean(results);
                MakeDboLog(request.ToString(), isProcedureSucced.ToString(), "dbo.UpdatePaymentStatus");

                var errorObject     = GetParameterValue(commandWrapper, "@ERROR");
                var errorCodeObject = GetParameterValue(commandWrapper, "@ERROR_CODE");

                return(Convert.ToBoolean(results));
            }
            finally
            {
                commandWrapper.Dispose();
                conn.Close();
            }
        }
        public UpdatePaymentStatusResponse UpdatePaymentStatus(UpdatePaymentStatusRequest request)
        {
            var response = new UpdatePaymentStatusResponse {
                ResponseStatus = ResponseStatus.Success
            };

            var creationsProvider = new CreationsProvider();

            try
            {
                if (request.ActionType == ActionType.Update)
                {
                    response.IsSucessful = creationsProvider.UpdatePaymentStatus(request);
                }
                else
                {
                    response.ResponseStatus      = ResponseStatus.Failure;
                    response.ResponseDescription = "Not update action";
                }
            }
            catch (Exception ex)
            {
                response.ResponseStatus      = ResponseStatus.Failure;
                response.ResponseDescription = ex.Message;
            }
            return(response);
        }
Exemplo n.º 3
0
        public async Task BillingService_ShouldBeAddOneTaskInQueue_WhenUpdateBillingRequestHasOneValidElement()
        {
            var itemCode = "1.0.1";
            var items    = new List <BillingItemPlanDescriptionModel>
            {
                new BillingItemPlanDescriptionModel
                {
                    ItemCode    = "1.0.1",
                    description = "Test"
                }
            };

            var billingValidations = new List <IBillingValidation>
            {
                new BillingForArValidation(Mock.Of <ILogger <BillingForArValidation> >()),
                new BillingForUsValidation(Mock.Of <ILogger <BillingForUsValidation> >())
            };

            var timeZoneConfigurations = new TimeZoneConfigurations
            {
                InvoicesTimeZone = TimeZoneHelper.GetTimeZoneByOperativeSystem("Argentina Standard Time")
            };
            var sapBillingItemsServiceMock = new Mock <ISapBillingItemsService>();

            sapBillingItemsServiceMock.Setup(x => x.GetItemCode(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <bool>())).Returns(itemCode);
            sapBillingItemsServiceMock.Setup(x => x.GetItems(It.IsAny <int>())).Returns(items);

            var dateTimeProviderMock = new Mock <IDateTimeProvider>();

            dateTimeProviderMock.Setup(x => x.UtcNow)
            .Returns(new DateTime(2019, 09, 25));

            var billingMappers = new List <IBillingMapper>
            {
                new BillingForArMapper(sapBillingItemsServiceMock.Object, dateTimeProviderMock.Object, timeZoneConfigurations),
                new BillingForUsMapper(sapBillingItemsServiceMock.Object, dateTimeProviderMock.Object, timeZoneConfigurations)
            };

            var queuingServiceMock = new Mock <IQueuingService>();
            var billingService     = new BillingService(queuingServiceMock.Object,
                                                        dateTimeProviderMock.Object,
                                                        Mock.Of <ILogger <BillingService> >(),
                                                        Mock.Of <ISlackService>(),
                                                        billingMappers,
                                                        billingValidations,
                                                        Mock.Of <ISapServiceSettingsFactory>());

            var updateBillingRequestList = new UpdatePaymentStatusRequest
            {
                BillingSystemId = 9,
                InvoiceId       = 1
            };

            await billingService.UpdatePaymentStatus(updateBillingRequestList);

            queuingServiceMock.Verify(x => x.AddToTaskQueue(It.IsAny <SapTask>()), Times.Once);
        }
        public UpdatePaymentStatusRequest GetUpdatePaymentStatusRequest(Creation creation)
        {
            var request = new UpdatePaymentStatusRequest()
            {
                Creation   = creation,
                ActionType = Requests.ActionType.Update
            };

            return(request);
        }
Exemplo n.º 5
0
 public SapSaleOrderModel MapDopplerUpdateBillingRequestToSapSaleOrder(UpdatePaymentStatusRequest updateBillingRequest)
 {
     return(new SapSaleOrderModel
     {
         PlanType = updateBillingRequest.PlanType,
         BillingSystemId = updateBillingRequest.BillingSystemId,
         InvoiceId = updateBillingRequest.InvoiceId,
         U_DPL_CARD_ERROR_COD = updateBillingRequest.CardErrorCode,
         U_DPL_CARD_ERROR_DET = updateBillingRequest.CardErrorDetail,
         TransactionApproved = updateBillingRequest.TransactionApproved,
         TransferReference = updateBillingRequest.TransferReference,
         PaymentDate = updateBillingRequest.PaymentDate
     });
 }
Exemplo n.º 6
0
        public async Task BillingService_ShouldBeNotAddOneTaskInQueue_WhenUpdateBillingRequestHasOneInvalidElement()
        {
            var timeZoneConfigurations = new TimeZoneConfigurations
            {
                InvoicesTimeZone = TimeZoneHelper.GetTimeZoneByOperativeSystem("Argentina Standard Time")
            };
            var dateTimeProviderMock = new Mock <IDateTimeProvider>();

            dateTimeProviderMock.Setup(x => x.UtcNow)
            .Returns(new DateTime(2019, 09, 25));

            var billingMappers = new List <IBillingMapper>
            {
                new BillingForArMapper(Mock.Of <ISapBillingItemsService>(), dateTimeProviderMock.Object, timeZoneConfigurations),
                new BillingForUsMapper(Mock.Of <ISapBillingItemsService>(), dateTimeProviderMock.Object, timeZoneConfigurations)
            };

            var slackServiceMock = new Mock <ISlackService>();

            slackServiceMock.Setup(x => x.SendNotification(It.IsAny <string>())).Returns(Task.CompletedTask);

            var queuingServiceMock = new Mock <IQueuingService>();

            var billingService = new BillingService(queuingServiceMock.Object,
                                                    dateTimeProviderMock.Object,
                                                    Mock.Of <ILogger <BillingService> >(),
                                                    slackServiceMock.Object,
                                                    billingMappers,
                                                    null,
                                                    Mock.Of <ISapServiceSettingsFactory>());

            var updateBillingRequestList = new UpdatePaymentStatusRequest
            {
                BillingSystemId = 9,
                InvoiceId       = 0
            };

            await billingService.UpdatePaymentStatus(updateBillingRequestList);

            queuingServiceMock.Verify(x => x.AddToTaskQueue(It.IsAny <SapTask>()), Times.Never);
            slackServiceMock.Verify(x => x.SendNotification(It.IsAny <string>()), Times.Once);
        }
Exemplo n.º 7
0
        public async Task UpdatePaymentStatus(UpdatePaymentStatusRequest updateBillingRequest)
        {
            try
            {
                var sapSystem = SapSystemHelper.GetSapSystemByBillingSystem(updateBillingRequest.BillingSystemId);
                var validator = GetValidator(sapSystem);
                validator.ValidateUpdateRequest(updateBillingRequest);
                var billingRequest = GetMapper(sapSystem).MapDopplerUpdateBillingRequestToSapSaleOrder(updateBillingRequest);

                _queuingService.AddToTaskQueue(
                    new SapTask
                {
                    BillingRequest = billingRequest,
                    TaskType       = SapTaskEnum.UpdateBilling
                }
                    );
            }
            catch (Exception e)
            {
                _logger.LogError($"Failed at update billing request for invoice: {updateBillingRequest.InvoiceId}.", e);
                await _slackService.SendNotification($"Failed at update billing request for invoice: {updateBillingRequest.InvoiceId}. Error: {e.Message}");
            }
        }
Exemplo n.º 8
0
 public Task UpdatePaymentStatus(UpdatePaymentStatusRequest updateBillingRequest)
 {
     return(Task.CompletedTask);
 }