Hace poco me llego la tarea de conectar un "webservice" para validar un PIN de tarjetas, pero el codigo viene en C# y la verdad no entiendo mucho... la duda es como puedo ejecutar este codigo en php o si tengo que transformar para conectar y validar los PIN
Aquí dejo una parte del codigo
Código:
Si me pueden dar alguna idea de que tengo que hacer para validar los PIN.using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml; using System.Net; namespace PinTest { public class PinTest { public static void Run() { PinTest test = new PinTest("https://url.com/pingen"); var reply = test.CreatePin("XXX", "XXX", "000-000-001", 1000, 0, 6); DisplayXml(reply); } private string urlBase; public PinTest(string urlBase) { this.urlBase = urlBase; } private XmlDocument CreatePin(string authUser, string authPassword, string cardNumber, int creditAmount, int siteCode, int pinLength) { StringBuilder xml = new StringBuilder(); xml.AppendLine("<PinRequest>"); xml.AppendFormat("<AuthUser>{0}</AuthUser>\n", authUser); xml.AppendFormat("<AuthPassword>{0}</AuthPassword>\n", authPassword); xml.AppendFormat("<CardNumber>{0}</CardNumber>\n", cardNumber); xml.AppendFormat("<CreditAmount>{0}</CreditAmount>", creditAmount); xml.AppendFormat("<PINLength>{0}</PINLength>", pinLength); xml.AppendFormat("<SiteCode>{0}</SiteCode>", siteCode); xml.AppendLine("</PinRequest>"); XmlDocument doc = this.DoHttpPost("createPIN", xml.ToString()); if (doc.DocumentElement.Name != "PinResponse") throw new Exception("PinService.CreatePin: Unexpected Reply: \n" + doc.DocumentElement.OuterXml); return doc; } private XmlDocument DoHttpPost(string url, string xmlContent) { HttpWebRequest req = (HttpWebRequest)WebRequest.Create(string.Format("{0}/PinService.svc/{1}", this.urlBase, url)); byte[] xmlBytes = Encoding.UTF8.GetBytes(xmlContent); req.Method = "POST"; req.ContentType = "text/xml;"; req.ContentLength = xmlBytes.Length; req.GetRequestStream().Write(xmlBytes, 0, xmlBytes.Length); WebResponse resp = req.GetResponse(); string contentType = resp.ContentType.Split(' ', ';')[0]; switch (contentType) { case "application/xml": { XmlDocument doc = new XmlDocument(); doc.Load(resp.GetResponseStream()); return doc; } default: throw new Exception("PinService.DoHttpPost: Unsupported Content Type: " + resp.ContentType); } } private static void DisplayXml(XmlDocument doc) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; XmlWriter writer = XmlWriter.Create(Console.Out, settings); doc.WriteTo(writer); writer.Flush(); } } }
Slds!