Skip to content

Commit

Permalink
Feature/v3 9 2 (#398)
Browse files Browse the repository at this point in the history
* Updated the SDK to net8.0
* ZarinPal bug fixed.
* Updated the Virtual Gateway design
  • Loading branch information
Sina-Soltani authored Oct 28, 2024
1 parent 7feb428 commit f9a82b4
Show file tree
Hide file tree
Showing 56 changed files with 1,232 additions and 1,069 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ steps:
displayName: Use Dotnet
inputs:
packageType: sdk
version: 7.x
version: 8.x
- task: NuGetCommand@2
displayName: 'restoring'
inputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
using Microsoft.AspNetCore.Mvc;
using Parbad.AspNetCore.ActionResults;

namespace Parbad.AspNetCore
namespace Parbad.AspNetCore;

public static class GatewayTransporterExtensions
{
public static class GatewayTransporterExtensions
/// <summary>
/// Transports the client to the specified gateway.
/// </summary>
public static IActionResult TransportToGateway(this IGatewayTransporter transporter)
{
/// <summary>
/// Transports the client to the specified gateway.
/// </summary>
public static IActionResult TransportToGateway(this IGatewayTransporter transporter)
{
return new TransportToGatewayActionResult(transporter);
}
return new TransportToGatewayActionResult(transporter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,26 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace Parbad.AspNetCore.ActionResults
namespace Parbad.AspNetCore.ActionResults;

/// <summary>
/// An <see cref="IActionResult"/> for transporting the client to the specified gateway.
/// </summary>
public class TransportToGatewayActionResult : IActionResult
{
private readonly IGatewayTransporter _transporter;

/// <summary>
/// An <see cref="IActionResult"/> for transporting the client to the specified gateway.
/// Initializes an instance of <see cref="TransportToGatewayActionResult"/> for redirecting the client to the gateway.
/// </summary>
public class TransportToGatewayActionResult : IActionResult
public TransportToGatewayActionResult(IGatewayTransporter transporter)
{
private readonly IGatewayTransporter _transporter;

/// <summary>
/// Initializes an instance of <see cref="TransportToGatewayActionResult"/> for redirecting the client to the gateway.
/// </summary>
public TransportToGatewayActionResult(IGatewayTransporter transporter)
{
_transporter = transporter;
}
_transporter = transporter;
}

/// <inheritdoc />
public Task ExecuteResultAsync(ActionContext context)
{
return _transporter.TransportAsync();
}
/// <inheritdoc />
public Task ExecuteResultAsync(ActionContext context)
{
return _transporter.TransportAsync();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
using Microsoft.Extensions.DependencyInjection;
using Parbad.Http;

namespace Parbad.Builder
namespace Parbad.Builder;

public static class AspNetCoreHttpContextBuilderExtensions
{
public static class AspNetCoreHttpContextBuilderExtensions
/// <summary>
/// Uses the default ASP.NET CORE <see cref="IHttpContextAccessor"/>. If it exists, no action is
/// taken. If it does not exist then a default implementation for the <see cref="IHttpContextAccessor"/> is added.
/// </summary>
/// <param name="builder"></param>
public static IHttpContextBuilder UseDefaultAspNetCore(this IHttpContextBuilder builder)
{
/// <summary>
/// Uses the default ASP.NET CORE <see cref="IHttpContextAccessor"/>. If it exists, no action is
/// taken. If it does not exist then a default implementation for the <see cref="IHttpContextAccessor"/> is added.
/// </summary>
/// <param name="builder"></param>
public static IHttpContextBuilder UseDefaultAspNetCore(this IHttpContextBuilder builder)
{
builder.Services.AddHttpContextAccessor();
builder.Services.AddHttpContextAccessor();

return builder;
}
return builder;
}
}
8 changes: 4 additions & 4 deletions src/Parbad.AspNetCore/src/Parbad.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<PackageId>Parbad.AspNetCore</PackageId>
<Product>Parbad.AspNetCore</Product>
<VersionPrefix>1.3.0</VersionPrefix>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.0;netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
<VersionPrefix>1.4.0</VersionPrefix>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.0;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Authors>Sina Soltani</Authors>
<Copyright>Copyright © Sina Soltani 2016</Copyright>
Expand All @@ -20,7 +20,7 @@ For more information see: https://www.nuget.org/packages/Parbad/</Description>
<PackageTags>parbad aspnetcore Payment Gateway Bank Iran Shetab IranKish Mellat Melli Sadad Parsian Pasargad Saman Asan-Pardakht پرداخت درگاه بانک ایران شتاب ایران-کیش ملت ملی سداد پارسیان پاسارگاد سامان آسان-پرداخت</PackageTags>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
<PackageReleaseNotes>https://github.com/Sina-Soltani/Parbad/releases/tag/v3.9.0</PackageReleaseNotes>
<PackageReleaseNotes>https://github.com/Sina-Soltani/Parbad/releases/tag/v3.9.2</PackageReleaseNotes>
</PropertyGroup>

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

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' or '$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net5.0' or '$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net7.0' ">
<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' ">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
using Microsoft.AspNetCore.Http;
using Parbad.Gateway.ParbadVirtual.MiddlewareInvoker;

namespace Parbad.AspNetCore.VirtualGateway
namespace Parbad.AspNetCore.VirtualGateway;

public class ParbadVirtualGatewayMiddleware
{
public class ParbadVirtualGatewayMiddleware
public ParbadVirtualGatewayMiddleware(RequestDelegate next)
{
public ParbadVirtualGatewayMiddleware(RequestDelegate next)
{
}
}

public Task Invoke(HttpContext httpContext, IParbadVirtualGatewayMiddlewareInvoker invoker)
{
return invoker.InvokeAsync();
}
public Task Invoke(HttpContext httpContext, IParbadVirtualGatewayMiddlewareInvoker invoker)
{
return invoker.InvokeAsync();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,65 +8,64 @@
using Parbad.AspNetCore.VirtualGateway;
using Parbad.Gateway.ParbadVirtual;

namespace Microsoft.AspNetCore.Builder
namespace Microsoft.AspNetCore.Builder;

public static class ParbadVirtualGatewayMiddlewareExtensions
{
public static class ParbadVirtualGatewayMiddlewareExtensions
/// <summary>
/// Adds the Parbad Virtual Gateway middleware to the pipeline if the current
/// hosting environment name is <see cref="Hosting.EnvironmentName.Development"/>.
/// </summary>
/// <param name="builder"></param>
public static IApplicationBuilder UseParbadVirtualGatewayWhenDeveloping(this IApplicationBuilder builder)
{
/// <summary>
/// Adds the Parbad Virtual Gateway middleware to the pipeline if the current
/// hosting environment name is <see cref="Hosting.EnvironmentName.Development"/>.
/// </summary>
/// <param name="builder"></param>
public static IApplicationBuilder UseParbadVirtualGatewayWhenDeveloping(this IApplicationBuilder builder)
{
if (builder == null) throw new ArgumentNullException(nameof(builder));
if (builder == null) throw new ArgumentNullException(nameof(builder));

#if NETCOREAPP3_0 || Net_5 || Net_6 || Net_7
#if NETCOREAPP3_0 || Net_5 || Net_6 || Net_7 || Net_8
var hostEnvironment = builder.ApplicationServices.GetRequiredService<Hosting.IWebHostEnvironment>();
var isDevelopment = Microsoft.Extensions.Hosting.HostEnvironmentEnvExtensions.IsDevelopment(hostEnvironment);
#else
var hostEnvironment = builder.ApplicationServices.GetRequiredService<Hosting.IHostingEnvironment>();
var isDevelopment = Hosting.HostingEnvironmentExtensions.IsDevelopment(hostEnvironment);
var hostEnvironment = builder.ApplicationServices.GetRequiredService<Hosting.IHostingEnvironment>();
var isDevelopment = Hosting.HostingEnvironmentExtensions.IsDevelopment(hostEnvironment);
#endif
return builder.UseParbadVirtualGatewayWhen(context => isDevelopment);
}

/// <summary>
/// Adds the Parbad Virtual Gateway middleware to the pipeline.
/// </summary>
/// <param name="builder"></param>
/// <param name="predicate"></param>
public static IApplicationBuilder UseParbadVirtualGatewayWhen(this IApplicationBuilder builder,
Func<HttpContext, bool> predicate)
{
if (builder == null) throw new ArgumentNullException(nameof(builder));
return builder.UseParbadVirtualGatewayWhen(context => isDevelopment);
}

return builder.MapWhen(predicate,
applicationBuilder => applicationBuilder.UseParbadVirtualGateway());
}
/// <summary>
/// Adds the Parbad Virtual Gateway middleware to the pipeline.
/// </summary>
/// <param name="builder"></param>
/// <param name="predicate"></param>
public static IApplicationBuilder UseParbadVirtualGatewayWhen(this IApplicationBuilder builder,
Func<HttpContext, bool> predicate)
{
if (builder == null) throw new ArgumentNullException(nameof(builder));

/// <summary>
/// Adds the Parbad Virtual Gateway middleware to the pipeline.
/// </summary>
/// <param name="builder"></param>
public static IApplicationBuilder UseParbadVirtualGateway(this IApplicationBuilder builder)
{
if (builder == null) throw new ArgumentNullException(nameof(builder));
return builder.MapWhen(predicate,
applicationBuilder => applicationBuilder.UseParbadVirtualGateway());
}

var options = builder
.ApplicationServices
.GetRequiredService<IOptions<ParbadVirtualGatewayOptions>>();
/// <summary>
/// Adds the Parbad Virtual Gateway middleware to the pipeline.
/// </summary>
/// <param name="builder"></param>
public static IApplicationBuilder UseParbadVirtualGateway(this IApplicationBuilder builder)
{
if (builder == null) throw new ArgumentNullException(nameof(builder));

if (options.Value == null ||
options.Value.GatewayPath == null ||
!options.Value.GatewayPath.HasValue)
{
throw new InvalidOperationException("Cannot get Parbad Virtual gateway path value. " +
"Make sure that you have already configured it.");
}
var options = builder
.ApplicationServices
.GetRequiredService<IOptions<ParbadVirtualGatewayOptions>>();

return builder.Map(options.Value.GatewayPath,
applicationBuilder => applicationBuilder.UseMiddleware<ParbadVirtualGatewayMiddleware>());
if (options.Value == null ||
options.Value.GatewayPath == null ||
!options.Value.GatewayPath.HasValue)
{
throw new InvalidOperationException("Cannot get Parbad Virtual gateway path value. " +
"Make sure that you have already configured it.");
}

return builder.Map(options.Value.GatewayPath,
applicationBuilder => applicationBuilder.UseMiddleware<ParbadVirtualGatewayMiddleware>());
}
}
}
6 changes: 3 additions & 3 deletions src/Parbad.Gateway/FanAva/src/Parbad.Gateway.FanAva.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<PackageId>Parbad.Gateway.FanAva</PackageId>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.0;net5.0;net6.0;net7.0</TargetFrameworks>
<VersionPrefix>1.1.0</VersionPrefix>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.0;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<VersionPrefix>1.2.0</VersionPrefix>
<LangVersion>latest</LangVersion>
<Authors>Mohammad Mokhtari</Authors>
<Copyright>Copyright © Sina Soltani 2016</Copyright>
Expand All @@ -15,7 +15,7 @@
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageTags>parbad Payment Gateway FanAva پرداخت درگاه بانک فن آوا</PackageTags>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReleaseNotes>https://github.com/Sina-Soltani/Parbad/releases/tag/v3.9.0</PackageReleaseNotes>
<PackageReleaseNotes>https://github.com/Sina-Soltani/Parbad/releases/tag/v3.9.2</PackageReleaseNotes>
<Description>FanAva Gateway for Parbad project.
For more information see: https://www.nuget.org/packages/Parbad/</Description>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/Parbad.Gateway/IdPay/src/Parbad.Gateway.IdPay.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

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

For more information see: https://www.nuget.org/packages/Parbad/</Description>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<PackageId>Parbad.Gateway.IranKish</PackageId>
<Product>Parbad.Gateway.IranKish</Product>
<VersionPrefix>1.0.0</VersionPrefix>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.0;net5.0;net6.0;net7.0</TargetFrameworks>
<VersionPrefix>1.1.0</VersionPrefix>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.0;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Authors>Sina Soltani</Authors>
<Copyright>Copyright © Sina Soltani 2016</Copyright>
Expand All @@ -16,7 +16,7 @@
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageTags>parbad Payment gateway bank Iran shetab irankish پرداخت درگاه بانک ایران کیش</PackageTags>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReleaseNotes>https://github.com/Sina-Soltani/Parbad/releases/tag/v3.9.0</PackageReleaseNotes>
<PackageReleaseNotes>https://github.com/Sina-Soltani/Parbad/releases/tag/v3.9.2</PackageReleaseNotes>
<Description>IranKish Gateway for Parbad project.

For more information see: https://www.nuget.org/packages/Parbad/</Description>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
6 changes: 3 additions & 3 deletions src/Parbad.Gateway/PayIr/src/Parbad.Gateway.PayIr.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<PackageId>Parbad.Gateway.PayIr</PackageId>
<Product>Parbad.Gateway.PayIr</Product>
<VersionPrefix>1.5.0</VersionPrefix>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.0;net5.0;net6.0;net7.0</TargetFrameworks>
<VersionPrefix>1.6.0</VersionPrefix>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.0;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Authors>Sina Soltani</Authors>
<Copyright>Copyright © Sina Soltani 2016</Copyright>
Expand All @@ -16,7 +16,7 @@
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageTags>parbad Payment Gateway Bank Iran Shetab pay.ir پرداخت درگاه بانک ایران شتاب پی</PackageTags>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReleaseNotes>https://github.com/Sina-Soltani/Parbad/releases/tag/v3.9.0</PackageReleaseNotes>
<PackageReleaseNotes>https://github.com/Sina-Soltani/Parbad/releases/tag/v3.9.2</PackageReleaseNotes>
<Description>Pay.ir Gateway for Parbad project.

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

0 comments on commit f9a82b4

Please sign in to comment.