Payzippy Payment Gateway Integration in ASP.NET/MVC C#

Payzippy is the newest star in the Indian payment gateway, Developed by Flipkart One of the most popular and trusted e-commerce portal of I...

Payzippy is the newest star in the Indian payment gateway, Developed by Flipkart One of the most popular and trusted e-commerce portal of India. As flipkart is a very experienced e-commerce portal they are very well versed with each and every pain and loopholes of Indian payment gateway market and with this very lucrative launch offer it is a very viable solution for most of the websites.

Payzippy is providing the SDK for Java and PHP developer with supports for some very popular e commerce packages like Magento.
But still no SDK for ASP.NET/MVC platform. But Using Payzippy Rest API (JSON) , We can create Payment Integration in ASP.NET.

Prerequisites for Payzippy payment gateway integration in Asp.net/Asp.net MVC
First you have to register with PayZippy and get 

1. MID (merchant_id)
2. Secure key (used to determine hash)
3. Secure key id (merchant_key_id)



.CS File Code (Payzippy Asp.net payment gateway )

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Cryptography;
using System.Text;

public partial class PayzippyPaymentGatewayIntegration : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected PayzippyPaymentGatewayIntegration()
        {
            this.Init += Charging_Init;
            Main();
        }
       private void Charging_Init(object sender, EventArgs e)
        {
            this.EnableViewState = false;
        }
       private static string secretKey = "KEY_KEY_KEY_KEY_KEY";
        private static string generateSHA256(String input)
        {
            SHA256Managed crypt = new SHA256Managed();
            string hash = String.Empty;
            byte[] crypto = crypt.ComputeHash(Encoding.ASCII.GetBytes(input), 0, Encoding.ASCII.GetByteCount(input));
            foreach (byte bit in crypto)
            {
                hash += bit.ToString("x2");
            }
            return hash;
        }
        static string GenHash(Dictionary<string, string> chargingParams)
        {
            // Acquire keys and sort them.
            List<string> list = new List<string>(chargingParams.Keys);
            list.Sort();
            StringBuilder stringForHash = new StringBuilder();
            // Loop through keys.
            foreach (var key in list)
            {
                stringForHash.Append(chargingParams[key] + '|');
            }
            stringForHash.Append(secretKey);
            return generateSHA256(stringForHash.ToString());
        }
        public Dictionary<string, string> chargingParams;
        private void Main()
        {
            var currentTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;

            this.chargingParams = new Dictionary<string, string>();
            chargingParams.Add("merchant_id", "test"); //Your MID issued by PayZippy.
            chargingParams.Add("buyer_email_address", "email@gmail.com"); // Email Address
            chargingParams.Add("merchant_transaction_id", "PAY_" + currentTime); //Your Transaction Id
            chargingParams.Add("transaction_type", "SALE"); //This is the default Value.
            chargingParams.Add("transaction_amount", "10000"); //Amount must be in paise. So, 1 Rupee= 100.
            chargingParams.Add("payment_method", "CREDIT"); // CREDIT,DEBIT,EMI,NET
            chargingParams.Add("bank_name", ""); //Bank Name required in case of EMI/NET.
            chargingParams.Add("emi_months", "0"); // Emi Months in case of EMI.
            chargingParams.Add("currency", "INR"); //INR is default.
            chargingParams.Add("ui_mode", "IFRAME"); //REDIRECT/IFRAME.
            chargingParams.Add("hash_method", "SHA256"); //MD5, SHA256
            chargingParams.Add("merchant_key_id", "payment"); //This is the default value.
            chargingParams.Add("timegmt", currentTime.ToString());
            chargingParams.Add("callback_url", "http://yoursite.com/bus/default.aspx");
            chargingParams.Add("hash", GenHash(chargingParams));

            StringBuilder builder = new StringBuilder();
            builder.Append("https://www.payzippy.com/payment/api/charging/v1?");
            foreach (var entry in chargingParams)
            {
                builder.AppendFormat("{0}={1}&", entry.Key, entry.Value);
            }
            Console.WriteLine(builder.ToString());

        }


    }




.ASPX File Code(Design code)


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PayzippyPaymentGatewayIntegration.aspx.cs" Inherits="PayzippyPaymentGatewayIntegration" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" action="https://www.payzippy.com/payment/api/charging/v1" method="post" runat="server">
    <div>
          <div>
                <%
                    var url = "https://www.payzippy.com/payment/api/charging/v1?";
                    foreach (var entry in chargingParams)
                    {
                %>
                <input type="hidden" name="<%=entry.Key %>" value="<%=entry.Value %>" />
                <%
                        url += entry.Key + "=" + entry.Value + "&";
                        // do something with entry.Value or entry.Key
                    }

                %>

                <input type="submit" />
            </div>
            <iframe width="500" height="500" src="<%=url %>"></iframe>
    </div>
    </form>
       <script>
           var x = document.getElementById("__VIEWSTATE");
           x.parentNode.removeChild(x);
    </script>
</body>
</html>

Payzippy use Rest API with support for JSON , we can use it in ASP.net to integrate it. This a very good tutorial on it. Full Source Download
In the same way you can integrate Payzippy payment gateway with Asp.net MVC also.

Related

Payzippy 559517132129479053

Post a comment

emo-but-icon

Follow Us

Recent

Comments

Donate

Side Ads

Text Widget

Connect Us

Sql Server 2017 Interview Questions
Sql Server Basic Interview Query Set-1
Sql Server Basic Interview Query Set-2
Sql Server Date-Time Interview Query SET-3
Sql Server Salary Interview Query SET-4
Sql Server Group By Interview Query SET-5
Sql Server Join Interview Query SET-6
Sql Server Tricky Join Interview Query SET-7
Sql Server DDL Interview Query SET-8
Small but very Tricky Sql Server Query SET-9
Very Much Tricky Query (not 4 fresher)SET-10
Sql Server Complex Interview Query SET-11
Sql Server Datatype Interview Questions
Sql Server View Interview Questions
Sql Server Index Interview Questions
TCS Tricky Sql Interview Queries
HCL Sql Interview Queries
Sql Server SP Interview Questions
Sql Server Trigger Interview Questions
Sql Server Temp Table Interview Questions
Sql Server 2016 Interview Questions
Sql Server Performance Tuning Interview Q.
Sql Server Constraints Interview Questions
Sql Server Storage/Size Interview Questions
Sql Server Very Basic Interview Questions
Sql Server Quiz for Fresher
Sql Server Icon Quiz for All
Sql Server 300+ Theoretical Interview Questions
Sql Server Complete Set

ASP.NET AND JQUERY INTERVIEW QUESTION
ASP.NET: Web Config Interview Question
ASP.NET: View State Interview Question
ASP.NET: Session Interview Question
ASP.NET: Session Interview Question 
ASP.NET: Security Interview Question
ASP.NET: Catching Interview Question
C# OOPS Interview Question
MORE Interview Question
JQUERY: Interview Question Set-1
JQUERY: Interview Question Set-2
JAVA-SCRIPT: Interview Question Set-1
JAVA-SCRIPT: Interview Question Set-2
ASP.NET MVC: Interview Question Set-1

POPULAR POSTS
10 MOST DIFFICULT INTERVIEW QUESTIONS
5 BEST INTERVIEW TIPS
YOUR 10 MISTAKE DURING INTERVIEW
2016 TOP 20 GROUP DISCUSSION TOPICS
HOW SQL PERFORMANCE AFFECTED BY DATATYPE
item