Ejemplo n.º 1
0
        public Dictionary <string, string> saleTxnVerify(TransVerifyVM vm)
        {
            string PTInvoice = "<req>" +
                               "<mer_id>" + MerchantId + "</mer_id>" +
                               "<mer_txn_id>" + vm.MerRefID + "</mer_txn_id>" +
                               "<txn_uuid>" + vm.TxnUUID + "</txn_uuid>" +
                               "<action>" + vm.Action + "</action>";

            PTInvoice = PTInvoice + "</req>";

            var finalHex = Cryptographer.ByteArrayToString(Encoding.UTF8.GetBytes(PTInvoice));

            return(PearToPear(finalHex, false, vm.Action));
        }
Ejemplo n.º 2
0
        private Dictionary <string, string> PearToPear(string sessionXML, bool bEncrypt, string Action)
        {
            Dictionary <string, string> PeerReturns = new Dictionary <string, string>();
            string UserAgent = "Mozilla/4.0";

            var hashedData = Cryptographer.ConvertToSHA256(sessionXML);

            encodedData = "VERSION=" + Version + "&PWD=" + WebUtility.UrlDecode(Password) + "&MERCHANTID=" + MerchantId + "&KEY=" + Key + "&HASH=" + hashedData;

            if (bEncrypt)
            {
                encodedData = encodedData + "&ENINVOICE=" + Cryptographer.EncryptInvoice(sessionXML);
            }
            else
            {
                encodedData = encodedData + "&PTINVOICE=" + sessionXML;
            }

            dataToPost = Encoding.UTF8.GetBytes(encodedData);

            // Create a new HttpWebRequest object.
            HttpWebRequest request2 = (HttpWebRequest)WebRequest.Create(API_URL);

            request2.UserAgent     = UserAgent;
            request2.ContentType   = "application/x-www-form-urlencoded";
            request2.ContentLength = dataToPost.Length;

            // Set the Method property to 'POST' to post data to the URI.
            request2.Method = "POST";

            // start the asynchronous operation
            request2.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), request2);

            // Keep the main thread from continuing while the asynchronous
            // operation completes. A real world application
            // could do something useful such as updating its user interface.
            allDone.WaitOne();

            //Break the return values by char '&'
            var dicVariables = BreakResponseString(responseString);


            //PeerReturns.Add("ipay_out__txn_uuid", UUID);
            //PeerReturns.Add("ipay_out__ipg_txn_id", UUID);

            return(dicVariables);
        }
Ejemplo n.º 3
0
        public Dictionary <string, string> saleTxn(PostingVM vm)
        {
            Dictionary <string, string> SalesData = new Dictionary <string, string>();

            string PTInvoice = "<req>" +
                               "<mer_id>" + MerchantId + "</mer_id>" +
                               "<mer_txn_id>" + vm.MerRefID + "</mer_txn_id>" +
                               "<action>" + vm.Action + "</action>" +
                               "<txn_amt>" + vm.TxnAmount + "</txn_amt>" +
                               "<cur>" + vm.CurrencyCode + "</cur>" +
                               "<lang>" + vm.LanguageCode + "</lang>";

            if ((vm.ReturnURL != null) && (vm.ReturnURL.Length > 0))
            {
                PTInvoice = PTInvoice + "<ret_url>" + vm.ReturnURL + "</ret_url>";
            }

            if ((vm.MerVar1 != null) && (vm.MerVar1.Length > 0))
            {
                PTInvoice = PTInvoice + "<mer_var1>" + vm.MerVar1 + "</mer_var1>";
            }

            if ((vm.MerVar2 != null) && (vm.MerVar2.Length > 0))
            {
                PTInvoice = PTInvoice + "<mer_var2>" + vm.MerVar2 + "</mer_var2>";
            }

            if ((vm.MerVar3 != null) && (vm.MerVar3.Length > 0))
            {
                PTInvoice = PTInvoice + "<mer_var3>" + vm.MerVar3 + "</mer_var3>";
            }

            if ((vm.MerVar4 != null) && (vm.MerVar4.Length > 0))
            {
                PTInvoice = PTInvoice + "<mer_var4>" + vm.MerVar4 + "</mer_var4>";
            }
            PTInvoice = PTInvoice + "</req>";

            var finalHex = Cryptographer.ByteArrayToString(Encoding.UTF8.GetBytes(PTInvoice));

            return(PearToPear(finalHex, false, vm.Action));
        }