如何在Asp.net中集成柑橘支付网关查询API代码

时间:2015-10-12 07:35:33

标签: asp.net payment-gateway

我已经实施了Citrus Payment gatway请求/响应页面我对查询API集成感到震惊,我必须在代码中实现它吗?我必须给出的页面名称是什么?

这是柑橘给我实施查询api的指南。

http://developers.citruspay.com/api/miscellaneous/Enquiry.html#/

Request.aspx页面代码 -  {

                                    string formPostUrl = "https://sandbox.citruspay.com/sslperf/xyzdoman";

                                    string secret_key = "xxxxxxxxxxxxxxx";

                                    //Need to change with your Vanity URL Key from the citrus panel
                                    string vanityUrl = "xxxxxyy";
                                    //Should be unique for every transaction
                                    string merchantTxnId = System.DateTime.Now.ToString("yyyyMMddHHmmssffff");

                                    //Need to change with your Order Amount
                                    string orderAmount = "10";
                                    string currency = "INR";
                                    string data = vanityUrl + orderAmount + merchantTxnId + currency;

                                    //Need to change with your Return URL
                                    string returnURL = "http://www.xxxxxyy.com/Response.aspx";
                                    //Need to change with your Notify URL
                                    string notifyUrl = "http://www.xxxxxyy.com/Response.aspx";

                                    System.Security.Cryptography.HMACSHA1 myhmacsha1 = new System.Security.Cryptography.HMACSHA1(Encoding.ASCII.GetBytes(secret_key));
                                    System.IO.MemoryStream stream = new System.IO.MemoryStream(Encoding.ASCII.GetBytes(data));
                                    string securitySignature = BitConverter.ToString(myhmacsha1.ComputeHash(stream)).Replace("-", "").ToLower();
                                %>

Response.aspx页面代码 {

    string secret_key = "xxxxxxxxxxxxxxxxxxxxx";
         string data="";
         string txnId=Request["TxId"];
         string txnStatus=Request["TxStatus"]; 
         string amount=Request["amount"]; 
         string pgTxnId=Request["pgTxnNo"];
         string issuerRefNo=Request["issuerRefNo"]; 
         string authIdCode=Request["authIdCode"];
         string firstName=Request["firstName"];
         string lastName=Request["lastName"];
         string pgRespCode=Request["pgRespCode"];
         string zipCode=Request["addressZip"];
         string resSignature=Request["signature"];
         bool flag = true;
         if (txnId != null) {
             data += txnId;
         }
         if (txnStatus != null) {
             data += txnStatus;
         }
         if (amount != null) {
             data += amount;
         }
         if (pgTxnId != null) {
             data += pgTxnId;
         }
         if (issuerRefNo != null) {
             data += issuerRefNo;
         }
         if (authIdCode != null) {
             data += authIdCode;
         }
         if (firstName != null) {
             data += firstName;
         }
        if (lastName != null) {
             data += lastName;
         }
         if (pgRespCode != null) {
             data += pgRespCode;
         }
         if (zipCode != null) {
             data += zipCode;
         }
         System.Security.Cryptography.HMACSHA1 myhmacsha1 = new System.Security.Cryptography.HMACSHA1(Encoding.ASCII.GetBytes(secret_key));
         System.IO.MemoryStream stream = new System.IO.MemoryStream(Encoding.ASCII.GetBytes(data));
         string signature = BitConverter.ToString(myhmacsha1.ComputeHash(stream)).Replace("-", "").ToLower();

         if(resSignature !=null && !signature.Equals(resSignature)) {
             flag = false;
         }
         if (flag) {
%>
    Your Unique Transaction/Order Id : <%=txnId%><br/>
    Transaction Status : <%=txnStatus%><br/>
<% } else { %>
    <label width="125px;">Citrus Response Signature and Our (Merchant) Signature Mis-Mactch</label>
<% } %>

0 个答案:

没有答案