diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentRequests/PaymentRequestAppService.cs b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentRequests/PaymentRequestAppService.cs index 9b4120df..da80df90 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentRequests/PaymentRequestAppService.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentRequests/PaymentRequestAppService.cs @@ -53,8 +53,9 @@ namespace EShopOnAbp.PaymentService.PaymentRequests public virtual async Task StartAsync(PaymentRequestStartDto input) { - PaymentRequest paymentRequest = await PaymentRequestRepository.GetAsync(input.PaymentRequestId, includeDetails: true); - + PaymentRequest paymentRequest = + await PaymentRequestRepository.GetAsync(input.PaymentRequestId, includeDetails: true); + var paymentService = _paymentServiceFactory.Create(input.PaymentTypeId); return await paymentService.StartAsync(paymentRequest, input); } @@ -62,7 +63,7 @@ namespace EShopOnAbp.PaymentService.PaymentRequests public virtual async Task CompleteAsync(PaymentRequestCompleteInputDto input) { var paymentService = _paymentServiceFactory.Create(input.PaymentTypeId); - + var paymentRequest = await paymentService.CompleteAsync(PaymentRequestRepository, input.Token); return ObjectMapper.Map(paymentRequest); } diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServices/DemoService.cs b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServices/DemoService.cs index da54bb5d..403d0eb5 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServices/DemoService.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServices/DemoService.cs @@ -1,9 +1,11 @@ using System; using System.Threading.Tasks; using EShopOnAbp.PaymentService.PaymentRequests; +using Volo.Abp.DependencyInjection; namespace EShopOnAbp.PaymentService.PaymentServices; +[ExposeServices(typeof(IPaymentStrategy), typeof(DemoService))] public class DemoService : IPaymentStrategy { public Task StartAsync(PaymentRequest paymentRequest, PaymentRequestStartDto input) diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServices/IPaymentStrategy.cs b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServices/IPaymentStrategy.cs index aafab8bd..4bb0a065 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServices/IPaymentStrategy.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServices/IPaymentStrategy.cs @@ -1,9 +1,10 @@ using System.Threading.Tasks; using EShopOnAbp.PaymentService.PaymentRequests; +using Volo.Abp.DependencyInjection; namespace EShopOnAbp.PaymentService.PaymentServices; -public interface IPaymentStrategy +public interface IPaymentStrategy : ITransientDependency { public Task StartAsync(PaymentRequest paymentRequest, PaymentRequestStartDto input); public Task CompleteAsync(IPaymentRequestRepository paymentRequestRepository, string token); diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServices/PaymentServiceFactory.cs b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServices/PaymentServiceFactory.cs index 7e2fab1d..0a4c15b4 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServices/PaymentServiceFactory.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServices/PaymentServiceFactory.cs @@ -1,7 +1,5 @@ using System; -using EShopOnAbp.PaymentService.PaymentRequests; using Microsoft.Extensions.DependencyInjection; -using PayPalCheckoutSdk.Core; using Volo.Abp.DependencyInjection; namespace EShopOnAbp.PaymentService.PaymentServices; @@ -19,17 +17,14 @@ public class PaymentServiceFactory : ITransientDependency { if (paymentTypeId == 0) { - return new DemoService(); + return _serviceProvider.GetRequiredService(); } if (paymentTypeId == 1) { - var paypalService = _serviceProvider.GetRequiredService(); - var requestDomainService = _serviceProvider.GetRequiredService(); - - return new PaypalService(paypalService, requestDomainService); + return _serviceProvider.GetRequiredService(); } - return new DemoService(); + return _serviceProvider.GetRequiredService(); } } \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServices/PaypalService.cs b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServices/PaypalService.cs index d0dce7c8..17cf81ef 100644 --- a/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServices/PaypalService.cs +++ b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServices/PaypalService.cs @@ -6,9 +6,11 @@ using System.Threading.Tasks; using EShopOnAbp.PaymentService.PaymentRequests; using PayPalCheckoutSdk.Core; using PayPalCheckoutSdk.Orders; +using Volo.Abp.DependencyInjection; namespace EShopOnAbp.PaymentService.PaymentServices; +[ExposeServices(typeof(IPaymentStrategy), typeof(PaypalService))] public class PaypalService : IPaymentStrategy { private readonly PayPalHttpClient _payPalHttpClient;