protected void GetResponse() { String URL = ""; String vpc_TxnResponseCode = ""; String txtRefCode = ""; String ShoWName = ""; String stramt = ""; String ReceiptNo = ""; String vpc_avsResultCode = ""; String TranSactNo = ""; String ResponseCode = ""; String Amount = ""; String vpc_3DSstatus = ""; String vpc_3DSenrolled = ""; String vpc_AcqAVSRespCode = ""; try { Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Prepare to transact wth AmEx..."); // Create the VPCRequest object VPCRequest conn = new VPCRequest("https://vpos.amxvpos.com/vpcpay"); //conn.setSecureSecret("C12DC6FE16681E9DD3211D2BB0C0BBA2"); //Live conn.setSecureSecret("44DD98D32ECD3C1AA7F12A1D0F8B41EA"); // Process the response conn.process3PartyResponse(Page.Request.QueryString); // Check if the transaction was successful or if there was an error vpc_TxnResponseCode = conn.getResultField("vpc_TxnResponseCode", "Unknown"); // Set the display fields for the receipt with the result fields // Core Fields // Label_vpc_TxnResponseCode.Text = vpc_TxnResponseCode; txtRefCode = conn.getResultField("vpc_MerchTxnRef", "Unknown"); ShoWName = conn.getResultField("vpc_OrderInfo", "Unknown"); Amount = conn.getResultField("vpc_Amount", "Unknown"); ReceiptNo = conn.getResultField("vpc_ReceiptNo", "Unknown"); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("AmEx Receiot No. : " + ReceiptNo); //**************Safe Key and AAV Verification************// vpc_3DSenrolled = conn.getResultField("vpc_3DSenrolled", "Unknown"); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("vpc_3DSenrolled : " + vpc_3DSenrolled); vpc_AcqAVSRespCode = conn.getResultField("vpc_AcqAVSRespCode", "Unknown"); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("vpc_AcqAVSRespCode : " + vpc_AcqAVSRespCode); //***********************************************// // Address Verification / Advanced Address Verification vpc_avsResultCode = conn.getResultField("vpc_AVSResultCode", "Unknown"); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("AmEx transaction Auth result code: " + vpc_avsResultCode); // Perform the Capture if the Authorization was successful TranSactNo = conn.getResultField("vpc_TransactionNo", "Unknown"); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("AmEx transaction Auth response code: " + vpc_TxnResponseCode); string errtxnresponce = PaymentCodesHelper.getTxnResponseCodeDescription(vpc_TxnResponseCode); string errAVSResultCode = PaymentCodesHelper.getAVSDescription(vpc_avsResultCode); if (vpc_3DSenrolled == "Y") { vpc_3DSstatus = conn.getResultField("vpc_3DSstatus", "Unknown"); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("AmEx transaction Auth safe key code vpc_3DSstatus: " + vpc_3DSstatus); if (vpc_TxnResponseCode == "0" && (vpc_3DSstatus == "Y" || vpc_3DSstatus == "A")) { Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("AmEx authorization successful, starting capture..."); // Create a new VPCRequest Object and set the proxy details if required conn = new VPCRequest("https://vpos.amxvpos.com/vpcdps"); conn.setProxyHost(""); conn.setProxyUser(""); conn.setProxyPassword(""); conn.setProxyDomain(""); //test server // Add the Required Fields //conn.addDigitialOrderField("vpc_Version", "1"); //conn.addDigitialOrderField("vpc_AccessCode", "D30639FF"); //conn.addDigitialOrderField("vpc_Merchant", "TEST9824533848"); //conn.addDigitialOrderField("vpc_User", "kingdomama"); //conn.addDigitialOrderField("vpc_Password", "0password"); //conn.addDigitialOrderField("vpc_Command", "capture"); //live server conn.addDigitialOrderField("vpc_Version", "1"); conn.addDigitialOrderField("vpc_AccessCode", "0FE6FE77"); conn.addDigitialOrderField("vpc_Merchant", "9824533848"); conn.addDigitialOrderField("vpc_User", "kingdomama"); conn.addDigitialOrderField("vpc_Password", "0password"); conn.addDigitialOrderField("vpc_Command", "capture"); conn.addDigitialOrderField("vpc_MerchTxnRef", txtRefCode.Substring(0, txtRefCode.Length - 2) + "-C"); conn.addDigitialOrderField("vpc_TransNo", TranSactNo); conn.addDigitialOrderField("vpc_Amount", Amount); // Perform the transaction conn.sendRequest(); // Check if the transaction was successful or if there was an error ResponseCode = conn.getResultField("vpc_TxnResponseCode", "Unknown"); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("AmEx transaction Capture response code: " + ResponseCode); } } else { if (vpc_TxnResponseCode == "0" && vpc_AcqAVSRespCode == "M") { Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("AmEx authorization successful, starting capture..."); // Create a new VPCRequest Object and set the proxy details if required conn = new VPCRequest("https://vpos.amxvpos.com/vpcdps"); conn.setProxyHost(""); conn.setProxyUser(""); conn.setProxyPassword(""); conn.setProxyDomain(""); //test server // Add the Required Fields //conn.addDigitialOrderField("vpc_Version", "1"); //conn.addDigitialOrderField("vpc_AccessCode", "D30639FF"); //conn.addDigitialOrderField("vpc_Merchant", "TEST9824533848"); //conn.addDigitialOrderField("vpc_User", "kingdomama"); //conn.addDigitialOrderField("vpc_Password", "0password"); //conn.addDigitialOrderField("vpc_Command", "capture"); //live server conn.addDigitialOrderField("vpc_Version", "1"); conn.addDigitialOrderField("vpc_AccessCode", "0FE6FE77"); conn.addDigitialOrderField("vpc_Merchant", "9824533848"); conn.addDigitialOrderField("vpc_User", "kingdomama"); conn.addDigitialOrderField("vpc_Password", "0password"); conn.addDigitialOrderField("vpc_Command", "capture"); conn.addDigitialOrderField("vpc_MerchTxnRef", txtRefCode.Substring(0, txtRefCode.Length - 2) + "-C"); conn.addDigitialOrderField("vpc_TransNo", TranSactNo); conn.addDigitialOrderField("vpc_Amount", Amount); // Perform the transaction conn.sendRequest(); // Check if the transaction was successful or if there was an error ResponseCode = conn.getResultField("vpc_TxnResponseCode", "Unknown"); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("AmEx transaction Capture response code: " + ResponseCode); } } /*******************Payement Gateway Error Value Code**********************/ #region PG_DB if (vpc_TxnResponseCode != "0") { Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("PG_DB"); string bookingid = txtRefCode.Split('_')[1].ToString().Split('~')[0].ToString(); int i = GTICKBOL.Insert_Payment_DB(errtxnresponce, bookingid, "AMEX"); } else if (vpc_avsResultCode != "X" && vpc_avsResultCode != "Y") { Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("PG_DB"); string bookingid = txtRefCode.Split('_')[1].ToString().Split('~')[0].ToString(); int i = GTICKBOL.Insert_Payment_DB(errAVSResultCode, bookingid, "AMEX"); } #endregion PG_DB /*********************End******************************/ //convert amt int amt = (Convert.ToInt32(Amount)) / 100; stramt = amt.ToString(); GTICKBOL gb = new GTICKBOL(); GTICKV.LogEntry(txtRefCode.Split('_')[0], "Return From AMEX Payment Gateway, amt : " + stramt + ",recieptNO : " + ReceiptNo, "13", txtRefCode.Split('_')[1].Split('~')[0]); //***********Url for address Verification*********// //URL = "ReturnReceipt.aspx?tid=" + txtRefCode + "&sta=" + vpc_TxnResponseCode + "&amt=" + stramt + "&rec=" + ReceiptNo + "&ResultCode=" + vpc_avsResultCode; //************************************************// URL = "ReturnReceipt.aspx?tid=" + txtRefCode + "&sta=" + vpc_TxnResponseCode + "&amt=" + stramt + "&rec=" + ReceiptNo + "&Safecode=" + vpc_3DSstatus + "&response=" + vpc_AcqAVSRespCode + "&enroll=" + vpc_3DSenrolled; Response.Redirect(URL, false); } catch (Exception ex) { Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Error in AmEx Payment Response: " + ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { try { string transactionTypeCode, installments, transactionId, amount, exponent, currencyCode, merchantReferenceNo, status, eci, pgErrorCode, pgErrorDetail, pgErrorMsg, messageHash, messageHashBuf, messageHashClient; bool hashMatch = false; string URL = ""; //fill response from idbi transactionTypeCode = Request.Form["transaction_type_code"]; installments = Request.Form["installments"]; transactionId = Request.Form["transaction_id"]; amount = Request.Form["amount"]; exponent = Request.Form["exponent"]; currencyCode = Request.Form["currency_code"]; merchantReferenceNo = Request.Form["merchant_reference_no"]; status = Request.Form["status"]; eci = Request.Form["3ds_eci"]; pgErrorCode = Request.Form["pg_error_code"]; Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI: " + pgErrorCode); pgErrorDetail = Request.Form["pg_error_detail"]; Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI: " + pgErrorDetail); pgErrorMsg = Request.Form["pg_error_msg"]; Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI: " + pgErrorMsg); messageHash = Request.Form["message_hash"]; messageHashBuf = System.Configuration.ConfigurationManager.AppSettings["pgInstanceId"] + "|" + System.Configuration.ConfigurationManager.AppSettings["merchantId"] + "|" + transactionTypeCode + "|" + installments + "|" + transactionId + "|" + amount + "|" + exponent + "|" + currencyCode + "|" + merchantReferenceNo + "|" + status + "|" + eci + "|" + pgErrorCode + "|" + System.Configuration.ConfigurationManager.AppSettings["hashKey"] + "|"; Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI: " + messageHashBuf); /*******************Payement Gateway Error Value Code**********************/ #region PG_DB for ReturnReceipt Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("PG_DB"); string bookingid = merchantReferenceNo.Split('_')[1].ToString().Split('~')[0].ToString(); int i = GTICKBOL.Insert_Payment_DB(pgErrorDetail.ToString(), bookingid, "IDBI"); #endregion PG_DB for ReturnReceipt /*********************End******************************/ messageHashClient = "13:" + enUtility.DoHash(messageHashBuf); hashMatch = (messageHash == messageHashClient); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI hash " + (hashMatch ? "matched" : "mismatched")); //Url needed for the agent module to replace here if (merchantReferenceNo.Contains("RCM-topup") || merchantReferenceNo.Contains("RCM-signup")) { URL = "http://royalty.kingdomofdreams.in/Payment/Idbi/cr.aspx?tid=" + merchantReferenceNo + "&sta=" + status + "&amt=" + amount + "&rec=" + transactionId; } else { if (merchantReferenceNo.Split('_').Length > 2) { URL = "http://www.kodagent.com/ReturnReceipt.aspx?tid=" + merchantReferenceNo + "&sta=" + status + "&amt=" + amount + "&rec=" + transactionId; } else { KoDTicketing.GTICKV.LogEntry(merchantReferenceNo.Split('_')[0].ToString(), "Return From IDBI Payment Gateway, amt : " + amount + ",recieptNO : " + transactionId, "13", merchantReferenceNo.Split('_')[1].Split('~')[0]); if (merchantReferenceNo.Contains("royal_card_payment_idbi")) { Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Royal Card Payment reference no " + merchantReferenceNo); URL = "../../RoyalCard/Account/Payment/Idbi/CR.aspx?tid=" + merchantReferenceNo + "&sta=" + status + "&amt=" + amount + "&rec=" + transactionId; } else { URL = "CR.aspx?tid=" + merchantReferenceNo + "&sta=" + status + "&amt=" + amount + "&rec=" + transactionId; } } } Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Payment Redirecting..." + URL); Response.Redirect(URL, false); } catch (Exception ex) { Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("IDBI Return Receipt Exception " + ex.Message); if (ex.Message != null) { ReceiptUtils.IDBIReturnReceipt(ex.Message, ""); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string paymentId, ErrorText, result, postdate, tranid, auth, amt, reference; string ErrorNo, udf1, udf2, udf3, udf4, udf5, trackid; paymentId = Request["paymentid"] ?? String.Empty; ErrorText = Request["ErrorText"] ?? String.Empty; ErrorNo = Request["Error"] ?? String.Empty; udf1 = Request["udf1"] ?? String.Empty; udf2 = Request["udf2"] ?? String.Empty; udf3 = Request["udf3"] ?? String.Empty; udf4 = Request["udf4"] ?? String.Empty; udf5 = Request["udf5"] ?? String.Empty; if (ErrorNo == String.Empty) { result = Request["result"] ?? String.Empty; postdate = Request["postdate"] ?? String.Empty; tranid = Request["tranid"] ?? String.Empty; auth = Request["auth"] ?? String.Empty; trackid = Request["trackid"] ?? String.Empty; reference = Request["ref"] ?? String.Empty; amt = Request["amt"] ?? String.Empty; String responseDetails = string.Format("HDFC Response: paymentId[{0}], ErrorText[{1}], result[{2}], postdate[{3}], tranid[{4}], auth[{5}], amt[{6}], reference[{7}], ErrorNo[{8}], udf1[{9}], udf2[{10}], udf3[{11}], udf4[{12}], udf5[{13}], trackid[{14}]", paymentId, ErrorText, result, postdate, tranid, auth, amt, reference, ErrorNo, udf1, udf2, udf3, udf4, udf5, trackid); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(responseDetails); if (trackid != String.Empty) { Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Track ID: " + trackid); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Result: " + Request["result"].ToString()); KoDTicketing.GTICKV.LogEntry(trackid.Split('_')[0], "Payment Getaway Response: " + Request["result"].ToString(), "14", trackid.Split('_')[1].Split('-')[0]); /*******************Payement Gateway Error Value Code**********************/ #region PG_DB for ReturnReceipt Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("PG_DB"); string bookingid = Request["trackid"].Split('_')[1].ToString().Split('-')[0].ToString(); int i = GTICKBOL.Insert_Payment_DB(Request["result"].ToString(), bookingid, "HDFC"); #endregion PG_DB for ReturnReceipt /*********************End******************************/ string qstring = UpdateResponse(trackid, reference, result, postdate, auth); if (!string.IsNullOrEmpty(qstring)) { string redirectURL = "REDIRECT=" + KoDTicketingIPAddress + "Payment/Print-Receipt.aspx" + qstring; Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC response redirection: " + redirectURL); Response.Write(redirectURL); return; } else { Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC response processing failed and resulting in empty receipt."); } } else { Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Response contains NO track ID"); } Response.Write("REDIRECT=" + KoDTicketingIPAddress + "Payment/Print-Receipt.aspx?err=pay"); } else { String errorDetails = string.Format("paymentId[{0}], ErrorText[{1}], ErrorNo[{2}], udf1[{3}], udf2[{4}], udf3[{5}], udf4[{6}], udf5[{7}]", paymentId, ErrorText, ErrorNo, udf1, udf2, udf3, udf4, udf5); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Response: " + errorDetails); /*******************Payement Gateway Error Value Code**********************/ #region PG_DB for ReturnReceipt Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("PG_DB"); string bookingid = Request["trackid"].Split('_')[1].ToString().Split('-')[0].ToString(); int i = GTICKBOL.Insert_Payment_DB(ErrorText.ToString(), bookingid, "HDFC"); #endregion PG_DB for ReturnReceipt /*********************End******************************/ string err; if (Request["ErrorText"] != null) { err = Request["ErrorText"].ToString(); } else { err = "Error occcured in processing payment through HDFC payment gateway."; } Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("HDFC Error Response: " + err); Response.Write("REDIRECT=" + KoDTicketingIPAddress + "Payment/Print-Receipt.aspx?err=pay"); } }//!postback }