Skip to content

Commit ef887d3

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

29 files changed

Lines changed: 557 additions & 358 deletions

changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* (Developer) Admin: Implemented _entity-commit_ event message (for client EventBroker) in order to support custom data persistence in a loosely coupled manner.
1616
* Enabled fulltext search
1717
* New setting to redirect to order detail page if an order completed
18-
* New setting to suppress the search of SKUs
18+
* New setting to suppress the search for SKUs
1919
* Shipment list can be filtered by tracking number
2020
* #238 Working currency in context of request domain
2121

@@ -52,6 +52,7 @@
5252
* #180 Display delivery time in shopping cart and relevant mails
5353
* #217 GMC Feed Plugin: Make export of expiration_date configurable
5454
* #222 Feed Plugins: Take special price into consideration
55+
* (Developer) Implemented _PaymentMethodBase_ abstract class to simplify payment plugin development
5556
* Canceling a PayPal, SU or PostFinance payment now redirects to the order detail page rather than checkout complete
5657
* Added an option to display the short description of products within the order summary
5758

src/Libraries/SmartStore.Core/Async/AsyncRunner.cs

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,36 @@
77

88
namespace SmartStore.Core.Async
99
{
10-
11-
public interface IAsyncRunner
12-
{
13-
Task Run(Action<ILifetimeScope> action, CancellationToken cancellationToken, TaskCreationOptions options, TaskScheduler scheduler);
14-
}
1510

16-
public static class IAsyncRunnerExtensions
11+
public static class AsyncRunner
1712
{
18-
public static Task Run(this IAsyncRunner runner, Action<ILifetimeScope> action)
13+
14+
public static Task Run(Action<ILifetimeScope> action)
1915
{
20-
return runner.Run(action, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default);
16+
return Run(action, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default);
2117
}
2218

23-
public static Task Run(this IAsyncRunner runner, Action<ILifetimeScope> action, CancellationToken cancellationToken)
19+
public static Task Run(Action<ILifetimeScope> action, CancellationToken cancellationToken)
2420
{
25-
return runner.Run(action, cancellationToken, TaskCreationOptions.None, TaskScheduler.Default);
21+
return Run(action, cancellationToken, TaskCreationOptions.None, TaskScheduler.Default);
2622
}
2723

28-
public static Task Run(this IAsyncRunner runner, Action<ILifetimeScope> action, TaskCreationOptions options)
24+
public static Task Run(Action<ILifetimeScope> action, TaskCreationOptions options)
2925
{
30-
return runner.Run(action, CancellationToken.None, options, TaskScheduler.Default);
26+
return Run(action, CancellationToken.None, options, TaskScheduler.Default);
3127
}
3228

33-
public static Task Run(this IAsyncRunner runner, Action<ILifetimeScope> action, CancellationToken cancellationToken, TaskCreationOptions options)
29+
public static Task Run(Action<ILifetimeScope> action, CancellationToken cancellationToken, TaskCreationOptions options)
3430
{
35-
return runner.Run(action, cancellationToken, options, TaskScheduler.Default);
31+
return Run(action, cancellationToken, options, TaskScheduler.Default);
3632
}
3733

38-
public static Task Run(this IAsyncRunner runner, Action<ILifetimeScope> action, TaskScheduler scheduler)
34+
public static Task Run(Action<ILifetimeScope> action, TaskScheduler scheduler)
3935
{
40-
return runner.Run(action, CancellationToken.None, TaskCreationOptions.None, scheduler);
36+
return Run(action, CancellationToken.None, TaskCreationOptions.None, scheduler);
4137
}
42-
}
43-
44-
public class AsyncRunner : IAsyncRunner
45-
{
46-
public Task Run(Action<ILifetimeScope> action, CancellationToken cancellationToken, TaskCreationOptions options, TaskScheduler scheduler)
38+
39+
public static Task Run(Action<ILifetimeScope> action, CancellationToken cancellationToken, TaskCreationOptions options, TaskScheduler scheduler)
4740
{
4841
Guard.ArgumentNotNull(() => action);
4942
Guard.ArgumentNotNull(() => scheduler);
@@ -57,6 +50,7 @@ public Task Run(Action<ILifetimeScope> action, CancellationToken cancellationTok
5750

5851
return t;
5952
}
53+
6054
}
6155

6256
}

src/Libraries/SmartStore.Core/IPersistentCollection.cs renamed to src/Libraries/SmartStore.Core/Collections/IPersistentCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections;
33
using System.Collections.Generic;
44

5-
namespace SmartStore.Core
5+
namespace SmartStore.Collections
66
{
77
public interface IPersistentCollection<T> : ICollection<T>, ICollection
88
where T : class

src/Libraries/SmartStore.Core/PersistentCollection.cs renamed to src/Libraries/SmartStore.Core/Collections/PersistentCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Collections.Generic;
44
using System.Linq;
55

6-
namespace SmartStore.Core
6+
namespace SmartStore.Collections
77
{
88
public class PersistentCollection<T> : IPersistentCollection<T>
99
where T : class

src/Libraries/SmartStore.Core/Collections/QuerystringBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Web;
33
using System.Collections.Specialized;
44

5-
namespace SmartStore.Core.Collections
5+
namespace SmartStore.Collections
66
{
77
/// <summary>
88
/// http://weblogs.asp.net/bradvincent/archive/2008/10/27/helper-class-querystring-builder-chainable.aspx

src/Libraries/SmartStore.Core/CommonHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public static TypeConverter GetCustomTypeConverter(Type type)
215215
//we can't use the following code in order to register our custom type descriptors
216216
//TypeDescriptor.AddAttributes(typeof(List<int>), new TypeConverterAttribute(typeof(GenericListTypeConverter<int>)));
217217
//so we do it manually here
218-
218+
219219
#region Old code (doesn't work in meidum trust)
220220

221221
// namespace SmartStore.Core

src/Libraries/SmartStore.Core/Data/Impex/ImportProgressInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public int TotalRecords
1616
set;
1717
}
1818

19-
public int TotalProcessed
19+
public int TotalProcessed
2020
{
2121
get;
2222
set;
@@ -26,7 +26,7 @@ public double ProcessedPercent
2626
{
2727
get
2828
{
29-
return (double)((TotalProcessed / TotalRecords) * 100);
29+
return ((double)TotalProcessed / (double)TotalRecords) * 100;
3030
}
3131
}
3232

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web.Routing;
5+
6+
namespace SmartStore
7+
{
8+
9+
public class RouteInfo
10+
{
11+
12+
public RouteInfo(string action, string controller, object routeValues)
13+
: this(action, controller, new RouteValueDictionary(routeValues))
14+
{
15+
Guard.ArgumentNotNull(() => routeValues);
16+
}
17+
18+
public RouteInfo(string action, string controller, IDictionary<string, object> routeValues)
19+
: this(action, controller, new RouteValueDictionary(routeValues))
20+
{
21+
Guard.ArgumentNotNull(() => routeValues);
22+
}
23+
24+
public RouteInfo(string action, string controller, RouteValueDictionary routeValues)
25+
{
26+
Guard.ArgumentNotEmpty(() => action);
27+
Guard.ArgumentNotEmpty(() => controller);
28+
Guard.ArgumentNotNull(() => routeValues);
29+
30+
this.Action = action;
31+
this.Controller = controller;
32+
this.RouteValues = routeValues;
33+
}
34+
35+
public string Action
36+
{
37+
get;
38+
private set;
39+
}
40+
41+
public string Controller
42+
{
43+
get;
44+
private set;
45+
}
46+
47+
public RouteValueDictionary RouteValues
48+
{
49+
get;
50+
private set;
51+
}
52+
53+
}
54+
55+
}

src/Libraries/SmartStore.Core/SmartStore.Core.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@
326326
<Compile Include="Infrastructure\Misc.cs" />
327327
<Compile Include="Infrastructure\RegularExpressions.cs" />
328328
<Compile Include="Infrastructure\ValueObject.cs" />
329-
<Compile Include="IPersistentCollection.cs" />
329+
<Compile Include="Collections\IPersistentCollection.cs" />
330330
<Compile Include="IWebHelper.cs" />
331331
<Compile Include="Domain\Security\DefaultPermissionRecord.cs" />
332332
<Compile Include="Domain\Security\PermissionRecord.cs" />
@@ -394,7 +394,7 @@
394394
<Compile Include="IPageable.cs" />
395395
<Compile Include="Linq\LinqContainsPredicateBuilder.cs" />
396396
<Compile Include="Linq\PredicateBuilder.cs" />
397-
<Compile Include="PersistentCollection.cs" />
397+
<Compile Include="Collections\PersistentCollection.cs" />
398398
<Compile Include="Plugins\BasePlugin.cs" />
399399
<Compile Include="Plugins\IPreApplicationStart.cs" />
400400
<Compile Include="Plugins\PluginFileParser.cs" />
@@ -440,6 +440,7 @@
440440
<Compile Include="IO\IStorageProvider.cs" />
441441
<Compile Include="Domain\Customers\PasswordFormat.cs" />
442442
<Compile Include="HttpSecurityMode.cs" />
443+
<Compile Include="RouteInfo.cs" />
443444
<Compile Include="SmartStoreVersion.cs" />
444445
<Compile Include="Themes\IThemeRegistry.cs" />
445446
<Compile Include="Themes\ThemeManifest.cs" />

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace SmartStore.Services.Payments
88
{
99
/// <summary>
10-
/// Provides an interface for creating payment gateways & methods
10+
/// Provides an interface for creating payment gateways and methods
1111
/// </summary>
1212
public partial interface IPaymentMethod : IPlugin
1313
{
@@ -91,6 +91,17 @@ 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();
104+
94105
Type GetControllerType();
95106

96107
#endregion

0 commit comments

Comments
 (0)