Zarinpal 3.0.1

درگاه پرداخت زرین پال
Zarinpal payment gateway

Install-Package Zarinpal -Version 3.0.1
dotnet add package Zarinpal --version 3.0.1
<PackageReference Include="Zarinpal" Version="3.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Zarinpal --version 3.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

public class HomeController : Controller
{
private readonly Payment _payment;
private readonly Authority _authority;
private readonly Transactions _transactions;

public HomeController()
{
    var expose = new Expose();
    _payment = expose.CreatePayment();
    _authority = expose.CreateAuthority();
    _transactions = expose.CreateTransactions();
}
public async Task<IActionResult> Index()
{
    return View();
}
/// <summary>
/// ﻓﺮﺍﻳﻨﺪ ﺧﺮﻳﺪ
/// </summary>
/// <returns></returns>
public async Task<IActionResult> Request()
{
    var result = await _payment.Request(new DtoRequest()
    {
        Mobile = "09121112222",
        CallbackUrl = "https://localhost:44310/home/validate",
        Description = "توضیحات",
        Email = "farazmaan@outlook.com",
        Amount = 1000000,
        MerchantId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
    }, ZarinPal.Class.Payment.Mode.sandbox);
    return Redirect($"https://sandbox.zarinpal.com/pg/StartPay/{result.Authority}");
}

/// <summary>
/// ﻓﺮﺍﻳﻨﺪ ﺧﺮﻳﺪ ﺑﺎ ﺗﺴﻮﻳﻪ ﺍﺷﺘﺮﺍﻛﻲ 
/// </summary>
/// <returns></returns>
public async Task<IActionResult> RequestWithExtra()
{
    var result = await _payment.Request(new DtoRequestWithExtra()
    {
        Mobile = "09121112222",
        CallbackUrl = "https://localhost:44310/home/validate",
        Description = "توضیحات",
        Email = "farazmaan@outlook.com",
        Amount = 1000000,
        MerchantId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
        AdditionalData = "{\"Wages\":{\"zp.1.1\":{\"Amount\":120,\"Description\":\" ﺗﻘﺴﻴﻢ \"}, \" ﺳﻮﺩ ﺗﺮﺍﻛﻨﺶ zp.2.5\":{\"Amount\":60,\"Description\":\" ﻭﺍﺭﻳﺰ \"}}} "
    }, ZarinPal.Class.Payment.Mode.sandbox);
    return Redirect($"https://sandbox.zarinpal.com/pg/StartPay/{result.Authority}");
}
/// <summary>
/// اعتبار سنجی خرید
/// </summary>
/// <param name="authority"></param>
/// <param name="status"></param>
/// <returns></returns>

public async Task<IActionResult> Validate(string authority, string status)
{
    var verification = await _payment.Verification(new DtoVerification
    {
        Amount = 1000000,
        MerchantId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
        Authority = authority
    }, Payment.Mode.sandbox);
    return View();
}

/// <summary>
/// ﺩﺭ ﺭﻭﺵ ﺍﻳﺠﺎﺩ ﺷﻨﺎﺳﻪ ﭘﺮﺩﺍﺧﺖ ﺑﺎ ﻃﻮﻝ ﻋﻤﺮ ﺑﺎﻻ ﻣﻤﻜﻦ ﺍﺳﺖ ﺣﺎﻟﺘﻲ ﭘﻴﺶ ﺁﻳﺪ ﻛﻪ ﺷﻤﺎ ﺑﻪ ﺗﻤﺪﻳﺪ ﺑﻴﺸﺘﺮ ﻃﻮﻝ ﻋﻤﺮ ﻳﻚ ﺷﻨﺎﺳﻪ ﭘﺮﺩﺍﺧﺖ ﻧﻴﺎﺯ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻴﺪ
/// ﺩﺭ ﺍﻳﻦ ﺻﻮﺭﺕ ﻣﻲ ﺗﻮﺍﻧﻴﺪ ﺍﺯ ﻣﺘﺪ زیر ﺍﺳﺘﻔﺎﺩﻩ ﻧﻤﺎﻳﻴﺪ 
/// </summary>
/// <returns></returns>
public async Task<IActionResult> RefreshAuthority()
{
    var refresh = await _authority.Refresh(new DtoRefreshAuthority
    {
        Authority = "",
        ExpireIn = 1,
        MerchantId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
    }, Payment.Mode.sandbox);
    return View();
}

/// <summary>
/// ﻣﻤﻜﻦ ﺍﺳﺖ ﺷﻤﺎ ﻧﻴﺎﺯ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻴﺪ ﻛﻪ ﻣﺘﻮﺟﻪ ﺷﻮﻳﺪ ﭼﻪ ﭘﺮﺩﺍﺧﺖ ﻫﺎﻱ ﺗﻮﺳﻂ ﻭﺏ ﺳﺮﻭﻳﺲ ﺷﻤﺎ ﺑﻪ ﺩﺭﺳﺘﻲ ﺍﻧﺠﺎﻡ ﺷﺪﻩ ﺍﻣﺎ ﻣﺘﺪ  ﺭﻭﻱ ﺁﻧﻬﺎ ﺍﻋﻤﺎﻝ ﻧﺸﺪﻩ
/// ، ﺑﻪ ﻋﺒﺎﺭﺕ ﺩﻳﮕﺮ ﺍﻳﻦ ﻣﺘﺪ ﻟﻴﺴﺖ ﭘﺮﺩﺍﺧﺖ ﻫﺎﻱ ﻣﻮﻓﻘﻲ ﻛﻪ ﺷﻤﺎ ﺁﻧﻬﺎ ﺭﺍ ﺗﺼﺪﻳﻖ ﻧﻜﺮﺩﻩ ﺍﻳﺪ ﺭﺍ ﺑﻪ PaymentVerification ﺷﻤﺎ ﻧﻤﺎﻳﺶ ﻣﻲ ﺩﻫﺪ.
/// </summary>
/// <returns></returns>

public async Task<IActionResult> Unverified()
{
    var refresh = await _transactions.GetUnverified(new DtoMerchant
    {
        MerchantId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
    }, Payment.Mode.sandbox);
    return View();
}

}

