Ejemplo n.º 1
0
 /// <summary>
 /// Girilen parametrelerle request başlatır ve response bilgileri ile döner
 /// </summary>
 /// <param name="config">PayuLib.Config türünde configurations</param>
 /// <returns></returns>
 public static bool Complete(AppConfig config) {
     try {
         Hashtable cnf = AppConfig.My;
         string account = cnf[PayuLib.Constants.MerchantPosId].ToString();
         string secretKey = config.SignatureKey;
         string openPayuEndPointUrl = config.Environment;
         string xml = OpenPayU.buildOpenPayUDocument(cnf);
         Request.LOG[VALUE_XML_REQUEST] = xml;
         string responseXMLstring = OpenPayU.sendOpenPayuDocumentAuth(
             xml, account, secretKey, openPayuEndPointUrl, config);
         Request.LOG[VALUE_XML_RESPONSE] = responseXMLstring;
         Response.SetXMLString(responseXMLstring);
         Request.setResponse(responseXMLstring);
         if (Response.Succes(config.CurrentVersion)) {
             Request.LOG[VALUE_ERROR] = Response.GetErrorMessage();
             return true;
         } else {
             Request.LOG[VALUE_ERROR] = Response.GetErrorMessage();
             return false;
         }
     } catch (Exception e) {
         Response.SetErrorMessage("Library Exception: " + e.Message);
         Request.LOG[VALUE_ERROR] = Response.GetErrorMessage();
         return false;
     }
 }
