Skip to content

Commit f9a82b4

Browse files
authored
Feature/v3 9 2 (#398)
* Updated the SDK to net8.0 * ZarinPal bug fixed. * Updated the Virtual Gateway design
1 parent 7feb428 commit f9a82b4

File tree

56 files changed

+1232
-1069
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1232
-1069
lines changed

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ steps:
2222
displayName: Use Dotnet
2323
inputs:
2424
packageType: sdk
25-
version: 7.x
25+
version: 8.x
2626
- task: NuGetCommand@2
2727
displayName: 'restoring'
2828
inputs:

src/Parbad.AspNetCore/src/ActionResults/GatewayTransporterExtensions.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
using Microsoft.AspNetCore.Mvc;
55
using Parbad.AspNetCore.ActionResults;
66

7-
namespace Parbad.AspNetCore
7+
namespace Parbad.AspNetCore;
8+
9+
public static class GatewayTransporterExtensions
810
{
9-
public static class GatewayTransporterExtensions
11+
/// <summary>
12+
/// Transports the client to the specified gateway.
13+
/// </summary>
14+
public static IActionResult TransportToGateway(this IGatewayTransporter transporter)
1015
{
11-
/// <summary>
12-
/// Transports the client to the specified gateway.
13-
/// </summary>
14-
public static IActionResult TransportToGateway(this IGatewayTransporter transporter)
15-
{
16-
return new TransportToGatewayActionResult(transporter);
17-
}
16+
return new TransportToGatewayActionResult(transporter);
1817
}
1918
}

src/Parbad.AspNetCore/src/ActionResults/TransportToGatewayActionResult.cs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,26 @@
44
using System.Threading.Tasks;
55
using Microsoft.AspNetCore.Mvc;
66

7-
namespace Parbad.AspNetCore.ActionResults
7+
namespace Parbad.AspNetCore.ActionResults;
8+
9+
/// <summary>
10+
/// An <see cref="IActionResult"/> for transporting the client to the specified gateway.
11+
/// </summary>
12+
public class TransportToGatewayActionResult : IActionResult
813
{
14+
private readonly IGatewayTransporter _transporter;
15+
916
/// <summary>
10-
/// An <see cref="IActionResult"/> for transporting the client to the specified gateway.
17+
/// Initializes an instance of <see cref="TransportToGatewayActionResult"/> for redirecting the client to the gateway.
1118
/// </summary>
12-
public class TransportToGatewayActionResult : IActionResult
19+
public TransportToGatewayActionResult(IGatewayTransporter transporter)
1320
{
14-
private readonly IGatewayTransporter _transporter;
15-
16-
/// <summary>
17-
/// Initializes an instance of <see cref="TransportToGatewayActionResult"/> for redirecting the client to the gateway.
18-
/// </summary>
19-
public TransportToGatewayActionResult(IGatewayTransporter transporter)
20-
{
21-
_transporter = transporter;
22-
}
21+
_transporter = transporter;
22+
}
2323

24-
/// <inheritdoc />
25-
public Task ExecuteResultAsync(ActionContext context)
26-
{
27-
return _transporter.TransportAsync();
28-
}
24+
/// <inheritdoc />
25+
public Task ExecuteResultAsync(ActionContext context)
26+
{
27+
return _transporter.TransportAsync();
2928
}
3029
}

src/Parbad.AspNetCore/src/Http/AspNetCoreHttpContextBuilderExtensions.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@
55
using Microsoft.Extensions.DependencyInjection;
66
using Parbad.Http;
77

8-
namespace Parbad.Builder
8+
namespace Parbad.Builder;
9+
10+
public static class AspNetCoreHttpContextBuilderExtensions
911
{
10-
public static class AspNetCoreHttpContextBuilderExtensions
12+
/// <summary>
13+
/// Uses the default ASP.NET CORE <see cref="IHttpContextAccessor"/>. If it exists, no action is
14+
/// taken. If it does not exist then a default implementation for the <see cref="IHttpContextAccessor"/> is added.
15+
/// </summary>
16+
/// <param name="builder"></param>
17+
public static IHttpContextBuilder UseDefaultAspNetCore(this IHttpContextBuilder builder)
1118
{
12-
/// <summary>
13-
/// Uses the default ASP.NET CORE <see cref="IHttpContextAccessor"/>. If it exists, no action is
14-
/// taken. If it does not exist then a default implementation for the <see cref="IHttpContextAccessor"/> is added.
15-
/// </summary>
16-
/// <param name="builder"></param>
17-
public static IHttpContextBuilder UseDefaultAspNetCore(this IHttpContextBuilder builder)
18-
{
19-
builder.Services.AddHttpContextAccessor();
19+
builder.Services.AddHttpContextAccessor();
2020

21-
return builder;
22-
}
21+
return builder;
2322
}
2423
}

src/Parbad.AspNetCore/src/Parbad.AspNetCore.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<PropertyGroup>
44
<PackageId>Parbad.AspNetCore</PackageId>
55
<Product>Parbad.AspNetCore</Product>
6-
<VersionPrefix>1.3.0</VersionPrefix>
7-
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.0;netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
6+
<VersionPrefix>1.4.0</VersionPrefix>
7+
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.0;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
88
<LangVersion>latest</LangVersion>
99
<Authors>Sina Soltani</Authors>
1010
<Copyright>Copyright © Sina Soltani 2016</Copyright>
@@ -20,7 +20,7 @@ For more information see: https://www.nuget.org/packages/Parbad/</Description>
2020
<PackageTags>parbad aspnetcore Payment Gateway Bank Iran Shetab IranKish Mellat Melli Sadad Parsian Pasargad Saman Asan-Pardakht پرداخت درگاه بانک ایران شتاب ایران-کیش ملت ملی سداد پارسیان پاسارگاد سامان آسان-پرداخت</PackageTags>
2121
<GenerateDocumentationFile>true</GenerateDocumentationFile>
2222
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
23-
<PackageReleaseNotes>https://github.com/Sina-Soltani/Parbad/releases/tag/v3.9.0</PackageReleaseNotes>
23+
<PackageReleaseNotes>https://github.com/Sina-Soltani/Parbad/releases/tag/v3.9.2</PackageReleaseNotes>
2424
</PropertyGroup>
2525

2626
<PropertyGroup>
@@ -38,7 +38,7 @@ For more information see: https://www.nuget.org/packages/Parbad/</Description>
3838
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
3939
</ItemGroup>
4040

41-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' or '$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net5.0' or '$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net7.0' ">
41+
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' or '$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net5.0' or '$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net8.0' ">
4242
<FrameworkReference Include="Microsoft.AspNetCore.App" />
4343
</ItemGroup>
4444

src/Parbad.AspNetCore/src/VirtualGateway/ParbadVirtualGatewayMiddleware.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
using Microsoft.AspNetCore.Http;
66
using Parbad.Gateway.ParbadVirtual.MiddlewareInvoker;
77

8-
namespace Parbad.AspNetCore.VirtualGateway
8+
namespace Parbad.AspNetCore.VirtualGateway;
9+
10+
public class ParbadVirtualGatewayMiddleware
911
{
10-
public class ParbadVirtualGatewayMiddleware
12+
public ParbadVirtualGatewayMiddleware(RequestDelegate next)
1113
{
12-
public ParbadVirtualGatewayMiddleware(RequestDelegate next)
13-
{
14-
}
14+
}
1515

16-
public Task Invoke(HttpContext httpContext, IParbadVirtualGatewayMiddlewareInvoker invoker)
17-
{
18-
return invoker.InvokeAsync();
19-
}
16+
public Task Invoke(HttpContext httpContext, IParbadVirtualGatewayMiddlewareInvoker invoker)
17+
{
18+
return invoker.InvokeAsync();
2019
}
2120
}

src/Parbad.AspNetCore/src/VirtualGateway/ParbadVirtualGatewayMiddlewareExtensions.cs

Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,65 +8,64 @@
88
using Parbad.AspNetCore.VirtualGateway;
99
using Parbad.Gateway.ParbadVirtual;
1010

11-
namespace Microsoft.AspNetCore.Builder
11+
namespace Microsoft.AspNetCore.Builder;
12+
13+
public static class ParbadVirtualGatewayMiddlewareExtensions
1214
{
13-
public static class ParbadVirtualGatewayMiddlewareExtensions
15+
/// <summary>
16+
/// Adds the Parbad Virtual Gateway middleware to the pipeline if the current
17+
/// hosting environment name is <see cref="Hosting.EnvironmentName.Development"/>.
18+
/// </summary>
19+
/// <param name="builder"></param>
20+
public static IApplicationBuilder UseParbadVirtualGatewayWhenDeveloping(this IApplicationBuilder builder)
1421
{
15-
/// <summary>
16-
/// Adds the Parbad Virtual Gateway middleware to the pipeline if the current
17-
/// hosting environment name is <see cref="Hosting.EnvironmentName.Development"/>.
18-
/// </summary>
19-
/// <param name="builder"></param>
20-
public static IApplicationBuilder UseParbadVirtualGatewayWhenDeveloping(this IApplicationBuilder builder)
21-
{
22-
if (builder == null) throw new ArgumentNullException(nameof(builder));
22+
if (builder == null) throw new ArgumentNullException(nameof(builder));
2323

24-
#if NETCOREAPP3_0 || Net_5 || Net_6 || Net_7
24+
#if NETCOREAPP3_0 || Net_5 || Net_6 || Net_7 || Net_8
2525
var hostEnvironment = builder.ApplicationServices.GetRequiredService<Hosting.IWebHostEnvironment>();
2626
var isDevelopment = Microsoft.Extensions.Hosting.HostEnvironmentEnvExtensions.IsDevelopment(hostEnvironment);
2727
#else
28-
var hostEnvironment = builder.ApplicationServices.GetRequiredService<Hosting.IHostingEnvironment>();
29-
var isDevelopment = Hosting.HostingEnvironmentExtensions.IsDevelopment(hostEnvironment);
28+
var hostEnvironment = builder.ApplicationServices.GetRequiredService<Hosting.IHostingEnvironment>();
29+
var isDevelopment = Hosting.HostingEnvironmentExtensions.IsDevelopment(hostEnvironment);
3030
#endif
31-
return builder.UseParbadVirtualGatewayWhen(context => isDevelopment);
32-
}
33-
34-
/// <summary>
35-
/// Adds the Parbad Virtual Gateway middleware to the pipeline.
36-
/// </summary>
37-
/// <param name="builder"></param>
38-
/// <param name="predicate"></param>
39-
public static IApplicationBuilder UseParbadVirtualGatewayWhen(this IApplicationBuilder builder,
40-
Func<HttpContext, bool> predicate)
41-
{
42-
if (builder == null) throw new ArgumentNullException(nameof(builder));
31+
return builder.UseParbadVirtualGatewayWhen(context => isDevelopment);
32+
}
4333

44-
return builder.MapWhen(predicate,
45-
applicationBuilder => applicationBuilder.UseParbadVirtualGateway());
46-
}
34+
/// <summary>
35+
/// Adds the Parbad Virtual Gateway middleware to the pipeline.
36+
/// </summary>
37+
/// <param name="builder"></param>
38+
/// <param name="predicate"></param>
39+
public static IApplicationBuilder UseParbadVirtualGatewayWhen(this IApplicationBuilder builder,
40+
Func<HttpContext, bool> predicate)
41+
{
42+
if (builder == null) throw new ArgumentNullException(nameof(builder));
4743

48-
/// <summary>
49-
/// Adds the Parbad Virtual Gateway middleware to the pipeline.
50-
/// </summary>
51-
/// <param name="builder"></param>
52-
public static IApplicationBuilder UseParbadVirtualGateway(this IApplicationBuilder builder)
53-
{
54-
if (builder == null) throw new ArgumentNullException(nameof(builder));
44+
return builder.MapWhen(predicate,
45+
applicationBuilder => applicationBuilder.UseParbadVirtualGateway());
46+
}
5547

56-
var options = builder
57-
.ApplicationServices
58-
.GetRequiredService<IOptions<ParbadVirtualGatewayOptions>>();
48+
/// <summary>
49+
/// Adds the Parbad Virtual Gateway middleware to the pipeline.
50+
/// </summary>
51+
/// <param name="builder"></param>
52+
public static IApplicationBuilder UseParbadVirtualGateway(this IApplicationBuilder builder)
53+
{
54+
if (builder == null) throw new ArgumentNullException(nameof(builder));
5955

60-
if (options.Value == null ||
61-
options.Value.GatewayPath == null ||
62-
!options.Value.GatewayPath.HasValue)
63-
{
64-
throw new InvalidOperationException("Cannot get Parbad Virtual gateway path value. " +
65-
"Make sure that you have already configured it.");
66-
}
56+
var options = builder
57+
.ApplicationServices
58+
.GetRequiredService<IOptions<ParbadVirtualGatewayOptions>>();
6759

68-
return builder.Map(options.Value.GatewayPath,
69-
applicationBuilder => applicationBuilder.UseMiddleware<ParbadVirtualGatewayMiddleware>());
60+
if (options.Value == null ||
61+
options.Value.GatewayPath == null ||
62+
!options.Value.GatewayPath.HasValue)
63+
{
64+
throw new InvalidOperationException("Cannot get Parbad Virtual gateway path value. " +
65+
"Make sure that you have already configured it.");
7066
}
67+
68+
return builder.Map(options.Value.GatewayPath,
69+
applicationBuilder => applicationBuilder.UseMiddleware<ParbadVirtualGatewayMiddleware>());
7170
}
72-
}
71+
}

src/Parbad.Gateway/FanAva/src/Parbad.Gateway.FanAva.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
<PropertyGroup>
44
<PackageId>Parbad.Gateway.FanAva</PackageId>
5-
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.0;net5.0;net6.0;net7.0</TargetFrameworks>
6-
<VersionPrefix>1.1.0</VersionPrefix>
5+
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.0;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
6+
<VersionPrefix>1.2.0</VersionPrefix>
77
<LangVersion>latest</LangVersion>
88
<Authors>Mohammad Mokhtari</Authors>
99
<Copyright>Copyright © Sina Soltani 2016</Copyright>
@@ -15,7 +15,7 @@
1515
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
1616
<PackageTags>parbad Payment Gateway FanAva پرداخت درگاه بانک فن آوا</PackageTags>
1717
<GenerateDocumentationFile>true</GenerateDocumentationFile>
18-
<PackageReleaseNotes>https://github.com/Sina-Soltani/Parbad/releases/tag/v3.9.0</PackageReleaseNotes>
18+
<PackageReleaseNotes>https://github.com/Sina-Soltani/Parbad/releases/tag/v3.9.2</PackageReleaseNotes>
1919
<Description>FanAva Gateway for Parbad project.
2020
For more information see: https://www.nuget.org/packages/Parbad/</Description>
2121
</PropertyGroup>

src/Parbad.Gateway/FanAva/tests/Parbad.Gateway.FanAva.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<LangVersion>latest</LangVersion>
66
<IsPackable>false</IsPackable>
77
</PropertyGroup>

src/Parbad.Gateway/IdPay/src/Parbad.Gateway.IdPay.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.0;net5.0;net6.0;net7.0</TargetFrameworks>
5-
<VersionPrefix>1.3.0</VersionPrefix>
4+
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.0;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
5+
<VersionPrefix>1.4.0</VersionPrefix>
66
<LangVersion>latest</LangVersion>
77
<Authors>Sina Soltani</Authors>
88
<Copyright>Copyright © Sina Soltani 2016</Copyright>
@@ -14,7 +14,7 @@
1414
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
1515
<PackageTags>parbad Payment Gateway Bank Iran Shetab idpay پرداخت درگاه بانک ایران شتاب</PackageTags>
1616
<GenerateDocumentationFile>true</GenerateDocumentationFile>
17-
<PackageReleaseNotes>https://github.com/Sina-Soltani/Parbad/releases/tag/v3.9.0</PackageReleaseNotes>
17+
<PackageReleaseNotes>https://github.com/Sina-Soltani/Parbad/releases/tag/v3.9.2</PackageReleaseNotes>
1818
<Description>IDPay.ir Gateway for Parbad project.
1919

2020
For more information see: https://www.nuget.org/packages/Parbad/</Description>

0 commit comments

Comments
 (0)