//this doesnt work and I dont need it so tough
    protected void lb3DSecureReciept_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("transaction01", "EUR", 9999);
        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 cardRef = "card1";
        string cvn = "123";
        string autoSettle = "1";

        RealVaultTransactionResponse resp = RealVault.RealVault3DSVerifyEnrolled(merchant, order, payer, cardRef, autoSettle, timestamp, new ArrayList());
        //TODO: Run RealAuth verify signed
        //TODO: Run Reciept-In with 3d secure details

        lblErrorCode.Text = resp.ResultCode.ToString();
        lblResult.Text = resp.Message;
    }
    protected void lbBasicAuth_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);
        //working
        CreditCard card = new CreditCard("MC", "5425232820001308", "0118", "Phil McCracken", "123", 1);
        //invalid
        //CreditCard card = new CreditCard("MC", "1234123412341234", "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.Auth(merchant, order, card, autoSettle, timestamp);

        lblErrorCode.Text = resp.ResultCode.ToString();
        lblResult.Text = resp.ResultMessage;
    }
Exemple #3
0
        /// <summary>
        /// Cancel existing card
        /// </summary>
        /// <param name="timestamp">timestamp</param>
        /// <param name="cardRef">card ref to be cancelled</param>
        /// <param name="merchant">merchant details</param>
        /// <param name="payer">payer details</param>
        /// <returns>real vault transaction response</returns>
        public static RealVaultTransactionResponse CardCancelCard(string timestamp, string cardRef, Merchant merchant, Payer payer)
        {
            string hashInput = timestamp + "." +
                merchant.MerchantId + "." +
                payer.PayerRef + "." +
                cardRef;
            string SHA1Hash = Common.GenerateSHA1Hash(hashInput, merchant.SharedSecret);

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

            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.WriteStartElement("card");
                {
                    xml.WriteElementString("ref", cardRef);
                    xml.WriteElementString("payerref", payer.PayerRef);
                }
                xml.WriteEndElement();

                xml.WriteElementString("sha1hash", SHA1Hash);

            }
            xml.WriteEndElement();

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

            xmlString = strBuilder.ToString();

            return Common.SendRealVaultRequest(xmlString);
        }
    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;
    }
    protected void lbCancelCard_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);
        Address address = new Address("", "", "", "", "", "", "", "");
        PhoneNumbers numbers = new PhoneNumbers("", "", "", "");
        Payer payer = new Payer("Business", "test", "", "First", "Second", "", address, numbers, "", new ArrayList());

        string cardRef = "card1";

        string timestamp = Common.GenerateTimestamp();

        RealVaultTransactionResponse resp = RealVault.CardCancelCard(timestamp, cardRef, merchant, payer);

        lblErrorCode.Text = resp.ResultCode.ToString();
        lblResult.Text = resp.Message;
    }
    protected void lbEditPayer_Click(object sender, EventArgs e)
    {
        string merchantId = ConfigurationManager.AppSettings["MerchantID"];
        string account = ConfigurationManager.AppSettings["Account"];
        string sharedSecret = ConfigurationManager.AppSettings["SharedSecret"];

        string timestamp = Common.GenerateTimestamp();

        Merchant merchant = new Merchant(merchantId, account, sharedSecret);
        Order order = new Order("123123wdfsdf", "GBP", 00);
        Address address = new Address("", "", "", "", "", "", "", "");
        PhoneNumbers numbers = new PhoneNumbers("", "", "", "");
        Payer payer = new Payer("Business", "test", "", "Phil", "McCracken", "", address, numbers, "", new ArrayList());
        CreditCard card = new CreditCard("MC", "5425232820001308", "0118", "Phil McCracken", "123", 1);

        RealVaultTransactionResponse resp = RealVault.PayerEdit(timestamp, merchant, order, payer, new ArrayList());

        lblErrorCode.Text = resp.ResultCode.ToString();
        lblResult.Text = resp.Message;
    }
    protected void lblbRecieptIn_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", 9999);
        Address address = new Address("", "", "", "", "", "", "", "");
        PhoneNumbers numbers = new PhoneNumbers("", "", "", "");
        Payer payer = new Payer("Business", "test", "", "Phil", "McCracken", "", address, numbers, "", new ArrayList());

        string timestamp = Common.GenerateTimestamp();

        //only needed if
        //string cvn = "123";
        string cardRef = "card1";
        string autoSettle = "1";

        //not needed if not a recurring payment, use reciept in overload without recurring
        bool recurring = true;

        //fixed or variable
        //fixed - order amount is the same every transaction
        //variable - order amount is different in every transaction
        string recurringType = "variable";

        //first - first payment in a sequence
        //subsequent - any subsequent payments after the initial
        //final - no more payments in sequence will follow
        string recurringSequence = "first";

        RealVaultTransactionResponse resp = RealVault.RecieptIn(merchant, order, payer, cardRef, autoSettle, timestamp, new ArrayList(), recurring, recurringType, recurringSequence);

        lblErrorCode.Text = resp.ResultCode.ToString();
        lblResult.Text = resp.Message;
    }
