Codecell.Getway.Zarinpal 6.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Codecell.Getway.Zarinpal --version 6.0.2                
NuGet\Install-Package Codecell.Getway.Zarinpal -Version 6.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Codecell.Getway.Zarinpal" Version="6.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Codecell.Getway.Zarinpal --version 6.0.2                
#r "nuget: Codecell.Getway.Zarinpal, 6.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Codecell.Getway.Zarinpal as a Cake Addin
#addin nuget:?package=Codecell.Getway.Zarinpal&version=6.0.2

// Install Codecell.Getway.Zarinpal as a Cake Tool
#tool nuget:?package=Codecell.Getway.Zarinpal&version=6.0.2                

Codecell.Getway.Zarinpal

A light weight library to help online payment using Zarinpal for net6 and net7 web application.

Installation

You can download the latest version of Codecell.Getway.Zarinpal from Github repository. To install via nuget:

Install-Package Codecell.Getway.Zarinpal -Version 6.0.0
Install-Package Codecell.Getway.Zarinpal -Version 7.0.0

Install from Nuget directly.

How to use

Register ZarinpalService to project container in program.cs file for net6 and net7:

using CodeCellZarinpalV7;

builder.Services.AddCodecellZarinpalGetway();

then register this service to DI and use it, for example in HomeController:

using CodeCellZarinpalV7;
...
    public class HomeController : Controller
    {
         private readonly IZarinpalService _zarinpalService;

        public HomeController(IZarinpalService zarinpalService)
        {
            _zarinpalService = zarinpalService;
        }

        public IActionResult Index()
        {
            return View();
        }
        public async Task<IActionResult> ZarinpalPayment()
        {
            long orderId = 278;
            //get order detail from db with orderId
            string callbackUrl = $"{Request.Scheme}://{Request.Host}/codecell-pay/{orderId}";
            var requestDto = new ZarinpalRequestDto
            {
                Amount = 100_000,////get it from db via orderId
                CallbackUrl = callbackUrl,
                MerchantId = "4ced0a1e-4ad8-4309-9668-3ea3ae8e8897",
                Description="test",
                Mobile = "09217245937",
                Email = "codecell.ir@gmail.com"
            };
            var requestResult=await _zarinpalService.ZarinPalRequestPaymentAsync(requestDto);
            if (requestResult.IsSuccess)
            {
                return Redirect(requestResult.CallBackUrl);
            }
            return Json(requestResult);
        }

        [HttpGet("codecell-pay/{orderId}")]
        public async Task<IActionResult> CodeCellPayment(long orderId)
        {
            //get order detail from db with orderId
            string status = HttpContext.Request.Query["Status"].ToString();
            string authority = HttpContext.Request.Query["Authority"].ToString();
            var result = await _zarinpalService.ZarinPalVerifyPaymentAsync(new ZarinpalVerifyDto
            {
                Amount=100_000,//get it from db via orderId
                Authority=authority,
                Status=status,
                MerchantId= "4ced0a1e-4ad8-4309-9668-3ea3ae8e8897"
            });
            return Json(result);
        }
    }
...

Tutorial video

see the tutorial persian video here

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
7.0.2 234 11/26/2022
6.0.2 211 11/26/2022