Skip to content

Commit

Permalink
Feature/157 v3.6.0 (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sina-Soltani authored Dec 13, 2020
1 parent 02b8567 commit 2bb0fdf
Show file tree
Hide file tree
Showing 349 changed files with 5,722 additions and 3,751 deletions.
148 changes: 111 additions & 37 deletions Parbad.sln

Large diffs are not rendered by default.

25 changes: 10 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[<img align="right" width="150px" src="https://raw.githubusercontent.com/Sina-Soltani/Parbad/master/images/Parbad-256x256.png" />](https://www.nuget.org/packages/Parbad/)

Parbad is a free and open-source integrated online payment library which helps developers and website owners to add the online payment ability to their websites. It provides an easy solution to perform payment request, verify the requested payment and refund a payment.
Parbad is a free and open-source integrated online payment library which helps developers to add the online payment ability to their websites. It provides an easy solution to perform payment request, verify the requested payment and refund a payment.

[![NuGet version](https://img.shields.io/nuget/v/parbad.svg?style=flat&label=nuget)](https://www.nuget.org/packages/Parbad/)
[![Nuget Downloads](https://img.shields.io/nuget/dt/parbad.svg?color=blue&label=Downloads)](https://www.nuget.org/packages/Parbad/)
Expand All @@ -13,7 +13,11 @@ Parbad is a free and open-source integrated online payment library which helps d
* Easy installation using Nuget
* No need to add any web service
* High security checks
* Supports most known online payment providers (Banks) such as:
* Virtual Gateway for developing and testing your application.
* Configurable Proxy
* Created with modern and standard technologies
* Supports ASP.NET CORE, ASP.NET MVC and ASP.NET WebForms
* Supported online payment providers:
* [Mellat](https://www.nuget.org/packages/Parbad/)
* [Melli](https://www.nuget.org/packages/Parbad/)
* [Saman](https://www.nuget.org/packages/Parbad/)
Expand All @@ -26,33 +30,24 @@ Parbad is a free and open-source integrated online payment library which helps d
* [Pay.ir](https://www.nuget.org/packages/Parbad.Gateway.PayIr/)
* [IDPay.ir](https://www.nuget.org/packages/Parbad.Gateway.IdPay/)
* [YekPay](https://www.nuget.org/packages/Parbad.Gateway.YekPay/)
* Virtual gateway for developing and testing your application.
* Using Proxy
* Created with modern and standard technologies
* Supports ASP.NET CORE, ASP.NET MVC and ASP.NET WebForms

# How it works?
![image](https://raw.githubusercontent.com/Sina-Soltani/Parbad/master/images/How-it-works.png)

# Tutorials

* [How to use it?](https://github.com/Sina-Soltani/Parbad/wiki/How-to-use-it%3F)
* [Installation](https://github.com/Sina-Soltani/Parbad/wiki/Installation)
* [Configuration](https://github.com/Sina-Soltani/Parbad/wiki/Configuration)
* [Payment](https://github.com/Sina-Soltani/Parbad/wiki/Payment)
* [Invoice Builder](https://github.com/Sina-Soltani/Parbad/wiki/Invoice-Builder)
* [Virtual Gateway](https://github.com/Sina-Soltani/Parbad/wiki/Virtual-Gateway)
* [Developing a new Gateway](https://github.com/Sina-Soltani/Parbad/wiki/Developing-a-new-Gateway)
* [Samples](https://github.com/Sina-Soltani/Parbad/wiki/Samples)
* [Any question, problem or suggestion?](https://github.com/Sina-Soltani/Parbad/issues/new/choose)

توجه: آموزش‌ها و مثال‌های به روز شده را توسط لینک‌های بالا دنبال کنید

# Videos
* [Any question, problem or idea?](https://github.com/Sina-Soltani/Parbad/discussions?discussions_q=category%3AQ%26A)

* [ASP.NET CORE](https://youtu.be/zGGpf-Csj8Y)
* [ASP.NET MVC](https://youtu.be/gnofCtdPP5k)
[مشاهده مقاله قدیمی به فارسی](https://www.dotnettips.info/post/3009/%d9%be%d8%b1%d8%a8%d8%a7%d8%af-%d8%a2%d9%85%d9%88%d8%b2%d8%b4-%d9%be%db%8c%d8%a7%d8%af%d9%87%e2%80%8c%d8%b3%d8%a7%d8%b2%db%8c-%d9%be%d8%b1%d8%af%d8%a7%d8%ae%d8%aa-%d8%a2%d9%86%d9%84%d8%a7%db%8c%d9%86-%d8%af%d8%b1-%d8%af%d8%a7%d8%aa-%d9%86%d8%aa-%d9%85%d9%82%d8%af%d9%85%d9%87)

[مشاهده مقاله به فارسی](https://www.dotnettips.info/post/3009/%d9%be%d8%b1%d8%a8%d8%a7%d8%af-%d8%a2%d9%85%d9%88%d8%b2%d8%b4-%d9%be%db%8c%d8%a7%d8%af%d9%87%e2%80%8c%d8%b3%d8%a7%d8%b2%db%8c-%d9%be%d8%b1%d8%af%d8%a7%d8%ae%d8%aa-%d8%a2%d9%86%d9%84%d8%a7%db%8c%d9%86-%d8%af%d8%b1-%d8%af%d8%a7%d8%aa-%d9%86%d8%aa-%d9%85%d9%82%d8%af%d9%85%d9%87)
توجه: آموزش‌ها و مثال‌های به روز شده را در گیت هاب دنبال کنید

# How can I contribute?
[Contributing](https://github.com/Sina-Soltani/Parbad/blob/master/CONTRIBUTING.md) explains what kinds of changes are welcome.
Expand Down
1 change: 0 additions & 1 deletion _config.yml

This file was deleted.

5 changes: 5 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ steps:
command: 'build'
projects: $(projects)
arguments: '-c $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: 'testing'
inputs:
command: 'test'
projects: '**/*.Tests.csproj'
- task: DotNetCoreCLI@2
displayName: 'packing'
condition: eq(variables['build.sourceBranch'], 'refs/heads/dev')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ public async Task<IActionResult> Refund(RefundViewModel viewModel)
{
var result = await _onlinePayment.RefundCompletelyAsync(viewModel.TrackingNumber);

// Note: This is just for development and testing.
// Don't show the actual result object to clients in production environment.
// Instead, show only the important information such as IsSucceed, Tracking Number and Transaction Code.
return View("RefundResult", result);
}

Expand Down
2 changes: 1 addition & 1 deletion samples/Parbad.Sample.AspNetCore/Models/PayViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class PayViewModel
[Display(Name = "Generate the Tracking number automatically?")]
public bool GenerateTrackingNumberAutomatically { get; set; } = true;

public long Amount { get; set; }
public decimal Amount { get; set; }

[Display(Name = "Gateway")]
public Gateways SelectedGateway { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>latest</LangVersion>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>9</LangVersion>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Parbad.AspNetCore\Parbad.AspNetCore.csproj" />
<ProjectReference Include="..\..\src\Parbad.AspNetCore\src\Parbad.AspNetCore.csproj" />
<ProjectReference Include="..\..\src\Parbad.Gateway\IdPay\src\Parbad.Gateway.IdPay.csproj" />
<ProjectReference Include="..\..\src\Parbad.Gateway\PayIr\src\Parbad.Gateway.PayIr.csproj" />
<ProjectReference Include="..\..\src\Parbad.Gateway\Sepehr\src\Parbad.Gateway.Sepehr.csproj" />
<ProjectReference Include="..\..\src\Parbad.Gateway\YekPay\src\Parbad.Gateway.YekPay.csproj" />
<ProjectReference Include="..\..\src\Parbad.Gateway\ZarinPal\src\Parbad.Gateway.ZarinPal.csproj" />
<ProjectReference Include="..\..\src\Parbad.Storage\Cache\src\Parbad.Storage.Cache.csproj" />
<ProjectReference Include="..\..\src\Parbad.Storage\EntityFrameworkCore\src\Parbad.Storage.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\src\Parbad\Parbad.csproj" />
<ProjectReference Include="..\..\src\Parbad\src\Parbad.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"Parbad.Sample.AspNetCore": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "http://localhost:5000",
"applicationUrl": "http://localhost:5001",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
Expand Down
2 changes: 2 additions & 0 deletions samples/Parbad.Sample.AspNetCore/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Parbad.Builder;
using Parbad.Gateway.Mellat;
using Parbad.Gateway.ParbadVirtual;

namespace Parbad.Sample.AspNetCore
{
Expand Down
2 changes: 2 additions & 0 deletions samples/Parbad.Sample.Mvc/App_Start/ParbadConfig.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Parbad.Builder;
using Parbad.Gateway.Mellat;
using Parbad.Gateway.ParbadVirtual;

namespace Parbad.Sample.Mvc
{
Expand Down
6 changes: 3 additions & 3 deletions samples/Parbad.Sample.Mvc/Parbad.Sample.Mvc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,11 @@
<Project>{0f2cd6c7-3d9a-4d9d-9132-afbcbda3f47c}</Project>
<Name>Parbad.Gateway.ZarinPal</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Parbad.Mvc\Parbad.Mvc.csproj">
<ProjectReference Include="..\..\src\Parbad.Mvc\src\Parbad.Mvc.csproj">
<Project>{19fbd363-c6f1-4dfc-a311-da8485b6f8a4}</Project>
<Name>Parbad.Mvc</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Parbad.Owin\Parbad.Owin.csproj">
<ProjectReference Include="..\..\src\Parbad.Owin\src\Parbad.Owin.csproj">
<Project>{a1815d72-31a8-45bf-95b5-2a1f1008e0f8}</Project>
<Name>Parbad.Owin</Name>
</ProjectReference>
Expand All @@ -366,7 +366,7 @@
<Project>{601e9a72-3154-4d7b-aada-68167a60e29e}</Project>
<Name>Parbad.Storage.EntityFrameworkCore</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Parbad\Parbad.csproj">
<ProjectReference Include="..\..\src\Parbad\src\Parbad.csproj">
<Project>{53d0b3cc-2fd4-4113-a368-60715fb8518e}</Project>
<Name>Parbad</Name>
</ProjectReference>
Expand Down
2 changes: 2 additions & 0 deletions samples/Parbad.Sample.WebForm/App_Start/ParbadConfig.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Parbad.Builder;
using Parbad.Gateway.Mellat;
using Parbad.Gateway.ParbadVirtual;

namespace Parbad.Sample.WebForm
{
Expand Down
4 changes: 2 additions & 2 deletions samples/Parbad.Sample.WebForm/Parbad.Sample.WebForm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@
<Project>{0f2cd6c7-3d9a-4d9d-9132-afbcbda3f47c}</Project>
<Name>Parbad.Gateway.ZarinPal</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Parbad.Owin\Parbad.Owin.csproj">
<ProjectReference Include="..\..\src\Parbad.Owin\src\Parbad.Owin.csproj">
<Project>{a1815d72-31a8-45bf-95b5-2a1f1008e0f8}</Project>
<Name>Parbad.Owin</Name>
</ProjectReference>
Expand All @@ -362,7 +362,7 @@
<Project>{601e9a72-3154-4d7b-aada-68167a60e29e}</Project>
<Name>Parbad.Storage.EntityFrameworkCore</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Parbad\Parbad.csproj">
<ProjectReference Include="..\..\src\Parbad\src\Parbad.csproj">
<Project>{53d0b3cc-2fd4-4113-a368-60715fb8518e}</Project>
<Name>Parbad</Name>
</ProjectReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<VersionPrefix>1.0.6</VersionPrefix>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.0;netcoreapp3.1;net5.0</TargetFrameworks>
<LangVersion>9</LangVersion>
<VersionPrefix>1.1.0</VersionPrefix>
<Authors>Sina Soltani</Authors>
<Copyright>Copyright © Sina Soltani 2016</Copyright>
<PackageProjectUrl>https://github.com/Sina-Soltani/Parbad</PackageProjectUrl>
Expand All @@ -18,7 +18,11 @@ 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>Bug Ticket #71 is fixed.</PackageReleaseNotes>
<PackageReleaseNotes>Supporting the netstandard2.1, netcoreapp3.1 and net5.0 is added.</PackageReleaseNotes>
</PropertyGroup>

<PropertyGroup>
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -28,22 +32,22 @@ For more information see: https://www.nuget.org/packages/Parbad/</Description>
<DocumentationFile>Parbad.AspNetCore.xml</DocumentationFile>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'netstandard2.1' ">
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.0' or '$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net5.0' ">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Parbad\Parbad.csproj" />
<ProjectReference Include="..\..\Parbad\src\Parbad.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="icon.png" pack="true" Visible="false" PackagePath="" />
<None Include="readme.txt" pack="true" PackagePath="." />
<None Include="Parbad.AspNetCore.xml" pack="true" Visible="false" PackagePath=""/>
<None Include="Parbad.AspNetCore.xml" pack="true" Visible="false" PackagePath="" />
</ItemGroup>

</Project>
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static IApplicationBuilder UseParbadVirtualGatewayWhenDeveloping(this IAp
{
if (builder == null) throw new ArgumentNullException(nameof(builder));

#if NETCOREAPP3_0
#if NETCOREAPP3_0 || Net_5
var hostEnvironment = builder.ApplicationServices.GetRequiredService<Hosting.IWebHostEnvironment>();
var isDevelopment = Microsoft.Extensions.Hosting.HostEnvironmentEnvExtensions.IsDevelopment(hostEnvironment);
#else
Expand Down
File renamed without changes
File renamed without changes.
25 changes: 14 additions & 11 deletions src/Parbad.Gateway/IdPay/src/IdPayGateway.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Copyright (c) Parbad. All rights reserved.
// Licensed under the GNU GENERAL PUBLIC License, Version 3.0. See License.txt in the project root for license information.

using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
Expand All @@ -15,6 +11,10 @@
using Parbad.Internal;
using Parbad.Net;
using Parbad.Options;
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

namespace Parbad.Gateway.IdPay
{
Expand All @@ -23,11 +23,12 @@ public class IdPayGateway : GatewayBase<IdPayGatewayAccount>
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly HttpClient _httpClient;
private readonly IOptions<MessagesOptions> _messagesOptions;
private readonly IdPayGatewayOptions _gatewayOptions;
private readonly MessagesOptions _messagesOptions;

public const string Name = "IdPay";

private JsonSerializerSettings DefaultSerializerSettings => new JsonSerializerSettings
private static JsonSerializerSettings DefaultSerializerSettings => new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
};
Expand All @@ -36,11 +37,13 @@ public IdPayGateway(
IGatewayAccountProvider<IdPayGatewayAccount> accountProvider,
IHttpContextAccessor httpContextAccessor,
IHttpClientFactory httpClientFactory,
IOptions<IdPayGatewayOptions> gatewayOptions,
IOptions<MessagesOptions> messagesOptions) : base(accountProvider)
{
_httpContextAccessor = httpContextAccessor;
_httpClient = httpClientFactory.CreateClient(this);
_messagesOptions = messagesOptions;
_gatewayOptions = gatewayOptions.Value;
_messagesOptions = messagesOptions.Value;
}

/// <inheritdoc />
Expand All @@ -55,7 +58,7 @@ public override async Task<IPaymentRequestResult> RequestAsync(Invoice invoice,
var data = IdPayHelper.CreateRequestData(invoice);

var responseMessage = await _httpClient
.PostJsonAsync(IdPayHelper.RequestUrl, data, DefaultSerializerSettings, cancellationToken)
.PostJsonAsync(_gatewayOptions.ApiRequestUrl, data, DefaultSerializerSettings, cancellationToken)
.ConfigureAwaitFalse();

return await IdPayHelper.CreateRequestResult(responseMessage, _httpContextAccessor.HttpContext, account);
Expand All @@ -69,7 +72,7 @@ public override async Task<IPaymentVerifyResult> VerifyAsync(InvoiceContext cont
var callbackResult = await IdPayHelper.CreateCallbackResultAsync(
context,
_httpContextAccessor.HttpContext.Request,
_messagesOptions.Value,
_messagesOptions,
cancellationToken)
.ConfigureAwaitFalse();

Expand All @@ -85,10 +88,10 @@ public override async Task<IPaymentVerifyResult> VerifyAsync(InvoiceContext cont
var data = IdPayHelper.CreateVerifyData(context, callbackResult);

var responseMessage = await _httpClient
.PostJsonAsync(IdPayHelper.VerifyUrl, data, DefaultSerializerSettings, cancellationToken)
.PostJsonAsync(_gatewayOptions.ApiVerificationUrl, data, DefaultSerializerSettings, cancellationToken)
.ConfigureAwaitFalse();

return await IdPayHelper.CreateVerifyResult(responseMessage, _messagesOptions.Value);
return await IdPayHelper.CreateVerifyResult(responseMessage, _messagesOptions);
}

/// <inheritdoc />
Expand Down
25 changes: 19 additions & 6 deletions src/Parbad.Gateway/IdPay/src/IdPayGatewayBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@

using System;
using Microsoft.Extensions.DependencyInjection;
using Parbad.Gateway.IdPay;
using Parbad.Gateway.IdPay.Internal;
using Parbad.GatewayBuilders;

namespace Parbad.Builder
namespace Parbad.Gateway.IdPay
{
public static class IdPayGatewayBuilderExtensions
{
Expand All @@ -19,9 +17,10 @@ public static IGatewayConfigurationBuilder<IdPayGateway> AddIdPay(this IGatewayB
{
if (builder == null) throw new ArgumentNullException(nameof(builder));

return builder.AddGateway<IdPayGateway>()
.WithHttpClient(clientBuilder =>
clientBuilder.ConfigureHttpClient(client => client.BaseAddress = new Uri(IdPayHelper.ApiUrl)));
return builder
.AddGateway<IdPayGateway>()
.WithHttpClient(clientBuilder => { })
.WithOptions(options => { });
}

/// <summary>
Expand All @@ -37,5 +36,19 @@ public static IGatewayConfigurationBuilder<IdPayGateway> WithAccounts(

return builder.WithAccounts(configureAccounts);
}

/// <summary>
/// Configures the options for IdPay Gateway.
/// </summary>
/// <param name="builder"></param>
/// <param name="configureOptions">Configuration</param>
public static IGatewayConfigurationBuilder<IdPayGateway> WithOptions(
this IGatewayConfigurationBuilder<IdPayGateway> builder,
Action<IdPayGatewayOptions> configureOptions)
{
builder.Services.Configure(configureOptions);

return builder;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
// Licensed under the GNU GENERAL PUBLIC License, Version 3.0. See License.txt in the project root for license information.

using System;
using Parbad.Gateway.IdPay;
using Parbad.InvoiceBuilder;

namespace Parbad
namespace Parbad.Gateway.IdPay
{
public static class IdPayGatewayInvoiceBuilderExtensions
{
Expand Down
Loading

0 comments on commit 2bb0fdf

Please sign in to comment.