Exemple #8
0
        /// <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 lbNewPayer_Click(object sender, EventArgs e)
    {
        string merchantId = ConfigurationManager.AppSettings["MerchantID"];
        string account = ConfigurationManager.AppSettings["Account"];
        string sharedSecret = ConfigurationManager.AppSettings["SharedSecret"];

        //You need to generate the following to complete any process, the following order might be helpful as well.
        //Timestamp ==> Merchant ==> Order ==> Address ==> PhoneNumbers ==> Payer ==> CreditCard ==> SHA1Hash

        //Current timestamp
        string timestamp = Common.GenerateTimestamp();

        //New Merchant
        //merchant id
        //account
        //shared secret
        Merchant merchant = new Merchant(merchantId, account, sharedSecret);

        //New Order
        //order id (optional)
        //currency code
        //order amount
        Order order = new Order("123123wdfsdf", "GBP", 1099);

        //New Address (optional)
        //Line 1 (optional)
        //Line 2 (optional)
        //Line 3 (optional)
        //City (optional)
        //County (optional)
        //Postcode (optional)
        //Country Code (optional)
        //Country Name (optional)
        Address address = new Address("", "", "", "", "", "", "", "");

        //New Phone Numbers (optional)
        //home (optional)
        //work (optional)
        //fax (optional)
        //mobile (optional)
        PhoneNumbers numbers = new PhoneNumbers("", "", "", "");

        //New Payer
        //Payer type (default to 'Business')
        //Payer ref
        //Title (optional)
        //First Name
        //Surname
        //Company (optional)
        //Address (optional)
        //Numbers (optional)
        //email (optional)
        //comments (optional)
        Payer payer = new Payer("Business", "test", "", "First", "Second", "", address, numbers, "", new ArrayList());

        //New Credit Card
        //Card type
        //Card number
        //Expiry date
        //Cardholder name
        //cvn
        //Is cvn present
        //Issue number (optional)
        CreditCard card = new CreditCard("MC", "5425232820001308", "0118", "Phil McCracken", "123", 1);

        //Create new payer
        //timestamp
        //SHA1Hash
        //merchant
        //order
        //payer
        //comments
        RealVaultTransactionResponse resp = RealVault.PayerNew(timestamp, merchant, order, payer, new ArrayList());

        lblErrorCode.Text = resp.ResultCode.ToString();
        lblResult.Text = resp.Message;
    }
Exemple #10
0
        /// <summary>
        /// Verify card stored is 3d secured
        /// </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 verify</param>
        /// <param name="autoSettle">auto settle with bank</param>
        /// <param name="timestamp">timestamp</param>
        /// <param name="comments">comments</param>
        /// <returns></returns>
        public static RealVaultTransactionResponse RealVault3DSVerifyEnrolled(Merchant merchant, Order order, Payer payer, string cardRef, string autoSettle, string timestamp, ArrayList comments)
        {
            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 = "realvault-3ds-verifyenrolled";

            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.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();

            }
            xml.WriteEndElement();

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

            xmlString = strBuilder.ToString();

            return Common.SendRealVaultRequest(xmlString);
        }
Exemple #11
0
        /// <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));
        }
Exemple #12
0
        //3D Secure
        #region RealVault-3DS-VerifyEnrolled

        /// <summary>
        /// Verify card stored is 3d secured
        /// </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 verify</param>
        /// <param name="autoSettle">auto settle with bank</param>
        /// <param name="timestamp">timestamp</param>
        /// <param name="comments">comments</param>
        /// <returns></returns>
        public static RealVaultTransactionResponse RealVault3DSVerifyEnrolled(Merchant merchant, Order order, Payer payer, string cardRef, string autoSettle, string timestamp, ArrayList comments)
        {
            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 = "realvault-3ds-verifyenrolled";

            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.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();
            }
            xml.WriteEndElement();

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

            xmlString = strBuilder.ToString();

            return(Common.SendRealVaultRequest(xmlString));
        }
