예제 #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);
     }
 }
예제 #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);
        }
예제 #3
0
        public static string buildOpenPayUDocument(object config,
                                                   string startElement = "OrderCreateRequest", int request = 1,
                                                   string xml_version  = "1.0", string xml_encoding        = "UTF-8")
        {
            if (config.GetType().ToString() != "System.Collections.Hashtable")
            {
                return(null);
            }
            StringWriter  sw     = new StringWriter();
            XmlTextWriter writer = new XmlTextWriter(sw);

            writer.WriteStartElement(startElement);
            Hashtable data1 = config as Hashtable;

            OpenPayU.arr2xml(writer, data1);
            writer.WriteEndElement();
            writer.Flush();
            StringBuilder sb        = new StringBuilder();
            string        xmlString = sb.AppendFormat(PayuLib.PayuInternals.xmlStringFormat, sw.ToString()).ToString();

            string xmlStringOLD = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                                  "<OpenPayU xmlns=\"http://www.openpayu.com/openpayu.xsd\">" +
                                  sw.ToString() + "</OpenPayU>";

            writer.Close();
            sw.Close();
            return(xmlString);
        }
예제 #4
0
        public static string gen_uuid()
        {
            string uuid =
                OpenPayU.ForBitHex() + OpenPayU.ForBitHex() +
                OpenPayU.ForBitHex() + "-" + OpenPayU.ForBitHex() + "-" + OpenPayU.ForBitHex() + "-" +
                OpenPayU.ForBitHex() + OpenPayU.ForBitHex() + OpenPayU.ForBitHex();

            return(uuid.ToLower());
        }
예제 #5
0
        private static void arr2xml(XmlWriter xml, Hashtable data)
        {
            string substr = "";
            int    status = 0;

            if (data != null && data.GetType().ToString() == "System.Collections.Hashtable")
            {
                foreach (DictionaryEntry item in data)
                {
                    if (item.Value.GetType().ToString() == "System.Collections.Hashtable")
                    {
                        xml.WriteStartElement(item.Key.ToString());
                        Hashtable v2 = item.Value as Hashtable;
                        OpenPayU.arr2xml(xml, v2);
                        xml.WriteEndElement();
                        status = 0;
                        continue;
                    }
                    else
                    {
                        status = 0;
                        substr = item.Value.GetType().ToString();
                        if (substr.Length > 30)
                        {
                            substr = item.Value.GetType().ToString().Substring(0, 32);
                        }
                        if (substr == "System.Collections.Generic.Stack")
                        {
                            xml.WriteStartElement(item.Key.ToString());
                            status = 1;
                            Stack <Hashtable> v3 = item.Value as Stack <Hashtable>;
                            foreach (Hashtable item2 in v3)
                            {
                                Hashtable v4 = item2 as Hashtable;
                                OpenPayU.arr2xml(xml, v4);
                            }
                            xml.WriteEndElement();
                            continue;
                        }
                    }
                    if (status == 0)
                    {
                        xml.WriteElementString(item.Key.ToString(), item.Value.ToString());
                    }
                    status = 0;
                }
            }
        }