public class HomeController : Controller
{
private readonly Payment _payment;
private readonly Authority _authority;
private readonly Transactions _transactions;

public HomeController()
{
    var expose = new Expose();
    _payment = expose.CreatePayment();
    _authority = expose.CreateAuthority();
    _transactions = expose.CreateTransactions();
}
public async Task<IActionResult> Index()
{
    return View();
}
/// <summary>
/// ﻓﺮﺍﻳﻨﺪ ﺧﺮﻳﺪ
/// </summary>
/// <returns></returns>
public async Task<IActionResult> Request()
{
    var result = await _payment.Request(new DtoRequest()
    {
        Mobile = "09121112222",
        CallbackUrl = "https://localhost:44310/home/validate",
        Description = "توضیحات",
        Email = "farazmaan@outlook.com",
        Amount = 1000000,
        MerchantId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
    }, ZarinPal.Class.Payment.Mode.sandbox);
    return Redirect($"https://sandbox.zarinpal.com/pg/StartPay/{result.Authority}");
}

/// <summary>
/// ﻓﺮﺍﻳﻨﺪ ﺧﺮﻳﺪ ﺑﺎ ﺗﺴﻮﻳﻪ ﺍﺷﺘﺮﺍﻛﻲ 
/// </summary>
/// <returns></returns>
public async Task<IActionResult> RequestWithExtra()
{
    var result = await _payment.Request(new DtoRequestWithExtra()
    {
        Mobile = "09121112222",
        CallbackUrl = "https://localhost:44310/home/validate",
        Description = "توضیحات",
        Email = "farazmaan@outlook.com",
        Amount = 1000000,
        MerchantId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
        AdditionalData = "{\"Wages\":{\"zp.1.1\":{\"Amount\":120,\"Description\":\" ﺗﻘﺴﻴﻢ \"}, \" ﺳﻮﺩ ﺗﺮﺍﻛﻨﺶ zp.2.5\":{\"Amount\":60,\"Description\":\" ﻭﺍﺭﻳﺰ \"}}} "
    }, ZarinPal.Class.Payment.Mode.sandbox);
    return Redirect($"https://sandbox.zarinpal.com/pg/StartPay/{result.Authority}");
}
/// <summary>
/// اعتبار سنجی خرید
/// </summary>
/// <param name="authority"></param>
/// <param name="status"></param>
/// <returns></returns>

public async Task<IActionResult> Validate(string authority, string status)
{
    var verification = await _payment.Verification(new DtoVerification
    {
        Amount = 1000000,
        MerchantId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
        Authority = authority
    }, Payment.Mode.sandbox);
    return View();
}

/// <summary>
/// ﺩﺭ ﺭﻭﺵ ﺍﻳﺠﺎﺩ ﺷﻨﺎﺳﻪ ﭘﺮﺩﺍﺧﺖ ﺑﺎ ﻃﻮﻝ ﻋﻤﺮ ﺑﺎﻻ ﻣﻤﻜﻦ ﺍﺳﺖ ﺣﺎﻟﺘﻲ ﭘﻴﺶ ﺁﻳﺪ ﻛﻪ ﺷﻤﺎ ﺑﻪ ﺗﻤﺪﻳﺪ ﺑﻴﺸﺘﺮ ﻃﻮﻝ ﻋﻤﺮ ﻳﻚ ﺷﻨﺎﺳﻪ ﭘﺮﺩﺍﺧﺖ ﻧﻴﺎﺯ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻴﺪ
/// ﺩﺭ ﺍﻳﻦ ﺻﻮﺭﺕ ﻣﻲ ﺗﻮﺍﻧﻴﺪ ﺍﺯ ﻣﺘﺪ زیر ﺍﺳﺘﻔﺎﺩﻩ ﻧﻤﺎﻳﻴﺪ 
/// </summary>
/// <returns></returns>
public async Task<IActionResult> RefreshAuthority()
{
    var refresh = await _authority.Refresh(new DtoRefreshAuthority
    {
        Authority = "",
        ExpireIn = 1,
        MerchantId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
    }, Payment.Mode.sandbox);
    return View();
}

/// <summary>
/// ﻣﻤﻜﻦ ﺍﺳﺖ ﺷﻤﺎ ﻧﻴﺎﺯ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻴﺪ ﻛﻪ ﻣﺘﻮﺟﻪ ﺷﻮﻳﺪ ﭼﻪ ﭘﺮﺩﺍﺧﺖ ﻫﺎﻱ ﺗﻮﺳﻂ ﻭﺏ ﺳﺮﻭﻳﺲ ﺷﻤﺎ ﺑﻪ ﺩﺭﺳﺘﻲ ﺍﻧﺠﺎﻡ ﺷﺪﻩ ﺍﻣﺎ ﻣﺘﺪ  ﺭﻭﻱ ﺁﻧﻬﺎ ﺍﻋﻤﺎﻝ ﻧﺸﺪﻩ
/// ، ﺑﻪ ﻋﺒﺎﺭﺕ ﺩﻳﮕﺮ ﺍﻳﻦ ﻣﺘﺪ ﻟﻴﺴﺖ ﭘﺮﺩﺍﺧﺖ ﻫﺎﻱ ﻣﻮﻓﻘﻲ ﻛﻪ ﺷﻤﺎ ﺁﻧﻬﺎ ﺭﺍ ﺗﺼﺪﻳﻖ ﻧﻜﺮﺩﻩ ﺍﻳﺪ ﺭﺍ ﺑﻪ PaymentVerification ﺷﻤﺎ ﻧﻤﺎﻳﺶ ﻣﻲ ﺩﻫﺪ.
/// </summary>
/// <returns></returns>

public async Task<IActionResult> Unverified()
{
    var refresh = await _transactions.GetUnverified(new DtoMerchant
    {
        MerchantId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
    }, Payment.Mode.sandbox);
    return View();
}

}

Dependencies

This package has no dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
3.0.1 112 1/31/2020
2.0.4 5,204 1/25/2018
2.0.3 629 11/4/2017