diff --git a/Nop.Plugin.Misc.AuctionPlugin/Infrastructure/PluginNopStartup.cs b/Nop.Plugin.Misc.AuctionPlugin/Infrastructure/PluginNopStartup.cs index 7cfb9e9..de618f9 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Infrastructure/PluginNopStartup.cs +++ b/Nop.Plugin.Misc.AuctionPlugin/Infrastructure/PluginNopStartup.cs @@ -71,6 +71,8 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Infrastructure services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); + services.AddScoped(); } /// diff --git a/Nop.Plugin.Misc.AuctionPlugin/Services/AuctionService.cs b/Nop.Plugin.Misc.AuctionPlugin/Services/AuctionService.cs index fe5a948..d849fcd 100644 --- a/Nop.Plugin.Misc.AuctionPlugin/Services/AuctionService.cs +++ b/Nop.Plugin.Misc.AuctionPlugin/Services/AuctionService.cs @@ -23,6 +23,8 @@ public class AuctionService : IAuctionService private readonly IWorkContext _workContext; private readonly IPaymentService _paymentService; private readonly IOrderProcessingService _orderProcessingService; + private readonly IShoppingCartService _shoppingCartService; + private readonly IStoreContext _storeContext; private readonly ILogger _logger; #endregion @@ -36,13 +38,21 @@ public class AuctionService : IAuctionService /// /// /// - /// - public AuctionService(AuctionDbContext ctx, IProductService productService, IWorkContext workContext, IOrderProcessingService orderProcessingService, IPaymentService paymentService, ILogger logger) + public AuctionService( + AuctionDbContext ctx, + IProductService productService, + IWorkContext workContext, + IOrderProcessingService orderProcessingService, + IShoppingCartService shoppingCartService, + IStoreContext storeContext, + ILogger logger) { _ctx = ctx; _productService = productService; _workContext = workContext; _orderProcessingService = orderProcessingService; + _shoppingCartService = shoppingCartService; + _storeContext = storeContext; _paymentService = paymentService; _logger = logger; } @@ -197,12 +207,21 @@ public class AuctionService : IAuctionService { var processPaymentRequest = new ProcessPaymentRequest { + PaymentMethodSystemName = "Payments.CheckMoneyOrder", CustomerId = auctionItem.WinnerCustomerId, OrderTotal = auctionItem.CurrentPrice, }; - + + var currentCustomer = await _workContext.GetCurrentCustomerAsync(); + var product = await _productService.GetProductByIdAsync(auctionItem.ProductId); + var currentStore = await _storeContext.GetCurrentStoreAsync(); processPaymentRequest.CustomValues.Add("ProductToAuctionMappingId", auctionItem.Id); + product.DisableBuyButton = false; + + var cartResult = await _shoppingCartService.AddToCartAsync(currentCustomer, product, ShoppingCartType.ShoppingCart, currentStore.Id); + + //TODO: valszeg a GenerateOrderGuidAsync-ot kell használni, de nemtom egy példában láttam... - J. await _paymentService.GenerateOrderGuidAsync(processPaymentRequest);