在Asp.net Payzippy支付网关整合 [英] Payzippy Payment gateway Integration in Asp.net

查看:177
本文介绍了在Asp.net Payzippy支付网关整合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Payzippy是最新的支付网关在印度提供的服务之一。他们正在为PHP和Java,但仍然没有SDK的Asp.net平台SDK。我们如何整合它。

Payzippy is one of the latest payment gateway providing service in india. They are providing SDK for PHP and Java but still no SDK for Asp.net platform. How can we integrate it.

推荐答案

Payzippy使用REST API与JSON支持,我们可以用它在ASP.net整合它。这上有一个很好的教程。完整的源下载

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

在codeS I在CS文件中使用了

The codes i have used in CS file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Security.Cryptography;
public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
       protected Default2()
        {
            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://busnow.in/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());

        }

    }

codeS设计文件

Codes for design file

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

<!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>

我希望这将帮助!

这篇关于在Asp.net Payzippy支付网关整合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