Ejemplo n.º 2
0
        public static string sendOpenPayuDocumentAuth(string xml, string merchantPosId,
            string signatureKey, string openPayuEndPointUrl, AppConfig config) 
        {
            if (openPayuEndPointUrl == "") {
                throw new Exception(PayuLib.SystemMessages.getMessage(config.CurrentVersion, PayuLib.SystemMessages.openPayuEndPointUrl));
            }

            if (signatureKey == null || signatureKey == "") {
                throw new Exception(PayuLib.SystemMessages.getMessage(config.CurrentVersion, PayuLib.SystemMessages.signatureKey));
            }

            if (merchantPosId == null || merchantPosId == "") {
                throw new Exception(PayuLib.SystemMessages.getMessage(config.CurrentVersion, PayuLib.SystemMessages.merchantPosId));
            }
            string tosigndata = xml + signatureKey;
            xml = System.Web.HttpUtility.UrlEncode(xml);
            string signature = OpenPayU.PayuSHA256(tosigndata);
            
            StringBuilder sb = new StringBuilder();
            string authData = sb.AppendFormat(PayuLib.PayuInternals.auth_data_string_format, merchantPosId, signature).ToString();
            string authData2 = "OpenPayu-Signature:sender=" + merchantPosId +
                    ";signature=" + signature +
                    ";algorithm=SHA256" +
                    ";content=DOCUMENT";
            string response = "";
            response = OpenPayU.sendDataAuth(openPayuEndPointUrl, "DOCUMENT=" + xml, authData);
            return response;
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            NameValueCollection nvc = Request.Form;

            payu.AppConfig conf = new payu.AppConfig();

            conf.SetSignatureKey("SECRET_KEY");
            conf.SetEnvironment("https://secure.payu.com.tr/openpayu/v2/order.xml");
            conf.CurrentVersion = "TR";
            conf.Set(payu.Constants.ReqId, payu.OpenPayU.gen_uuid())
            .Set(payu.Constants.CurrencyCode, "TRY")
            .Set(payu.Constants.CustomerIp, "127.0.0.1")
            .Set(payu.Constants.ExtOrderId, "ExtOrderId0")
            .Set(payu.Constants.MerchantPosId, "OPU_TEST")
            .Set(payu.Constants.Description, nvc["Description"])
            .Set(payu.Constants.TotalAmount, nvc["Amount"]);

            conf.SetBuyer(payu.Constants.FirstName, nvc["FirstName"])
            .SetBuyer(payu.Constants.LastName, nvc["LastName"])
            .SetBuyer(payu.Constants.CountryCode, "tr")
            .SetBuyer(payu.Constants.Email, nvc["Email"])
            .SetBuyer(payu.Constants.PhoneNumber, nvc["Phone"])
            .SetBuyer(payu.Constants.Language, "en");

            conf.SetProduct(payu.Constants.Name, "My Product1 Name")
            .SetProduct(payu.Constants.UnitPrice, "75")
            .SetProduct(payu.Constants.Quantity, "2")
            .Update();

            conf.SetProduct(payu.Constants.Name, "My Product 2 Name")
            .SetProduct(payu.Constants.UnitPrice, "40")
            .SetProduct(payu.Constants.Quantity, "1")
            .Update();

            conf.Set(payu.Constants.PayMethod, "DEFAULT")
            .Completed();

            string      JsonStr = "";
            string      XMLStr  = "";
            XmlDocument doc     = new XmlDocument();

            if (PayuLib.Request.Complete(conf))
            {
                XMLStr = payu.Response.GetXMLString();

                doc.LoadXml(XMLStr);
                JsonStr = PayuLib.JsonSerializer.XmlToJSON(doc);
            }
            else
            {
            }
            Response.AddHeader("Content-type", "text/json");
            Response.Write(JsonStr);
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e) {

            NameValueCollection nvc = Request.Form;

            payu.AppConfig conf = new payu.AppConfig();

            conf.SetSignatureKey("SECRET_KEY");
            conf.SetEnvironment("https://secure.payu.com.tr/openpayu/v2/order.xml");
            conf.CurrentVersion = "TR";
            conf.Set(payu.Constants.ReqId, payu.OpenPayU.gen_uuid())
                .Set(payu.Constants.CurrencyCode, "TRY")
                .Set(payu.Constants.CustomerIp, "127.0.0.1")
                .Set(payu.Constants.ExtOrderId, "ExtOrderId0")
                .Set(payu.Constants.MerchantPosId, "OPU_TEST")
                .Set(payu.Constants.Description, nvc["Description"])
                .Set(payu.Constants.TotalAmount, nvc["Amount"]);

            conf.SetBuyer(payu.Constants.FirstName, nvc["FirstName"])
                .SetBuyer(payu.Constants.LastName, nvc["LastName"])
                .SetBuyer(payu.Constants.CountryCode, "tr")
                .SetBuyer(payu.Constants.Email, nvc["Email"])
                .SetBuyer(payu.Constants.PhoneNumber, nvc["Phone"])
                .SetBuyer(payu.Constants.Language, "en");

            conf.SetProduct(payu.Constants.Name, "My Product1 Name")
                .SetProduct(payu.Constants.UnitPrice, "75")
                .SetProduct(payu.Constants.Quantity, "2")
                .Update();

            conf.SetProduct(payu.Constants.Name, "My Product 2 Name")
                .SetProduct(payu.Constants.UnitPrice, "40")
                .SetProduct(payu.Constants.Quantity, "1")
                .Update();

            conf.Set(payu.Constants.PayMethod, "DEFAULT")
                .Completed();

            string JsonStr = "";
            string XMLStr = "";
            XmlDocument doc = new XmlDocument();

            if (PayuLib.Request.Complete(conf)) {
                XMLStr = payu.Response.GetXMLString();
                
                doc.LoadXml(XMLStr);                
                JsonStr = PayuLib.JsonSerializer.XmlToJSON(doc);
            } else {
                
            }
            Response.AddHeader("Content-type", "text/json");
            Response.Write(JsonStr);
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            payu.AppConfig conf = new payu.AppConfig();

            conf.SetSignatureKey("SECRET_KEY");
            conf.SetEnvironment("https://secure.payu.com.tr/openpayu/v2/order.xml");
            conf.CurrentVersion = "TR";
            conf.Set(payu.Constants.ReqId, payu.OpenPayU.gen_uuid())
            .Set(payu.Constants.CurrencyCode, "TRY")
            .Set(payu.Constants.CustomerIp, "127.0.0.1")
            .Set(payu.Constants.ExtOrderId, "ExtOrderId0")
            .Set(payu.Constants.MerchantPosId, "OPU_TEST")
            .Set(payu.Constants.Description, "My Description")
            .Set(payu.Constants.TotalAmount, "190");

            conf.SetBuyer(payu.Constants.FirstName, "Vefa")
            .SetBuyer(payu.Constants.LastName, "Kayacı")
            .SetBuyer(payu.Constants.CountryCode, "tr")
            .SetBuyer(payu.Constants.Email, "*****@*****.**")
            .SetBuyer(payu.Constants.PhoneNumber, "09995320000")
            .SetBuyer(payu.Constants.Language, "en");

            conf.SetProduct(payu.Constants.Name, "My Product1 Name")
            .SetProduct(payu.Constants.UnitPrice, "75")
            .SetProduct(payu.Constants.Quantity, "2")
            .Update();

            conf.SetProduct(payu.Constants.Name, "My Product 2 Name")
            .SetProduct(payu.Constants.UnitPrice, "40")
            .SetProduct(payu.Constants.Quantity, "1")
            .Update();

            conf.Set(payu.Constants.PayMethod, "DEFAULT")
            .Completed();

            if (PayuLib.Request.Complete(conf))
            {
                string XMLStr = payu.Response.GetXMLString();
                //Console.WriteLine(XMLStr);
            }
            else
            {
                //Console.WriteLine(payu.Response.GetErrorMessage());
            }
            Console.WriteLine("Payu Sunucuya Gönderilen XML İfade: " + Response.GetLOG(Request.VALUE_XML_REQUEST));
            Console.WriteLine("\nPayu Sunucudan Dönen XML İfade: " + Response.GetLOG(Request.VALUE_XML_RESPONSE));
            Console.WriteLine("\nİşlemlerden Dönen Kod " + Response.GetLOG(Request.VALUE_ERROR));
            Console.Read();
        }
