Пример #1
0
 private static void ProcessPaymentRequest(HttpContext context)
 {
     if (context.Request["action"] == "getlist")
     {
         PaymentPlugins paymentPlugins = PaymentPlugins.Instance();
         context.Response.ContentType = "application/json";
         context.Response.Write(paymentPlugins.GetPlugins().ToJsonString());
     }
     else
     {
         if (context.Request["action"] == "getmetadata")
         {
             context.Response.ContentType = "text/xml";
             PaymentRequest paymentRequest = PaymentRequest.CreateInstance(context.Request["name"]);
             if (paymentRequest == null)
             {
                 context.Response.Write("<xml></xml>");
             }
             else
             {
                 context.Response.Write(paymentRequest.GetMetaData().OuterXml);
             }
         }
     }
 }
Пример #2
0
        public static PaymentNotify CreateInstance(string name, NameValueCollection parameters)
        {
            PaymentNotify result;

            if (string.IsNullOrEmpty(name))
            {
                result = null;
            }
            else
            {
                object[] args = new object[]
                {
                    parameters
                };
                PaymentPlugins paymentPlugins = PaymentPlugins.Instance();
                Type           plugin         = paymentPlugins.GetPlugin("PaymentRequest", name);
                if (plugin == null)
                {
                    result = null;
                }
                else
                {
                    Type pluginWithNamespace = paymentPlugins.GetPluginWithNamespace("PaymentNotify", plugin.Namespace);
                    if (pluginWithNamespace == null)
                    {
                        result = null;
                    }
                    else
                    {
                        result = (Activator.CreateInstance(pluginWithNamespace, args) as PaymentNotify);
                    }
                }
            }
            return(result);
        }
Пример #3
0
        public static PaymentRequest CreateInstance(string name, string configXml, string orderId, decimal amount, string subject, string body, string buyerEmail, DateTime date, string showUrl, string returnUrl, string notifyUrl, string attach)
        {
            PaymentRequest result;

            if (string.IsNullOrEmpty(name))
            {
                result = null;
            }
            else
            {
                object[] args = new object[]
                {
                    orderId,
                    amount,
                    subject,
                    body,
                    buyerEmail,
                    date,
                    showUrl,
                    returnUrl,
                    notifyUrl,
                    attach
                };
                Type plugin = PaymentPlugins.Instance().GetPlugin("PaymentRequest", name);
                if (plugin == null)
                {
                    result = null;
                }
                else
                {
                    PaymentRequest paymentRequest = Activator.CreateInstance(plugin, args) as PaymentRequest;
                    if (paymentRequest != null && !string.IsNullOrEmpty(configXml))
                    {
                        XmlDocument xmlDocument = new XmlDocument();
                        xmlDocument.LoadXml(configXml);
                        paymentRequest.InitConfig(xmlDocument.FirstChild);
                    }
                    result = paymentRequest;
                }
            }
            return(result);
        }
Пример #4
0
 public static PaymentPlugins Instance()
 {
     if (PaymentPlugins.instance == null)
     {
         object lockHelper;
         Monitor.Enter(lockHelper = PaymentPlugins.LockHelper);
         try
         {
             if (PaymentPlugins.instance == null)
             {
                 PaymentPlugins.instance = new PaymentPlugins();
             }
         }
         finally
         {
             Monitor.Exit(lockHelper);
         }
     }
     PaymentPlugins.instance.VerifyIndex();
     return(PaymentPlugins.instance);
 }
Пример #5
0
        public static PaymentRequest CreateInstance(string name)
        {
            PaymentRequest result;

            if (string.IsNullOrEmpty(name))
            {
                result = null;
            }
            else
            {
                Type plugin = PaymentPlugins.Instance().GetPlugin("PaymentRequest", name);
                if (plugin == null)
                {
                    result = null;
                }
                else
                {
                    result = (Activator.CreateInstance(plugin) as PaymentRequest);
                }
            }
            return(result);
        }