Exemple #13
0
        /// <summary>
        /// Cancel existing card
        /// </summary>
        /// <param name="timestamp">timestamp</param>
        /// <param name="cardRef">card ref to be cancelled</param>
        /// <param name="merchant">merchant details</param>
        /// <param name="payer">payer details</param>
        /// <returns>real vault transaction response</returns>
        public static RealVaultTransactionResponse CardCancelCard(string timestamp, string cardRef, Merchant merchant, Payer payer)
        {
            string hashInput = timestamp + "." +
                               merchant.MerchantId + "." +
                               payer.PayerRef + "." +
                               cardRef;
            string SHA1Hash = Common.GenerateSHA1Hash(hashInput, merchant.SharedSecret);

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

            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.WriteStartElement("card");
                {
                    xml.WriteElementString("ref", cardRef);
                    xml.WriteElementString("payerref", payer.PayerRef);
                }
                xml.WriteEndElement();

                xml.WriteElementString("sha1hash", SHA1Hash);
            }
            xml.WriteEndElement();

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

            xmlString = strBuilder.ToString();

            return(Common.SendRealVaultRequest(xmlString));
        }
Exemple #14
0
        /// <summary>
        /// Create new payer
        /// </summary>
        /// <param name="timestamp">timestamp</param>
        /// <param name="merchant">merchant details</param>
        /// <param name="order">order details</param>
        /// <param name="payer">payer details</param>
        /// <param name="comments">comment details - can use new ArrayList()</param>
        /// <returns>transaction response</returns>
        public static RealVaultTransactionResponse PayerNew(String timestamp, Merchant merchant, Order order, Payer payer, ArrayList comments)
        {
            string hashInput =
                timestamp + "." +
                merchant.MerchantId + "." +
                order.OrderId + "." +
                "" + "." + //documentation says to put order amount in here... its only wants blank
                "" + "." + //documentation says to put order currency in here... its only wants blank
                payer.PayerRef;
            string SHA1Hash = Common.GenerateSHA1Hash(hashInput, merchant.SharedSecret);

            String xmlString = string.Empty;
            String requestType = "payer-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);

                //payer details
                payer.WriteXml(xml);

                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.SendRealVaultRequest(xmlString);
        }
Exemple #15
0
        /// <summary>
        /// Update existing card
        /// </summary>
        /// <param name="timestamp">timestamp</param>
        /// <param name="cardRef">card ref to be updated</param>
        /// <param name="merchant">merchant details</param>
        /// <param name="card">card details</param>
        /// <param name="payer">payer details</param>
        /// <returns>real vault transaction response</returns>
        public static RealVaultTransactionResponse CardUpdateCard(string timestamp, string cardRef, Merchant merchant, CreditCard card, Payer payer)
        {
            string hashInput = timestamp + "." +
                               merchant.MerchantId + "." +
                               payer.PayerRef + "." +
                               cardRef + "." +
                               card.ExpiryDate + "." +
                               card.CardNumber;
            string SHA1Hash = Common.GenerateSHA1Hash(hashInput, merchant.SharedSecret);

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

            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.WriteStartElement("card");
                {
                    xml.WriteElementString("ref", cardRef);
                    xml.WriteElementString("payerref", payer.PayerRef);
                    xml.WriteElementString("number", card.CardNumber);
                    xml.WriteElementString("expdate", card.ExpiryDate);
                    xml.WriteElementString("chname", card.CardholderName);
                    xml.WriteElementString("type", card.CardType);
                    if (card.CardType.Equals("SWITCH"))
                    {
                        xml.WriteElementString("issueno", card.IssueNumber.ToString());
                    }
                }
                xml.WriteEndElement();

                xml.WriteElementString("sha1hash", SHA1Hash);
            }
            xml.WriteEndElement();

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

            xmlString = strBuilder.ToString();

            return(Common.SendRealVaultRequest(xmlString));
        }
Exemple #16
0
        //Payer Management
        #region Payer-New

        /// <summary>
        /// Create new payer
        /// </summary>
        /// <param name="timestamp">timestamp</param>
        /// <param name="merchant">merchant details</param>
        /// <param name="order">order details</param>
        /// <param name="payer">payer details</param>
        /// <param name="comments">comment details - can use new ArrayList()</param>
        /// <returns>transaction response</returns>
        public static RealVaultTransactionResponse PayerNew(String timestamp, Merchant merchant, Order order, Payer payer, ArrayList comments)
        {
            string hashInput =
                timestamp + "." +
                merchant.MerchantId + "." +
                order.OrderId + "." +
                "" + "." + //documentation says to put order amount in here... its only wants blank
                "" + "." + //documentation says to put order currency in here... its only wants blank
                payer.PayerRef;
            string SHA1Hash = Common.GenerateSHA1Hash(hashInput, merchant.SharedSecret);

            String xmlString   = string.Empty;
            String requestType = "payer-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);

                //payer details
                payer.WriteXml(xml);

                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.SendRealVaultRequest(xmlString));
        }
Exemple #17
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);
        }
Exemple #18
0
        /// <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);
        }
Exemple #19
0
        /// <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);
        }