Skip to content

Commit

Permalink
Bug/gateway result status (#73)
Browse files Browse the repository at this point in the history
* Gateways result status bug is fixed.
  • Loading branch information
Sina-Soltani authored Apr 14, 2020
1 parent db0ddb9 commit cd6ac5e
Show file tree
Hide file tree
Showing 20 changed files with 42 additions and 36 deletions.
2 changes: 1 addition & 1 deletion samples/Parbad.Sample.Mvc/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<div class="text-center">
<h1 class="display-4">Parbad Demo</h1>
<br />
<a href="@Url.Action("PayRequest", "Payment")" class="btn btn-primary btn-lg">Make a payment</a>
<a href="@Url.Action("Pay", "Payment")" class="btn btn-primary btn-lg">Make a payment</a>
<a href="@Url.Action("Refund", "Payment")" class="btn btn-primary btn-lg">Refund a payment</a>
</div>
4 changes: 2 additions & 2 deletions samples/Parbad.Sample.Mvc/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@Html.ActionLink("Parbad Demo", "PayRequest", "Payment", new { area = "" }, new { @class = "navbar-brand" })
@Html.ActionLink("Parbad Demo", "Pay", "Payment", new { area = "" }, new { @class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Make a payment", "PayRequest", "Payment")</li>
<li>@Html.ActionLink("Make a payment", "Pay", "Payment")</li>
<li>@Html.ActionLink("Refund a payment", "Refund", "Payment")</li>
</ul>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/Parbad.AspNetCore/Parbad.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<VersionPrefix>1.0.4</VersionPrefix>
<VersionPrefix>1.0.5</VersionPrefix>
<Authors>Sina Soltani</Authors>
<Copyright>Copyright © Sina Soltani 2016</Copyright>
<PackageLicenseUrl></PackageLicenseUrl>
Expand All @@ -18,7 +18,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>Code improvement.</PackageReleaseNotes>
<PackageReleaseNotes>Bug Ticket #71 is fixed.</PackageReleaseNotes>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
4 changes: 2 additions & 2 deletions src/Parbad.Gateway/IdPay/src/Parbad.Gateway.IdPay.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.0</TargetFrameworks>
<VersionPrefix>1.0.1</VersionPrefix>
<VersionPrefix>1.0.2</VersionPrefix>
<LangVersion>latest</LangVersion>
<Authors>Sina Soltani</Authors>
<Copyright>Copyright © Sina Soltani 2016</Copyright>
Expand All @@ -16,7 +16,7 @@
<Description>IDPay.ir Gateway for Parbad project.

For more information see: https://www.nuget.org/packages/Parbad/</Description>
<PackageReleaseNotes>Newtonsoft.Json is upgraded to version 11.0.1.</PackageReleaseNotes>
<PackageReleaseNotes>Bug Ticket #71 is fixed.</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Parbad.Gateway/PayIr/src/Parbad.Gateway.PayIr.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.0</TargetFrameworks>
<VersionPrefix>1.1.0</VersionPrefix>
<VersionPrefix>1.1.1</VersionPrefix>
<LangVersion>latest</LangVersion>
<Authors>Sina Soltani</Authors>
<Copyright>Copyright © Sina Soltani 2016</Copyright>
Expand All @@ -16,7 +16,7 @@
<Description>Pay.ir Gateway for Parbad project.

For more information see: https://www.nuget.org/packages/Parbad/</Description>
<PackageReleaseNotes>Verify Response Additional Data (ex. masked card number) are now included in the result object.</PackageReleaseNotes>
<PackageReleaseNotes>Bug Ticket #71 is fixed.</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Parbad\Parbad.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.0</TargetFrameworks>
<VersionPrefix>1.0.3</VersionPrefix>
<VersionPrefix>1.0.4</VersionPrefix>
<LangVersion>latest</LangVersion>
<Authors>Sina Soltani</Authors>
<Copyright>Copyright © Sina Soltani 2016</Copyright>
Expand All @@ -16,7 +16,7 @@
<Description>ZarinPal Gateway for Parbad project.

For more information see: https://github.com/Sina-Soltani/Parbad</Description>
<PackageReleaseNotes>The bug for ticket #62 is fixed.</PackageReleaseNotes>
<PackageReleaseNotes>Bug Ticket #71 is fixed.</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/Parbad.Mvc/Parbad.Mvc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<VersionPrefix>2.0.3</VersionPrefix>
<VersionPrefix>2.0.4</VersionPrefix>
<LangVersion>latest</LangVersion>
<Authors>Sina Soltani</Authors>
<Description>ASP.NET MVC 4 and 5 integration for Parbad project.
Expand All @@ -20,6 +20,7 @@ For more information see: https://www.nuget.org/packages/Parbad/</Description>
<PackageTags>parbad mvc 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>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
3 changes: 2 additions & 1 deletion src/Parbad.Owin/Parbad.Owin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<VersionPrefix>1.0.2</VersionPrefix>
<VersionPrefix>1.0.3</VersionPrefix>
<LangVersion>latest</LangVersion>
<Authors>Sina Soltani</Authors>
<Description>Owin integration for Parbad project.
Expand All @@ -18,6 +18,7 @@ For more information see: https://www.nuget.org/packages/Parbad/</Description>
<PackageTags>parbad owin webforms 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>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
4 changes: 2 additions & 2 deletions src/Parbad.Storage/Cache/src/Parbad.Storage.Cache.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<PackageId>Parbad.Storage.Cache</PackageId>
<VersionPrefix>1.0.1</VersionPrefix>
<VersionPrefix>1.0.2</VersionPrefix>
<LangVersion>latest</LangVersion>
<TargetFrameworks>netstandard2.0;netcoreapp3.0</TargetFrameworks>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
Expand All @@ -17,7 +17,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Authors>Sina Soltani</Authors>
<Product>Parbad.Storage.Cache</Product>
<PackageReleaseNotes>Targeting .NETCORE3.x is added.</PackageReleaseNotes>
<PackageReleaseNotes>Bug Ticket #71 is fixed.</PackageReleaseNotes>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<PackageId>Parbad.Storage.EntityFrameworkCore</PackageId>
<VersionPrefix>1.0.3</VersionPrefix>
<VersionPrefix>1.0.4</VersionPrefix>
<LangVersion>latest</LangVersion>
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
Expand All @@ -17,7 +17,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Authors>Sina Soltani</Authors>
<Product>Parbad.Storage.EntityframeworkCore</Product>
<PackageReleaseNotes>EF CORE implementation of StorageManager is added.</PackageReleaseNotes>
<PackageReleaseNotes>Bug Ticket #71 is fixed.</PackageReleaseNotes>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public static AsanPardakhtCallbackResult CreateCallbackResult(
{
verifyResult = new PaymentVerifyResult
{
IsSucceed = false,
Status = PaymentVerifyResultStatus.Failed,
TrackingNumber = context.Payment.TrackingNumber,
TransactionCode = rrn,
Message = message
Expand Down Expand Up @@ -253,7 +253,7 @@ public static PaymentVerifyResult CreateSettleResult(

var verifyResult = new PaymentVerifyResult
{
IsSucceed = isSucceed,
Status = isSucceed ? PaymentVerifyResultStatus.Succeed : PaymentVerifyResultStatus.Failed,
TransactionCode = callbackResult.Rrn,
Message = message
};
Expand Down
6 changes: 3 additions & 3 deletions src/Parbad/Gateway/IranKish/Internal/IranKishHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static IranKishCallbackResult CreateCallbackResult(
{
TrackingNumber = invoiceNumber,
TransactionCode = referenceId,
IsSucceed = false,
Status = PaymentVerifyResultStatus.Failed,
Message = translatedMessage
};
}
Expand Down Expand Up @@ -168,7 +168,7 @@ public static PaymentVerifyResult CreateVerifyResult(
{
TrackingNumber = callbackResult.InvoiceNumber,
TransactionCode = callbackResult.ReferenceId,
IsSucceed = false,
Status = PaymentVerifyResultStatus.Failed,
Message = messagesOptions.InvalidDataReceivedFromGateway
};
}
Expand All @@ -183,7 +183,7 @@ public static PaymentVerifyResult CreateVerifyResult(
{
TrackingNumber = callbackResult.InvoiceNumber,
TransactionCode = callbackResult.ReferenceId,
IsSucceed = true,
Status = PaymentVerifyResultStatus.Succeed,
Message = translatedMessage
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/Parbad/Gateway/Mellat/Internal/MellatHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public static PaymentVerifyResult CreateSettleResult(string webServiceResponse,

return new PaymentVerifyResult
{
IsSucceed = isSuccess,
Status = isSuccess ? PaymentVerifyResultStatus.Succeed : PaymentVerifyResultStatus.Failed,
TransactionCode = callbackResult.SaleReferenceId,
Message = message,
};
Expand Down Expand Up @@ -223,7 +223,7 @@ public static PaymentRefundResult CreateRefundResult(string webServiceResponse,

return new PaymentRefundResult
{
IsSucceed = isSuccess,
Status = isSuccess ? PaymentRefundResultStatus.Succeed : PaymentRefundResultStatus.Failed,
Message = message
};
}
Expand Down
8 changes: 6 additions & 2 deletions src/Parbad/Gateway/Melli/Internal/MelliHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static MelliCallbackResult CreateCallbackResult(InvoiceContext context, H
};
}

public static PaymentVerifyResult CreateVerifyResult(string token, MelliApiVerifyResult result, MessagesOptions messagesOptions)
public static PaymentVerifyResult CreateVerifyResult(MelliApiVerifyResult result, MessagesOptions messagesOptions)
{
if (result == null)
{
Expand All @@ -125,9 +125,13 @@ public static PaymentVerifyResult CreateVerifyResult(string token, MelliApiVerif
message = MelliVerifyResultTranslator.Translate(result.ResCode, messagesOptions);
}

var status = result.ResCode == SuccessCode
? PaymentVerifyResultStatus.Succeed
: PaymentVerifyResultStatus.Failed;

return new PaymentVerifyResult
{
IsSucceed = result.ResCode == SuccessCode,
Status = status,
TransactionCode = result.RetrivalRefNo,
Message = message
};
Expand Down
2 changes: 1 addition & 1 deletion src/Parbad/Gateway/Melli/MelliGateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public override async Task<IPaymentVerifyResult> VerifyAsync(InvoiceContext cont

var result = await PostJsonAsync<MelliApiVerifyResult>(MelliHelper.ServiceVerifyUrl, data.JsonDataToVerify, cancellationToken).ConfigureAwaitFalse();

return MelliHelper.CreateVerifyResult(data.Token, result, _messageOptions.Value);
return MelliHelper.CreateVerifyResult(result, _messageOptions.Value);
}

/// <inheritdoc />
Expand Down
2 changes: 1 addition & 1 deletion src/Parbad/Gateway/ParbadVirtual/ParbadVirtualGateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public override Task<IPaymentVerifyResult> VerifyAsync(InvoiceContext context, C

return new PaymentVerifyResult
{
IsSucceed = isSucceed,
Status = isSucceed ? PaymentVerifyResultStatus.Succeed : PaymentVerifyResultStatus.Failed,
TransactionCode = transactionCode,
Message = message
}.ToInterfaceAsync();
Expand Down
4 changes: 2 additions & 2 deletions src/Parbad/Gateway/Parsian/Internal/ParsianHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public static PaymentVerifyResult CreateVerifyResult(string webServiceResponse,

var result = new PaymentVerifyResult
{
IsSucceed = isSucceed,
Status = isSucceed ? PaymentVerifyResultStatus.Succeed : PaymentVerifyResultStatus.Failed,
TransactionCode = rrn,
Message = message
};
Expand Down Expand Up @@ -234,7 +234,7 @@ public static PaymentRefundResult CreateRefundResult(string webServiceResponse,

var result = new PaymentRefundResult
{
IsSucceed = status == "0",
Status = status == "0" ? PaymentRefundResultStatus.Succeed : PaymentRefundResultStatus.Failed,
Message = message
};

Expand Down
4 changes: 2 additions & 2 deletions src/Parbad/Gateway/Pasargad/Internal/PasargadHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public static PaymentVerifyResult CreateVerifyResult(string webServiceResponse,

return new PaymentVerifyResult
{
IsSucceed = isSucceed,
Status = isSucceed ? PaymentVerifyResultStatus.Succeed : PaymentVerifyResultStatus.Failed,
TransactionCode = callbackResult.TransactionId,
Message = message
};
Expand Down Expand Up @@ -243,7 +243,7 @@ public static PaymentRefundResult CreateRefundResult(string webServiceResponse,

return new PaymentRefundResult
{
IsSucceed = isSucceed,
Status = isSucceed ? PaymentRefundResultStatus.Succeed : PaymentRefundResultStatus.Failed,
Message = message
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/Parbad/Gateway/Saman/Internal/SamanHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static PaymentVerifyResult CreateVerifyResult(string webServiceResponse,

return new PaymentVerifyResult
{
IsSucceed = isSuccess,
Status = isSuccess ? PaymentVerifyResultStatus.Succeed : PaymentVerifyResultStatus.Failed,
TransactionCode = callbackResult.TransactionId,
Message = message
};
Expand Down Expand Up @@ -139,7 +139,7 @@ public static PaymentRefundResult CreateRefundResult(string webServiceResponse,

return new PaymentRefundResult
{
IsSucceed = isSucceed,
Status = isSucceed ? PaymentRefundResultStatus.Succeed : PaymentRefundResultStatus.Failed,
Message = message
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/Parbad/Parbad.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<VersionPrefix>3.3.2</VersionPrefix>
<VersionPrefix>3.3.3</VersionPrefix>
<Authors>Parbad Sina Soltani</Authors>
<Description>Parbad is a free and open-source integrated online payment library which helps developers and site owners to add the online payment ability to their websites. It provides an easy solution to perform payment request, verify a payment and refund a paid payment.
It supports the most known online payment providers in Iran such as Mellat, Melli, Parsian, Tejarat, Saman, Pasargad and Asan Pardakht.
Expand All @@ -20,7 +20,7 @@ More information: https://github.com/Sina-Soltani/Parbad
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageTags>parbad Payment Gateway virtual virtual-gateway Bank Iran Shetab IranKish Mellat Melli Sadad Parsian Pasargad Saman Asan-Pardakht پرداخت درگاه بانک ایران شتاب ایران-کیش ملت ملی سداد پارسیان پاسارگاد سامان آسان-پرداخت</PackageTags>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReleaseNotes>Code improvement.</PackageReleaseNotes>
<PackageReleaseNotes>Bug Ticket #71 is fixed.</PackageReleaseNotes>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down

0 comments on commit cd6ac5e

Please sign in to comment.