/**
         * Permite inicializar una transacción en Webpay. Como respuesta a la invocación se genera un token que representa en forma única una transacción.
         *
         * */
        public wsInitTransactionOutput initTransaction(decimal amount, string buyOrder, string sessionId, string urlReturn, string urlFinal)
        {
            wsInitTransactionInput initTransaction = new wsInitTransactionInput();

            /** Indica el tipo de transacción, su valor debe ser siempre TR_NORMAL_WS */
            initTransaction.wSTransactionType = wsTransactionType.TR_NORMAL_WS;

            initTransaction.buyOrder  = buyOrder;
            initTransaction.sessionId = sessionId;
            initTransaction.returnURL = urlReturn;
            initTransaction.finalURL  = urlFinal;

            wsTransactionDetail details = new wsTransactionDetail();

            details.commerceCode = this.config.CommerceCode;;
            details.buyOrder     = buyOrder;
            details.amount       = amount;

            wsTransactionDetail[] wsTransactionDetail = new wsTransactionDetail[] { details };

            initTransaction.transactionDetails = wsTransactionDetail;

            using (WSWebpayServiceImplService proxy = new WSWebpayServiceImplService())
            {
                PrepareProxy(proxy);
                wsInitTransactionOutput wsInitTransactionOutput = proxy.initTransaction(initTransaction);
                return(wsInitTransactionOutput);
            }
        }
        /**
         * Permite inicializar una transacción en Webpay.
         * Como respuesta a la invocación se genera un token que representa en forma única una transacción.
         * */
        public wsInitTransactionOutput initTransaction(string buyOrder, string sessionId, string urlReturn, string urlFinal, Dictionary <string, string[]> stores)
        {
            wsInitTransactionInput initTransaction = new wsInitTransactionInput();

            /** Indica el tipo de transacción, su valor debe ser siempre TR_MALL_WS */
            initTransaction.wSTransactionType = wsTransactionType.TR_MALL_WS;

            initTransaction.buyOrder  = buyOrder;
            initTransaction.sessionId = sessionId;

            initTransaction.returnURL  = urlReturn;
            initTransaction.finalURL   = urlFinal;
            initTransaction.commerceId = this.config.CommerceCode;

            wsTransactionDetail[] details = new wsTransactionDetail[100]; //Como ejemplo se agregan dos detalles de comercios

            int counter = 0;

            foreach (KeyValuePair <string, string[]> entry in stores)
            {
                details[counter] = new wsTransactionDetail
                {
                    commerceCode = entry.Value[0],
                    amount       = System.Convert.ToDecimal(entry.Value[1]),
                    buyOrder     = entry.Value[2],
                };

                counter++;
            }

            wsTransactionDetail[] wsTransactionDetail = new wsTransactionDetail[1];
            wsTransactionDetail = details;

            initTransaction.transactionDetails = wsTransactionDetail;

            using (WSWebpayServiceImplService proxy = new WSWebpayServiceImplService())
            {
                /*Define el ENDPOINT del Web Service Webpay*/
                proxy.Url = WSDL;

                Policy myPolicy = new Policy();
                myPolicy.Assertions.Add(new CustomPolicyAssertion(this.config));

                proxy.SetPolicy(myPolicy);
                proxy.Timeout = 60000;
                proxy.UseDefaultCredentials = false;

                wsInitTransactionOutput wsInitTransactionOutput = proxy.initTransaction(initTransaction);
                return(wsInitTransactionOutput);
            }
        }
Exemple #3
0
        /**
         * Permite inicializar una transacción en Webpay. Como respuesta a la invocación se genera un token que representa en forma única una transacción.
         *
         * */
        public wsInitTransactionOutput initTransaction(decimal amount, string buyOrder, string sessionId, string urlReturn, string urlFinal)
        {
            wsInitTransactionInput initTransaction = new wsInitTransactionInput();

            /** Indica el tipo de transacción, su valor debe ser siempre TR_NORMAL_WS */
            initTransaction.wSTransactionType = wsTransactionType.TR_NORMAL_WS;

            initTransaction.buyOrder  = buyOrder;
            initTransaction.sessionId = sessionId;
            initTransaction.returnURL = urlReturn;
            initTransaction.finalURL  = urlFinal;

            wsTransactionDetail details = new wsTransactionDetail();

            details.commerceCode = this.config.CommerceCode;;
            details.buyOrder     = buyOrder;
            details.amount       = amount;

            wsTransactionDetail[] wsTransactionDetail = new wsTransactionDetail[] { details };

            initTransaction.transactionDetails = wsTransactionDetail;

            using (WSWebpayServiceImplService proxy = new WSWebpayServiceImplService())
            {
                /*Define el ENDPOINT del Web Service Webpay*/
                proxy.Url = WSDL;

                Policy myPolicy = new Policy();
                myPolicy.Assertions.Add(new CustomPolicyAssertion(this.config));

                proxy.SetPolicy(myPolicy);
                proxy.Timeout = 60000;
                proxy.UseDefaultCredentials = false;

                wsInitTransactionOutput wsInitTransactionOutput = proxy.initTransaction(initTransaction);
                return(wsInitTransactionOutput);
            }
        }