Ejemplo n.º 6
0
        static void Main(string[] args) {
            payu.AppConfig conf = new payu.AppConfig();

            conf.SetSignatureKey("SECRET_KEY");
            conf.SetEnvironment("https://secure.payu.com.tr/openpayu/v2/order.xml");
            conf.CurrentVersion = "TR";
            conf.Set(payu.Constants.ReqId, payu.OpenPayU.gen_uuid())
                .Set(payu.Constants.CurrencyCode, "TRY")
                .Set(payu.Constants.CustomerIp, "127.0.0.1")
                .Set(payu.Constants.ExtOrderId, "ExtOrderId0")
                .Set(payu.Constants.MerchantPosId, "OPU_TEST")
                .Set(payu.Constants.Description, "My Description")
                .Set(payu.Constants.TotalAmount, "190");

            conf.SetBuyer(payu.Constants.FirstName, "Vefa")
                .SetBuyer(payu.Constants.LastName, "Kayacı")
                .SetBuyer(payu.Constants.CountryCode, "tr")
                .SetBuyer(payu.Constants.Email, "*****@*****.**")
                .SetBuyer(payu.Constants.PhoneNumber, "09995320000")
                .SetBuyer(payu.Constants.Language, "en");

            conf.SetProduct(payu.Constants.Name, "My Product1 Name")
                .SetProduct(payu.Constants.UnitPrice, "75")
                .SetProduct(payu.Constants.Quantity, "2")
                .Update();

            conf.SetProduct(payu.Constants.Name, "My Product 2 Name")
                .SetProduct(payu.Constants.UnitPrice, "40")
                .SetProduct(payu.Constants.Quantity, "1")
                .Update();

            conf.Set(payu.Constants.PayMethod, "DEFAULT")
                .Completed();

            if (PayuLib.Request.Complete(conf)) {
                string XMLStr = payu.Response.GetXMLString();
                //Console.WriteLine(XMLStr);
            } else {
                //Console.WriteLine(payu.Response.GetErrorMessage());
            }
            Console.WriteLine("Payu Sunucuya Gönderilen XML İfade: " + Response.GetLOG(Request.VALUE_XML_REQUEST));
            Console.WriteLine("\nPayu Sunucudan Dönen XML İfade: " + Response.GetLOG(Request.VALUE_XML_RESPONSE));
            Console.WriteLine("\nİşlemlerden Dönen Kod " + Response.GetLOG(Request.VALUE_ERROR));
            Console.Read();
        }