示例#1
0
        public static BEWSGenCIPResponseMod1 GenerarCIPMod1(BEWSGenCIPRequestMod1 request)
        {
            BEWSGenCIPResponseMod1 response = new BEWSGenCIPResponseMod1();

            using (var proxy = new WSCrypto())
            {
                proxy.Credentials       = System.Net.CredentialCache.DefaultNetworkCredentials;
                proxy.Proxy             = WebProxy.GetDefaultProxy();
                proxy.Proxy.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
                request.Xml             = request.Xml.Trim();
                request.Firma           = proxy.Signer(request.Xml, ByteUtil.FileToByteArray(PrivatePath));
                request.Xml             = proxy.EncryptText(request.Xml, ByteUtil.FileToByteArray(PublicPathContraparte));
                using (var proxyCIP = new Service())
                {
                    response = proxyCIP.GenerarCIPMod1(request);
                    if (response != null)
                    {
                        if (!String.IsNullOrEmpty(response.Xml))
                        {
                            response.Xml = proxy.DecryptText(response.Xml, ByteUtil.FileToByteArray(PrivatePath));
                        }
                    }
                }
            }
            return(response);
        }
示例#2
0
        public static BEpaymentResponse GenerarCIP(BEGenRequest paymentRequest)
        {
            BEWSGenCIPRequestMod1 solicitud = new BEWSGenCIPRequestMod1();

            solicitud.CodServ = ConfigurationManager.AppSettings["PE_MERCHAND_ID"];
            bl_helper hlp = new bl_helper();

            solicitud.Xml = hlp.convertToXml(ref paymentRequest).Replace("BEGenRequest", "SolPago");

            BEWSGenCIPResponseMod1 response = new BEWSGenCIPResponseMod1();

            using (var proxy = new WSCrypto())
            {
                proxy.Credentials       = System.Net.CredentialCache.DefaultNetworkCredentials;
                proxy.Proxy             = WebProxy.GetDefaultProxy();
                proxy.Proxy.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
                solicitud.Xml           = solicitud.Xml.Trim();
                solicitud.Firma         = proxy.Signer(solicitud.Xml, ByteUtil.FileToByteArray(PrivateKey));
                solicitud.Xml           = proxy.EncryptText(solicitud.Xml, ByteUtil.FileToByteArray(PublicKey));
                using (var proxyCIP = new Service())
                {
                    response = proxyCIP.GenerarCIPMod1(solicitud);
                    if (response != null)
                    {
                        if (!String.IsNullOrEmpty(response.Xml))
                        {
                            response.Xml = proxy.DecryptText(response.Xml, ByteUtil.FileToByteArray(PrivateKey));
                        }
                    }
                }
            }
            BEpaymentResponse paymentResponse = new BEpaymentResponse();
            XmlElement        element         = default(XmlElement);

            if ((response != null))
            {
                XmlDocument xml = new XmlDocument();
                xml.InnerXml = response.Xml;
                element      = (XmlElement)xml.SelectSingleNode("ConfirSolPago");
                XmlElement elementchild           = (XmlElement)element.SelectSingleNode("CIP");
                XmlElement elementchildCIP        = (XmlElement)elementchild.SelectSingleNode("NumeroOrdenPago");
                XmlElement elementchildMerchandID = (XmlElement)elementchild.SelectSingleNode("MerchantID");
                XmlElement elementchildtoken      = (XmlElement)element.SelectSingleNode("Token");

                paymentResponse.NumeroCip  = elementchildCIP.InnerText;
                paymentResponse.IdComercio = elementchildMerchandID.InnerText;
                paymentResponse.Token      = elementchildtoken.InnerText;
                paymentResponse.Estado     = response.Estado;
                paymentResponse.Mensaje    = response.Mensaje;
                paymentResponse.Xml        = response.Xml;
            }
            else
            {
                return(null);
            }
            return(paymentResponse);
        }
示例#3
0
        private void GenerarCip()
        {
            try
            {
                BEWSGenCIPRequestMod1 request = new BEWSGenCIPRequestMod1();
                //string pathPublicKeyContraparte = ConfigurationManager.AppSettings["pathPublicKeyContraparte"];
                //string pathPrivateKey = ConfigurationManager.AppSettings["pathPrivateKey"];
                string CodServicio = ConfigurationManager.AppSettings["cCodServicio"];

                string path = MapPath("/claves/");
                string pathPublicKeyContraparte = path + ConfigurationManager.AppSettings["pathPublicKeyContraparte"];
                string pathPrivateKey           = path + ConfigurationManager.AppSettings["pathPrivateKey"];

                request.CodServ = CodServicio;
                request.Xml     = GenerarXML();

                SPE.Api.PagoEfectivo.PrivatePath           = pathPrivateKey;
                SPE.Api.PagoEfectivo.PublicPathContraparte = pathPublicKeyContraparte;

                BEWSGenCIPResponseMod1 response = SPE.Api.PagoEfectivo.GenerarCIPMod1(request);

                if (response != null)
                {
                    XmlDocument xml = new XmlDocument();
                    xml.InnerXml = response.Xml;
                    XmlNode element           = xml.SelectSingleNode("ConfirSolPago");
                    XmlNode elementchild      = element.SelectSingleNode("CIP");
                    XmlNode elementchildCIP   = elementchild.SelectSingleNode("NumeroOrdenPago");
                    string  strCIP            = elementchildCIP.InnerText;
                    XmlNode elementchildtoken = element.SelectSingleNode("Token");
                    string  UrlRedirect       = ConfigurationManager.AppSettings["UrlSPE"] + "/GenPagoIF.aspx?Token=" + elementchildtoken.InnerText;
                    ltlUrl.Text = ltlUrl.Text + "<iframe style='width:100%;height:1285px;' src=" + UrlRedirect + "></iframe>";

                    CarritoBE objCarritoBE = (CarritoBE)Session["CARRITO"];
                    objCarritoBE.Cip   = elementchildCIP.InnerText;
                    Session["CARRITO"] = objCarritoBE;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }