Skip to content

ImanX/zarinpal-dotNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZarinPal .NET SDK

Getting Started

Open your project and go to nuget then search Zarinpal when found it install library.

Requirement

4.5.1 .NET framework is Require

Example in Payment Request Page:

           ZarinPal.ZarinPal zarinpal = ZarinPal.ZarinPal.Get();

         String MerchantID = "71c705f8-bd37-11e6-aa0c-000c295eb8fc";
         String CallbackURL = "http://localhost:59701/VerficationPage.aspx";
         long Amount = 100;
         String Description = "This is Test Payment";

         ZarinPal.PaymentRequest pr = new ZarinPal.PaymentRequest(MerchantID, Amount, CallbackURL, Description);

         zarinpal.EnableSandboxMode();
         var res = zarinpal.InvokePaymentRequest(pr);
         if (res.Status == 100) {
             Response.Redirect(res.PaymentURL);
         }
          

Example in Payment Verification Page:

            var collection = HttpUtility.ParseQueryString(this.ClientQueryString);
            String Status = collection["Status"];

            if (Status != "OK")
            {
                Response.Write("<script>alert('Purchase unsuccessfully')</script>");
                return;
            }

            var zarinpal = ZarinPal.ZarinPal.Get();

            String Authority = collection["Authority"];
            String MerchantID = "71c705f8-bd37-11e6-aa0c-000c295eb8fc";
            long Amount = 100;

            var pv = new ZarinPal.PaymentVerification(MerchantID, Amount, Authority);
            var verificationResponse = zarinpal.InvokePaymentVerification(pv);
            if (verificationResponse.Status == 100)
            {
                Response.Write(String.Format("<script>alert('Purchase successfully with ref transaction {0}')</script>", verificationResponse.RefID));
            }
            else {

                Response.Write(String.Format("<script>alert('Purchase unsuccessfully Error code is: {0}')</script>",verificationResponse.Status));

            }
          

Releases

No releases published

Packages

No packages published