public void Can_edit_paymentGatewaySettings()
        {
            // Arrange
            var brand = Container.Resolve <BrandTestHelper>().CreateBrand(isActive: true);

            var paymentGatewaySettings = Container.Resolve <PaymentTestHelper>().CreatePaymentGatewaySettings(
                brand.Id,
                enable: false,
                onlinePaymentMethodName: "TEST PAYMENT NAME1",
                paymentGatewayName: "XXPAY",
                channel: 99,
                entryPoint: "http://test.com/payment/issue",
                remarks: "ADD SETTING REMARK");


            var editData = new SavePaymentGatewaysSettingsData
            {
                Id    = paymentGatewaySettings.Id,
                Brand = paymentGatewaySettings.BrandId,
                OnlinePaymentMethodName = "Modified Name",
                PaymentGatewayName      = "YYPAY",
                Channel    = 100,
                EntryPoint = "http://changedDomain.com/payment/issue",
                Remarks    = "Edit SETTING REMARK"
            };
            // Act
            var response = _commands.Edit(editData);

            //Assert
            response.PaymentGatewaySettingsId.Should().Be(paymentGatewaySettings.Id);

            var settings = _paymentRepository.PaymentGatewaySettings.Single(x => x.Id == paymentGatewaySettings.Id);

            settings.Should().NotBeNull();
            settings.BrandId.Should().NotBeEmpty();
            settings.OnlinePaymentMethodName.ShouldBeEquivalentTo("Modified Name");
            settings.PaymentGatewayName.ShouldBeEquivalentTo("YYPAY");
            settings.Channel.ShouldBeEquivalentTo(100);
            settings.EntryPoint.ShouldBeEquivalentTo("http://changedDomain.com/payment/issue");
            settings.Remarks.ShouldBeEquivalentTo("Edit SETTING REMARK");
            settings.Status.Should().Be(Status.Inactive);
            settings.UpdatedBy.ShouldBeEquivalentTo(_actorInfoProvider.Actor.UserName);
            settings.DateUpdated.Should().BeCloseTo(DateTime.Now, 60000);
            settings.ActivatedBy.Should().BeNull();
            settings.DateActivated.Should().NotHaveValue();
            settings.DeactivatedBy.Should().BeNull();
            settings.DateDeactivated.Should().NotHaveValue();
        }
Beispiel #2
0
        public SavePaymentGatewaySettingsResponse Edit(SavePaymentGatewaySettingsRequest request)
        {
            VerifyPermission(Permissions.Update, Modules.PaymentGatewaySettings);

            CheckBrand(request.Brand);

            var model = Mapper.DynamicMap <Core.Payment.Interface.Data.Commands.SavePaymentGatewaysSettingsData>(request);

            var validatResult = _paymentGatewaySettingsCommands.ValidateThatPaymentGatewaySettingsCanBeEdited(model);

            if (false == validatResult.IsValid)
            {
                return(ValidationErrorResponse <SavePaymentGatewaySettingsResponse>(validatResult));
            }

            var result = _paymentGatewaySettingsCommands.Edit(model);

            return(new SavePaymentGatewaySettingsResponse
            {
                Success = true,
                Id = result.PaymentGatewaySettingsId
            });
        }