Skip to content

Commit 06c9614

Browse files
committed
* Implemented 'PaymentMethodBase' abstract class to simplify payment plugin development and avoid redundant code
* Minor refactoring and cleanup
1 parent ef887d3 commit 06c9614

5 files changed

Lines changed: 29 additions & 27 deletions

File tree

src/Libraries/SmartStore.Services/Payments/IPaymentMethod.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,16 @@ public partial interface IPaymentMethod : IPlugin
9191
/// <param name="routeValues">Route values</param>
9292
void GetPaymentInfoRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues);
9393

94-
/// <summary>
95-
/// Gets a route for the payment info handler controller action
96-
/// </summary>
97-
/// <param name="order">Order</param>
98-
/// <returns>Result</returns>
99-
/// <remarks>
100-
/// The defined route is being redirected to during the checkout process > PaymentInfo page.
101-
/// Implementors should return <c>null</c> if no redirection occurs.
102-
/// </remarks>
103-
RouteInfo GetPaymentInfoHandlerRoute();
94+
///// <summary>
95+
///// Gets a route for the payment info handler controller action
96+
///// </summary>
97+
///// <param name="order">Order</param>
98+
///// <returns>Result</returns>
99+
///// <remarks>
100+
///// The defined route is being redirected to during the checkout process > PaymentInfo page.
101+
///// Implementors should return <c>null</c> if no redirection occurs.
102+
///// </remarks>
103+
//RouteInfo GetPaymentInfoHandlerRoute();
104104

105105
Type GetControllerType();
106106

src/Libraries/SmartStore.Services/Payments/PaymentMethodBase.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Web.Routing;
@@ -160,7 +160,7 @@ public virtual RouteInfo GetPaymentInfoHandlerRoute()
160160
/// <summary>
161161
/// Gets a value indicating whether capture is supported
162162
/// </summary>
163-
public bool SupportCapture
163+
public virtual bool SupportCapture
164164
{
165165
get
166166
{
@@ -171,7 +171,7 @@ public bool SupportCapture
171171
/// <summary>
172172
/// Gets a value indicating whether partial refund is supported
173173
/// </summary>
174-
public bool SupportPartiallyRefund
174+
public virtual bool SupportPartiallyRefund
175175
{
176176
get
177177
{
@@ -182,7 +182,7 @@ public bool SupportPartiallyRefund
182182
/// <summary>
183183
/// Gets a value indicating whether refund is supported
184184
/// </summary>
185-
public bool SupportRefund
185+
public virtual bool SupportRefund
186186
{
187187
get
188188
{
@@ -193,7 +193,7 @@ public bool SupportRefund
193193
/// <summary>
194194
/// Gets a value indicating whether void is supported
195195
/// </summary>
196-
public bool SupportVoid
196+
public virtual bool SupportVoid
197197
{
198198
get
199199
{
@@ -204,7 +204,7 @@ public bool SupportVoid
204204
/// <summary>
205205
/// Gets a recurring payment type of payment method
206206
/// </summary>
207-
public RecurringPaymentType RecurringPaymentType
207+
public virtual RecurringPaymentType RecurringPaymentType
208208
{
209209
get
210210
{
@@ -215,7 +215,7 @@ public RecurringPaymentType RecurringPaymentType
215215
/// <summary>
216216
/// Gets a payment method type
217217
/// </summary>
218-
public PaymentMethodType PaymentMethodType
218+
public virtual PaymentMethodType PaymentMethodType
219219
{
220220
get
221221
{

src/Libraries/SmartStore.Services/Payments/PaymentService.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using SmartStore.Core.Domain.Orders;
55
using SmartStore.Core.Domain.Payments;
6+
using SmartStore.Core.Infrastructure;
67
using SmartStore.Core.Plugins;
78
using SmartStore.Services.Configuration;
89
using SmartStore.Services.Localization;
@@ -35,14 +36,14 @@ public partial class PaymentService : IPaymentService
3536
/// <param name="pluginService">Plugin service</param>
3637
public PaymentService(PaymentSettings paymentSettings, IPluginFinder pluginFinder,
3738
ShoppingCartSettings shoppingCartSettings,
38-
ISettingService settingService,
39-
ILocalizationService localizationService)
39+
ISettingService settingService)
4040
{
4141
this._paymentSettings = paymentSettings;
4242
this._pluginFinder = pluginFinder;
4343
this._shoppingCartSettings = shoppingCartSettings;
4444
this._settingService = settingService;
45-
this._localizationService = localizationService;
45+
// TODO: (MC) Make ctor injection (didn't want to break unit tests)
46+
this._localizationService = EngineContext.Current.Resolve<ILocalizationService>();
4647
}
4748

4849
#endregion

src/Plugins/Payments.Manual/ManualPaymentProcessor.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public ManualPaymentProcessor(ManualPaymentSettings manualPaymentSettings,
4949
/// </summary>
5050
/// <param name="processPaymentRequest">Payment info required for an order processing</param>
5151
/// <returns>Process payment result</returns>
52-
public ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
52+
public override ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
5353
{
5454
var result = new ProcessPaymentResult();
5555

@@ -135,7 +135,7 @@ public override CancelRecurringPaymentResult CancelRecurringPayment(CancelRecurr
135135
/// <param name="actionName">Action name</param>
136136
/// <param name="controllerName">Controller name</param>
137137
/// <param name="routeValues">Route values</param>
138-
public void GetConfigurationRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues)
138+
public override void GetConfigurationRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues)
139139
{
140140
actionName = "Configure";
141141
controllerName = "PaymentManual";
@@ -148,17 +148,17 @@ public void GetConfigurationRoute(out string actionName, out string controllerNa
148148
/// <param name="actionName">Action name</param>
149149
/// <param name="controllerName">Controller name</param>
150150
/// <param name="routeValues">Route values</param>
151-
public void GetPaymentInfoRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues)
151+
public override void GetPaymentInfoRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues)
152152
{
153153
actionName = "PaymentInfo";
154154
controllerName = "PaymentManual";
155155
routeValues = new RouteValueDictionary() { { "Namespaces", "SmartStore.Plugin.Payments.Manual.Controllers" }, { "area", null } };
156156
}
157157

158-
public Type GetControllerType()
159-
{
160-
return typeof(PaymentManualController);
161-
}
158+
public override Type GetControllerType()
159+
{
160+
return typeof(PaymentManualController);
161+
}
162162

163163
public override void Install()
164164
{

src/Tests/SmartStore.Services.Tests/Payments/PaymentServiceTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using NUnit.Framework;
88
using Rhino.Mocks;
99
using SmartStore.Services.Configuration;
10+
using SmartStore.Services.Localization;
1011

1112
namespace SmartStore.Services.Tests.Payments
1213
{

0 commit comments

Comments
 (0)