Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create new card
        /// </summary>
        /// <param name="timestamp">timestamp</param>
        /// <param name="cardRef">name to save card against payer</param>
        /// <param name="merchant">merchant details</param>
        /// <param name="order">order details</param>
        /// <param name="cc">credit card details</param>
        /// <param name="payer">payer details</param>
        /// <returns>real vault transaction response</returns>
        public static RealVaultTransactionResponse CardNew(string timestamp, string cardRef, Merchant merchant, Order order, CreditCard cc, Payer payer)
        {
            string hashInput = timestamp + "." +
                merchant.MerchantId + "." +
                order.OrderId + "." +
                "" + "." +
                "" + "." +
                payer.PayerRef + "." +
                cc.CardholderName + "." +
                cc.CardNumber;
            string SHA1Hash = Common.GenerateSHA1Hash(hashInput, merchant.SharedSecret);

            String xmlString = string.Empty;
            String requestType = "card-new";

            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("orderid", order.OrderId);

                xml.WriteStartElement("card");
                {
                    xml.WriteElementString("ref", cardRef);
                    xml.WriteElementString("payerref", payer.PayerRef);
                    xml.WriteElementString("number", cc.CardNumber);
                    xml.WriteElementString("expdate", cc.ExpiryDate);
                    xml.WriteElementString("type", cc.CardType);
                    xml.WriteElementString("chname", cc.CardholderName);
                    if (cc.CardType.Equals("SWITCH"))
                    {
                        xml.WriteElementString("issueno", cc.IssueNumber.ToString());
                    }
                }
                xml.WriteEndElement();

                xml.WriteElementString("sha1hash", SHA1Hash);

            }
            xml.WriteEndElement();

            xml.WriteEndDocument();
            xml.Flush();
            xml.Close();

            xmlString = strBuilder.ToString();

            return Common.SendRealVaultRequest(xmlString);
        }