How To Get All Payments From Razorpay In Asp.Net MVC

In this article, we are getting or retrieving all paments from Razorpay in Asp.Net MVC.

I am using its NuGet Package named Razorpay In our .Net Application. if you don’t know How To Integrate Razorpay In Asp.Net MVC then click here.

we are getting all payments from Razorpay, you can filter it out also.but for the demonstration I get all payments in this article.

Now, create the GetPayments Method and add the following code into the GetPayments Method.

public ActionResult GetPayments()
            List<Payment> result = new List<Payment>();
                Dictionary<string, object> options = new Dictionary<string, object>();
                //supported option filters (from, to, count, skip)
                options.Add("count", 50);
                result = client.Payment.All(options);

            catch (Razorpay.Api.Errors.BadRequestError ex)

            catch (Exception ex)
            return View(result);

in the above code, I defined options Dictionary in which we store all options related to Payments. there are different options which you can use according to your requirement. you can get more details about it by clicking here.

here I only use the count which you have to give a number of payments to be fetched. The default value is 10. The maximum value is 100. you can use it for pagination, in combination with the Skip parameter. so our code will return 50 payments as we give 50 as a count option.

now create GetPayments.cshtml, and add the following code into it.

@using Razorpay.Api;
@model List<Payment>

    ViewBag.Title = "GetPayments";

<br />
<div class="row">

    <div class="col-md-12">

        <table class="table table-bordered">

                <th>Paymnet Id</th>

            @foreach (var item in Model)
                    @{var FinalAmount = Convert.ToInt32(item.Attributes["amount"]) / 100; }





here we display only few properties of Payment. you can fetch and display according to your needs.

The above code will produce output like below.



Submit a Comment

Your email address will not be published. Required fields are marked *


Select Categories