Skip to content

Commit

Permalink
Feature/354 update saman (#370)
Browse files Browse the repository at this point in the history
Updated Saman gateway to the documentation v3.2
  • Loading branch information
Sina-Soltani committed Sep 24, 2023
1 parent a7a7a90 commit b23a3ce
Show file tree
Hide file tree
Showing 26 changed files with 637 additions and 802 deletions.
4 changes: 2 additions & 2 deletions src/Parbad.Gateway/IranKish/src/IranKishGateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public override async Task<IPaymentRequestResult> RequestAsync(Invoice invoice,
var data = IranKishHelper.CreateRequestData(invoice, account);

var result = await _httpClient
.PostJsonAsync<IranKishTokenResult>(_gatewayOptions.ApiTokenUrl, data, cancellationToken)
.PostJsonAsync<IranKishTokenResult>(_gatewayOptions.ApiTokenUrl, data, cancellationToken: cancellationToken)
.ConfigureAwaitFalse();

return IranKishHelper.CreateRequestResult(result, _httpContextAccessor.HttpContext, account, _gatewayOptions, _messageOptions.Value);
Expand Down Expand Up @@ -106,7 +106,7 @@ public override async Task<IPaymentVerifyResult> VerifyAsync(InvoiceContext cont
};

var result = await _httpClient
.PostJsonAsync<IranKishVerifyResult>(_gatewayOptions.ApiVerificationUrl, data, cancellationToken)
.PostJsonAsync<IranKishVerifyResult>(_gatewayOptions.ApiVerificationUrl, data, cancellationToken: cancellationToken)
.ConfigureAwaitFalse();

return IranKishHelper.CreateVerifyResult(result, _messageOptions.Value);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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.

namespace Parbad.Gateway.Saman.Internal.Models;

internal class SamanCallbackResponse
{
public string? MID { get; set; }

public string? State { get; set; }

public string? Status { get; set; }

public string? Rrn { get; set; }

public string? RefNum { get; set; }

public string? ResNum { get; set; }

public string? TerminalId { get; set; }

public string? Amount { get; set; }

public string? Wage { get; set; }

public string? TraceNo { get; set; }

public string? SecurePan { get; set; }

public string? HashedCardNumber { get; set; }
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// 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.

namespace Parbad.Gateway.Saman.Internal.Models;

internal class SamanReverseRequest
{
public string TerminalNumber { get; set; }

public string RefNum { get; set; }
}
22 changes: 22 additions & 0 deletions src/Parbad/src/Gateway/Saman/Internal/Models/SamanTokenRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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 Newtonsoft.Json;

namespace Parbad.Gateway.Saman.Internal.Models;

internal class SamanTokenRequest
{
[JsonProperty("action")]
public string Action { get; set; }

public string TerminalId { get; set; }

public long Amount { get; set; }

public string ResNum { get; set; }

public CallbackUrl RedirectUrl { get; set; }

public string CellNumber { get; set; }
}
15 changes: 15 additions & 0 deletions src/Parbad/src/Gateway/Saman/Internal/Models/SamanTokenResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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.

namespace Parbad.Gateway.Saman.Internal.Models;

internal class SamanTokenResponse
{
public int Status { get; set; }

public string Token { get; set; }

public string ErrorCode { get; set; }

public string ErrorDesc { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// 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.

namespace Parbad.Gateway.Saman.Internal.Models;

internal class SamanVerificationAndRefundResponse
{
public TransactionDetail TransactionDetail { get; set; }

public int ResultCode { get; set; }

public string ResultDescription { get; set; }

public bool Success { get; set; }
}

internal class TransactionDetail
{
public string Rrn { get; set; }

public string RefNum { get; set; }

public string MaskedPan { get; set; }

public string HashedPan { get; set; }

public long TerminalNumber { get; set; }

public long OrginalAmount { get; set; }

public long AffectiveAmount { get; set; }

public string StraceDate { get; set; }

public string StraceNo { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// 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.

namespace Parbad.Gateway.Saman.Internal.Models;

internal class SamanVerificationRequest
{
public string RefNum { get; set; }

public string TerminalNumber { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,22 @@

using Parbad.Options;

namespace Parbad.Gateway.Saman.Internal.ResultTranslators
namespace Parbad.Gateway.Saman.Internal.ResultTranslators;

internal static class SamanResultTranslator
{
internal static class SamanResultTranslator
public static string Translate(string result, MessagesOptions options)
{
public static string Translate(long result, MessagesOptions options)
return result switch
{
if (result >= 0)
{
return "تراکنش با موفقیت انجام گردید";
}

return result switch
{
-1 => "خطای داخلی شبکه مالی",
-2 => "سپرده ها برابر نیستند",
-3 => "ورودی ها حاوی کاراکترهای غیرمجاز هستند",
-4 => "کد پذیرنده و یا کلمه عبور آن اشتباه است",
-5 => "Database Exception",
-6 => "سند قبلا برگشت کامل یافته است",
-7 => "رسید دیجیتالی تهی است",
-8 => "طول ورودی ها بیشتر از حد مجاز است",
-9 => "وجود کاراکترهای غیرمجاز در مبلغ برگشتی",
-10 => "رسید دیجیتالی حاوی کاراکترهای غیرمجاز است",
-11 => "طول ورودی ها کمتر از حد مجاز است",
-12 => "مبلغ برگشتی منفی است",
-13 => "مبلغ برگشتی برای برگشت جزئی بیش از مبلغ برگشت نخورده رسیده دیجیتالی است",
-14 => "چنین تراکنشی تعریف نشده است",
-15 => "مبلغ برگشتی بصورت اعشاری داده شده است",
-16 => "خطای داخلی سیستم",
-17 => "برگشت زدن جزئی تراکنشی که با کارتی غیر از بانک سامان انجام شده است",
-18 => "IP Address پذیرنده نامعتبر است",
_ => $"{options.UnexpectedErrorText} Response: {result}"
};
}
"0" => options.PaymentSucceed,
"2" => "درخواست تکراری می باشد",
"-2" => "تراکنش یافته نشد",
"-6" => "بیش از نیم ساعت از زمان اجرای تراکنش گذشته است.",
"-104" => "ترمینال ارسال ی غیرفعا ل م ی باشد",
"-105" => "کد پذیرنده و یا کلمه عبور آن اشتباه است",
"-106" => "آدرس آی پ ی درخواست ی غی ر مجاز می باشد",
_ => $"{options.UnexpectedErrorText} Response: {result}"
};
}
}

This file was deleted.

Loading

0 comments on commit b23a3ce

Please sign in to comment.