/// <summary> /// Authorise payment /// </summary> /// <param name="merchant">Merchant Details</param> /// <param name="order">Order Details</param> /// <param name="card">Card Details</param> /// <param name="autoSettle">Auto Settle (1 or 0)</param> /// <param name="timestamp">Timestamp</param> /// <param name="comments">Comments</param> /// <returns>Response from realex</returns> public static RealAuthTransactionResponse Auth(Merchant merchant, Order order, CreditCard card, string autoSettle, string timestamp, ArrayList comments) { bool is3DSecure = false; _3DSecure tdSec = null; return(Auth(merchant, order, card, autoSettle, timestamp, comments, is3DSecure, tdSec)); }
/// <summary> /// Take payment from real vault - recurring /// </summary> /// <param name="merchant">merchant details</param> /// <param name="order">order details</param> /// <param name="payer">payer details</param> /// <param name="cardRef">card ref to chanrge</param> /// <param name="autoSettle">auto settle with bank (usually 1)</param> /// <param name="timestamp">timestamp</param> /// <param name="comments">comments</param> /// <param name="recurring">is recurring?</param> /// <param name="recurringType">type of recurring amount - fixed / variable</param> /// <param name="recurringSequence">first/subsequent/final</param> /// <returns></returns> public static RealVaultTransactionResponse RecieptIn(Merchant merchant, Order order, Payer payer, string cardRef, string autoSettle, string timestamp, ArrayList comments, bool recurring, string recurringType, string recurringSequence) { _3DSecure tdSecure = new _3DSecure(); string cvn = ""; return(RecieptIn(merchant, tdSecure, order, payer, cardRef, cvn, autoSettle, timestamp, comments, recurring, recurringType, recurringSequence)); }
protected void lb3DSecureAuth_Click(object sender, EventArgs e) { string merchantId = ConfigurationManager.AppSettings["MerchantID"]; string account = ConfigurationManager.AppSettings["Account"]; string sharedSecret = ConfigurationManager.AppSettings["SharedSecret"]; Merchant merchant = new Merchant(merchantId, account, sharedSecret); Order order = new Order("GBP", 999); CreditCard card = new CreditCard("MC", "5425232820001308", "0118", "Phil McCracken", "123", 1); Address address = new Address("", "", "", "", "", "", "", ""); PhoneNumbers numbers = new PhoneNumbers("", "", "", ""); Payer payer = new Payer("Business", "test", "", "Phil", "McCracken", "", address, numbers, "", new ArrayList()); string timestamp = Common.GenerateTimestamp(); string autoSettle = "1"; RealAuthTransactionResponse resp = RealAuthorisation.RealAuth3DSecureVerifyEnrolled(merchant, order, card, timestamp); //00 is enrolled //110 is not enrolled, should be sent to Attempt ACS server is available if (resp.ResultCode == 00 || resp.ResultCode == 110) { string paReq = resp.PaReq; string url = resp.URL; if(paReq != "" && url != "") { _3DSecure tdSecure = new _3DSecure("", "", "", paReq, url); //resp = RealAuthorisation.RealAuth3DSecureVerifySig(merchant, order, card, tdSecure, timestamp); } } string termUrlPrefix = Request.ServerVariables["HTTPS"] == "ON" ? "https://" : "http://"; string termUrl = string.Format("{0}{1}", termUrlPrefix, Request.Url.Authority + "/3DSResponse.aspx"); pnlACS.Visible = true; lblErrorCode.Text = resp.ResultCode.ToString(); lblResult.Text = resp.ResultMessage; }
/// <summary> /// Take payment from real vault - everything /// </summary> /// <param name="merchant">merchant details</param> /// <param name="tdSecure">3d secure details</param> /// <param name="order">order details</param> /// <param name="payer">payer details</param> /// <param name="cardRef">card ref to charge</param> /// <param name="cvn">cvn of card</param> /// <param name="autoSettle">auto settle with bank (usullay 1)</param> /// <param name="timestamp">timestamp</param> /// <param name="comments">comments</param> /// <param name="recurring">is recurring?</param> /// <param name="recurringType">type of recurring amount - fixed / variable</param> /// <param name="recurringSequence">first/subsequent/final</param> /// <returns></returns> public static RealVaultTransactionResponse RecieptIn(Merchant merchant, _3DSecure tdSecure, Order order, Payer payer, string cardRef, string cvn, string autoSettle, string timestamp, ArrayList comments, bool recurring, string recurringType, string recurringSequence) { string hashInput = timestamp + "." + merchant.MerchantId + "." + order.OrderId + "." + order.OrderAmount + "." + order.OrderCurrency + "." + payer.PayerRef; string SHA1Hash = Common.GenerateSHA1Hash(hashInput, merchant.SharedSecret); String xmlString = string.Empty; String requestType = "receipt-in"; XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Indent = true; xmlSettings.NewLineOnAttributes = false; xmlSettings.NewLineChars = "\r\n"; xmlSettings.CloseOutput = true; StringBuilder strBuilder = new StringBuilder(); XmlWriter xml = XmlWriter.Create(strBuilder, xmlSettings); xml.WriteStartDocument(); xml.WriteStartElement("request"); { xml.WriteAttributeString("type", requestType); xml.WriteAttributeString("timestamp", timestamp); xml.WriteElementString("merchantid", merchant.MerchantId); xml.WriteElementString("account", merchant.Account); xml.WriteElementString("orderid", order.OrderId); if (cvn != "") { xml.WriteStartElement("paymentdata"); { xml.WriteStartElement("cvn"); { xml.WriteElementString("number", cvn); } xml.WriteEndElement(); } xml.WriteEndElement(); } xml.WriteStartElement("mpi"); { xml.WriteElementString("cavv", tdSecure.CAVV); xml.WriteElementString("xid", tdSecure.XID); xml.WriteElementString("eci", tdSecure.ECI); } xml.WriteEndElement(); //might need dccinfo in here?? xml.WriteStartElement("amount"); { xml.WriteAttributeString("currency", order.OrderCurrency); xml.WriteString(order.OrderAmount.ToString()); } xml.WriteEndElement(); xml.WriteElementString("payerref", payer.PayerRef); xml.WriteElementString("paymentmethod", cardRef); xml.WriteStartElement("autosettle"); { xml.WriteAttributeString("flag", autoSettle); } xml.WriteEndElement(); xml.WriteElementString("sha1hash", SHA1Hash); xml.WriteStartElement("comments"); { int i = 1; foreach (string s in comments) { xml.WriteStartElement("comment"); xml.WriteAttributeString("id", i.ToString()); xml.WriteString(s); xml.WriteEndElement(); i++; } } xml.WriteEndElement(); if (recurring) { xml.WriteStartElement("recurring"); { xml.WriteAttributeString("type", recurringType); xml.WriteAttributeString("sequence", recurringSequence); } xml.WriteEndElement(); } //tss?? //supplementary data?? } xml.WriteEndElement(); xml.WriteEndDocument(); xml.Flush(); xml.Close(); xmlString = strBuilder.ToString(); return(Common.SendRealVaultRequest(xmlString)); }
/// <summary> /// Authorise payment /// </summary> /// <param name="merchant">Merchant Details</param> /// <param name="order">Order Details</param> /// <param name="card">Card Details</param> /// <param name="autoSettle">Auto Settle (1 or 0)</param> /// <param name="timestamp">Timestamp</param> /// <param name="comments">Comments</param> /// <param name="is3DSecure">Is transaction 3D Secure</param> /// <param name="tdSecure">3D Secure details</param> /// <returns>Response from Realex</returns> public static RealAuthTransactionResponse Auth(Merchant merchant, Order order, CreditCard card, string autoSettle, string timestamp, ArrayList comments, bool is3DSecure, _3DSecure tdSecure) { string hashInput = timestamp + "." + merchant.MerchantId + "." + order.OrderId + "." + order.OrderAmount + "." + order.OrderCurrency + "." + card.CardNumber; string SHA1Hash = Common.GenerateSHA1Hash(hashInput, merchant.SharedSecret); String xmlString = string.Empty; String requestType = "auth"; XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Indent = true; xmlSettings.NewLineOnAttributes = false; xmlSettings.NewLineChars = "\r\n"; xmlSettings.CloseOutput = true; StringBuilder strBuilder = new StringBuilder(); XmlWriter xml = XmlWriter.Create(strBuilder, xmlSettings); xml.WriteStartDocument(); xml.WriteStartElement("request"); { xml.WriteAttributeString("type", requestType); xml.WriteAttributeString("timestamp", timestamp); xml.WriteElementString("merchantid", merchant.MerchantId); xml.WriteElementString("account", merchant.Account); xml.WriteElementString("orderid", order.OrderId); xml.WriteStartElement("amount"); { xml.WriteAttributeString("currency", order.OrderCurrency); xml.WriteString(order.OrderAmount.ToString()); } xml.WriteEndElement(); card.WriteXML(xml); xml.WriteStartElement("autosettle"); { xml.WriteAttributeString("flag", autoSettle); } xml.WriteEndElement(); if (is3DSecure) { xml.WriteStartElement("mpi"); { xml.WriteElementString("cavv", tdSecure.CAVV); xml.WriteElementString("xid", tdSecure.XID); xml.WriteElementString("eci", tdSecure.ECI); } xml.WriteEndElement(); } xml.WriteElementString("sha1hash", SHA1Hash); xml.WriteStartElement("comments"); { int i = 1; foreach (string s in comments) { xml.WriteStartElement("comment"); xml.WriteAttributeString("id", i.ToString()); xml.WriteString(s); xml.WriteEndElement(); i++; } } xml.WriteEndElement(); } xml.WriteEndElement(); xml.WriteEndDocument(); xml.Flush(); xml.Close(); xmlString = strBuilder.ToString(); return(Common.SendRealAuthRequest(xmlString)); }
/// <summary> /// 3D Secure Verify Digital Signature /// </summary> /// <param name="merchant">Merchant Details</param> /// <param name="order">Order Details</param> /// <param name="card">Card Details</param> /// <param name="tdSecure">3D Secure Details</param> /// <param name="timestamp">Timestamp</param> /// <returns>Response from Realex</returns> public static RealAuthTransactionResponse RealAuth3DSecureVerifySig(Merchant merchant, Order order, CreditCard card, _3DSecure tdSecure, string timestamp) { string hashInput = timestamp + "." + merchant.MerchantId + "." + order.OrderId + "." + order.OrderAmount + "." + order.OrderCurrency + "." + card.CardNumber; string SHA1Hash = Common.GenerateSHA1Hash(hashInput, merchant.SharedSecret); String xmlString = string.Empty; String requestType = "3ds-verifysig"; XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Indent = true; xmlSettings.NewLineOnAttributes = false; xmlSettings.NewLineChars = "\r\n"; xmlSettings.CloseOutput = true; StringBuilder strBuilder = new StringBuilder(); XmlWriter xml = XmlWriter.Create(strBuilder, xmlSettings); xml.WriteStartDocument(); xml.WriteStartElement("request"); { xml.WriteAttributeString("type", requestType); xml.WriteAttributeString("timestamp", timestamp); xml.WriteElementString("merchantid", merchant.MerchantId); xml.WriteElementString("account", merchant.Account); xml.WriteElementString("orderid", order.OrderId); xml.WriteStartElement("amount"); { xml.WriteAttributeString("currency", order.OrderCurrency); xml.WriteString(order.OrderAmount.ToString()); } xml.WriteEndElement(); xml.WriteStartElement("card"); { xml.WriteElementString("number", card.CardNumber); xml.WriteElementString("expdate", card.ExpiryDate); xml.WriteElementString("type", card.CardType); xml.WriteElementString("chname", card.CardholderName); } xml.WriteEndElement(); xml.WriteElementString("pares", tdSecure.PaRes); xml.WriteElementString("sha1hash", SHA1Hash); } xml.WriteEndElement(); xml.WriteEndDocument(); xml.Flush(); xml.Close(); xmlString = strBuilder.ToString(); return(Common.SendRealAuthRequest(xmlString)); }
/// <summary> /// Authorise payment /// </summary> /// <param name="merchant">Merchant Details</param> /// <param name="order">Order Details</param> /// <param name="card">Card Details</param> /// <param name="autoSettle">Auto Settle (1 or 0)</param> /// <param name="timestamp">Timestamp</param> /// <param name="comments">Comments</param> /// <param name="is3DSecure">Is transaction 3D Secure</param> /// <param name="tdSecure">3D Secure details</param> /// <returns>Response from Realex</returns> public static RealAuthTransactionResponse Auth(Merchant merchant, Order order, CreditCard card, string autoSettle, string timestamp, ArrayList comments, bool is3DSecure, _3DSecure tdSecure) { string hashInput = timestamp + "." + merchant.MerchantId + "." + order.OrderId + "." + order.OrderAmount + "." + order.OrderCurrency + "." + card.CardNumber; string SHA1Hash = Common.GenerateSHA1Hash(hashInput, merchant.SharedSecret); String xmlString = string.Empty; String requestType = "auth"; XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Indent = true; xmlSettings.NewLineOnAttributes = false; xmlSettings.NewLineChars = "\r\n"; xmlSettings.CloseOutput = true; StringBuilder strBuilder = new StringBuilder(); XmlWriter xml = XmlWriter.Create(strBuilder, xmlSettings); xml.WriteStartDocument(); xml.WriteStartElement("request"); { xml.WriteAttributeString("type", requestType); xml.WriteAttributeString("timestamp", timestamp); xml.WriteElementString("merchantid", merchant.MerchantId); xml.WriteElementString("account", merchant.Account); xml.WriteElementString("orderid", order.OrderId); xml.WriteStartElement("amount"); { xml.WriteAttributeString("currency", order.OrderCurrency); xml.WriteString(order.OrderAmount.ToString()); } xml.WriteEndElement(); card.WriteXML(xml); xml.WriteStartElement("autosettle"); { xml.WriteAttributeString("flag", autoSettle); } xml.WriteEndElement(); if (is3DSecure) { xml.WriteStartElement("mpi"); { xml.WriteElementString("cavv", tdSecure.CAVV); xml.WriteElementString("xid", tdSecure.XID); xml.WriteElementString("eci", tdSecure.ECI); } xml.WriteEndElement(); } xml.WriteElementString("sha1hash", SHA1Hash); xml.WriteStartElement("comments"); { int i = 1; foreach (string s in comments) { xml.WriteStartElement("comment"); xml.WriteAttributeString("id", i.ToString()); xml.WriteString(s); xml.WriteEndElement(); i++; } } xml.WriteEndElement(); } xml.WriteEndElement(); xml.WriteEndDocument(); xml.Flush(); xml.Close(); xmlString = strBuilder.ToString(); return Common.SendRealAuthRequest(xmlString); }
/// <summary> /// Authorise payment /// </summary> /// <param name="merchant">Merchant Details</param> /// <param name="order">Order Details</param> /// <param name="card">Card Details</param> /// <param name="autoSettle">Auto Settle (1 or 0)</param> /// <param name="timestamp">Timestamp</param> /// <param name="comments">Comments</param> /// <returns>Response from realex</returns> public static RealAuthTransactionResponse Auth(Merchant merchant, Order order, CreditCard card, string autoSettle, string timestamp, bool is3DSecure, _3DSecure tdSec) { ArrayList comments = new ArrayList(); return Auth(merchant, order, card, autoSettle, timestamp, comments, is3DSecure, tdSec); }
/// <summary> /// 3D Secure Verify Digital Signature /// </summary> /// <param name="merchant">Merchant Details</param> /// <param name="order">Order Details</param> /// <param name="card">Card Details</param> /// <param name="tdSecure">3D Secure Details</param> /// <param name="timestamp">Timestamp</param> /// <returns>Response from Realex</returns> public static RealAuthTransactionResponse RealAuth3DSecureVerifySig(Merchant merchant, Order order, CreditCard card, _3DSecure tdSecure, string timestamp) { string hashInput = timestamp + "." + merchant.MerchantId + "." + order.OrderId + "." + order.OrderAmount + "." + order.OrderCurrency + "." + card.CardNumber; string SHA1Hash = Common.GenerateSHA1Hash(hashInput, merchant.SharedSecret); String xmlString = string.Empty; String requestType = "3ds-verifysig"; XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Indent = true; xmlSettings.NewLineOnAttributes = false; xmlSettings.NewLineChars = "\r\n"; xmlSettings.CloseOutput = true; StringBuilder strBuilder = new StringBuilder(); XmlWriter xml = XmlWriter.Create(strBuilder, xmlSettings); xml.WriteStartDocument(); xml.WriteStartElement("request"); { xml.WriteAttributeString("type", requestType); xml.WriteAttributeString("timestamp", timestamp); xml.WriteElementString("merchantid", merchant.MerchantId); xml.WriteElementString("account", merchant.Account); xml.WriteElementString("orderid", order.OrderId); xml.WriteStartElement("amount"); { xml.WriteAttributeString("currency", order.OrderCurrency); xml.WriteString(order.OrderAmount.ToString()); } xml.WriteEndElement(); xml.WriteStartElement("card"); { xml.WriteElementString("number", card.CardNumber); xml.WriteElementString("expdate", card.ExpiryDate); xml.WriteElementString("type", card.CardType); xml.WriteElementString("chname", card.CardholderName); } xml.WriteEndElement(); xml.WriteElementString("pares", tdSecure.PaRes); xml.WriteElementString("sha1hash", SHA1Hash); } xml.WriteEndElement(); xml.WriteEndDocument(); xml.Flush(); xml.Close(); xmlString = strBuilder.ToString(); return Common.SendRealAuthRequest(xmlString); }
/// <summary> /// Take payment from real vault - everything /// </summary> /// <param name="merchant">merchant details</param> /// <param name="tdSecure">3d secure details</param> /// <param name="order">order details</param> /// <param name="payer">payer details</param> /// <param name="cardRef">card ref to charge</param> /// <param name="cvn">cvn of card</param> /// <param name="autoSettle">auto settle with bank (usullay 1)</param> /// <param name="timestamp">timestamp</param> /// <param name="comments">comments</param> /// <param name="recurring">is recurring?</param> /// <param name="recurringType">type of recurring amount - fixed / variable</param> /// <param name="recurringSequence">first/subsequent/final</param> /// <returns></returns> public static RealVaultTransactionResponse RecieptIn(Merchant merchant, _3DSecure tdSecure, Order order, Payer payer, string cardRef, string cvn, string autoSettle, string timestamp, ArrayList comments, bool recurring, string recurringType, string recurringSequence) { string hashInput = timestamp + "." + merchant.MerchantId + "." + order.OrderId + "." + order.OrderAmount + "." + order.OrderCurrency + "." + payer.PayerRef; string SHA1Hash = Common.GenerateSHA1Hash(hashInput, merchant.SharedSecret); String xmlString = string.Empty; String requestType = "receipt-in"; XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.Indent = true; xmlSettings.NewLineOnAttributes = false; xmlSettings.NewLineChars = "\r\n"; xmlSettings.CloseOutput = true; StringBuilder strBuilder = new StringBuilder(); XmlWriter xml = XmlWriter.Create(strBuilder, xmlSettings); xml.WriteStartDocument(); xml.WriteStartElement("request"); { xml.WriteAttributeString("type", requestType); xml.WriteAttributeString("timestamp", timestamp); xml.WriteElementString("merchantid", merchant.MerchantId); xml.WriteElementString("account", merchant.Account); xml.WriteElementString("orderid", order.OrderId); if (cvn != "") { xml.WriteStartElement("paymentdata"); { xml.WriteStartElement("cvn"); { xml.WriteElementString("number", cvn); } xml.WriteEndElement(); } xml.WriteEndElement(); } xml.WriteStartElement("mpi"); { xml.WriteElementString("cavv", tdSecure.CAVV); xml.WriteElementString("xid", tdSecure.XID); xml.WriteElementString("eci", tdSecure.ECI); } xml.WriteEndElement(); //might need dccinfo in here?? xml.WriteStartElement("amount"); { xml.WriteAttributeString("currency", order.OrderCurrency); xml.WriteString(order.OrderAmount.ToString()); } xml.WriteEndElement(); xml.WriteElementString("payerref", payer.PayerRef); xml.WriteElementString("paymentmethod", cardRef); xml.WriteStartElement("autosettle"); { xml.WriteAttributeString("flag", autoSettle); } xml.WriteEndElement(); xml.WriteElementString("sha1hash", SHA1Hash); xml.WriteStartElement("comments"); { int i = 1; foreach (string s in comments) { xml.WriteStartElement("comment"); xml.WriteAttributeString("id", i.ToString()); xml.WriteString(s); xml.WriteEndElement(); i++; } } xml.WriteEndElement(); if (recurring) { xml.WriteStartElement("recurring"); { xml.WriteAttributeString("type", recurringType); xml.WriteAttributeString("sequence", recurringSequence); } xml.WriteEndElement(); } //tss?? //supplementary data?? } xml.WriteEndElement(); xml.WriteEndDocument(); xml.Flush(); xml.Close(); xmlString = strBuilder.ToString(); return Common.SendRealVaultRequest(xmlString); }
/// <summary> /// Take payment from real vault - recurring /// </summary> /// <param name="merchant">merchant details</param> /// <param name="order">order details</param> /// <param name="payer">payer details</param> /// <param name="cardRef">card ref to chanrge</param> /// <param name="autoSettle">auto settle with bank (usually 1)</param> /// <param name="timestamp">timestamp</param> /// <param name="comments">comments</param> /// <param name="recurring">is recurring?</param> /// <param name="recurringType">type of recurring amount - fixed / variable</param> /// <param name="recurringSequence">first/subsequent/final</param> /// <returns></returns> public static RealVaultTransactionResponse RecieptIn(Merchant merchant, Order order, Payer payer, string cardRef, string autoSettle, string timestamp, ArrayList comments, bool recurring, string recurringType, string recurringSequence) { _3DSecure tdSecure = new _3DSecure(); string cvn = ""; return RecieptIn(merchant, tdSecure, order, payer, cardRef, cvn, autoSettle, timestamp, comments, recurring, recurringType, recurringSequence); }