protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { pnlReceiptError.Visible = false; pnlResponse.Visible = false; } try { // Create a new VPCRequest object VPCRequest conn = new VPCRequest(); // Process the response received conn.Process3PartyResponse(Page.Request.QueryString); // Check if the transaction was successful or if there was an error String 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; Label_vpc_MerchTxnRef.Text = conn.GetResultField("vpc_MerchTxnRef", "Unknown"); Label_vpc_OrderInfo.Text = conn.GetResultField("vpc_OrderInfo", "Unknown"); Label_vpc_Merchant.Text = conn.GetResultField("vpc_Merchant", "Unknown"); Label_vpc_Amount.Text = conn.GetResultField("vpc_Amount", "Unknown"); Label_vpc_Message.Text = conn.GetResultField("vpc_Message", "Unknown"); Label_vpc_ReceiptNo.Text = conn.GetResultField("vpc_ReceiptNo", "Unknown"); Label_vpc_AcqResponseCode.Text = conn.GetResultField("vpc_AcqResponseCode", "Unknown"); Label_vpc_AuthorizeId.Text = conn.GetResultField("vpc_AuthorizeId", "Unknown"); Label_vpc_BatchNo.Text = conn.GetResultField("vpc_BatchNo", "Unknown"); Label_vpc_TransactionNo.Text = conn.GetResultField("vpc_TransactionNo", "Unknown"); Label_vpc_Card.Text = conn.GetResultField("vpc_Card", "Unknown"); Label_vpc_3DSECI.Text = conn.GetResultField("vpc_3DSECI", "Unknown"); Label_vpc_3DSXID.Text = conn.GetResultField("vpc_3DSXID", "Unknown"); Label_vpc_3DSenrolled.Text = conn.GetResultField("vpc_3DSenrolled", "Unknown"); Label_vpc_3DSstatus.Text = conn.GetResultField("vpc_3DSstatus", "Unknown"); Label_vpc_VerToken.Text = conn.GetResultField("vpc_VerToken", "Unknown"); Label_vpc_VerType.Text = conn.GetResultField("vpc_VerType", "Unknown"); Label_vpc_VerSecurityLevel.Text = conn.GetResultField("vpc_VerSecurityLevel", "Unknown"); Label_vpc_VerStatus.Text = conn.GetResultField("vpc_VerStatus", "Unknown"); Label_vpc_RiskOverallResult.Text = conn.GetResultField("vpc_RiskOverallResult", "Unknown"); Label_vpc_TxnReversalResult.Text = conn.GetResultField("vpc_TxnReversalResult", "No Value Returned"); Label_TxnResponseCodeDesc.Text = PaymentCodesHelper.GetTxnResponseCodeDescription(Label_vpc_TxnResponseCode.Text); // Card Security Code Fields Label_vpc_cscResultCode.Text = conn.GetResultField("vpc_cscResultCode", "Unknown"); Label_cscResultCodeDesc.Text = PaymentCodesHelper.GetCSCDescription(Label_vpc_cscResultCode.Text); // Display the response fields pnlResponse.Visible = true; } catch (Exception ex) { // Capture the error and display the error information lblReceiptErrorMessage.Text = ex.Message + (ex.InnerException != null ? ex.InnerException.Message : ""); pnlReceiptError.Visible = true; } }
private Boolean AmexRefund(string BookingID, string ReferenceNo, string TotalAmount, string TransactionNo) { VPCRequest conn = AmexConfig(); string MerchantRefNo = BookingID + "_" + ReferenceNo + "~WEB"; string vpc_TransNo = TransactionNo; if (TotalAmount.Contains(".")) { TotalAmount = TotalAmount.Replace(".00", ""); } TotalAmount = Convert.ToString(Convert.ToInt32(TotalAmount) * 100); string vpc_Amount = TotalAmount; conn.AddDigitalOrderField("vpc_Command", "refund"); conn.AddDigitalOrderField("vpc_MerchTxnRef", MerchantRefNo); conn.AddDigitalOrderField("vpc_TransNo", vpc_TransNo); conn.AddDigitalOrderField("vpc_Amount", vpc_Amount); conn.SendRequest(); string ResponseResult = null; int CounterChkAmexRefundValue; for (CounterChkAmexRefundValue = 1; CounterChkAmexRefundValue <= 2; CounterChkAmexRefundValue++) { string vpc_TxnResponseCode = conn.GetResultField("vpc_TxnResponseCode", "Unknown"); ResponseResult = PaymentCodesHelper.GetTxnResponseCodeDescription(vpc_TxnResponseCode); if (ResponseResult == "" || ResponseResult == null) { conn.SendRequest(); } else { StringBuilder RefundDetails = new StringBuilder(); RefundDetails.Append(" These are the Refund Details for Booking ID and Reference : " + BookingID + "," + ReferenceNo + "<br/>"); RefundDetails.Append(" vpc_TxnResponseCode : " + conn.GetResultField("vpc_TxnResponseCode", "Unknown") + "<br/>"); RefundDetails.Append(" vpc_MerchTxnRef : " + conn.GetResultField("vpc_MerchTxnRef", "Unknown") + "<br/>"); RefundDetails.Append(" vpc_Merchant : " + conn.GetResultField("vpc_Merchant", "Unknown") + "<br/>"); RefundDetails.Append(" vpc_OrderInfo : " + conn.GetResultField("vpc_OrderInfo", "Unknown") + "<br/>"); RefundDetails.Append(" vpc_Amount : " + conn.GetResultField("vpc_Amount", "Unknown") + "<br/>"); RefundDetails.Append(" vpc_DRExists :" + conn.GetResultField("vpc_DRExists", "Unknown") + "<br/>"); RefundDetails.Append(" vpc_FoundMultipleDRs : " + conn.GetResultField("vpc_FoundMultipleDRs", "Unknown") + "<br/>"); RefundDetails.Append(" vpc_Message : " + conn.GetResultField("vpc_Message", "Unknown") + "<br/>"); RefundDetails.Append(" vpc_AcqResponseCode : " + conn.GetResultField("vpc_AcqResponseCode", "Unknown") + "<br/>"); RefundDetails.Append(" vpc_TransactionNo : " + conn.GetResultField("vpc_TransactionNo", "Unknown") + "<br/>"); RefundDetails.Append(" vpc_ReceiptNo : " + conn.GetResultField("vpc_ReceiptNo", "Unknown") + "<br/>"); RefundDetails.Append(" vpc_AuthorizeId : " + conn.GetResultField("vpc_AuthorizeId", "Unknown") + "<br/>"); RefundDetails.Append(" vpc_BatchNo : " + conn.GetResultField("vpc_BatchNo", "Unknown") + "<br/>"); RefundDetails.Append(" vpc_TicketNo : " + conn.GetResultField("vpc_TicketNo", "Unknown") + "<br/>"); RefundDetails.Append(" vpc_Card : " + conn.GetResultField("vpc_Card", "Unknown") + "<br/>"); RefundDetails.Append(" Response Result :" + ResponseResult + "<br/>"); RefundDetails.Append(" vpc_AuthorisedAmount : " + conn.GetResultField("vpc_AuthorisedAmount", "Unknown") + "<br/>"); RefundDetails.Append(" vpc_CapturedAmount : " + conn.GetResultField("vpc_CapturedAmount", "Unknown") + "<br/>"); RefundDetails.Append(" vpc_RefundedAmount : " + conn.GetResultField("vpc_RefundedAmount", "Unknown") + "<br/>"); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Refund Details for Amex : " + RefundDetails); string vpc_avsResultCode = conn.GetResultField("vpc_AVSResultCode", "Unknown"); string Transaction = conn.GetResultField("vpc_TransactionNo", "Unknown"); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("vpc_AVSResultCode : " + vpc_avsResultCode + " and vpc_TransactionNo : " + TransactionNo); if (vpc_TxnResponseCode == "0")//&& (vpc_avsResultCode == "Y" || vpc_avsResultCode == "M") { Boolean IsSuccess = Successfull_1(BookingID); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Update ISProcessed Value to ' 1 ' and Payment Successful : " + IsSuccess + " for BookingID : " + BookingID); return(IsSuccess); } else { Boolean IsRefundPossible = RefundNotPossible_5(BookingID); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Update ISProcessed Value to ' 5 ' and Refund : " + IsRefundPossible + " for BookingID : " + BookingID); return(IsRefundPossible); } } } if (CounterChkAmexRefundValue == 3) { Boolean IsAmexException = ExceptioninRefund_4(BookingID); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Update ISProcessed Value to ' 4 ' and Refund : " + IsAmexException + " for BookingID : " + BookingID); return(IsAmexException); } return(false); }
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); } }
public Boolean AmexQuery(string BookingID, string ReferenceNo, string TotalAmount) { VPCRequest conn = AmexConfig(); string MerchantRefNo = BookingID + "_" + ReferenceNo + "~WEB"; conn.AddDigitalOrderField("vpc_Command", "queryDR"); conn.AddDigitalOrderField("vpc_MerchTxnRef", MerchantRefNo); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Amex Reversal Payment process for MerchantRefNo. : " + MerchantRefNo); // Perform the transaction conn.SendRequest(); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Returning form Amex Gateway"); string ResponseResult = null; int CounterChkAmexQueryValue; for (CounterChkAmexQueryValue = 1; CounterChkAmexQueryValue <= 2; CounterChkAmexQueryValue++) { string vpc_TxnResponseCode = conn.GetResultField("vpc_TxnResponseCode", "Unknown"); ResponseResult = PaymentCodesHelper.GetTxnResponseCodeDescription(vpc_TxnResponseCode); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Response Code : " + ResponseResult); if (ResponseResult == "" || ResponseResult == null || ResponseResult == "null response") { conn.SendRequest(); } else { StringBuilder InquiryDetails = new StringBuilder(); InquiryDetails.Append("These are the Inquiry Details for Booking ID and Reference :" + BookingID + "," + ReferenceNo + "<br/>"); InquiryDetails.Append(" vpc_TxnResponseCode :" + conn.GetResultField("vpc_TxnResponseCode", "Unknown") + "<br/>"); InquiryDetails.Append(" vpc_MerchTxnRef :" + conn.GetResultField("vpc_MerchTxnRef", "Unknown") + "<br/>"); InquiryDetails.Append(" vpc_Merchant :" + conn.GetResultField("vpc_Merchant", "Unknown") + "<br/>"); InquiryDetails.Append(" vpc_OrderInfo :" + conn.GetResultField("vpc_OrderInfo", "Unknown") + "<br/>"); InquiryDetails.Append(" vpc_Amount :" + conn.GetResultField("vpc_Amount", "Unknown") + "<br/>"); InquiryDetails.Append(" vpc_DRExists :" + conn.GetResultField("vpc_DRExists", "Unknown")); InquiryDetails.Append(" vpc_FoundMultipleDRs :" + conn.GetResultField("vpc_FoundMultipleDRs", "Unknown") + "<br/>"); InquiryDetails.Append(" vpc_Message :" + conn.GetResultField("vpc_Message", "Unknown") + "<br/>"); InquiryDetails.Append(" vpc_AcqResponseCode :" + conn.GetResultField("vpc_AcqResponseCode", "Unknown") + "<br/>"); InquiryDetails.Append(" vpc_TransactionNo :" + conn.GetResultField("vpc_TransactionNo", "Unknown") + "<br/>"); InquiryDetails.Append(" vpc_ReceiptNo :" + conn.GetResultField("vpc_ReceiptNo", "Unknown") + "<br/>"); InquiryDetails.Append(" vpc_AuthorizeId :" + conn.GetResultField("vpc_AuthorizeId", "Unknown") + "<br/>"); InquiryDetails.Append(" vpc_BatchNo :" + conn.GetResultField("vpc_BatchNo", "Unknown") + "<br/>"); InquiryDetails.Append(" vpc_TicketNo :" + conn.GetResultField("vpc_TicketNo", "Unknown") + "<br/>"); InquiryDetails.Append(" vpc_Card :" + conn.GetResultField("vpc_Card", "Unknown") + "<br/>"); InquiryDetails.Append(" Response Result :" + ResponseResult + "<br/>"); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Inquiry Details for Amex : " + InquiryDetails); string vpc_avsResultCode = conn.GetResultField("vpc_AVSResultCode", "Unknown"); string TransactionNo = conn.GetResultField("vpc_TransactionNo", "Unknown"); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("vpc_AVSResultCode : " + vpc_avsResultCode + " and vpc_TransactionNo : " + TransactionNo); if (vpc_TxnResponseCode == "0" && (vpc_avsResultCode == "Y" || vpc_avsResultCode == "M")) { if ((MerchantRefNo != "" || MerchantRefNo != null) && (TotalAmount != "" || TotalAmount != null) && (TransactionNo != "" || TransactionNo != null)) { Boolean Result = AmexRefund(BookingID, ReferenceNo, TotalAmount, TransactionNo); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Value Return from AmexRefund i.e. IsSuccess : " + Result); if (Result == true) { return(true); } else { return(false); } } else { return(false); } } else { Boolean IsPaymentSuccess = UserPaymentNotSuccess_3(BookingID); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Update ISProcessed Value to ' 3 ' and Inquiry Payment Success : " + IsPaymentSuccess + " for BookingID : " + BookingID); return(IsPaymentSuccess); } } }//for loop end if (CounterChkAmexQueryValue == 3) { Boolean IsHDFCInquirySuccess = ExceptioninInquiry_2(BookingID); Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Update ISProcessed Value to ' 2 ' and Inquiry Payment Success : " + IsHDFCInquirySuccess + " for BookingID : " + BookingID); return(IsHDFCInquirySuccess); } return(false); }